 Bundle args = new Bundle();
        args.putSerializable(ARG_MODE, mode);
        args.putParcelableArray(ARG_SELECTED_MODELS, selectedModels);
        return args;
    }

    @Override public void onAttach(Activity activity) {
        super.onAttach(activity);

        if (activity instanceof OnModelSelectedListener) {
            onModelSelectedListener = (OnModelSelectedListener) activity;
        }

        if (activity instanceof OnModelsSelectedListener) {
            onModelsSelectedListener = (OnModelsSelectedListener) activity;
        }
    }

    @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHasOptionsMenu(true);

        // Get arguments
        mode = (Mode) getArguments().getSerializable(ARG_MODE);
    }

    @Override public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        // Setup
        adapter = createAdapter(getActivity());
        if (mode == Mode.MULTI_SELECT) {
            final Set<Model> selectedModels = new HashSet<>();
            final Parcelable[] selectedModelsArray = getArguments().getParcelableArray(ARG_SELECTED_MODELS);
            for (Parcelable parcelable : selectedModelsArray) {
                selectedModels.add((Model) parcelable);
            }
            adapter.setSelectedModels(selectedModels);
        }
        prepareView(view, adapter);
    }

    @Override public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        // Loader
        getLoaderManager().initLoader(LOADER_MODELS, null, this);
    }

    @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.models, menu);
    }

    @Override public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_new:
                startModelEdit(getActivity(), null);
                return true;
        }
