Skip to content

tehras/LoadingSkeleton

Repository files navigation

LoadingSkeleton

Build Status Download codecov


How it looks:


Demo GIF


How To Use Skeleton Layout:


  1. Wrap your layout
<com.github.tehras.loadingskeleton.LoadingSkeleton
    android:id="@+id/skeleton_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    ...
        
</com.github.tehras.loadingskeleton.LoadingSkeleton>
  1. Start and Stop
        //use as a normal layout
        val loadingSkeleton = findViewById(R.id.skeleton_layout) as LoadingSkeleton
        
        //start loading layout
        loadingSkeleton.start()
        
        //stop loading layout
        loadingSkeleton.stop()
  1. Setting custom actions

Java:

  //Set your own Skeleton View Converter
   
  loadingSkeleton
          .skeletonViewConverter(new LoadingSkeletonViewConverter.Builder()
                  .color(R.color.colorPrimary) //set color
                  .shimmer(true)  //shimmer, true/false
                  .cornerRadius(16f) //corner radius
                  .gradient(true) //gradient, true/false
                  .addConvert(YourLoadingSkeletonViewConverter1()) //add your own custom conver
                  .addConvert(YourLoadingSkeletonViewConverter2()) //adding converter ovverides default ones
                  .build()) //build, and you're done

Kotlin:

loadingSkeleton
        .skeletonViewConverter(LoadingSkeletonViewConverter.Builder()
                .color(R.color.colorPrimary) //set color
                .shimmer(true)  //shimmer, true/false
                .gradient(true) //gradient, true/false
                .cornerRadius(16.toFloat()) //corner radius
                .addConvert(YourLoadingSkeletonViewConverter1()) //add your own custom conver
                .addConvert(YourLoadingSkeletonViewConverter2()) //adding converter ovverides default ones
                .build()) //build, and you're done

Creating your own converter:


  1. Extend LoadingSkeletonViewStreamer<T : View>
  2. Implement public void convert(Context c, T v, Options options) || fun convert(c: Context, v: T, options: Options) - Called when .start() is called for EVERY view
  3. Implement public void revert(Context c, T v) || fun revert(c: Context, v: T) - Called when .stop is called for EVERY view
  4. There are optional public void start(){} || fun start(){} and public void stop(){} fun stop(){} fields that are called only once at start and stop

(Just take a look at the DefaultTextViewStreamer or DefaultImageViewStreamer for examples)

Gradle:

compile 'com.github.tehras:loading-skeleton:0.2.9'

Maven:

<dependency>
  <groupId>com.github.tehras</groupId>
  <artifactId>loading-skeleton</artifactId>
  <version>0.2.9</version>
  <type>pom</type>
</dependency>