Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.egslava.telemed.ui.druglist;
- import android.database.Cursor;
- //import android.support.v4.content.CursorLoader;
- import android.support.v4.app.FragmentActivity;
- import android.widget.AbsListView;
- import android.widget.ListView;
- import ru.egslava.telemed.R;
- import ru.egslava.telemed.model.DrugContract;
- import ru.egslava.telemed.ui.utils.content.ContentListAdapter;
- import ru.egslava.telemed.ui.utils.content.ContentListLoader;
- import org.androidannotations.annotations.AfterViews;
- import org.androidannotations.annotations.Bean;
- import org.androidannotations.annotations.EActivity;
- import org.androidannotations.annotations.ItemClick;
- import org.androidannotations.annotations.ViewById;
- /**
- * Created by egslava on 01/05/15.
- */
- @EActivity(R.layout.activity_drug_list)
- public class DrugListActivity extends FragmentActivity { // instead of just Activity for SupportLoader
- @ViewById ListView list;
- public ContentListAdapter adapter;
- @Bean ContentListLoader contentListLoader;
- @AfterViews void init() {
- list.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
- adapter = new ContentListAdapter<>(this, list, SelectableDrugItem_::build);
- list.setAdapter(adapter);
- contentListLoader.init( getSupportLoaderManager(), DrugContract.CONTENT_URI, adapter );
- }
- @ItemClick void list ( Cursor cursor ) {
- // I fixed that bug too much time. In the beginning ListView will call setChecked with
- // its own (ListView) values. You can change it with ListView.setItemChecked
- // (see listParams.setItemChecked( position, drug.inCart ) in DrugItem.bind );
- // So if you will notify right from Checkable.setChecked it will change cursor and
- // in the new beginning will call setChecked again and again cursor will be changed
- getContentResolver().notifyChange(DrugContract.CONTENT_URI, null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment