Search in sources :

Example 6 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project remusic by aa112901.

the class ArtistFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.recylerview, container, false);
    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
    layoutManager = new LinearLayoutManager(mContext);
    recyclerView.setLayoutManager(layoutManager);
    //fastScroller = (FastScroller) view.findViewById(R.id.fastscroller);
    //new loadArtists().execute("");
    mAdapter = new ArtistAdapter(null);
    recyclerView.setAdapter(mAdapter);
    recyclerView.setHasFixedSize(true);
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    setItemDecoration();
    isAZSort = mPreferences.getArtistSortOrder().equals(SortOrder.ArtistSortOrder.ARTIST_A_Z);
    dialogText = (TextView) view.findViewById(R.id.dialog_text);
    sideBar = (SideBar) view.findViewById(R.id.sidebar);
    sideBar.setOnTouchingLetterChangedListener(new SideBar.OnTouchingLetterChangedListener() {

        @Override
        public void onTouchingLetterChanged(String s) {
            dialogText.setText(s);
            sideBar.setView(dialogText);
            Log.e("scrol", "  " + s);
            if (positionMap.get(s) != null) {
                int i = positionMap.get(s);
                Log.e("scrolget", "  " + i);
                ((LinearLayoutManager) recyclerView.getLayoutManager()).scrollToPositionWithOffset(i, 0);
            }
        }
    });
    reloadAdapter();
    return view;
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TintImageView(com.bilibili.magicasakura.widgets.TintImageView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) SideBar(com.wm.remusic.widget.SideBar)

Example 7 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project remusic by aa112901.

the class DownFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_down, container, false);
    allStart = (LinearLayout) view.findViewById(R.id.down_start_all);
    allStop = (LinearLayout) view.findViewById(R.id.down_pause_all);
    clear = (LinearLayout) view.findViewById(R.id.down_clear_all);
    setListener();
    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(mContext);
    recyclerView.setLayoutManager(layoutManager);
    adapter = new DownLoadAdapter(null, null);
    recyclerView.setAdapter(adapter);
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    reload();
    return view;
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Nullable(android.support.annotation.Nullable)

Example 8 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project remusic by aa112901.

the class MainFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_main, container, false);
    swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh);
    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
    layoutManager = new LinearLayoutManager(mContext);
    recyclerView.setLayoutManager(layoutManager);
    //swipeRefresh.setColorSchemeResources(R.color.theme_color_PrimaryAccent);
    swipeRefresh.setColorSchemeColors(ThemeUtils.getColorById(mContext, R.color.theme_color_primary));
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            reloadAdapter();
        }
    });
    //先给adapter设置空数据,异步加载好后更新数据,防止Recyclerview no attach
    mAdapter = new MainFragmentAdapter(mContext);
    recyclerView.setAdapter(mAdapter);
    recyclerView.setHasFixedSize(true);
    recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
    //设置没有item动画
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    reloadAdapter();
    mContext.getWindow().setBackgroundDrawableResource(R.color.background_material_light_1);
    return view;
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) MainFragmentAdapter(com.wm.remusic.adapter.MainFragmentAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.wm.remusic.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Example 9 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project AntennaPod by AntennaPod.

the class QueueFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    ((MainActivity) getActivity()).getSupportActionBar().setTitle(R.string.queue_label);
    View root = inflater.inflate(R.layout.queue_fragment, container, false);
    infoBar = (TextView) root.findViewById(R.id.info_bar);
    recyclerView = (RecyclerView) root.findViewById(R.id.recyclerView);
    RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(getActivity()).build());
    recyclerView.setHasFixedSize(true);
    registerForContextMenu(recyclerView);
    itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.RIGHT) {

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            int from = viewHolder.getAdapterPosition();
            int to = target.getAdapterPosition();
            Log.d(TAG, "move(" + from + ", " + to + ")");
            queue.add(to, queue.remove(from));
            recyclerAdapter.notifyItemMoved(from, to);
            DBWriter.moveQueueItem(from, to, true);
            return true;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            if (subscription != null) {
                subscription.unsubscribe();
            }
            final int position = viewHolder.getAdapterPosition();
            Log.d(TAG, "remove(" + position + ")");
            final FeedItem item = queue.get(position);
            final boolean isRead = item.isPlayed();
            DBWriter.markItemPlayed(FeedItem.PLAYED, false, item.getId());
            DBWriter.removeQueueItem(getActivity(), item, true);
            Snackbar snackbar = Snackbar.make(root, getString(R.string.marked_as_read_label), Snackbar.LENGTH_LONG);
            snackbar.setAction(getString(R.string.undo), v -> {
                DBWriter.addQueueItemAt(getActivity(), item.getId(), position, false);
                if (!isRead) {
                    DBWriter.markItemPlayed(FeedItem.UNPLAYED, item.getId());
                }
            });
            snackbar.show();
        }

        @Override
        public boolean isLongPressDragEnabled() {
            return !UserPreferences.isQueueLocked();
        }

        @Override
        public boolean isItemViewSwipeEnabled() {
            return !UserPreferences.isQueueLocked();
        }

        @Override
        public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
            // We only want the active item
            if (actionState != ItemTouchHelper.ACTION_STATE_IDLE) {
                if (viewHolder instanceof QueueRecyclerAdapter.ItemTouchHelperViewHolder) {
                    QueueRecyclerAdapter.ItemTouchHelperViewHolder itemViewHolder = (QueueRecyclerAdapter.ItemTouchHelperViewHolder) viewHolder;
                    itemViewHolder.onItemSelected();
                }
            }
            super.onSelectedChanged(viewHolder, actionState);
        }

        @Override
        public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
            super.clearView(recyclerView, viewHolder);
            if (viewHolder instanceof QueueRecyclerAdapter.ItemTouchHelperViewHolder) {
                QueueRecyclerAdapter.ItemTouchHelperViewHolder itemViewHolder = (QueueRecyclerAdapter.ItemTouchHelperViewHolder) viewHolder;
                itemViewHolder.onItemClear();
            }
        }
    });
    itemTouchHelper.attachToRecyclerView(recyclerView);
    txtvEmpty = (TextView) root.findViewById(android.R.id.empty);
    txtvEmpty.setVisibility(View.GONE);
    progLoading = (ProgressBar) root.findViewById(R.id.progLoading);
    progLoading.setVisibility(View.VISIBLE);
    return root;
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) QueueRecyclerAdapter(de.danoeh.antennapod.adapter.QueueRecyclerAdapter) SearchView(android.support.v7.widget.SearchView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) FeedItem(de.danoeh.antennapod.core.feed.FeedItem) RecyclerView(android.support.v7.widget.RecyclerView) Snackbar(android.support.design.widget.Snackbar)

