Search in sources :

Example 1 with AnimationAdapter

use of jp.wasabeef.recyclerview.adapters.AnimationAdapter in project recyclerview-animators by wasabeef.

the class AdapterSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_adapter_sample);
    Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    if (getIntent().getBooleanExtra("GRID", true)) {
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    } else {
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
    }
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    for (Type type : Type.values()) {
        spinnerAdapter.add(type.name());
    }
    spinner.setAdapter(spinnerAdapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            AnimationAdapter adapter = Type.values()[position].get(AdapterSampleActivity.this);
            adapter.setFirstOnly(true);
            adapter.setDuration(500);
            adapter.setInterpolator(new OvershootInterpolator(.5f));
            recyclerView.setAdapter(adapter);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    recyclerView.setItemAnimator(new FadeInAnimator());
    MainAdapter adapter = new MainAdapter(this, new ArrayList<>(Arrays.asList(data)));
    AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(adapter);
    alphaAdapter.setFirstOnly(true);
    alphaAdapter.setDuration(500);
    alphaAdapter.setInterpolator(new OvershootInterpolator(.5f));
    recyclerView.setAdapter(alphaAdapter);
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) Spinner(android.widget.Spinner) AlphaInAnimationAdapter(jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) SlideInRightAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInRightAnimationAdapter) AnimationAdapter(jp.wasabeef.recyclerview.adapters.AnimationAdapter) ScaleInAnimationAdapter(jp.wasabeef.recyclerview.adapters.ScaleInAnimationAdapter) SlideInBottomAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInBottomAnimationAdapter) SlideInLeftAnimationAdapter(jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter) AlphaInAnimationAdapter(jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter) Toolbar(android.support.v7.widget.Toolbar) FadeInAnimator(jp.wasabeef.recyclerview.animators.FadeInAnimator)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 OvershootInterpolator (android.view.animation.OvershootInterpolator)1 AdapterView (android.widget.AdapterView)1 ArrayAdapter (android.widget.ArrayAdapter)1 Spinner (android.widget.Spinner)1 AlphaInAnimationAdapter (jp.wasabeef.recyclerview.adapters.AlphaInAnimationAdapter)1 AnimationAdapter (jp.wasabeef.recyclerview.adapters.AnimationAdapter)1 ScaleInAnimationAdapter (jp.wasabeef.recyclerview.adapters.ScaleInAnimationAdapter)1 SlideInBottomAnimationAdapter (jp.wasabeef.recyclerview.adapters.SlideInBottomAnimationAdapter)1 SlideInLeftAnimationAdapter (jp.wasabeef.recyclerview.adapters.SlideInLeftAnimationAdapter)1 SlideInRightAnimationAdapter (jp.wasabeef.recyclerview.adapters.SlideInRightAnimationAdapter)1 FadeInAnimator (jp.wasabeef.recyclerview.animators.FadeInAnimator)1