Search in sources :

Example 1 with AnimateDismissAdapter

use of com.marshalchen.common.uimodule.listviewanimations.itemmanipulation.AnimateDismissAdapter in project UltimateAndroid by cymcsg.

the class AnimateDismissActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_anim_activity_animateremoval);
    mSelectedPositions = new ArrayList<Integer>();
    ListView listView = (ListView) findViewById(R.id.activity_animateremoval_listview);
    mAdapter = new MyListAdapter(ListAnimationListActivity.getItems());
    final AnimateDismissAdapter animateDismissAdapter = new AnimateDismissAdapter(mAdapter, new MyOnDismissCallback());
    animateDismissAdapter.setAbsListView(listView);
    listView.setAdapter(animateDismissAdapter);
    Button button = (Button) findViewById(R.id.activity_animateremoval_button);
    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            animateDismissAdapter.animateDismiss(mSelectedPositions);
            mSelectedPositions.clear();
        }
    });
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
            CheckedTextView tv = (CheckedTextView) view;
            tv.toggle();
            if (tv.isChecked()) {
                mSelectedPositions.add(position);
            } else {
                mSelectedPositions.remove((Integer) position);
            }
        }
    });
}
Also used : AnimateDismissAdapter(com.marshalchen.common.uimodule.listviewanimations.itemmanipulation.AnimateDismissAdapter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) CheckedTextView(android.widget.CheckedTextView) AbsListView(android.widget.AbsListView) CheckedTextView(android.widget.CheckedTextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener)

Aggregations

View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 Button (android.widget.Button)1 CheckedTextView (android.widget.CheckedTextView)1 ListView (android.widget.ListView)1 AnimateDismissAdapter (com.marshalchen.common.uimodule.listviewanimations.itemmanipulation.AnimateDismissAdapter)1