Search in sources :

Example 31 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project Android-Iconics by mikepenz.

the class IconsFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // Init and Setup RecyclerView
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
    recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
    //animator not yet working
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    mAdapter = new FastItemAdapter<>();
    configAdapter();
    recyclerView.setAdapter(mAdapter);
    if (getArguments() != null) {
        String fontName = getArguments().getString(FONT_NAME);
        for (ITypeface iTypeface : Iconics.getRegisteredFonts(getActivity())) {
            if (iTypeface.getFontName().equalsIgnoreCase(fontName)) {
                if (iTypeface.getIcons() != null) {
                    for (String icon : iTypeface.getIcons()) {
                        icons.add(new IconItem(icon));
                    }
                    mAdapter.set(icons);
                    break;
                }
            }
        }
    }
    //filter if a search param was provided
    onSearch(search);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) IconItem(com.mikepenz.iconics.sample.item.IconItem) ITypeface(com.mikepenz.iconics.typeface.ITypeface) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 32 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project AboutLibraries by mikepenz.

the class LibsFragmentCompat method onCreateView.

public View onCreateView(Context context, LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, Bundle arguments) {
    if (arguments != null) {
        builder = (LibsBuilder) arguments.getSerializable("data");
    } else {
        Log.e("AboutLibraries", "The AboutLibraries fragment can't be build without the bundle containing the LibsBuilder");
    }
    View view = inflater.inflate(R.layout.fragment_opensource, container, false);
    //allows to modify the view before creating
    if (LibsConfiguration.getInstance().getUiListener() != null) {
        view = LibsConfiguration.getInstance().getUiListener().preOnCreateView(view);
    }
    // init CardView
    RecyclerView mRecyclerView;
    if (view.getId() == R.id.cardListView) {
        mRecyclerView = (RecyclerView) view;
    } else {
        mRecyclerView = (RecyclerView) view.findViewById(R.id.cardListView);
    }
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
    if (LibsConfiguration.getInstance().getItemAnimator() != null) {
        mRecyclerView.setItemAnimator(LibsConfiguration.getInstance().getItemAnimator());
    } else {
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    }
    if (builder != null) {
        mAdapter = new FastAdapter();
        mItemAdapter = new ItemAdapter();
        mRecyclerView.setAdapter(mItemAdapter.wrap(mAdapter));
        mItemAdapter.add(new LoaderItem());
    }
    //allows to modify the view after creating
    if (LibsConfiguration.getInstance().getUiListener() != null) {
        view = LibsConfiguration.getInstance().getUiListener().postOnCreateView(view);
    }
    return view;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) FastAdapter(com.mikepenz.fastadapter.FastAdapter) LoaderItem(com.mikepenz.aboutlibraries.ui.item.LoaderItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) ItemAdapter(com.mikepenz.fastadapter.adapters.ItemAdapter)

Example 33 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project MaterialDrawer by mikepenz.

the class MiniDrawer method build.

/**
     * build the MiniDrawer
     *
     * @param ctx
     * @return
     */
public View build(Context ctx) {
    mContainer = new LinearLayout(ctx);
    if (mInnerShadow) {
        if (!mInRTL) {
            mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_left);
        } else {
            mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_right);
        }
    }
    //create and append recyclerView
    mRecyclerView = new RecyclerView(ctx);
    mContainer.addView(mRecyclerView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    //set the itemAnimator
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    //some style improvements on older devices
    mRecyclerView.setFadingEdgeLength(0);
    //set the drawing cache background to the same color as the slider to improve performance
    //mRecyclerView.setDrawingCacheBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(mActivity, R.attr.material_drawer_background, R.color.material_drawer_background));
    mRecyclerView.setClipToPadding(false);
    //additional stuff
    mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
    //adapter
    mAdapter = new FastAdapter<>();
    mItemAdapter = new ItemAdapter<>();
    mAdapter.withSelectable(true);
    mAdapter.withAllowDeselection(false);
    mAdapter.withPositionBasedStateManagement(mPositionBasedStateManagement);
    mRecyclerView.setAdapter(mItemAdapter.wrap(mAdapter));
    //if the activity with the drawer should be fullscreen add the padding for the statusbar
    if (mDrawer != null && mDrawer.mDrawerBuilder != null && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentStatusBar)) {
        mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), UIUtils.getStatusBarHeight(ctx), mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom());
    }
    //if the activity with the drawer should be fullscreen add the padding for the navigationBar
    if (mDrawer != null && mDrawer.mDrawerBuilder != null && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentNavigationBar) && ctx.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(), mRecyclerView.getPaddingRight(), UIUtils.getNavigationBarHeight(ctx));
    }
    //set the adapter with the items
    createItems();
    return mContainer;
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinearLayout(android.widget.LinearLayout) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 34 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project Signal-Android by WhisperSystems.

the class GiphyFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle bundle) {
    super.onActivityCreated(bundle);
    this.giphyAdapter = new GiphyAdapter(getActivity(), new LinkedList<GiphyImage>());
    this.giphyAdapter.setListener(this);
    this.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    this.recyclerView.setItemAnimator(new DefaultItemAnimator());
    this.recyclerView.setAdapter(giphyAdapter);
    this.recyclerView.addOnScrollListener(new GiphyScrollListener());
    getLoaderManager().initLoader(0, null, this);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinkedList(java.util.LinkedList) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 35 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project FastDev4Android by jiangqqlmj.

the class RecyclerViewTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.recyclerview_test_layout);
    top_bar_linear_back = (LinearLayout) this.findViewById(R.id.top_bar_linear_back);
    btn_add = (Button) this.findViewById(R.id.btn_add);
    btn_delete = (Button) this.findViewById(R.id.btn_delete);
    top_bar_linear_back.setOnClickListener(new CustomOnClickListener());
    btn_add.setOnClickListener(new CustomOnClickListener());
    btn_delete.setOnClickListener(new CustomOnClickListener());
    top_bar_title = (TextView) this.findViewById(R.id.top_bar_title);
    top_bar_title.setText("RecyclerView使用实例");
    //开始设置RecyclerView
    recyclerView_one = (RecyclerView) this.findViewById(R.id.recyclerView_one);
    recyclerView_one.setHasFixedSize(true);
    //1.LinearLayoutManager 线性布局类型
    mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(OrientationHelper.VERTICAL);
    recyclerView_one.setLayoutManager(mLayoutManager);
    //2.GridLayoutManager 表格布局类型
    //        GridLayoutManager girdLayoutManager=new GridLayoutManager(this,4);
    //        recyclerView_one.setLayoutManager(girdLayoutManager);
    //3.采用StaggeredGridLayoutManager  流式布局类型
    //        StaggeredGridLayoutManager staggeredGridLayoutManager=new StaggeredGridLayoutManager(2,OrientationHelper.VERTICAL);
    //        recyclerView_one.setLayoutManager(staggeredGridLayoutManager);
    //添加默认的动画效果
    recyclerView_one.setItemAnimator(new DefaultItemAnimator());
    //添加分隔线
    recyclerView_one.addItemDecoration(new AdvanceDecoration(this, OrientationHelper.VERTICAL));
    mAdapter = new TestRecyclerAdapter(this, new TestRecyclerAdapter.OnRecyclerItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            Toast.makeText(RecyclerViewTestActivity.this, "点击了第" + position + "项", Toast.LENGTH_SHORT).show();
        }
    });
    recyclerView_one.setAdapter(mAdapter);
}
Also used : AdvanceDecoration(com.chinaztt.fda.widget.AdvanceDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) TestRecyclerAdapter(com.chinaztt.fda.adapter.TestRecyclerAdapter)

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