├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── styles.xml │ │ ├── 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 │ │ ├── drawable-xhdpi │ │ │ ├── down_arrow.png │ │ │ └── ic_arrow_right.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── drawable │ │ │ ├── bg_bottom_eeeeee_stroke_white_solid.xml │ │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ │ ├── activity_main.xml │ │ │ ├── rv_item_discount_third.xml │ │ │ ├── rv_item_discount_second.xml │ │ │ └── rv_item_discount_first.xml │ │ └── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── wellijohn │ │ └── org │ │ └── multilevelrecyclerview │ │ ├── viewholder │ │ ├── DiscountThirdVH.java │ │ ├── DiscountSecondVH.java │ │ └── DiscountFirstVH.java │ │ ├── DemoActivity.java │ │ ├── TestData.java │ │ └── DemoRVAdapter.java ├── proguard-rules.pro └── build.gradle ├── treerecyclerview ├── .gitignore ├── src │ └── main │ │ ├── res │ │ └── values │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── wellijohn │ │ └── org │ │ └── treerecyclerview │ │ ├── vo │ │ ├── Tree.java │ │ └── TreeItem.java │ │ ├── ex │ │ └── StopMsgException.java │ │ └── adapter │ │ ├── BaseRVAdapterV2.java │ │ └── BaseTreeRVAdapter.java ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /treerecyclerview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':treerecyclerview' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MultiLevelRecyclerView 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /treerecyclerview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TreeRecyclerView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/down_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/drawable-xhdpi/down_arrow.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/drawable-xhdpi/ic_arrow_right.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /treerecyclerview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WelliJohn/MultiLevelRecyclerView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | /.idea/ 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Aug 17 16:27:02 CST 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/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_bottom_eeeeee_stroke_white_solid.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /treerecyclerview/src/main/java/wellijohn/org/treerecyclerview/vo/Tree.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.treerecyclerview.vo; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author: WelliJohn 7 | * @time: 2018/8/3-15:29 8 | * @email: wellijohn1991@gmail.com 9 | * @desc: 10 | */ 11 | public interface Tree { 12 | 13 | int getLevel(); 14 | 15 | List getChilds(); 16 | 17 | boolean isExpand(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #333333 7 | #666666 8 | #eeeeee 9 | #4a4a4a 10 | #FFFFFF 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 25dp 4 | 2dp 5 | 20sp 6 | 15dp 7 | 60dp 8 | 16sp 9 | 70dp 10 | 10dp 11 | 12sp 12 | 5dp 13 | 4dp 14 | -------------------------------------------------------------------------------- /treerecyclerview/src/main/java/wellijohn/org/treerecyclerview/vo/TreeItem.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.treerecyclerview.vo; 2 | 3 | /** 4 | * @author: WelliJohn 5 | * @time: 2018/8/13-15:49 6 | * @email: wellijohn1991@gmail.com 7 | * @desc: 8 | */ 9 | public abstract class TreeItem implements Tree { 10 | private boolean isOpen; 11 | 12 | public final boolean isOpen() { 13 | return isOpen; 14 | } 15 | 16 | public final void setOpen(boolean open) { 17 | isOpen = open; 18 | } 19 | 20 | @Override 21 | public final boolean isExpand() { 22 | return isOpen; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /treerecyclerview/src/main/java/wellijohn/org/treerecyclerview/ex/StopMsgException.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.treerecyclerview.ex; 2 | 3 | 4 | import wellijohn.org.treerecyclerview.vo.Tree; 5 | 6 | /** 7 | * @author: WelliJohn 8 | * @time: 2018/8/6-17:12 9 | * @email: wellijohn1991@gmail.com 10 | * @desc: 递归跳出的异常 11 | */ 12 | public class StopMsgException extends RuntimeException { 13 | private Tree tree; 14 | 15 | public T getTree() { 16 | return (T) tree; 17 | } 18 | 19 | public StopMsgException setTree(Tree tree) { 20 | this.tree = tree; 21 | return this; 22 | } 23 | 24 | public StopMsgException(String message) { 25 | super(message); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /treerecyclerview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 27 5 | 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 15 10 | targetSdkVersion 27 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | } 26 | 27 | dependencies { 28 | implementation 'com.android.support:appcompat-v7:27.1.1' 29 | implementation 'com.android.support:recyclerview-v7:27.1.1' 30 | implementation 'com.github.ReactiveX:RxAndroid:2.1.0' 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /treerecyclerview/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/java/wellijohn/org/multilevelrecyclerview/viewholder/DiscountThirdVH.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.multilevelrecyclerview.viewholder; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import wellijohn.org.multilevelrecyclerview.R; 8 | 9 | 10 | /** 11 | * @author: WelliJohn 12 | * @time: 2018/8/7-10:04 13 | * @email: wellijohn1991@gmail.com 14 | * @desc: 15 | */ 16 | public class DiscountThirdVH extends RecyclerView.ViewHolder { 17 | public TextView tvName; 18 | public TextView tvZhe; 19 | public TextView tvNum; 20 | 21 | public DiscountThirdVH(View view) { 22 | super(view); 23 | initView(); 24 | } 25 | 26 | private void initView() { 27 | tvName = itemView.findViewById(R.id.tv_name); 28 | tvZhe = itemView.findViewById(R.id.tv_zhe); 29 | tvNum = itemView.findViewById(R.id.tv_num); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/wellijohn/org/multilevelrecyclerview/DemoActivity.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.multilevelrecyclerview; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | 8 | public class DemoActivity extends AppCompatActivity { 9 | 10 | private RecyclerView mRv; 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | initView(); 17 | mRv.setLayoutManager(new LinearLayoutManager(this)); 18 | DemoRVAdapter demoRVAdapter = new DemoRVAdapter(); 19 | mRv.setAdapter(demoRVAdapter); 20 | demoRVAdapter.setDatas(TestData.getTestData()); 21 | 22 | } 23 | 24 | private void initView() { 25 | mRv = findViewById(R.id.rv); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | defaultConfig { 6 | applicationId "wellijohn.org.multilevelrecyclerview" 7 | minSdkVersion 15 8 | targetSdkVersion 27 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:27.1.1' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.2' 25 | implementation project(':treerecyclerview') 26 | implementation 'com.android.support:recyclerview-v7:27.1.1' 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/wellijohn/org/multilevelrecyclerview/viewholder/DiscountSecondVH.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.multilevelrecyclerview.viewholder; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.view.View; 5 | import android.widget.ImageView; 6 | import android.widget.TextView; 7 | 8 | import wellijohn.org.multilevelrecyclerview.R; 9 | 10 | 11 | /** 12 | * @author: WelliJohn 13 | * @time: 2018/8/7-10:04 14 | * @email: wellijohn1991@gmail.com 15 | * @desc: 16 | */ 17 | public class DiscountSecondVH extends RecyclerView.ViewHolder { 18 | public TextView tvName; 19 | public TextView tvZhe; 20 | public TextView tvNum; 21 | public ImageView iv; 22 | 23 | public DiscountSecondVH(View view) { 24 | super(view); 25 | initView(); 26 | } 27 | 28 | private void initView() { 29 | tvName = itemView.findViewById(R.id.tv_name); 30 | tvZhe = itemView.findViewById(R.id.tv_zhe); 31 | tvNum = itemView.findViewById(R.id.tv_num); 32 | iv = itemView.findViewById(R.id.iv); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/wellijohn/org/multilevelrecyclerview/viewholder/DiscountFirstVH.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.multilevelrecyclerview.viewholder; 2 | 3 | import android.support.constraint.ConstraintLayout; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.View; 6 | import android.widget.ImageView; 7 | import android.widget.TextView; 8 | 9 | import wellijohn.org.multilevelrecyclerview.R; 10 | 11 | 12 | /** 13 | * @author: WelliJohn 14 | * @time: 2018/8/7-10:03 15 | * @email: wellijohn1991@gmail.com 16 | * @desc: 17 | */ 18 | public class DiscountFirstVH extends RecyclerView.ViewHolder { 19 | 20 | public TextView tvName; 21 | public TextView tvDes; 22 | public ImageView iv; 23 | public ConstraintLayout cl; 24 | public View viewLine; 25 | public TextView tvZhe; 26 | 27 | public DiscountFirstVH(View itemView) { 28 | super(itemView); 29 | initView(); 30 | } 31 | 32 | private void initView() { 33 | tvName = itemView.findViewById(R.id.tv_name); 34 | tvZhe = itemView.findViewById(R.id.tv_zhe); 35 | tvDes = itemView.findViewById(R.id.tv_des); 36 | iv = itemView.findViewById(R.id.iv); 37 | cl = itemView.findViewById(R.id.cl); 38 | viewLine = itemView.findViewById(R.id.view_sp); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /treerecyclerview/src/main/java/wellijohn/org/treerecyclerview/adapter/BaseRVAdapterV2.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.treerecyclerview.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import wellijohn.org.treerecyclerview.vo.Tree; 9 | 10 | /** 11 | * @author: WelliJohn 12 | * @time: 2018/8/3-15:32 13 | * @email: wellijohn1991@gmail.com 14 | * @desc: 15 | */ 16 | public abstract class BaseRVAdapterV2 extends RecyclerView.Adapter { 17 | 18 | 19 | private OnRVDataChangeListener onRVDataChangeListener; 20 | 21 | List mDatas = new ArrayList<>(); 22 | 23 | 24 | @Override 25 | public int getItemCount() { 26 | return mDatas != null ? mDatas.size() : 0; 27 | } 28 | 29 | public void addMoreDatas(List info) { 30 | if (info != null && info.size() > 0) { 31 | mDatas.addAll(mDatas.size(), info); 32 | notifyItemRangeInserted(mDatas.size(), info.size()); 33 | } 34 | } 35 | 36 | public List getDatas() { 37 | return mDatas; 38 | } 39 | 40 | public void setDatas(List info) { 41 | if (info != null) { 42 | mDatas = (List) info; 43 | } else { 44 | mDatas.clear(); 45 | } 46 | notifyDataSetChanged(); 47 | if (onRVDataChangeListener != null) 48 | onRVDataChangeListener.isEmpty(mDatas == null || mDatas.size() == 0); 49 | } 50 | 51 | public void setOnRVDataChangeListener(OnRVDataChangeListener onRVDataChangeListener) { 52 | this.onRVDataChangeListener = onRVDataChangeListener; 53 | } 54 | 55 | public interface OnRVDataChangeListener { 56 | void isEmpty(boolean isEmpty); 57 | } 58 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/wellijohn/org/multilevelrecyclerview/TestData.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.multilevelrecyclerview; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import wellijohn.org.treerecyclerview.vo.Tree; 7 | import wellijohn.org.treerecyclerview.vo.TreeItem; 8 | 9 | /** 10 | * @author: WelliJohn 11 | * @time: 2018/8/17-16:37 12 | * @email: wellijohn1991@gmail.com 13 | * @desc: 14 | */ 15 | public class TestData { 16 | public static List getTestData() { 17 | List list = new ArrayList(); 18 | for (int i = 0; i < 5; i++) { 19 | Person person = new Person(); 20 | list.add(person); 21 | } 22 | return list; 23 | } 24 | 25 | static class Person extends TreeItem { 26 | private boolean isOpean = true; 27 | List list = new ArrayList(); 28 | 29 | public Person() { 30 | Person1 person1 = new Person1(); 31 | list.add(person1); 32 | person1.setOpen(false); 33 | Person1 person2 = new Person1(); 34 | person2.setOpen(false); 35 | list.add(person2); 36 | } 37 | 38 | public int getLevel() { 39 | return 0; 40 | } 41 | 42 | public List getChilds() { 43 | 44 | return list; 45 | } 46 | 47 | } 48 | 49 | static class Person1 extends TreeItem { 50 | List list = new ArrayList(); 51 | 52 | 53 | public Person1() { 54 | Person2 person1 = new Person2(); 55 | list.add(person1); 56 | Person2 person2 = new Person2(); 57 | list.add(person2); 58 | } 59 | 60 | public int getLevel() { 61 | return 1; 62 | } 63 | 64 | 65 | public List getChilds() { 66 | 67 | return list; 68 | } 69 | 70 | } 71 | 72 | static class Person2 extends TreeItem { 73 | 74 | public int getLevel() { 75 | return 2; 76 | } 77 | 78 | 79 | public List getChilds() { 80 | return null; 81 | } 82 | 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/res/layout/rv_item_discount_third.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 20 | 21 | 31 | 32 | 33 | 42 | 43 | 54 | 55 | 56 | 62 | 63 | -------------------------------------------------------------------------------- /app/src/main/res/layout/rv_item_discount_second.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | 30 | 31 | 32 | 41 | 42 | 53 | 54 | 65 | 66 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /app/src/main/res/layout/rv_item_discount_first.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 20 | 21 | 22 | 30 | 31 | 38 | 39 | 47 | 48 | 49 | 58 | 59 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /app/src/main/java/wellijohn/org/multilevelrecyclerview/DemoRVAdapter.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.multilevelrecyclerview; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import wellijohn.org.multilevelrecyclerview.viewholder.DiscountFirstVH; 10 | import wellijohn.org.multilevelrecyclerview.viewholder.DiscountSecondVH; 11 | import wellijohn.org.multilevelrecyclerview.viewholder.DiscountThirdVH; 12 | import wellijohn.org.treerecyclerview.adapter.BaseTreeRVAdapter; 13 | import wellijohn.org.treerecyclerview.vo.TreeItem; 14 | 15 | /** 16 | * @author: WelliJohn 17 | * @time: 2018/8/17-16:42 18 | * @email: wellijohn1991@gmail.com 19 | * @desc: 20 | */ 21 | public class DemoRVAdapter extends BaseTreeRVAdapter { 22 | @NonNull 23 | @Override 24 | public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 25 | View view; 26 | RecyclerView.ViewHolder vh; 27 | switch (viewType) { 28 | case 0: 29 | view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item_discount_first, parent, false); 30 | vh = new DiscountFirstVH(view); 31 | break; 32 | case 1: 33 | view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item_discount_second, parent, false); 34 | vh = new DiscountSecondVH(view); 35 | break; 36 | case 2: 37 | default: 38 | view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item_discount_third, parent, false); 39 | vh = new DiscountThirdVH(view); 40 | break; 41 | } 42 | return vh; 43 | } 44 | 45 | 46 | @Override 47 | public void onBindViewHolder(int type, final TreeItem itemCategoryListBean, RecyclerView.ViewHolder holder) { 48 | switch (type) { 49 | case 0: 50 | DiscountFirstVH FHolder = (DiscountFirstVH) holder; 51 | FHolder.tvName.setText("第一级数据"); 52 | FHolder.itemView.setOnClickListener(new View.OnClickListener() { 53 | @Override 54 | public void onClick(View v) { 55 | itemCategoryListBean.setOpen(!itemCategoryListBean.isExpand()); 56 | notifyDataSetChanged(); 57 | } 58 | }); 59 | FHolder.iv.setImageResource(itemCategoryListBean.isExpand() ? R.drawable.down_arrow : 60 | R.drawable.ic_arrow_right); 61 | break; 62 | case 1: 63 | DiscountSecondVH SHolder = (DiscountSecondVH) holder; 64 | SHolder.tvName.setText("第二级数据"); 65 | SHolder.itemView.setOnClickListener(new View.OnClickListener() { 66 | @Override 67 | public void onClick(View v) { 68 | itemCategoryListBean.setOpen(!itemCategoryListBean.isExpand()); 69 | notifyDataSetChanged(); 70 | } 71 | }); 72 | SHolder.iv.setImageResource(itemCategoryListBean.isExpand() ? R.drawable.down_arrow : 73 | R.drawable.ic_arrow_right); 74 | break; 75 | case 2: 76 | DiscountThirdVH THolder = (DiscountThirdVH) holder; 77 | THolder.tvName.setText("第三级数据"); 78 | break; 79 | } 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 先上效果图: 2 | ![](https://user-gold-cdn.xitu.io/2018/8/20/165560462c7326fe?w=282&h=500&f=gif&s=549336) 3 | ## 1.该多级列表的优势: 4 | 1. 支持无限级列表展开 5 | 2. 基于一个recyclerView实现 6 | 3. 可以自定义每一级item的样式,定制化更强 7 | 8 | ## 2.设计的思路 9 | 1. 数据结构List,ItemBean类中有变量List,构造整体RecyclerView的数据源 10 | 2. 因为RecyclerView.Adapter本来就支持多个type的item布局,不清楚的可以看下getItemViewType这个方法,所以我们可以利用这个类,来区分不同级用不同的Item。 11 | 3. 将Item必须具备的方法放在一个Tree接口里面,以后自定义的类只需要继承Tree接口就好了。 12 | 13 | ## 3.代码分析 14 | ``` 15 | public abstract class BaseTreeRVAdapter extends BaseRVAdapterV2 { 16 | 17 | @Override 18 | public void onBindViewHolder(T holder, final int position) { 19 | try { 20 | getLevel(position, mDatas, new PosBean()); 21 | } catch (StopMsgException ex) { 22 | int type = Integer.parseInt(ex.getMessage()); 23 | M tree = ex.getTree(); 24 | onBindViewHolder(type, tree, holder); 25 | } 26 | } 27 | 28 | 29 | @Override 30 | public int getItemViewType(int position) { 31 | try { 32 | getLevel(position, mDatas, new PosBean()); 33 | } catch (StopMsgException ex) { 34 | return Integer.parseInt(ex.getMessage()); 35 | } 36 | return 0; 37 | } 38 | 39 | @Override 40 | public int getItemCount() { 41 | return getTotal(mDatas); 42 | } 43 | 44 | protected abstract void onBindViewHolder(int type, M tree, T holder); 45 | 46 | public List getDatas() { 47 | return mDatas; 48 | } 49 | 50 | public void setDatas(List info) { 51 | if (info != null) { 52 | mDatas = info; 53 | } else { 54 | mDatas.clear(); 55 | } 56 | notifyDataSetChanged(); 57 | } 58 | } 59 | 60 | ``` 61 | 注释1:主要是计算当前给的数据他的item个数,会根据是否展开的状态来统总个数 62 | 注释2:计算当前的postion对应的item层级,来显示对应的item布局 63 | ## 4.对于自己需要实现的地方 64 | ``` 65 | public class TreeListAdapter extends BaseTreeRVAdapter { 66 | 67 | @Override 68 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 69 | View view; 70 | RecyclerView.ViewHolder vh; 71 | switch (viewType) { 72 | case 0: 73 | ...... 74 | break; 75 | case 1: 76 | ...... 77 | break; 78 | case 2: 79 | ...... 80 | break; 81 | case 3: 82 | case 4: 83 | ...... 84 | } 85 | return vh; 86 | } 87 | 88 | 89 | @Override 90 | protected void onBindViewHolder(int type, final DiscountItem itemCategoryListBean, RecyclerView.ViewHolder holder) { 91 | switch (type) { 92 | case 0: 93 | ...... 94 | break; 95 | case 1: 96 | ...... 97 | break; 98 | case 2: 99 | ...... 100 | break; 101 | case 3: 102 | case 4: 103 | ...... 104 | } 105 | } 106 | } 107 | ``` 108 | 1. 上面的泛型T就是我们的Item的class类型,所以自定义的class要想用这个adapter的话,都需要实现Tree接口 109 | 2. onBindViewHolder方法中形参的的type就是层级,比如说第一级type就是0,第二级是1,以此类推 110 | 111 | ## 5.另外自定义的类如果不需要extends的话,那么需要继承wellijohn.org.treerecyclerview.vo.TreeItem,如果已经写了的话,那么就需要自己实现Tree接口。 112 | 必须实现的几个方法: 113 | ``` 114 | int getLevel();//每个item的层级,比如一级就是0,二级就返回1,这里的0和1可以自己定义,后面就是根据这个来选择哪种样式的item 115 | 116 | List getChilds();//返回的子列表,比如当前类是一级的话,那么这个方法返回的是二级的列表数据 117 | 118 | boolean isExpand();//是否展开,true展开,false不展开,一般就是点击下去修改这个值刷新adapter,就能达到展开还是折叠的目的了 119 | ``` 120 | 121 | ## 6.引入方式 122 | ``` 123 | step 1. 124 | Add it in your root build.gradle at the end of repositories: 125 | 126 | allprojects { 127 | repositories { 128 | ... 129 | maven { url 'https://jitpack.io' } 130 | } 131 | } 132 | Step 2. Add the dependency 133 | 134 | dependencies { 135 | implementation 'com.github.WelliJohn:MultiLevelRecyclerView:0.0.1' 136 | } 137 | ``` 138 | 139 | ## 7.demo示例 140 | [多级列表示例](https://github.com/WelliJohn/MultiLevelRecyclerView),如果觉得有用,还请点个赞。 -------------------------------------------------------------------------------- /treerecyclerview/src/main/java/wellijohn/org/treerecyclerview/adapter/BaseTreeRVAdapter.java: -------------------------------------------------------------------------------- 1 | package wellijohn.org.treerecyclerview.adapter; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | 5 | import java.util.List; 6 | 7 | import io.reactivex.Observable; 8 | import io.reactivex.ObservableEmitter; 9 | import io.reactivex.ObservableOnSubscribe; 10 | import io.reactivex.Observer; 11 | import io.reactivex.android.schedulers.AndroidSchedulers; 12 | import io.reactivex.disposables.Disposable; 13 | import io.reactivex.schedulers.Schedulers; 14 | import wellijohn.org.treerecyclerview.ex.StopMsgException; 15 | import wellijohn.org.treerecyclerview.vo.Tree; 16 | 17 | /** 18 | * @author: WelliJohn 19 | * @time: 2018/8/3-15:32 20 | * @email: wellijohn1991@gmail.com 21 | * @desc: 22 | */ 23 | public abstract class BaseTreeRVAdapter extends BaseRVAdapterV2 { 24 | 25 | @Override 26 | public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) { 27 | Observable.create(new ObservableOnSubscribe() { 28 | @Override 29 | public void subscribe(ObservableEmitter emitter) throws StopMsgException { 30 | try { 31 | getLevel(position, mDatas, new PosBean()); 32 | } catch (StopMsgException ex) { 33 | emitter.onNext(ex); 34 | } 35 | } 36 | }) 37 | .subscribeOn(Schedulers.io()) 38 | .observeOn(AndroidSchedulers.mainThread()) 39 | .subscribe(new Observer() { 40 | @Override 41 | public void onSubscribe(Disposable d) { 42 | 43 | } 44 | 45 | @Override 46 | public void onNext(StopMsgException ex) { 47 | int type = Integer.parseInt(ex.getMessage()); 48 | M tree = ex.getTree(); 49 | onBindViewHolder(type, tree, holder); 50 | } 51 | 52 | @Override 53 | public void onError(Throwable e) { 54 | 55 | } 56 | 57 | @Override 58 | public void onComplete() { 59 | 60 | } 61 | }); 62 | } 63 | 64 | 65 | @Override 66 | public int getItemViewType(int position) { 67 | try { 68 | getLevel(position, mDatas, new PosBean()); 69 | } catch (StopMsgException ex) { 70 | return Integer.parseInt(ex.getMessage()); 71 | } 72 | return 0; 73 | } 74 | 75 | @Override 76 | public int getItemCount() { 77 | return getTotal(mDatas); 78 | } 79 | 80 | public abstract void onBindViewHolder(int type, M tree, RecyclerView.ViewHolder holder); 81 | 82 | private Integer getTotal(List paramDatas) { 83 | int total = 0; 84 | for (int i = 0, size = paramDatas == null ? 0 : paramDatas.size(); i < size; i++) { 85 | M tree = paramDatas.get(i); 86 | if (tree.isExpand()) { 87 | total++; 88 | total = getTotal(tree.getChilds()) + total; 89 | } else { 90 | total++; 91 | } 92 | } 93 | return total; 94 | } 95 | 96 | 97 | private void getLevel(int position, List paramDatas, PosBean posBean) throws StopMsgException { 98 | if (paramDatas == null) return; 99 | for (M tree : paramDatas) { 100 | if (tree.isExpand()) { 101 | posBean.setIndex(posBean.getIndex() + 1); 102 | if (position + 1 == posBean.getIndex()) 103 | throw new StopMsgException(String.valueOf(tree.getLevel())).setTree(tree); 104 | getLevel(position, tree.getChilds(), posBean); 105 | } else { 106 | posBean.setIndex(posBean.getIndex() + 1); 107 | if (position + 1 == posBean.getIndex()) 108 | throw new StopMsgException(String.valueOf(tree.getLevel())).setTree(tree); 109 | } 110 | } 111 | } 112 | 113 | 114 | private static class PosBean { 115 | int index = 0; 116 | 117 | int getIndex() { 118 | return index; 119 | } 120 | 121 | void setIndex(int index) { 122 | this.index = index; 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | --------------------------------------------------------------------------------