All Projects → omtodkar → ShimmerRecyclerView

omtodkar / ShimmerRecyclerView

Licence: GPL-3.0 license
A custom Shimmer RecyclerView which adopt to list / grid transition automatically and also supports multiple view types while shimmering.

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to ShimmerRecyclerView

Shimmer-ReactNative
React Native Shimmer
Stars: ✭ 38 (-79.35%)
Mutual labels:  shimmer, shimmerlayout, shimmer-android
Modular2Recycler
Modular²Recycler is a RecyclerView.Adapter that is modular squared.
Stars: ✭ 72 (-60.87%)
Mutual labels:  recyclerview
InstantRecyclerView
A library that helps to implement a complex list with RecyclerView.(RecyclerView使用的封装与优化,帮助你快速利用RecyclerView构建复杂列表)
Stars: ✭ 22 (-88.04%)
Mutual labels:  recyclerview
FastWaiMai
仿写美团外卖电商项目
Stars: ✭ 123 (-33.15%)
Mutual labels:  recyclerview
recyclerview-adapters
Multiple item adapters for RecyclerView (inspired by Merge Adapter)
Stars: ✭ 24 (-86.96%)
Mutual labels:  recyclerview
MetalRecyclerPagerView
RecyclerView implementation for Android which makes it look and feel like ViewPager with item margins support (mutliple views effect).
Stars: ✭ 26 (-85.87%)
Mutual labels:  recyclerview
FacebookShimmer
Android adding loader screen using Facebook Shimmer library.
Stars: ✭ 18 (-90.22%)
Mutual labels:  shimmer-android
recyclerview-expandable
RecyclerView implementation of traex's ExpandableLayout
Stars: ✭ 70 (-61.96%)
Mutual labels:  recyclerview
android-thinkmap-treeview
Tree View; Mind map; Think map; tree map; custom view; 自定义;关系图;树状图;思维导图;组织机构图;层次图
Stars: ✭ 314 (+70.65%)
Mutual labels:  recyclerview
BaseRecyclerViewAdapter
RecyclerView通用适配器
Stars: ✭ 14 (-92.39%)
Mutual labels:  recyclerview
AutoPlayVideoRecyclerView
Android library to auto play video from url in Recyclerview.
Stars: ✭ 44 (-76.09%)
Mutual labels:  recyclerview
recyclerview-selection-demo
A simple Android project that demonstrates the usage of the androidx.recyclerview.selection support library
Stars: ✭ 27 (-85.33%)
Mutual labels:  recyclerview
MultiTypeAdapter
RecyclerView通用多类型适配器MultiTypeAdapter,以布局文件为单位更细粒度的条目复用。
Stars: ✭ 18 (-90.22%)
Mutual labels:  recyclerview
ConcatAdapter-sample
Load more recyclerview android using ConcatAdapter | Sample to practice RecyclerView ConcatAdapter
Stars: ✭ 26 (-85.87%)
Mutual labels:  recyclerview
ui
android examples for ui
Stars: ✭ 28 (-84.78%)
Mutual labels:  recyclerview
RecyclerviewNestedRecyclerview
An example of a recyclerview nested recyclerview
Stars: ✭ 31 (-83.15%)
Mutual labels:  recyclerview
Vitrin
A simple app that shows categories, subcategories and items.
Stars: ✭ 70 (-61.96%)
Mutual labels:  recyclerview
AdapterCommands
Drop in solution to animate RecyclerView's dataset changes by using command pattern
Stars: ✭ 74 (-59.78%)
Mutual labels:  recyclerview
SmartStickyHeader
A Custom Header View With Multiple Items to make selection from categories
Stars: ✭ 36 (-80.43%)
Mutual labels:  recyclerview
HoveringCallback
Drag & drop item decorator for RecyclerView with support for highlighting hovered items.
Stars: ✭ 15 (-91.85%)
Mutual labels:  recyclerview

ShimmerRecyclerView

Build Status Download GitHub API Android Arsenal

ShimmerRecyclerView is an custom RecyclerView library based on Facebook's Shimmer effect for Android library and inspired from Sharish's ShimmerRecyclerView.

There is reason behind creating a separate library for ShimmerRecyclerView, most of libraries doesn't not support runtime switching of LayoutManager or shimmer layout resources. Secondly the other similar library is build upon Supercharge's ShimmerLayout which is I feel very less active in terms of release. So I came up with an alternative.

Demo

Change layout manager in runtime LinearLayoutManager to GridLayoutManager and Shimmer will adopt accordingly. Setup mShimmerRecyclerView.setItemViewType(ShimmerAdapter.ItemViewType) to change view type of Shimmer adapter.

Switching Layouts Multiple Type Demo Grid Demo

Download

