Search in sources :

Example 86 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project AdvancedMaterialDrawer by madcyph3r.

the class ThemeFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.recycleview_layout, container, false);
    mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    createAdapter(mRecyclerView);
    return v;
}
Also used : DividerItemDecoration(de.madcyph3r.example.DividerItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 87 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project MaterialLibrary by DeveloperPaul123.

the class QuickReturnActivity method init.

@Override
public void init() {
    List<ListItem> items = new ArrayList<>();
    for (int i = 0; i < 45; i++) {
        items.add(new ListItem("Item " + i));
    }
    getRecyclerView().setHasFixedSize(true);
    getRecyclerView().setItemAnimator(new DefaultItemAnimator());
    getRecyclerView().setLayoutManager(new LinearLayoutManager(this));
    SimpleRecyclerViewAdapter adapter = new SimpleRecyclerViewAdapter(this, items);
    getRecyclerView().setAdapter(adapter);
}
Also used : SimpleRecyclerViewAdapter(com.materiallib.devpaul.materiallibrary.list.SimpleRecyclerViewAdapter) ArrayList(java.util.ArrayList) ListItem(com.materiallib.devpaul.materiallibrary.list.ListItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 88 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project FanLayoutManager by Cleveroad.

the class FullInfoTabFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    toolbar.setTitle(sportCardModel.getSportTitle());
    toolbar.setNavigationIcon(R.drawable.ic_back);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            getActivity().onBackPressed();
        }
    });
    toolbar.setBackgroundColor(ContextCompat.getColor(getContext(), sportCardModel.getBackgroundColorResId()));
    ivPhoto.setImageResource(sportCardModel.getImageResId());
    List<AthleticModel> items = new ArrayList<>();
    for (int i = 10; i > 0; i--) {
        int points = i * 100;
        items.add(new AthleticModel("Vae, mirabilis tumultumque", Country.ITALY, --points));
        items.add(new AthleticModel("Cobaltums favere", Country.USA, --points));
        items.add(new AthleticModel("Stella de peritus lixa", Country.ROK, --points));
    }
    ScoreAdapter scoreAdapter = new ScoreAdapter();
    scoreAdapter.addItems(items);
    rvAthletics.setAdapter(scoreAdapter);
    rvAthletics.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
    rvAthletics.setItemAnimator(new DefaultItemAnimator());
    rvAthletics.addItemDecoration(new DividerItemDecoration(getContext()));
}
Also used : AthleticModel(com.cleveroad.testrecycler.models.AthleticModel) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 89 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project FanLayoutManager by Cleveroad.

the class MainFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.rvCards);
    FanLayoutManagerSettings fanLayoutManagerSettings = FanLayoutManagerSettings.newBuilder(getContext()).withFanRadius(true).withAngleItemBounce(5).withViewHeightDp(160).withViewWidthDp(120).build();
    fanLayoutManager = new FanLayoutManager(getContext(), fanLayoutManagerSettings);
    recyclerView.setLayoutManager(fanLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    adapter = new SportCardsAdapter(getContext());
    adapter.addAll(SportCardsUtils.generateSportCards());
    adapter.setOnItemClickListener(new SportCardsAdapter.OnItemClickListener() {

        @Override
        public void onItemClicked(int itemPosition, final View view) {
            if (fanLayoutManager.getSelectedItemPosition() != itemPosition) {
                fanLayoutManager.switchItem(recyclerView, itemPosition);
            } else {
                fanLayoutManager.straightenSelectedItem(new Animator.AnimatorListener() {

                    @Override
                    public void onAnimationStart(Animator animator) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                            onClick(view, fanLayoutManager.getSelectedItemPosition());
                        } else {
                            onClick(fanLayoutManager.getSelectedItemPosition());
                        }
                    }

                    @Override
                    public void onAnimationCancel(Animator animator) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animator) {
                    }
                });
            }
        }
    });
    recyclerView.setAdapter(adapter);
    recyclerView.setChildDrawingOrderCallback(new FanChildDrawingOrderCallback(fanLayoutManager));
    (view.findViewById(R.id.logo)).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            fanLayoutManager.collapseViews();
        }
    });
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Animator(android.animation.Animator) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) FanLayoutManagerSettings(com.cleveroad.fanlayoutmanager.FanLayoutManagerSettings) FanLayoutManager(com.cleveroad.fanlayoutmanager.FanLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) FanChildDrawingOrderCallback(com.cleveroad.fanlayoutmanager.callbacks.FanChildDrawingOrderCallback)

