use of android.support.v7.widget.DefaultItemAnimator in project EffectiveAndroid by rallat.
the class TopArticleListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
layoutManager.scrollToPosition(0);
recyclerView.setLayoutManager(layoutManager);
// allows for optimizations if all items are of the same size:
recyclerView.setHasFixedSize(true);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addOnItemTouchListener(this);
gestureDetector = new GestureDetectorCompat(this, new RecyclerViewDemoOnGestureListener());
presenter = createPresenter();
presenter.create();
}
use of android.support.v7.widget.DefaultItemAnimator in project EffectiveAndroid by rallat.
the class TopImagesListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addOnItemTouchListener(this);
gestureDetector = new GestureDetectorCompat(this, new RecyclerViewDemoOnGestureListener());
presenter = createPresenter();
presenter.create();
}
use of android.support.v7.widget.DefaultItemAnimator in project storio by pushtorefresh.
the class TweetsFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(tweetsAdapter);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
uiStateController = new UiStateController.Builder().withLoadingUi(view.findViewById(R.id.tweets_loading_ui)).withErrorUi(view.findViewById(R.id.tweets_error_ui)).withEmptyUi(view.findViewById(R.id.tweets_empty_ui)).withContentUi(recyclerView).build();
}
use of android.support.v7.widget.DefaultItemAnimator in project material by rey5137.
the class TabIndicatorView method init.
protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
setHorizontalScrollBarEnabled(false);
mTabPadding = -1;
mTabSingleLine = true;
mCenterCurrentTab = false;
mIndicatorHeight = -1;
mIndicatorAtTop = false;
mScrolling = false;
mIsRtl = false;
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setStyle(Paint.Style.FILL);
mPaint.setColor(ThemeUtil.colorAccent(context, 0xFFFFFFFF));
mAdapter = new Adapter();
setAdapter(mAdapter);
mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, mIsRtl);
setLayoutManager(mLayoutManager);
setItemAnimator(new DefaultItemAnimator());
addOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
updateIndicator(mLayoutManager.findViewByPosition(mSelectedPosition));
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
updateIndicator(mLayoutManager.findViewByPosition(mSelectedPosition));
}
});
applyStyle(context, attrs, defStyleAttr, defStyleRes);
if (!isInEditMode())
mStyleId = ThemeManager.getStyleId(context, attrs, defStyleAttr, defStyleRes);
}
use of android.support.v7.widget.DefaultItemAnimator in project FastAdapter by mikepenz.
the class RadioButtonSampleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//style our ui
new MaterializeBuilder().withActivity(this).build();
//create our FastAdapter which will manage everything
fastItemAdapter = new FastItemAdapter<>();
fastItemAdapter.withSelectable(true);
//configure our fastAdapter
fastItemAdapter.withOnClickListener(new FastAdapter.OnClickListener<RadioButtonSampleItem>() {
@Override
public boolean onClick(View v, IAdapter<RadioButtonSampleItem> adapter, RadioButtonSampleItem item, int position) {
Toast.makeText(v.getContext(), (item).name.getText(v.getContext()), Toast.LENGTH_LONG).show();
return false;
}
});
//init the ClickListenerHelper which simplifies custom click listeners on views of the Adapter
mClickListenerHelper = new ClickListenerHelper<>(fastItemAdapter);
fastItemAdapter.withOnPreClickListener(new FastAdapter.OnClickListener<RadioButtonSampleItem>() {
@Override
public boolean onClick(View v, IAdapter<RadioButtonSampleItem> adapter, RadioButtonSampleItem item, int position) {
// consume otherwise radio/checkbox will be deselected
return true;
}
});
fastItemAdapter.withItemEvent(new RadioButtonSampleItem.RadioButtonClickEvent());
//get our recyclerView and do basic setup
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(fastItemAdapter);
//fill with some sample data
int x = 0;
List<RadioButtonSampleItem> items = new ArrayList<>();
for (String s : ALPHABET) {
int count = new Random().nextInt(20);
for (int i = 1; i <= count; i++) {
items.add(new RadioButtonSampleItem().withName(s + " Test " + x).withIdentifier(100 + x));
x++;
}
}
fastItemAdapter.add(items);
//restore selections (this has to be done after the items were added
fastItemAdapter.withSavedInstanceState(savedInstanceState);
//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
Aggregations