Search in sources :

Example 1 with SlideScaleInOutRightItemAnimator

use of it.gmariotti.recyclerview.itemanimator.SlideScaleInOutRightItemAnimator in project RecyclerViewItemAnimators by gabrielemariotti.

the class ListActivity method setupSpinner.

private void setupSpinner() {
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.animators, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            switch(position) {
                case 0:
                    mRecyclerView.setItemAnimator(new SlideInOutLeftItemAnimator(mRecyclerView));
                    break;
                case 1:
                    mRecyclerView.setItemAnimator(new SlideInOutRightItemAnimator(mRecyclerView));
                    break;
                case 2:
                    mRecyclerView.setItemAnimator(new SlideInOutTopItemAnimator(mRecyclerView));
                    break;
                case 3:
                    mRecyclerView.setItemAnimator(new SlideInOutBottomItemAnimator(mRecyclerView));
                    break;
                case 4:
                    mRecyclerView.setItemAnimator(new ScaleInOutItemAnimator(mRecyclerView));
                    break;
                case 5:
                    mRecyclerView.setItemAnimator(new SlideScaleInOutRightItemAnimator(mRecyclerView));
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
}
Also used : Spinner(android.widget.Spinner) SlideInOutTopItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutTopItemAnimator) SlideInOutRightItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutRightItemAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) SlideInOutLeftItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutLeftItemAnimator) ScaleInOutItemAnimator(it.gmariotti.recyclerview.itemanimator.ScaleInOutItemAnimator) SlideScaleInOutRightItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideScaleInOutRightItemAnimator) AdapterView(android.widget.AdapterView) SlideInOutBottomItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutBottomItemAnimator)

Example 2 with SlideScaleInOutRightItemAnimator

use of it.gmariotti.recyclerview.itemanimator.SlideScaleInOutRightItemAnimator in project RecyclerViewItemAnimators by gabrielemariotti.

the class GridActivity method setupSpinner.

private void setupSpinner() {
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.animators, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);
    spinner.setSelection(1);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            switch(position) {
                case 0:
                    mRecyclerView.setItemAnimator(new SlideInOutLeftItemAnimator(mRecyclerView));
                    break;
                case 1:
                    mRecyclerView.setItemAnimator(new SlideInOutRightItemAnimator(mRecyclerView));
                    break;
                case 2:
                    mRecyclerView.setItemAnimator(new SlideInOutTopItemAnimator(mRecyclerView));
                    break;
                case 3:
                    mRecyclerView.setItemAnimator(new SlideInOutBottomItemAnimator(mRecyclerView));
                    break;
                case 4:
                    mRecyclerView.setItemAnimator(new ScaleInOutItemAnimator(mRecyclerView));
                    break;
                case 5:
                    mRecyclerView.setItemAnimator(new SlideScaleInOutRightItemAnimator(mRecyclerView));
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
}
Also used : Spinner(android.widget.Spinner) SlideInOutTopItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutTopItemAnimator) SlideInOutRightItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutRightItemAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) SlideInOutLeftItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutLeftItemAnimator) ScaleInOutItemAnimator(it.gmariotti.recyclerview.itemanimator.ScaleInOutItemAnimator) SlideScaleInOutRightItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideScaleInOutRightItemAnimator) AdapterView(android.widget.AdapterView) SlideInOutBottomItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutBottomItemAnimator)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 Spinner (android.widget.Spinner)2 ScaleInOutItemAnimator (it.gmariotti.recyclerview.itemanimator.ScaleInOutItemAnimator)2 SlideInOutBottomItemAnimator (it.gmariotti.recyclerview.itemanimator.SlideInOutBottomItemAnimator)2 SlideInOutLeftItemAnimator (it.gmariotti.recyclerview.itemanimator.SlideInOutLeftItemAnimator)2 SlideInOutRightItemAnimator (it.gmariotti.recyclerview.itemanimator.SlideInOutRightItemAnimator)2 SlideInOutTopItemAnimator (it.gmariotti.recyclerview.itemanimator.SlideInOutTopItemAnimator)2 SlideScaleInOutRightItemAnimator (it.gmariotti.recyclerview.itemanimator.SlideScaleInOutRightItemAnimator)2