├── sample ├── .gitignore ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ └── layout │ │ │ │ ├── item_vertical_brand1.xml │ │ │ │ ├── item_vertical_brand2.xml │ │ │ │ ├── activity_linear.xml │ │ │ │ ├── activity_staggered_recycler.xml │ │ │ │ ├── activity_grid_recycler.xml │ │ │ │ └── activity_main.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── bosong │ │ │ │ └── sample │ │ │ │ ├── model │ │ │ │ └── BrandData.java │ │ │ │ ├── Utils.java │ │ │ │ ├── viewholder │ │ │ │ ├── VerticalBrandViewHolder2.java │ │ │ │ ├── VerticalBrandViewHolder1.java │ │ │ │ └── SViewHolderBase.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── adapter │ │ │ │ ├── VerticalAdapter.java │ │ │ │ └── StaggeredAdapter.java │ │ │ │ └── activity │ │ │ │ ├── LinearActivity.java │ │ │ │ ├── VerticalGridRecyclerActivity.java │ │ │ │ └── StaggeredRecyclerActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── bosong │ │ │ └── sample │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── bosong │ │ └── sample │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro ├── build.gradle ├── gradlew.bat └── gradlew ├── library ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── bosong │ │ │ └── commonitemdecoration │ │ │ └── SCommonItemDecoration.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── bosong │ │ │ └── commonitemdecoration │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── bosong │ │ └── commonitemdecoration │ │ └── ExampleInstrumentedTest.java ├── build.gradle └── proguard-rules.pro ├── demo.gif ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat ├── README_zh.md ├── gradlew └── LICENSE.txt /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/demo.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':library', ':sample' 2 | project(':sample').projectDir = new File('sample') -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CommonItemDecoration 3 | 4 | -------------------------------------------------------------------------------- /sample/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibosong/CommonItemDecoration/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Sep 16 14:21:22 CST 2019 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-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /sample/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Mar 22 16:50:35 CST 2017 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-3.3-all.zip 7 | -------------------------------------------------------------------------------- /sample/src/main/java/com/bosong/sample/model/BrandData.java: -------------------------------------------------------------------------------- 1 | package com.bosong.sample.model; 2 | 3 | /** 4 | * Created by boson on 2017/3/21. 5 | */ 6 | 7 | public class BrandData { 8 | public BrandData(String brandName){ 9 | this.brandName = brandName; 10 | } 11 | public String brandName; 12 | } 13 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CommonItemDecoration 3 | VerticalGridRecyclerActivity 4 | StaggeredRecyclerActivity 5 | LinearActivity 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/main/java/com/bosong/sample/Utils.java: -------------------------------------------------------------------------------- 1 | package com.bosong.sample; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Created by boson on 2017/3/10. 7 | */ 8 | 9 | public class Utils { 10 | private Utils(){} 11 | 12 | public static int dip2px(Context context, float dpValue) { 13 | final float scale = context.getApplicationContext().getResources().getDisplayMetrics().density; 14 | return (int) (dpValue * scale + 0.5f); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sample/src/test/java/com/bosong/sample/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.bosong.sample; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_vertical_brand1.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/test/java/com/bosong/commonitemdecoration/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.bosong.commonitemdecoration; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_vertical_brand2.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 13 | -------------------------------------------------------------------------------- /sample/src/main/java/com/bosong/sample/viewholder/VerticalBrandViewHolder2.java: -------------------------------------------------------------------------------- 1 | package com.bosong.sample.viewholder; 2 | 3 | import android.view.ViewGroup; 4 | import android.widget.TextView; 5 | 6 | import com.bosong.sample.model.BrandData; 7 | import com.bosong.sample.R; 8 | 9 | /** 10 | * Created by boson on 2017/3/12. 11 | */ 12 | 13 | public class VerticalBrandViewHolder2 extends SViewHolderBase { 14 | public TextView brandNameTv; 15 | 16 | public VerticalBrandViewHolder2(ViewGroup parent) { 17 | super(parent, R.layout.item_vertical_brand2); 18 | brandNameTv = findViewById(R.id.tv_preheat_brand); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample/src/main/java/com/bosong/sample/viewholder/VerticalBrandViewHolder1.java: -------------------------------------------------------------------------------- 1 | package com.bosong.sample.viewholder; 2 | 3 | import android.view.ViewGroup; 4 | import android.widget.TextView; 5 | 6 | import com.bosong.sample.model.BrandData; 7 | import com.bosong.sample.R; 8 | 9 | /** 10 | * Created by boson on 2017/3/10. 11 | */ 12 | 13 | public class VerticalBrandViewHolder1 extends SViewHolderBase { 14 | 15 | public volatile TextView brandNameTv; 16 | 17 | public VerticalBrandViewHolder1(ViewGroup itemView) { 18 | super(itemView, R.layout.item_vertical_brand1); 19 | brandNameTv = findViewById(R.id.tv_brand); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #built application files 2 | *.apk 3 | *.ap_ 4 | 5 | 6 | # files for the dex VM 7 | *.dex 8 | 9 | 10 | # Java class files 11 | *.class 12 | 13 | 14 | # generated files 15 | bin/ 16 | gen/ 17 | 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | 23 | # Windows thumbnail db 24 | Thumbs.db 25 | 26 | 27 | # OSX files 28 | .DS_Store 29 | 30 | 31 | # Eclipse project files 32 | .classpath 33 | .project 34 | 35 | 36 | # Android Studio 37 | .idea/ 38 | captures/ 39 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 40 | .gradle 41 | build/ 42 | 43 | 44 | # Signing files 45 | .signing/ 46 | 47 | 48 | # User-specific configurations 49 | *.iml -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_linear.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_staggered_recycler.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /sample/src/main/java/com/bosong/sample/viewholder/SViewHolderBase.java: -------------------------------------------------------------------------------- 1 | package com.bosong.sample.viewholder; 2 | 3 | import android.support.annotation.IdRes; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | /** 10 | * Created by boson on 2017/3/10. 11 | */ 12 | 13 | public class SViewHolderBase extends RecyclerView.ViewHolder{ 14 | public SViewHolderBase(View itemView) { 15 | super(itemView); 16 | } 17 | 18 | public SViewHolderBase(ViewGroup parent, int layoutId) { 19 | super(LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false)); 20 | } 21 | 22 | protected T findViewById(@IdRes int id){ 23 | return (T) itemView.findViewById(id); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/bosong/sample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.bosong.sample; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.bosong.brandlistdemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/bosong/commonitemdecoration/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.bosong.commonitemdecoration; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.bosong.commonitemdecoration.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_grid_recycler.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "28.0.3" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support:appcompat-v7:28.0.0' 30 | compile 'com.android.support:recyclerview-v7:28.0.0' 31 | testCompile 'junit:junit:4.12' 32 | } 33 | -------------------------------------------------------------------------------- /library/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 D:\Program\Android\sdk/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 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /sample/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 D:\Program\Android\sdk/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 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |