use of jp.wasabeef.recyclerview.animators.FadeInAnimator 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);
}
Aggregations