To include ShimmerRecyclerView in your project, add the following to your dependencies:

app/build.gradle

dependencies {
   implementation 'com.facebook.shimmer:shimmer:0.5.0'
   implementation 'com.todkars:shimmer-recyclerview:0.4.1'
}

Usage

The following snippet shows how you can use Shimmer RecyclerView in your project.

Layout

<com.todkars.shimmer.ShimmerRecyclerView
    android:id="@+id/shimmer_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
    app:shimmer_recycler_layout="@layout/list_item_shimmer_layout"
    app:shimmer_recycler_item_count="10" />

Activity

public class MainActivity extends Activity {
    
    private ShimmerRecyclerView mShimmerRecyclerView;
    
    //... other variables
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        mShimmerRecyclerView = findViewById(R.id.shimmer_recycler_view);
        
        mShimmerRecyclerView.setLayoutManager(new LinearLayoutManager(this),
            R.layout.list_item_shimmer_layout);
        
        mShimmerRecyclerView.setAdapter(adapter);
        
        // This is optional, use if no attributes are mentioned in layout xml resource.
        // WARNING: Setting Shimmer programmatically will obsolete all shimmer attributes.
        /* mShimmerRecyclerView.setShimmer(mShimmer); */
        
        /* Shimmer layout view type depending on List / Gird */
        mShimmerRecyclerView.setItemViewType((type, position) -> {
            switch (type) {
                case ShimmerRecyclerView.LAYOUT_GRID:
                    return position % 2 == 0
                            ? R.layout.list_item_shimmer_grid
                            : R.layout.list_item_shimmer_grid_alternate;

                default:
                case ShimmerRecyclerView.LAYOUT_LIST:
                    return position == 0 || position % 2 == 0
                            ? R.layout.list_item_shimmer
                            : R.layout.list_item_shimmer_alternate;
            }
        });
        
        mShimmerRecyclerView.showShimmer();     // to start showing shimmer
        
        // To stimulate long running work using android.os.Handler
        mHandler.postDelayed((Runnable) () -> {
            mShimmerRecyclerView.hideShimmer(); // to hide shimmer
        }, 3000);
    }
}

Attributes

Most of the attributes used for ShimmerRecyclerView are same as Facebook's ShimmerFrameLayout below is detail table:

Name Attribute Description
Shimmer Layout shimmer_recycler_layout Layout reference used for as shimmer base.
Shimmer Item Count shimmer_recycler_item_count Number of shimmers to be shown in list, default is 9.
Clip to Children shimmer_recycler_clip_to_children Whether to clip the shimmering effect to the children, or to opaquely draw the shimmer on top of the children. Use this if your overall layout contains transparency.
Colored shimmer_recycler_colored Whether you want the shimmer to affect just the alpha or draw colors on-top of the children.
Base Color shimmer_recycler_base_color If colored is specified, the base color of the content.
Highlight Color shimmer_recycler_highlight_color If colored is specified, the shimmer's highlight color.
Base Alpha shimmer_recycler_base_alpha If colored is not specified, the alpha used to render the base view i.e. the unhighlighted view over which the highlight is drawn.
Highlight Alpha shimmer_recycler_highlight_alpha If colored is not specified, the alpha of the shimmer highlight.
Auto Start shimmer_recycler_auto_start Whether to automatically start the animation when the view is shown, or not.
Duration shimmer_recycler_duration Time it takes for the highlight to move from one end of the layout to the other.
Repeat Count shimmer_recycler_repeat_count Number of times of the current animation will repeat.
Repeat Delay shimmer_recycler_repeat_delay Delay after which the current animation will repeat.
Repeat Mode shimmer_recycler_repeat_mode What the animation should do after reaching the end, either restart from the beginning or reverse back towards it.
Direction shimmer_recycler_direction The travel direction of the shimmer highlight: left to right, top to bottom, right to left or bottom to top.
Dropoff shimmer_recycler_dropoff Controls the size of the fading edge of the highlight.
Intensity shimmer_recycler_intensity Controls the brightness of the highlight at the center
Shape shimmer_recycler_shape Shape of the highlight mask, either with a linear or a circular gradient.
Tilt shimmer_recycler_tilt Angle at which the highlight is tilted, measured in degrees.
Fixed Width or Height shimmer_recycler_fixed_width or shimmer_recycler_fixed_height Fixed sized highlight mask, if set, overrides the relative size value.
Width or Height Ratio shimmer_recycler_width_ratio or shimmer_recycler_height_ratio Size of the highlight mask, relative to the layout it is applied to.

LICENSE

    ShimmerRecyclerView a custom RecyclerView library
    Copyright (C) 2019  Omkar Todkar <[email protected]>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see https://www.gnu.org/licenses/gpl.txt

Facebook Shimmer is published under BSD License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].