Example 10 with SimpleItemAnimator

use of android.support.v7.widget.SimpleItemAnimator in project Lightning-Browser by anthonycr.

the class TabsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view;
    final LayoutManager layoutManager;
    if (mShowInNavigationDrawer) {
        view = inflater.inflate(R.layout.tab_drawer, container, false);
        layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
        setupFrameLayoutButton(view, R.id.tab_header_button, R.id.plusIcon);
        setupFrameLayoutButton(view, R.id.new_tab_button, R.id.icon_plus);
        setupFrameLayoutButton(view, R.id.action_back, R.id.icon_back);
        setupFrameLayoutButton(view, R.id.action_forward, R.id.icon_forward);
        setupFrameLayoutButton(view, R.id.action_home, R.id.icon_home);
    } else {
        view = inflater.inflate(R.layout.tab_strip, container, false);
        layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
        ImageView newTab = (ImageView) view.findViewById(R.id.new_tab_button);
        newTab.setColorFilter(ThemeUtils.getIconDarkThemeColor(getActivity()));
        newTab.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mUiController.newTabButtonClicked();
            }
        });
    }
    mUnbinder = ButterKnife.bind(this, view);
    SimpleItemAnimator animator;
    if (mShowInNavigationDrawer) {
        animator = new VerticalItemAnimator();
    } else {
        animator = new HorizontalItemAnimator();
    }
    animator.setSupportsChangeAnimations(false);
    animator.setAddDuration(200);
    animator.setChangeDuration(0);
    animator.setRemoveDuration(200);
    animator.setMoveDuration(200);
    mRecyclerView.setLayerType(View.LAYER_TYPE_NONE, null);
    mRecyclerView.setItemAnimator(animator);
    mRecyclerView.setLayoutManager(layoutManager);
    mTabsAdapter = new LightningViewAdapter(mShowInNavigationDrawer);
    mRecyclerView.setAdapter(mTabsAdapter);
    mRecyclerView.setHasFixedSize(true);
    return view;
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) LayoutManager(android.support.v7.widget.RecyclerView.LayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LightningView(acr.browser.lightning.view.LightningView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) TabsView(acr.browser.lightning.browser.TabsView) HorizontalItemAnimator(acr.browser.lightning.fragment.anim.HorizontalItemAnimator) VerticalItemAnimator(acr.browser.lightning.fragment.anim.VerticalItemAnimator) Nullable(android.support.annotation.Nullable)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)10 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)10 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 View (android.view.View)9 TextView (android.widget.TextView)5 SearchView (android.support.v7.widget.SearchView)3 Nullable (android.support.annotation.Nullable)2 ImageView (android.widget.ImageView)2 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)2 DemoHeaderFooterAdapter (com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter)2 OnListItemClickMessageListener (com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener)2 RecyclerViewExpandableItemManager (com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)2 TabsView (acr.browser.lightning.browser.TabsView)1 HorizontalItemAnimator (acr.browser.lightning.fragment.anim.HorizontalItemAnimator)1 VerticalItemAnimator (acr.browser.lightning.fragment.anim.VerticalItemAnimator)1 LightningView (acr.browser.lightning.view.LightningView)1 Snackbar (android.support.design.widget.Snackbar)1 Fragment (android.support.v4.app.Fragment)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 LayoutManager (android.support.v7.widget.RecyclerView.LayoutManager)1