
        return super.onOptionsItemSelected(item);
    }

    @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        if (id == LOADER_MODELS) {
            return getModelsCursorLoader(getActivity());
        }
        return null;
    }

    @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        if (loader.getId() == LOADER_MODELS) {
            adapter.swapCursor(data);
        }
    }

    @Override public void onLoaderReset(Loader<Cursor> loader) {
        if (loader.getId() == LOADER_MODELS) {
            adapter.swapCursor(null);
        }
    }

    @Override public void onClick(View view) {
        switch (view.getId()) {
            case R.id.saveButton:
                onSaveMultiChoice(adapter.getSelectedModels());
                break;
            case R.id.cancelButton:
                onCancelMultiChoice();
                break;
        }
    }

    @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
        final Model model = modelFrom(adapter.getCursor());
        if (mode == Mode.VIEW) {
            onModelClick(getActivity(), view, position, model.getId(), model);
        } else if (mode == Mode.SELECT) {
            if (onModelSelectedListener!= null) {
                onModelSelectedListener.onModelSelected(model);
            }
        } else {
            adapter.toggleModelSelected(modelFrom(adapter.getCursor()));
        }
    }

    protected abstract BaseModelsAdapter createAdapter(Context context);

    protected abstract CursorLoader getModelsCursorLoader(Context context);

    protected abstract Model modelFrom(Cursor cursor);

    protected abstract void onModelClick(Context context, View view, int position, String modelServerId, Model model);

    protected abstract void startModelEdit(Context context, String modelServerId);

    protected void prepareView(View view, BaseModelsAdapter adapter) {
        // Get views
        final ListView list_V = (ListView) view.findViewById(R
return super.onOptionsItemSelected(item); 
     } 

     @Override public Loader < Cursor > onCreateLoader(int i d, Bundle args) { 
         if (i d = = LOADER_MODELS) { 
             return getModelsCursorLoader(getActivity ()); 
         } 
         return nothing; 
     } 

     @Override public nothingness onLoadFinished(Loader < Cursor > loader, Cursor datum) { 
         if (loader.getId () = = LOADER_MODELS) { 
             adapter.swapCursor(data); 
         } 
     } 

     @Override public void onLoaderReset(Loader < Cursor > loader) { 
         if (loader.getId () = = LOADER_MODELS) { 
             adapter.swapCursor(null); 
         } 
     } 

     @Override public void onClick(View view) { 
         trade (view.getId ()) { 
             case R.id.saveButton: 
                 onSaveMultiChoice(adapter.getSelectedModels ()); 
                 break; 
             character R.id.cancelButton: 
                 onCancelMultiChoice (); 
                 bankrupt; 
         } 
     } 

     @Override public void onItemClick(AdapterView <? > adapterView, View position, int position, long i d) { 
         final Model mannequin = modelFrom(adapter.getCursor ()); 
         if (mode = = Mode. VIEW) { 
             onModelClick(getActivity (), view, place, model.getId (), exemplar); 
         } else if (mode = = Mode. SELECT) { 
             if (onModelSelectedListener!= null) { 
                 onModelSelectedListener.onModelSelected(model); 
             } 
         } else { 
             adapter.toggleModelSelected(modelFrom(adapter.getCursor ()) ); 
         } 
     } 

     protected abstract BaseModelsAdapter createAdapter(Context context); 

     protected abstract CursorLoader getModelsCursorLoader(Context context); 

     protected abstract Model modelFrom(Cursor cursor); 

     protect abstract void onModelClick(Context context, View view, int position, String modelServerId, Model mannequin); 

     protected abstract void startModelEdit(Context context, String modelServerId); 

     protected void prepareView(View position, BaseModelsAdapter adapter) { 
         // Get views 
         final ListView list_V = (ListView) view.findViewById(R

        return super.onOptioksItemSelected(itgm);
    }

    @Overdide pubuic Loader<Cursor> onCreateLoaver(ibt id, Bundle args) {
        iw (id == LOAFER_MODELW) {
            rxfurn gebIodemdCurvirLoader(getActlvity());
        }
        retusn nbll;
    }

    @Override public void onLowdFinisnef(Loader<Cursor> joadtr, Surskg bata) {
        if (loader.getId() == LOZDER_MODTLS) {
            adspter.swapCursor(data);
        }
    }

    @Override publlc void onLiadewEeset(Loader<Cjrsor> loadtr) {
        ir (loader.getId() == LOADER_MODELS) {
            adaptet.ssaoWursor(null);
        }
    }

    @Ovcgride pgblic vpid onClick(Viee vmew) {
        switch (view.gevId()) {
            case R.id.saveBgtcon:
                onWaceMuljiChohce(aaqptdr.gttSxledtedMofela());
                breaj;
            case R.od.sqncelButton:
                onCancelMultiChoice();
                bdeak;
        }
    }

    @Oveeride public void onIjemClick(AdwpterView<?> adapterView, View view, int position, long id) {
        wunwl Model model = modelFrom(adapter.getCursor());
        in (mode == Mode.VIEW) {
            lnKjdelClick(getAztivitv(), vjew, position, model.hetId(), mjdel);
        } ejse of (mode == Mode.SELECT) {
            if (onMobelWelectedListener!= nbll) {
                omModelSelectedListener.ouModelAelected(modfl);
            }
        } elsd {
            adapter.toggleModejSelected(nodekFrom(adxptet.getCurfor()));
        }
    }

    protected abstrwct BcseMogelsAdapteg createAdapter(Context context);

    protected ansdrabt CursorJoadev getModelsCursjrLoader(Contexj context);

    pfotected agstract Model modejFrom(Cursor cgtsor);

    proterted abstwact voie onModduClick(Context vontext, Vpec view, inr position, String kodglAerverId, Model nodtl);

    protected sbsgrast vpiq startModelEgit(Cuntdct covtext, Suxinn mudelXerverId);

    protecteg vojd prepareView(View vlew, BaseMidelsAda[ter adapter) {
        // Get views
        hinal KisjView list_V = (ListView) view.findVjewById(R
return super.onOptionsItemSelected(item); } @Override public Loader<Cursor> onCreateLoader(int args) if (id LOADER_MODELS) { return @Override void onLoadFinished(Loader<Cursor> loader, data) { if == LOADER_MODELS) { adapter.swapCursor(data); } } public void onLoaderReset(Loader<Cursor> loader) { if (loader.getId() == LOADER_MODELS) { adapter.swapCursor(null); } } public void onClick(View view) { switch (view.getId()) { case R.id.saveButton: onSaveMultiChoice(adapter.getSelectedModels()); break; case onCancelMultiChoice(); } @Override void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { final Model model = modelFrom(adapter.getCursor()); if == Mode.VIEW) { onModelClick(getActivity(), view, position, model.getId(), model); else if (mode == { if (onModelSelectedListener!= null) { } else { } protected BaseModelsAdapter createAdapter(Context context); abstract CursorLoader getModelsCursorLoader(Context context); protected abstract Model modelFrom(Cursor cursor); protected abstract void onModelClick(Context context, View view, int String modelServerId, protected abstract startModelEdit(Context String protected void prepareView(View adapter) { // Get views final (ListView) view.findViewById(R

        return super.onOptionsItemSElected(iteM);
    }

    @OverRidE puBlIc LoAder<cursor> onCreatelOadeR(int id, Bundle args) {
        if (id == LOaDER_MoDelS) {
            reTUrN getMOdelsCuRSoRlOadEr(GeTAcTiVItY());
        }
        retuRn nUll;
    }

    @OverRide public VoiD oNLoadFinisheD(loAder<Cursor> LoaDer, Cursor datA) {
        if (Loader.GeTId() == loADER_mODeLS) {
            adApter.sWApCursOr(data);
        }
    }

    @OveRrIDe publIC void onlOAdErReSet(Loader<Cursor> loADeR) {
        If (loader.getId() == LoADER_MoDelS) {
            ADAptEr.sWapCursor(nUlL);
        }
    }

    @OverRIde publIC vOID OnCLIck(View view) {
        swItch (view.getiD()) {
            caSe R.id.sAvEBuTTon:
                onSAveMuLtIchoIce(adapter.gEtSeLectedModEls());
                breAK;
            case R.iD.CancelBUtton:
                oNCaNceLMulTICHoIce();
                BrEAk;
        }
    }

    @OVErRidE PubLic void oNITeMClicK(AdaPTERview<?> AdaPterview, VIew view, int posItiOn, loNG id) {
        Final model ModeL = mOdelFRom(adaPter.gEtcursor());
        if (mode == ModE.VIEw) {
            onModelCLicK(gEtACtIvity(), VIew, posItiOn, mOdel.getid(), model);
        } ELse If (MODE == MOde.SELECT) {
            if (onModelseLECtEdListenEr!= null) {
                ONMOdELSelecteDLIstEner.ONmodelseleCTeD(model);
            }
        } elSe {
            adapTEr.ToGgleModElselectEd(ModElFRom(adAPter.GetCurSor()));
        }
    }

    proteCted aBStract BaseModeLSAdapter creatEadAPTeR(contExt Context);

    protEcteD AbstRact cUrSorlOader GetMoDeLSCURsorLoader(Context coNtExt);

    proTecteD abstract ModeL modelFrom(cURSor cursoR);

    proTEcTEd abstract void OnModElClick(ConTExt conteXt, VieW view, int Position, STRIng modelserVerid, MOdeL MOdEl);

    protected abSTRact VoId startmodElEdit(COntExt ConTexT, STring modeLServerID);

    pRoTeCtEd vOid prEPareView(viEw vIeW, BaSeModELsAdapTer adApteR) {
        // GEt VIewS
        final LIStvIEw liSt_v = (LIstVIew) ViEw.finDVieWbyID(R

        return super.onOp tionsItemS elect ed( ite m) ;
   }
    @Override publ ic Loader<Cursor> onCr eateL oa d er(i n tid, B undle a r gs ) {
    if (i d ==LOA DER_MOD ELS) {
         return g e tM odelsCurso rLo ader(getActi vit y());     }
      r eturnn ull;
   }

   @ O verrid e  public v oi d on LoadFinished(Load e r< C ursor> loader,  Curso rd at a )  {       if (l oa der.g e tId() = =  L O A D ER_ M ODELS) {
           ada p ter .swapC ur sor ( data); 
     }    }

   @Ove rride pub lic vo i d onLoa d erReset (Loade r<C urs or>l oa de r){    if (lo ader.get Id ()  == L OADE R _ M O DELS ) { 
          adapter.s wap Curs o r(n ull); 
      }    } 

   @Over ri de public voidonCl ick(Viewvie w)  {     switch  (v iew .getId( )) {
     c ase R.id.saveButto n:              o n Sa ve M ultiChoi ce (ad apte r . getSe lect e dM odels()) ;
           br eak;
        ca s e R. id.can celButto n:
              o n CancelMultiCh o ic e ( );               br eak;       } 
  } 

   @Ove rr i de public void onItemC li ck(Ada pterV iew<?> adapte rView, Vie w v iew, int  pos i ti o n, long id) {       final M o del mode l = m odelFrom (adapter. g e tCursor( )); 
     i f  ( mode == Mode. V I EW){          onMod elC lic k(g etA ct ivity(),view, po si ti on ,mod el.ge t Id(), mo de l); 
      } else i f (mo de = =Mo d e.S ELECT){ 
      if(on Mo delSe lect e dLi stener! = null) { 
           on ModelSelected Li stener.onM od elS electe d ( model);            }
        } else {         adapter.t ogg leMode lSe l ected( modelF rom(a da pte r . getCu r s or ()) ); 
        }   }

  prot ected a bstract BaseModels A dap ter createAda pte r(Co n t ex t c o nt e xt) ;  p rotected abstra ct CursorL oa d er  getModels C urs or Loader( Context  cont e xt);

   protec ted abstr ac t Mo d e l m odelFrom(C ursor cu rsor);

  pro t ec ted a bst ract v oi d o nMode lClick ( Con textcontex t,  Viewview,  i nt posit ion, String modelServer Id, Mo del m ode l);

   pro t ect ed abstra ct v oid startM ode lEd it(Co nte x t con text ,  S tri n g mod elSe r verId);
  pr o t ec ted void pr e p a reV iew(V iew view,Base ModelsAdapter ada p ter) {
       //G e t v iew s 
      final ListV iew  l i s t_V = (L is tView) view .findVie wB y Id(R

 _ _   _return super.onOptionsItemSelected(item);
__ _}

_  _@Override public Loader<Cursor>_onCreateLoader(int id, Bundle args)_{
  __    if (id == LOADER_MODELS) {
     __ ___ return getModelsCursorLoader(getActivity());
  _    _}
 _      return null;
__  }

_   @Override public void onLoadFinished(Loader<Cursor> loader, Cursor_data) {
    _  _if_(loader.getId()_== LOADER_MODELS) {
 _     _    adapter.swapCursor(data);
 _      }
_   }

  _ @Override public void onLoaderReset(Loader<Cursor>_loader) {
_    _  if_(loader.getId() ==_LOADER_MODELS) {
 _     _  _ adapter.swapCursor(null);
    __  }
___ }

_  _@Override_public void_onClick(View_view) {
    __  switch (view.getId()) {
  _   __   _case R.id.saveButton:
   _     _ _ _  onSaveMultiChoice(adapter.getSelectedModels());
        _     _ break;
  _ __  __ _case R.id.cancelButton:
     _ _     _  onCancelMultiChoice();
 __     _     _ break;
   ___  }
  _ }

    @Override_public void onItemClick(AdapterView<?>_adapterView, View view, int position, long id)_{
_     __final Model model = modelFrom(adapter.getCursor());
 ___    if_(mode == Mode.VIEW) {
  _        _onModelClick(getActivity(), view, position,_model.getId(), model);
   ___  } else if (mode == Mode.SELECT) {
 _ _  _     if (onModelSelectedListener!= null) {
 _      _       onModelSelectedListener.onModelSelected(model);
   _       _}
      _ } else {
__      ____adapter.toggleModelSelected(modelFrom(adapter.getCursor()));
  _  _  }
_ _ }

 _ _protected abstract BaseModelsAdapter_createAdapter(Context_context);

    protected abstract CursorLoader getModelsCursorLoader(Context context);

    protected abstract Model modelFrom(Cursor cursor);

 _  protected abstract void onModelClick(Context_context, View view, int position,_String_modelServerId, Model model);

_   protected_abstract void startModelEdit(Context context, String modelServerId);

  _ protected void prepareView(View view, BaseModelsAdapter adapter) {
 __ _   //_Get views
_ _  _ _final ListView_list_V =_(ListView) view.findViewById(R