├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable │ │ │ ├── bg_sharp_card.xml │ │ │ ├── bg_card.xml │ │ │ └── gradient_background.xml │ │ ├── layout │ │ │ ├── activity_second_grid.xml │ │ │ ├── activity_second_list.xml │ │ │ ├── activity_list.xml │ │ │ ├── activity_grid.xml │ │ │ ├── layout_second_demo_grid.xml │ │ │ ├── layout_demo_grid.xml │ │ │ ├── layout_second_news_card.xml │ │ │ ├── activity_main.xml │ │ │ ├── layout_ecom_item.xml │ │ │ ├── layout_news_card.xml │ │ │ ├── layout_second_demo.xml │ │ │ └── layout_demo.xml │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── styles.xml │ │ │ └── strings.xml │ │ ├── java │ │ └── com │ │ │ └── cooltechworks │ │ │ └── sample │ │ │ ├── utils │ │ │ ├── DemoConfiguration.kt │ │ │ ├── view │ │ │ │ └── CardPaddingItemDecoration.kt │ │ │ └── BaseUtils.kt │ │ │ ├── models │ │ │ └── ItemCard.kt │ │ │ ├── adapters │ │ │ └── CardAdapter.kt │ │ │ ├── MainActivity.kt │ │ │ ├── DemoActivity.kt │ │ │ └── viewholders │ │ │ └── ItemHolder.kt │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── shimmer ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── colors.xml │ │ │ └── attrs.xml │ │ └── layout │ │ │ ├── viewholder_shimmer.xml │ │ │ └── layout_sample_view.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── cooltechworks │ │ └── views │ │ └── shimmer │ │ ├── ShimmerViewHolder.kt │ │ ├── ShimmerAdapter.kt │ │ └── ShimmerRecyclerView.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── screenshots ├── grid_demo.gif ├── list_demo.gif ├── second_grid_demo.gif └── second_list_demo.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── .github └── workflows │ └── android.yml ├── .travis.yml ├── LICENSE.md ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /shimmer/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':shimmer' 2 | -------------------------------------------------------------------------------- /screenshots/grid_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/screenshots/grid_demo.gif -------------------------------------------------------------------------------- /screenshots/list_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/screenshots/list_demo.gif -------------------------------------------------------------------------------- /screenshots/second_grid_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/screenshots/second_grid_demo.gif -------------------------------------------------------------------------------- /screenshots/second_list_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/screenshots/second_list_demo.gif -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ShimmerRecyclerView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | /local.properties 5 | /.idea/workspace.xml 6 | /.idea/libraries 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /shimmer/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #16000000 4 | #e3e1e3 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Aug 13 15:09:32 AST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_sharp_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: set up JDK 1.8 17 | uses: actions/setup-java@v1 18 | with: 19 | java-version: 1.8 20 | - name: Build with Gradle 21 | run: ./gradlew build 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | 3 | sudo: false 4 | 5 | android: 6 | components: 7 | # Note that the tools section appears twice on purpose as it’s required to get the newest Android SDK tools. 8 | - tools 9 | - platform-tools 10 | - tools 11 | - build-tools-27.0.3 12 | - android-27 13 | - extra-android-m2repository 14 | 15 | before_install: 16 | - yes | sdkmanager "platforms;android-27" # https://github.com/travis-ci/travis-ci/issues/8651 17 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2017 Harish Sridharan 2 | 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/sample/utils/DemoConfiguration.kt: -------------------------------------------------------------------------------- 1 | package com.cooltechworks.sample.utils 2 | 3 | 4 | import android.support.annotation.LayoutRes 5 | import android.support.annotation.StringRes 6 | import android.support.annotation.StyleRes 7 | import android.support.v7.widget.RecyclerView 8 | 9 | class DemoConfiguration { 10 | @StyleRes 11 | var styleResource: Int = 0 12 | 13 | @LayoutRes 14 | var layoutResource: Int = 0 15 | 16 | @StringRes 17 | var titleResource: Int = 0 18 | 19 | var layoutManager: RecyclerView.LayoutManager? = null 20 | 21 | var itemDecoration: RecyclerView.ItemDecoration? = null 22 | } 23 | -------------------------------------------------------------------------------- /shimmer/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/sharish/SDK_HOME/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /shimmer/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/sharish/SDK_HOME/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/sample/utils/view/CardPaddingItemDecoration.kt: -------------------------------------------------------------------------------- 1 | package com.cooltechworks.sample.utils.view 2 | 3 | 4 | import android.content.Context 5 | import android.graphics.Rect 6 | import android.support.v7.widget.RecyclerView 7 | import android.util.TypedValue 8 | import android.view.View 9 | 10 | class CardPaddingItemDecoration(context: Context) : RecyclerView.ItemDecoration() { 11 | 12 | private val paddingBetweenItems = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8f, context.resources.displayMetrics).toInt() 13 | 14 | override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State?) { 15 | outRect.set(0, 0, 0, paddingBetweenItems) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_second_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_second_list.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #455a64 4 | #374850 5 | #FF4081 6 | 7 | #2874f0 8 | #2368d7 9 | #388e3c 10 | 11 | #717171 12 | @color/colorAccentGrid 13 | #737373 14 | 15 | #212121 16 | #8b8b8b 17 | 18 | #24000000 19 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 17 | -------------------------------------------------------------------------------- /shimmer/src/main/res/layout/viewholder_shimmer.xml: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /shimmer/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android-extensions' 3 | apply plugin: 'kotlin-android' 4 | 5 | android { 6 | compileSdkVersion 27 7 | buildToolsVersion "27.0.3" 8 | 9 | defaultConfig { 10 | minSdkVersion 14 11 | targetSdkVersion 27 12 | versionCode 2 13 | versionName "1.3" 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation 'com.android.support:recyclerview-v7:27.1.1' 26 | implementation 'io.supercharge:shimmerlayout:2.1.0' 27 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 28 | } 29 | repositories { 30 | mavenCentral() 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/sample/models/ItemCard.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Harish Sridharan 3 | * 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package com.cooltechworks.sample.models 20 | 21 | class ItemCard { 22 | 23 | var title: String? = null 24 | var description: String? = null 25 | var thumbnailUrl: String? = null 26 | var summaryText: String? = null 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/gradient_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 22 | 23 | 27 | 28 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android-extensions' 3 | apply plugin: 'kotlin-android' 4 | 5 | android { 6 | compileSdkVersion 27 7 | buildToolsVersion "27.0.3" 8 | defaultConfig { 9 | applicationId "com.cooltechworks.sample" 10 | minSdkVersion 14 11 | targetSdkVersion 27 12 | versionCode 2 13 | versionName "1.3" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation 'com.android.support:appcompat-v7:27.1.1' 25 | implementation 'com.android.support:recyclerview-v7:27.1.1' 26 | implementation 'com.github.bumptech.glide:glide:4.5.0' 27 | implementation project(':shimmer') 28 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 29 | } 30 | repositories { 31 | mavenCentral() 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_second_demo_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 21 | 22 | 30 | 31 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 21 | 22 | 23 | 24 | 25 | 29 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /shimmer/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/sample/adapters/CardAdapter.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Harish Sridharan 3 | * 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package com.cooltechworks.sample.adapters 20 | 21 | import android.support.v7.widget.RecyclerView 22 | import android.view.ViewGroup 23 | import com.cooltechworks.sample.models.ItemCard 24 | import com.cooltechworks.sample.utils.BaseUtils 25 | import com.cooltechworks.sample.viewholders.ItemHolder 26 | import java.util.* 27 | 28 | class CardAdapter : RecyclerView.Adapter() { 29 | 30 | private var mCards: List = ArrayList() 31 | private var mType = BaseUtils.TYPE_LIST 32 | 33 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder { 34 | return ItemHolder.newInstance(parent, mType) 35 | } 36 | 37 | override fun onBindViewHolder(holder: ItemHolder, position: Int) { 38 | holder.bind(mCards[position]) 39 | } 40 | 41 | override fun getItemCount() = mCards.size 42 | 43 | 44 | fun setCards(cards: List?) { 45 | if (cards == null) { 46 | return 47 | } 48 | 49 | mCards = cards 50 | } 51 | 52 | fun setType(type: Int) { 53 | this.mType = type 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Harish Sridharan 3 | * 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | package com.cooltechworks.sample 21 | 22 | import android.content.Intent 23 | import android.os.Bundle 24 | import android.support.v7.app.AppCompatActivity 25 | import android.widget.Button 26 | import com.cooltechworks.sample.utils.BaseUtils 27 | import kotlinx.android.synthetic.main.activity_main.* 28 | 29 | class MainActivity : AppCompatActivity() { 30 | 31 | override fun onCreate(savedInstanceState: Bundle?) { 32 | super.onCreate(savedInstanceState) 33 | setContentView(R.layout.activity_main) 34 | 35 | createClickListener(list_demo_button, BaseUtils.TYPE_LIST) 36 | createClickListener(grid_demo_button, BaseUtils.TYPE_GRID) 37 | createClickListener(list_second_demo_button, BaseUtils.TYPE_SECOND_LIST) 38 | createClickListener(grid_second_demo_button, BaseUtils.TYPE_SECOND_GRID) 39 | } 40 | 41 | private fun createClickListener(button: Button, demoType: Int) { 42 | button.setOnClickListener { startDemo(demoType) } 43 | } 44 | 45 | private fun startDemo(demoType: Int) { 46 | val intent = Intent(this, DemoActivity::class.java) 47 | intent.putExtra(DemoActivity.EXTRA_TYPE, demoType) 48 | startActivity(intent) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_demo_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 26 | 27 | 33 | 34 | 41 | 42 | 50 | 51 | 59 | 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/sample/DemoActivity.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Harish Sridharan 3 | * 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | package com.cooltechworks.sample 21 | 22 | import android.os.Bundle 23 | import android.support.v7.app.AppCompatActivity 24 | import android.support.v7.widget.RecyclerView 25 | import com.cooltechworks.sample.adapters.CardAdapter 26 | import com.cooltechworks.sample.utils.BaseUtils 27 | import kotlinx.android.synthetic.main.activity_grid.* 28 | 29 | 30 | class DemoActivity : AppCompatActivity() { 31 | 32 | private lateinit var mAdapter: CardAdapter 33 | 34 | private val type: Int 35 | get() = intent.getIntExtra(EXTRA_TYPE, BaseUtils.TYPE_LIST) 36 | 37 | override fun onCreate(savedInstanceState: Bundle?) { 38 | super.onCreate(savedInstanceState) 39 | 40 | val type = type 41 | 42 | val layoutManager: RecyclerView.LayoutManager 43 | 44 | val demoConfiguration = BaseUtils.getDemoConfiguration(type, this) 45 | setTheme(demoConfiguration!!.styleResource) 46 | setContentView(demoConfiguration.layoutResource) 47 | layoutManager = demoConfiguration.layoutManager!! 48 | setTitle(demoConfiguration.titleResource) 49 | 50 | if (demoConfiguration.itemDecoration != null) { 51 | shimmer_recycler_view.addItemDecoration(demoConfiguration.itemDecoration) 52 | } 53 | 54 | mAdapter = CardAdapter() 55 | mAdapter.setType(type) 56 | 57 | shimmer_recycler_view.layoutManager = layoutManager 58 | shimmer_recycler_view.adapter = mAdapter 59 | shimmer_recycler_view.showShimmerAdapter() 60 | 61 | shimmer_recycler_view.postDelayed({ loadCards() }, 3000) 62 | } 63 | 64 | private fun loadCards() { 65 | val type = type 66 | 67 | mAdapter.setCards(BaseUtils.getCards(resources, type)) 68 | shimmer_recycler_view.hideShimmerAdapter() 69 | } 70 | 71 | companion object { 72 | const val EXTRA_TYPE = "type" 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /shimmer/src/main/java/com/cooltechworks/views/shimmer/ShimmerViewHolder.kt: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Copyright 2017 Harish Sridharan 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package com.cooltechworks.views.shimmer 19 | 20 | import android.graphics.drawable.Drawable 21 | import android.os.Build 22 | import android.support.v7.widget.RecyclerView 23 | import android.view.LayoutInflater 24 | import android.view.ViewGroup 25 | 26 | import io.supercharge.shimmerlayout.ShimmerLayout 27 | 28 | class ShimmerViewHolder(inflater: LayoutInflater, parent: ViewGroup, innerViewResId: Int) : RecyclerView.ViewHolder(inflater.inflate(R.layout.viewholder_shimmer, parent, false)) { 29 | 30 | private val mShimmerLayout: ShimmerLayout = itemView as ShimmerLayout 31 | 32 | init { 33 | inflater.inflate(innerViewResId, mShimmerLayout, true) 34 | } 35 | 36 | fun setShimmerAngle(angle: Int) { 37 | mShimmerLayout.setShimmerAngle(angle) 38 | } 39 | 40 | fun setShimmerColor(color: Int) { 41 | mShimmerLayout.setShimmerColor(color) 42 | } 43 | 44 | fun setShimmerMaskWidth(maskWidth: Float) { 45 | mShimmerLayout.setMaskWidth(maskWidth) 46 | } 47 | 48 | fun setShimmerViewHolderBackground(viewHolderBackground: Drawable?) { 49 | if (viewHolderBackground != null) { 50 | setBackground(viewHolderBackground) 51 | } 52 | } 53 | 54 | fun setShimmerAnimationDuration(duration: Int) { 55 | mShimmerLayout.setShimmerAnimationDuration(duration) 56 | } 57 | 58 | fun setAnimationReversed(animationReversed: Boolean) { 59 | mShimmerLayout.setAnimationReversed(animationReversed) 60 | } 61 | 62 | fun bind() { 63 | mShimmerLayout.startShimmerAnimation() 64 | } 65 | 66 | private fun setBackground(background: Drawable) { 67 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) { 68 | mShimmerLayout.background = background 69 | } else { 70 | mShimmerLayout.setBackgroundDrawable(background) 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_second_news_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 21 | 22 | 32 | 33 | 44 | 45 | 46 | 52 | 53 | 54 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /shimmer/src/main/res/layout/layout_sample_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 28 | 29 | 39 | 40 | 49 | 50 | 55 | 56 | 61 | 62 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 27 | 28 | 32 | 33 |