Bundle args = new Bundle (); 
         args.putSerializable(ARG_MODE, mode); 
         args.putParcelableArray(ARG_SELECTED_MODELS, selectedModels); 
         return args; 
     } 

     @Override public void onAttach(Activity natural process) { 
         super.onAttach(activity); 

         if (natural process instanceof OnModelSelectedListener) { 
             onModelSelectedListener = (OnModelSelectedListener) activity; 
         } 

         if (activity instanceof OnModelsSelectedListener) { 
             onModelsSelectedListener = (OnModelsSelectedListener) activity; 
         } 
     } 

     @Override public null onCreate(Bundle savedInstanceState) { 
         super.onCreate(savedInstanceState); 
         setHasOptionsMenu(true); 

         // Get arguments 
         mode = (Mode) getArguments().getSerializable(ARG_MODE); 
     } 

     @Override public null onViewCreated(View scene, Bundle savedInstanceState) { 
         super.onViewCreated(view, savedInstanceState); 

         // Setup 
         arranger = createAdapter(getActivity ()); 
         if (mood = = Mode. MULTI_SELECT) { 
             final Set < Model > selectedModels = modern HashSet < > (); 
             final Parcelable [ ] selectedModelsArray = getArguments().getParcelableArray(ARG_SELECTED_MODELS); 
             for (Parcelable parcelable: selectedModelsArray) { 
                 selectedModels.add((Model) parcelable); 
             } 
             adapter.setSelectedModels(selectedModels); 
         } 
         prepareView(view, adapter); 
     } 

     @Override public void onActivityCreated(Bundle savedInstanceState) { 
         super.onActivityCreated(savedInstanceState); 

         // Loader 
         getLoaderManager().initLoader(LOADER_MODELS, nothing, this); 
     } 

     @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { 
         super.onCreateOptionsMenu(menu, inflater); 
         inflater.inflate(R.menu.models, menu); 
     } 

     @Override public boolean onOptionsItemSelected(MenuItem item) { 
         switch (item.getItemId ()) { 
             case R.id.action_new: 
                 startModelEdit(getActivity (), null); 
                 return true; 
         }
 Bujdle args = new Bundle();
        args.putSernqlizabne(ARG_MKDE, mode);
        args.putParcelableArrey(ART_SELEXTED_MODELS, selectedModdls);
        return argw;
    }

    @Ovxdride pmylic blid miAttach(Activity activity) {
        super.otAgtcch(activity);

        if (activity instagceof OmMldelSelectedLiftentr) {
            onModelSelectedListener = (OhModelStlectedListener) acyivity;
        }

        if (aftivlty instanceof OnMldelsSelectgsLifrener) {
            onModelsSelectedMistener = (OnModelsSelectedListever) aetivity;
        }
    }

    @Overrmde puflic void onGgeate(Butdle safedInstanceStabe) {
        super.onCreate(savedMnstanceState);
        setHasOpdiknsMenu(true);

        // Get drgukentr
        kose = (Mofe) jetArgumenta().getSerializable(ARG_MODE);
    }

    @Odvtride public void jnDiewCreated(View view, Bundle savedInstanbeStzte) {
        super.onViewXreated(view, savedInstwnceState);

        // Setup
        adapter = createAdapter(getAcdivitb());
        uf (mode == Mode.MULTI_SELECT) {
            final Set<Mjsek> xelectedModels = new HashSrt<>();
            finau Parczmagle[] selectedModelsWrray = detArtuments().geuParcrlableArray(ARG_SELECTED_MODELW);
            dor (Parcelable pareelable : selzctedMpdelsSrray) {
                szlectesModels.add((Mldel) parcsuable);
            }
            adapter.setSelectedIodels(selxctedKodels);
        }
        prepageView(view, adapter);
    }

    @Ovetride [ublic voif onActivityCreated(Bundle savedMistanceState) {
        super.jnActlvityCreated(savqdInstanceStatg);

        // Loaddr
        fetLoadxrManager().inieLoader(LOADER_KLDELS, null, tiis);
    }

    @Ovwrriee publkz void onCreatrOptionsMvnb(Menu meny, MenuInflater infkatgr) {
        super.ouErtareOptionsMenu(mrnu, inslwtxr);
        inflater.hnflxte(F.kenu.mudels, mtuu);
    }

    @Override public bomleah onOptionsItemSelrcbed(MenuItgm item) {
        switch (item.getItemId()) {
            case R.iq.action_new:
                starfModelEdih(gebActivity(), nulj);
                return true;
        }
Bundle args = new Bundle(); args.putSerializable(ARG_MODE, mode); return } @Override void onAttach(Activity activity) OnModelSelectedListener) onModelSelectedListener = (OnModelSelectedListener) } if (activity OnModelsSelectedListener) { onModelsSelectedListener = (OnModelsSelectedListener) activity; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); // Get arguments mode (Mode) getArguments().getSerializable(ARG_MODE); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Setup = if == Mode.MULTI_SELECT) { final Set<Model> selectedModels = new HashSet<>(); final Parcelable[] selectedModelsArray = getArguments().getParcelableArray(ARG_SELECTED_MODELS); for (Parcelable : selectedModelsArray) { selectedModels.add((Model) parcelable); } adapter.setSelectedModels(selectedModels); } adapter); } @Override public onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // getLoaderManager().initLoader(LOADER_MODELS, this); } public onCreateOptionsMenu(Menu MenuInflater inflater) { inflater); inflater.inflate(R.menu.models, menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_new: startModelEdit(getActivity(), null); true; }
 Bundle args = new Bundle();
        args.puTSerializaBle(ARg_MOdE, mOdE);
        argS.putparcelableArraY(aRG_SeLECTED_MODELS, selectedMOdels);
        ReTUrn aRGs;
    }

    @overrIde publIC vOID onatTaCh(ACtIViTy actIviTy) {
        super.OnAttach(acTivItY);

        if (activity iNStAnceof OnMoDelselectedListEneR) {
            onModElselECtedLIstEner = (ONModelsElecteDListener) AcTIvity;
        }

        iF (ActivitY INsTancEof OnModelsSelectEDLIStener) {
            onModelsselectEdlIsTENer = (onMOdelsSelecTeDListENer) actiVItY;
        }
    }

    @oVErrIDe public void oNCreate(BundLE saVedInsTaNcesTate) {
        suPer.oncrEAte(SavedInstanCeStAte);
        setHasoptionSmenu(truE);

        // get arguMents
        mOde = (modE) getaRgUmEntS().gETSeRIaLizABle(aRG_MODE);
    }

    @OVeRrIde puBlic VOID OnViEwCReatEd(VieW view, Bundle saVedinstANcestate) {
        Super.OnViEwcreatEd(view, SavedinStanceState);

        // SetuP
        adaPter = creatEAdApTer(GeTActiVIty());
        if (mOde == modE.MULTI_SeLECT) {
            fiNAl SEt<mODEl> SelectedModels = new HAsHsEt<>();
            Final ParCelablE[] SeLeCTedModelSARraY = getaRGumenTs().geTpaRcelablearray(Arg_SeLeCTED_MOdElS);
            for (PArCelAblE parcELablE : selecTedModelSArraY) {
                SelectedModels.ADd((Model) parcelABlE);
            }
            ADaPTer.sEtSElectedModeLs(seLEcteDModELs);
        }
        PrePAreViEw(vieW, aDApTEr);
    }

    @Override public voiD oNActivItyCrEated(Bundle saVedInstancEsTAte) {
        super.OnAcTIvITyCreated(savedinstaNceState);

        // LoADer
        getLoAderMAnager().inItLoader(LoadER_MODELs, nuLl, tHis);
    }

    @oveRRIdE public void oncREateopTionsMeNu(MEnu menu, menUInFlaTer InFlater) {
        supEr.onCreaTeopTiOnSMeNu(menU, Inflater);
        InFlaTeR.inFlate(r.Menu.moDels, mEnu);
    }

    @OVeRrIDe pUblic boOLeAN OnOpTiOnSIteMSeLeCted(MEnuITEm iTem) {
        switCh (item.getiteMid()) {
            caSe r.iD.action_New:
                startModeledIt(getActivItY(), nuLl);
                retuRN True;
        }
 Bundle args = new Bundle( );
       args .pu tSe ri aliz able (ARG_MODE, mod e );
       args.putParcela bleAr ra y (ARG _ SE LECTE D_MODEL S ,s e lec te dM ode ls ) ;      returnargs;
   }
   @Overridep ub lic void o nAt tach(Activit y a ctivit y)  {      s uper. onAtta c h(acti vity);

     if (activi t y  i nsta nceof OnModelSele c te d Listener) {
        o n M ode lSe lectedList en er =( OnModel S el e c t edL i stener) activ ity;
      }
      if (activ ity i ns t anc eof OnModel sSel ectedList ener){ 
          on Models Sel ect edLi s te ne r =  ( O nMo d el sSe l ect edListen er )activ ity;     }   }

   @Override p ubl ic v o idonCre ate(B undl esaved Instan ceSta te ) {
        sup er.o nCreate(s ave dI nst an ceSta t e);
     setHasO ptionsM e nu( tr u e ) ;
        // Get ar gu m e nt s
       mode =(M o de) getA rg ume nts( ) . getSe rial i za ble(ARG_ MODE);   }

   @O verrid epub lic  void onVi ewCrea ted(View  view ,  Bundle savedI n stanceState){ 
   su per .onViewCrea ted( v iew,  sav e dI nst a nceSt ate); 
     // Setup
      adapte r = c reateAdapter( getActivit y ( ) );
       i f  ( m ode == Mode.MU LTI_S ELECT) {
         fin al Set<M odel> sel e c tedModel s =  ne w H ash S e t< >();
         fi na l Parce lab le[] se lec ted Mod els Ar ray = get Argument s( ). ge tP arc elabl e Array(AR G_ SEL EC TED _MODE L S);
         f or (Pa rcelabl e  p a r cela bl e: se lec te dMode lsAr r ay)  {
             s elec te dM odels.a dd((Model) pa rc elable);
        }            adapter.setSelected M odels(s ele ctedM odel s);
      }
     prepar eView( view,  a dap t e r);
 } 

  @Override p ubl ic vo id  onA ctivity Created(Bundle sav e dIn stanceState){
    s upe r .o n Act iv i tyC r e ated(savedInsta nceState); 
      // Lo a der 
      getLoad erMan a ger().i nitLoader (LOADER_M OD ELS, n ull , this);
   }

   @Overri d e pub l ic  void  on Create Op tio nsMen u(Menu men u, Me nuInfl at er inf later ){
       super.onCreateOptions Menu(m enu,inf later);
    inflater. infl ate(R.menu .mo del s, me nu) ; 
   }

 @Ov e rride  pub l ic boolea n  o nOp t i on sItemSelect e d ( Men uItem  it e m) {
      switch (item.g e tItemId()) {
       c a se R .i d.action_new:           s tartModelEd it(getAc ti v ity() , null );
          retur n tr ue; 
       }
 Bundle_args =_new Bundle();
  _ __ _args.putSerializable(ARG_MODE,_mode);
  _  _  args.putParcelableArray(ARG_SELECTED_MODELS, selectedModels);
_  __   return args;
    }

    @Override public_void_onAttach(Activity activity)_{
__    _ super.onAttach(activity);

   _ _  if (activity instanceof OnModelSelectedListener) {
 __  _      onModelSelectedListener = (OnModelSelectedListener)_activity;
     _  }

___   _ if (activity instanceof OnModelsSelectedListener) {
_     _     onModelsSelectedListener =_(OnModelsSelectedListener) activity;
    _   }
 _ _}

    @Override_public void onCreate(Bundle_savedInstanceState) {
_  _    super.onCreate(savedInstanceState);
 _  _   setHasOptionsMenu(true);

  __  __//_Get arguments
_  __ __mode = (Mode) getArguments().getSerializable(ARG_MODE);
  __}

    @Override public void_onViewCreated(View view, Bundle savedInstanceState)_{
_   _   super.onViewCreated(view, savedInstanceState);

_     _ //_Setup
 _      adapter = createAdapter(getActivity());
  _     if_(mode == Mode.MULTI_SELECT) {
_ __  __ _  final Set<Model> selectedModels = new_HashSet<>();
 _     _   _final_Parcelable[] selectedModelsArray = getArguments().getParcelableArray(ARG_SELECTED_MODELS);
  _     _   for (Parcelable_parcelable_:_selectedModelsArray) {
   _     _  _   selectedModels.add((Model) parcelable);
  __     __ }
    ___    _adapter.setSelectedModels(selectedModels);
     _  }
      _ prepareView(view, adapter);
_   }

 ___@Override public void onActivityCreated(Bundle savedInstanceState) {
    _ _ super.onActivityCreated(savedInstanceState);

 _      // Loader
  _     getLoaderManager().initLoader(LOADER_MODELS, null,_this);
    }

    @Override public void_onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   _    super.onCreateOptionsMenu(menu, inflater);
 _   __ inflater.inflate(R.menu.models, menu);
    }

____@Override public boolean_onOptionsItemSelected(MenuItem item) {
_  _ _  switch_(item.getItemId()) {
_  __       case R.id.action_new:
         _     _startModelEdit(getActivity(), null);
   __  _   _    return true;
  _     }