Example 90 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project Reader by TheKeeperOfPie.

the class FragmentInbox method onCreateView.

@SuppressWarnings("ResourceType")
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_inbox, container, false);
    listener = new ControllerInbox.Listener() {

        @Override
        public void setPage(Page page) {
            spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(page));
        }

        @Override
        public RecyclerView.Adapter getAdapter() {
            return adapterInbox;
        }

        @Override
        public void setToolbarTitle(CharSequence title) {
            toolbar.setTitle(title);
        }

        @Override
        public void setRefreshing(boolean refreshing) {
            swipeRefreshInbox.setRefreshing(refreshing);
        }

        @Override
        public void post(Runnable runnable) {
            recyclerInbox.post(runnable);
        }
    };
    layoutCoordinator = (CoordinatorLayout) view.findViewById(R.id.layout_coordinator);
    layoutAppBar = (AppBarLayout) view.findViewById(R.id.layout_app_bar);
    int styleColorBackground = AppSettings.THEME_DARK.equals(mListener.getThemeBackground()) ? R.style.MenuDark : R.style.MenuLight;
    ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(new ThemeWrapper(activity, UtilsColor.getThemeForColor(getResources(), themer.getColorPrimary(), mListener)), styleColorBackground);
    toolbar = (Toolbar) activity.getLayoutInflater().cloneInContext(contextThemeWrapper).inflate(R.layout.toolbar, layoutAppBar, false);
    layoutAppBar.addView(toolbar);
    ((AppBarLayout.LayoutParams) toolbar.getLayoutParams()).setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    toolbar.setTitleTextColor(themer.getColorFilterPrimary().getColor());
    toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
    toolbar.getNavigationIcon().mutate().setColorFilter(themer.getColorFilterPrimary());
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mListener.openDrawer();
        }
    });
    setUpOptionsMenu();
    floatingActionButtonNewMessage = (FloatingActionButton) view.findViewById(R.id.fab_new_message);
    floatingActionButtonNewMessage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FragmentNewMessage fragmentNewMessage = FragmentNewMessage.newInstance();
            getFragmentManager().beginTransaction().hide(FragmentInbox.this).add(R.id.frame_fragment, fragmentNewMessage, FragmentNewMessage.TAG).addToBackStack(null).commit();
        }
    });
    floatingActionButtonNewMessage.setColorFilter(themer.getColorFilterAccent());
    behaviorFloatingActionButton = new ScrollAwareFloatingActionButtonBehavior(activity, null, new ScrollAwareFloatingActionButtonBehavior.OnVisibilityChangeListener() {

        @Override
        public void onStartHideFromScroll() {
        }

        @Override
        public void onEndHideFromScroll() {
        }
    });
    ((CoordinatorLayout.LayoutParams) floatingActionButtonNewMessage.getLayoutParams()).setBehavior(behaviorFloatingActionButton);
    adapterInboxPage = new AdapterInboxPage(activity);
    spinnerPage = new AppCompatSpinner(contextThemeWrapper);
    toolbar.addView(spinnerPage);
    ((Toolbar.LayoutParams) spinnerPage.getLayoutParams()).setMarginEnd((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()));
    spinnerPage.setAdapter(adapterInboxPage);
    spinnerPage.setSelection(adapterInboxPage.getPages().indexOf(controllerInbox.getPage()));
    spinnerPage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            controllerInbox.setPage(adapterInboxPage.getItem(position));
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    swipeRefreshInbox = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_inbox);
    swipeRefreshInbox.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            controllerInbox.reload();
        }
    });
    linearLayoutManager = new LinearLayoutManager(activity);
    recyclerInbox = (RecyclerView) view.findViewById(R.id.recycler_inbox);
    recyclerInbox.setHasFixedSize(true);
    recyclerInbox.setItemAnimator(new DefaultItemAnimator());
    recyclerInbox.getItemAnimator().setRemoveDuration(UtilsAnimation.EXPAND_ACTION_DURATION);
    recyclerInbox.setLayoutManager(linearLayoutManager);
    recyclerInbox.addItemDecoration(new ItemDecorationDivider(activity, ItemDecorationDivider.VERTICAL_LIST));
    AdapterListener adapterListener = new AdapterListener() {

        @Override
        public void scrollAndCenter(int position, int height) {
            linearLayoutManager.scrollToPositionWithOffset(position, 0);
        }

        @Override
        public void hideToolbar() {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void clearDecoration() {
            behaviorFloatingActionButton.animateOut(floatingActionButtonNewMessage);
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }

        @Override
        public void requestMore() {
            controllerInbox.loadMore();
        }

        @Override
        public void requestDisallowInterceptTouchEventVertical(boolean disallow) {
            recyclerInbox.requestDisallowInterceptTouchEvent(disallow);
            swipeRefreshInbox.requestDisallowInterceptTouchEvent(disallow);
        }

        @Override
        public void requestDisallowInterceptTouchEventHorizontal(boolean disallow) {
        }
    };
    AdapterCommentList.ViewHolderComment.Listener listenerComments = new AdapterCommentList.ViewHolderComment.Listener() {

        @Override
        public void onToggleComment(Comment comment) {
        }

        @Override
        public void onShowReplyEditor(Comment comment) {
        }

        @Override
        public void onEditComment(Comment comment, String text) {
        }

        @Override
        public void onSendComment(Comment comment, String text) {
        }

        @Override
        public void onMarkRead(Comment comment) {
        }

        @Override
        public void onLoadNestedComments(Comment comment) {
        }

        @Override
        public void onJumpToParent(Comment comment) {
        }

        @Override
        public void onViewProfile(Comment comment) {
        }

        @Override
        public void onCopyText(Comment comment) {
        }

        @Override
        public void onDeleteComment(Comment comment) {
        }

        @Override
        public void onReport(Comment comment) {
        }

        @Override
        public void onVoteComment(Comment comment, AdapterCommentList.ViewHolderComment viewHolderComment, Likes vote) {
        }

        @Override
        public void onSave(Comment comment) {
        }
    };
    if (adapterInbox == null) {
        adapterInbox = new AdapterInbox(controllerInbox, controllerUser, adapterListener, listenerComments, mListener.getEventListenerBase());
    }
    recyclerInbox.setAdapter(adapterInbox);
    return view;
}
Also used : ItemDecorationDivider(com.winsonchiu.reader.utils.ItemDecorationDivider) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) Page(com.winsonchiu.reader.data.Page) FragmentNewMessage(com.winsonchiu.reader.FragmentNewMessage) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) ThemeWrapper(com.winsonchiu.reader.theme.ThemeWrapper) AdapterCommentList(com.winsonchiu.reader.comments.AdapterCommentList) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) ScrollAwareFloatingActionButtonBehavior(com.winsonchiu.reader.utils.ScrollAwareFloatingActionButtonBehavior) AppBarLayout(android.support.design.widget.AppBarLayout) Comment(com.winsonchiu.reader.data.reddit.Comment) AdapterListener(com.winsonchiu.reader.adapter.AdapterListener) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) AppCompatSpinner(android.support.v7.widget.AppCompatSpinner) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ContextThemeWrapper(android.view.ContextThemeWrapper) AdapterView(android.widget.AdapterView) Likes(com.winsonchiu.reader.data.reddit.Likes)

Aggregations

DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)103 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)72 RecyclerView (android.support.v7.widget.RecyclerView)63 View (android.view.View)55 TextView (android.widget.TextView)30 ImageView (android.widget.ImageView)25 ArrayList (java.util.ArrayList)16 ClickItemTouchListener (com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)14 GridLayoutManager (android.support.v7.widget.GridLayoutManager)13 Toolbar (android.support.v7.widget.Toolbar)13 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)10 FastAdapter (com.mikepenz.fastadapter.FastAdapter)10 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)10 MaterializeBuilder (com.mikepenz.materialize.MaterializeBuilder)9 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)8 LocalTrack (com.sdsmdg.harjot.MusicDNA.models.LocalTrack)8 DividerItemDecoration (de.madcyph3r.example.DividerItemDecoration)8 Button (android.widget.Button)7 Random (java.util.Random)6 Intent (android.content.Intent)5