use of com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator in project android-advancedrecyclerview by h6ah4i.
the class AlreadyExpandedGroupsExpandableExampleFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext());
final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
// Expand all group items by default. This method must be called before creating a wrapper adapter.
//
// FYI: AbstractExpandableItemAdapter.getInitialGroupExpandedState() can also be used if you
// need fine control of initial group items' state.
mRecyclerViewExpandableItemManager.setDefaultGroupsExpandedState(true);
// adapter
final AlreadyExpandedGroupsExpandableExampleAdapter myItemAdapter = new AlreadyExpandedGroupsExpandableExampleAdapter(mRecyclerViewExpandableItemManager, getDataProvider());
mAdapter = myItemAdapter;
// wrap for expanding
mWrappedAdapter = mRecyclerViewExpandableItemManager.createWrappedAdapter(myItemAdapter);
final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Need to disable them when using animation indicator.
animator.setSupportsChangeAnimations(false);
mRecyclerView.setLayoutManager(mLayoutManager);
// requires *wrapped* adapter
mRecyclerView.setAdapter(mWrappedAdapter);
mRecyclerView.setItemAnimator(animator);
mRecyclerView.setHasFixedSize(false);
// noinspection StatementWithEmptyBody
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
use of com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator in project Phonograph by kabouzeid.
the class CardPlayerFragment method setUpRecyclerView.
private void setUpRecyclerView() {
recyclerViewDragDropManager = new RecyclerViewDragDropManager();
final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
playingQueueAdapter = new PlayingQueueAdapter(((AppCompatActivity) getActivity()), MusicPlayerRemote.getPlayingQueue(), MusicPlayerRemote.getPosition(), R.layout.item_list, false, null);
wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(playingQueueAdapter);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(wrappedAdapter);
recyclerView.setItemAnimator(animator);
recyclerViewDragDropManager.attachRecyclerView(recyclerView);
layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);
}
use of com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator in project Phonograph by kabouzeid.
the class PlaylistDetailActivity method setUpRecyclerView.
private void setUpRecyclerView() {
ViewUtil.setUpFastScrollRecyclerViewColor(this, ((FastScrollRecyclerView) recyclerView), ThemeStore.accentColor(this));
recyclerView.setLayoutManager(new LinearLayoutManager(this));
if (playlist instanceof AbsCustomPlaylist) {
adapter = new PlaylistSongAdapter(this, new ArrayList<Song>(), R.layout.item_list, false, this);
recyclerView.setAdapter(adapter);
} else {
recyclerViewDragDropManager = new RecyclerViewDragDropManager();
final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
adapter = new OrderablePlaylistSongAdapter(this, new ArrayList<PlaylistSong>(), R.layout.item_list, false, this, (fromPosition, toPosition) -> {
if (PlaylistsUtil.moveItem(PlaylistDetailActivity.this, playlist.id, fromPosition, toPosition)) {
Song song = adapter.getDataSet().remove(fromPosition);
adapter.getDataSet().add(toPosition, song);
adapter.notifyItemMoved(fromPosition, toPosition);
}
});
wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(adapter);
recyclerView.setAdapter(wrappedAdapter);
recyclerView.setItemAnimator(animator);
recyclerViewDragDropManager.attachRecyclerView(recyclerView);
}
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override
public void onChanged() {
super.onChanged();
checkIsEmpty();
}
});
}
use of com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator in project CoCoin by Nightonke.
the class TagSettingActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tag_setting);
mContext = this;
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) {
// Do something for lollipop and above versions
Window window = this.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.statusBarColor));
} else {
// do something for phones running an SDK before lollipop
}
//noinspection ConstantConditions
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
mLayoutManager = new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false);
// drag & drop manager
mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(this, R.drawable.material_shadow_z3));
// Start dragging after long press
mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
mRecyclerViewDragDropManager.setInitiateOnMove(false);
mRecyclerViewDragDropManager.setLongPressTimeout(750);
//adapter
myItemAdapter = new TagDraggableItemAdapter();
mAdapter = myItemAdapter;
// wrap for dragging
mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
mRecyclerView.setLayoutManager(mLayoutManager);
// requires *wrapped* adapter
mRecyclerView.setAdapter(mWrappedAdapter);
mRecyclerView.setItemAnimator(animator);
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(this, R.drawable.material_shadow_z1)));
mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
back = (MaterialIconView) findViewById(R.id.icon_left);
check = (MaterialIconView) findViewById(R.id.check);
title = (TextView) findViewById(R.id.title);
title.setText((RecordManager.TAGS.size() - 2) + mContext.getResources().getString(R.string.tag_number));
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
check.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveChanges(true);
}
});
}
use of com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator in project android-advancedrecyclerview by h6ah4i.
the class AddRemoveExpandableExampleFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// noinspection ConstantConditions
mRecyclerView = getView().findViewById(R.id.recycler_view);
mLayoutManager = new LinearLayoutManager(getContext());
final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
mRecyclerViewExpandableItemManager.setOnGroupExpandListener(this);
mRecyclerViewExpandableItemManager.setOnGroupCollapseListener(this);
// adapter
final AddRemoveExpandableExampleAdapter myItemAdapter = new AddRemoveExpandableExampleAdapter(mRecyclerViewExpandableItemManager, getDataProvider());
mAdapter = myItemAdapter;
// wrap for expanding
mWrappedAdapter = mRecyclerViewExpandableItemManager.createWrappedAdapter(myItemAdapter);
final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();
// Change animations are enabled by default since support-v7-recyclerview v22.
// Need to disable them when using animation indicator.
animator.setSupportsChangeAnimations(false);
mRecyclerView.setLayoutManager(mLayoutManager);
// requires *wrapped* adapter
mRecyclerView.setAdapter(mWrappedAdapter);
mRecyclerView.setItemAnimator(animator);
mRecyclerView.setHasFixedSize(false);
// noinspection StatementWithEmptyBody
if (supportsViewElevation()) {
// Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
} else {
mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
}
mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
Aggregations