Search in sources :

Example 1 with RefactoredDefaultItemAnimator

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);
}
Also used : RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) Parcelable(android.os.Parcelable) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewExpandableItemManager(com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 2 with RefactoredDefaultItemAnimator

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);
}
Also used : RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) PlayingQueueAdapter(com.kabouzeid.gramophone.adapter.song.PlayingQueueAdapter)

Example 3 with RefactoredDefaultItemAnimator

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();
        }
    });
}
Also used : MaterialCab(com.afollestad.materialcab.MaterialCab) Context(android.content.Context) Bundle(android.os.Bundle) ViewUtil(com.kabouzeid.gramophone.util.ViewUtil) ButterKnife(butterknife.ButterKnife) PlaylistSongLoader(com.kabouzeid.gramophone.loader.PlaylistSongLoader) PlaylistSong(com.kabouzeid.gramophone.model.PlaylistSong) MusicPlayerRemote(com.kabouzeid.gramophone.helper.MusicPlayerRemote) NonNull(android.support.annotation.NonNull) WrappedAsyncTaskLoader(com.kabouzeid.gramophone.misc.WrappedAsyncTaskLoader) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) ThemeStore(com.kabouzeid.appthemehelper.ThemeStore) Playlist(com.kabouzeid.gramophone.model.Playlist) LoaderIds(com.kabouzeid.gramophone.interfaces.LoaderIds) OrderablePlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.OrderablePlaylistSongAdapter) PlaylistsUtil(com.kabouzeid.gramophone.util.PlaylistsUtil) PhonographColorUtil(com.kabouzeid.gramophone.util.PhonographColorUtil) PlaylistLoader(com.kabouzeid.gramophone.loader.PlaylistLoader) Menu(android.view.Menu) View(android.view.View) RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) AbsCustomPlaylist(com.kabouzeid.gramophone.model.AbsCustomPlaylist) R(com.kabouzeid.gramophone.R) LoaderManager(android.support.v4.app.LoaderManager) WrapperAdapterUtils(com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) Loader(android.support.v4.content.Loader) SongAdapter(com.kabouzeid.gramophone.adapter.song.SongAdapter) Song(com.kabouzeid.gramophone.model.Song) PlaylistMenuHelper(com.kabouzeid.gramophone.helper.menu.PlaylistMenuHelper) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) TextView(android.widget.TextView) AbsSlidingMusicPanelActivity(com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) Toolbar(android.support.v7.widget.Toolbar) CabHolder(com.kabouzeid.gramophone.interfaces.CabHolder) PlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.PlaylistSongAdapter) OrderablePlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.OrderablePlaylistSongAdapter) PlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.PlaylistSongAdapter) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) PlaylistSong(com.kabouzeid.gramophone.model.PlaylistSong) Song(com.kabouzeid.gramophone.model.Song) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) AbsCustomPlaylist(com.kabouzeid.gramophone.model.AbsCustomPlaylist) FastScrollRecyclerView(com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) OrderablePlaylistSongAdapter(com.kabouzeid.gramophone.adapter.song.OrderablePlaylistSongAdapter) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)

Example 4 with RefactoredDefaultItemAnimator

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);
        }
    });
}
Also used : Window(android.view.Window) RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) GridLayoutManager(android.support.v7.widget.GridLayoutManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) TagDraggableItemAdapter(com.nightonke.saver.adapter.TagDraggableItemAdapter) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 5 with RefactoredDefaultItemAnimator

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);
}
Also used : RefactoredDefaultItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) Parcelable(android.os.Parcelable) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewExpandableItemManager(com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Aggregations

GeneralItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator)7 RefactoredDefaultItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)4 ItemShadowDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator)4 RecyclerViewDragDropManager (com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)4 Parcelable (android.os.Parcelable)3 SimpleListDividerDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator)3 RecyclerViewExpandableItemManager (com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)3 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TextView (android.widget.TextView)2 PlayingQueueAdapter (com.kabouzeid.gramophone.adapter.song.PlayingQueueAdapter)2 Context (android.content.Context)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 LoaderManager (android.support.v4.app.LoaderManager)1 Loader (android.support.v4.content.Loader)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 Toolbar (android.support.v7.widget.Toolbar)1