diff --git a/.gitignore b/.gitignore index 5edb4ee..dda0b2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,8 @@ *.iml .gradle /local.properties -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml .DS_Store /build /captures .externalNativeBuild +/.idea/ diff --git a/README.md b/README.md index 320b5a5..1b9e3b8 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ ### example: ```XML - { diff --git a/customrecyclerview/src/main/res/layout/item_container.xml b/customrecyclerview/src/main/res/layout/item_container.xml index 026ae94..38d2145 100644 --- a/customrecyclerview/src/main/res/layout/item_container.xml +++ b/customrecyclerview/src/main/res/layout/item_container.xml @@ -5,7 +5,7 @@ android:background="@android:color/transparent"> - diff --git a/customrecyclerview/src/main/res/layout/item_container_adapter.xml b/customrecyclerview/src/main/res/layout/item_container_adapter.xml index 67258d4..d8a554c 100644 --- a/customrecyclerview/src/main/res/layout/item_container_adapter.xml +++ b/customrecyclerview/src/main/res/layout/item_container_adapter.xml @@ -9,7 +9,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - diff --git a/customrecyclerview/src/main/res/layout/item_parent_view.xml b/customrecyclerview/src/main/res/layout/item_parent_view.xml index 96b7f6f..0cf6a2a 100644 --- a/customrecyclerview/src/main/res/layout/item_parent_view.xml +++ b/customrecyclerview/src/main/res/layout/item_parent_view.xml @@ -41,7 +41,7 @@ - diff --git a/gradle.properties b/gradle.properties index 743d692..8de5058 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,8 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f75bfb0..c031f3e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Dec 25 16:11:19 IRST 2018 +#Thu Sep 26 12:52:28 IRST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/sample/build.gradle b/sample/build.gradle index ca72308..fa38160 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,14 +1,14 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 27 + compileSdkVersion 29 defaultConfig { applicationId "farshid_roohi.ir.sample.customrecyclerview" minSdkVersion 14 - targetSdkVersion 27 + targetSdkVersion 29 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -20,15 +20,18 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:27.0.2' - testImplementation 'junit:junit:4.12' + implementation 'androidx.appcompat:appcompat:1.0.0' - implementation 'com.android.support:design:27.0.2' - implementation 'com.android.support:cardview-v7:27.0.2' - implementation 'com.android.support:recyclerview-v7:27.0.2' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.cardview:cardview:1.0.0' + implementation 'androidx.recyclerview:recyclerview:1.0.0' implementation 'com.squareup.picasso:picasso:2.71828' // Add lib customRecyclerView - implementation 'ir.farshid_roohi:customrecyclerview:0.1.2' +// implementation 'ir.farshid_roohi:customrecyclerview:0.1.2' + implementation project(":customrecyclerview") + + testImplementation 'junit:junit:4.12' + } diff --git a/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/ChildAdapter.java b/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/Adapter.java similarity index 81% rename from sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/ChildAdapter.java rename to sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/Adapter.java index 5f62683..b8de6ef 100644 --- a/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/ChildAdapter.java +++ b/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/Adapter.java @@ -1,7 +1,7 @@ package farshid_roohi.ir.sample.customrecyclerview.sample; -import android.support.v7.widget.CardView; -import android.support.v7.widget.RecyclerView; +import androidx.cardview.widget.CardView; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -16,20 +16,20 @@ import farshid_roohi.ir.sample.customrecyclerview.R; -public class ChildAdapter extends RecyclerView.Adapter { +public class Adapter extends RecyclerView.Adapter { - private List list; + private List list; - public ChildAdapter(List list) { + public Adapter(List list) { this.list = list; } - public ChildAdapter() { + public Adapter() { this.list = new ArrayList<>(); } - public void addList(List list) { + public void addList(List list) { this.list = list; } @@ -44,7 +44,7 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { @Override public void onBindViewHolder(ViewHolder holder, int position) { - ModelSample item = this.list.get(position); + Model item = this.list.get(position); holder.txtName.setText(item.getName()); Picasso.get() @@ -91,6 +91,6 @@ public int getItemCount() { } public interface OnClickItemListener { - void onItemClickListener(ModelSample item); + void onItemClickListener(Model item); } } diff --git a/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/MainActivity.java b/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/MainActivity.java index 2ceb253..1397454 100644 --- a/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/MainActivity.java +++ b/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/MainActivity.java @@ -1,23 +1,25 @@ package farshid_roohi.ir.sample.customrecyclerview.sample; import android.os.Handler; -import android.support.v7.app.AppCompatActivity; + +import androidx.appcompat.app.AppCompatActivity; + import android.os.Bundle; import android.widget.Toast; import java.util.ArrayList; import java.util.List; +import farshid_roohi.ir.customrecyclerview.view.ItemContainerView; +import farshid_roohi.ir.customrecyclerview.view.ItemParentView; import farshid_roohi.ir.customrecyclerview.view.listener.OnClickTitleListener; import farshid_roohi.ir.sample.customrecyclerview.R; -import farshid_roohi.ir.customrecyclerview.view.view.ItemContainerView; -import farshid_roohi.ir.customrecyclerview.view.view.ItemParentView; -public class MainActivity extends AppCompatActivity implements OnClickTitleListener, ChildAdapter.OnClickItemListener { +public class MainActivity extends AppCompatActivity implements OnClickTitleListener, Adapter.OnClickItemListener { - private List listOne; - private List listTwo; - private List listThree; + private List listOne; + private List listTwo; + private List listThree; @Override protected void onCreate(Bundle savedInstanceState) { @@ -28,12 +30,19 @@ protected void onCreate(Bundle savedInstanceState) { final ItemContainerView itemContainerView = findViewById(R.id.item_container); + //adapters + Adapter adapterOne = new Adapter(this.listOne); + Adapter adapterTwo = new Adapter(this.listTwo); + final Adapter adapterThree = new Adapter(); + adapterOne.setItemListener(this); + adapterTwo.setItemListener(this); + adapterThree.setItemListener(this); + + List itemParentViewList = new ArrayList<>(); // populate item fake one - ChildAdapter adapterOne = new ChildAdapter(this.listOne); - final ItemParentView item1 = new ItemParentView(this); - adapterOne.setItemListener(this); + final ItemParentView item1 = new ItemParentView(this); item1.setTitlesListener(this); item1.setSecondTitle("more"); item1.setFirstTitle("title A"); @@ -43,9 +52,7 @@ protected void onCreate(Bundle savedInstanceState) { // populate item fake two - ChildAdapter adapterTwo = new ChildAdapter(this.listTwo); - ItemParentView item2 = new ItemParentView(this); - adapterTwo.setItemListener(this); + ItemParentView item2 = new ItemParentView(this); item2.setTitlesListener(this); item2.setFirstTitle("title B"); item2.setSecondTitle("more"); @@ -53,9 +60,7 @@ protected void onCreate(Bundle savedInstanceState) { item2.setAdapter(adapterTwo); // populate item fake three - final ChildAdapter adapterThree = new ChildAdapter(); - final ItemParentView item3 = new ItemParentView(this); - adapterThree.setItemListener(this); + final ItemParentView item3 = new ItemParentView(this); item3.setTitlesListener(this); item3.setFirstTitle("title C"); item3.setSecondTitle("more"); @@ -69,7 +74,7 @@ protected void onCreate(Bundle savedInstanceState) { public void run() { adapterThree.addList(listThree); item3.setVisibilityProgressBar(false); - itemContainerView.getContainerAdapter().notifyDataSetChanged(); + itemContainerView.notifyDataSetChanged(); } }, 3000); @@ -91,23 +96,23 @@ private void populateFakeItem() { this.listThree = new ArrayList<>(); - this.listOne.add(new ModelSample(0, "A", imageUrl)); - this.listOne.add(new ModelSample(0, "B", imageUrl)); - this.listOne.add(new ModelSample(0, "C", imageUrl)); - this.listOne.add(new ModelSample(0, "D", imageUrl)); - this.listOne.add(new ModelSample(0, "E", imageUrl)); + this.listOne.add(new Model(0, "A", imageUrl)); + this.listOne.add(new Model(0, "B", imageUrl)); + this.listOne.add(new Model(0, "C", imageUrl)); + this.listOne.add(new Model(0, "D", imageUrl)); + this.listOne.add(new Model(0, "E", imageUrl)); - this.listTwo.add(new ModelSample(0, "1", imageUrl)); - this.listTwo.add(new ModelSample(0, "2", imageUrl)); - this.listTwo.add(new ModelSample(0, "3", imageUrl)); - this.listTwo.add(new ModelSample(0, "4", imageUrl)); - this.listTwo.add(new ModelSample(0, "5", imageUrl)); + this.listTwo.add(new Model(0, "1", imageUrl)); + this.listTwo.add(new Model(0, "2", imageUrl)); + this.listTwo.add(new Model(0, "3", imageUrl)); + this.listTwo.add(new Model(0, "4", imageUrl)); + this.listTwo.add(new Model(0, "5", imageUrl)); - this.listThree.add(new ModelSample(0, "!", imageUrl)); - this.listThree.add(new ModelSample(0, "@", imageUrl)); - this.listThree.add(new ModelSample(0, "#", imageUrl)); - this.listThree.add(new ModelSample(0, "$", imageUrl)); - this.listThree.add(new ModelSample(0, "%", imageUrl)); + this.listThree.add(new Model(0, "!", imageUrl)); + this.listThree.add(new Model(0, "@", imageUrl)); + this.listThree.add(new Model(0, "#", imageUrl)); + this.listThree.add(new Model(0, "$", imageUrl)); + this.listThree.add(new Model(0, "%", imageUrl)); } @Override @@ -122,7 +127,7 @@ public void onClickLeftTitleListener(String action) { } @Override - public void onItemClickListener(ModelSample item) { + public void onItemClickListener(Model item) { Toast.makeText(this, item.getName(), Toast.LENGTH_SHORT).show(); } } diff --git a/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/ModelSample.java b/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/Model.java similarity index 87% rename from sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/ModelSample.java rename to sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/Model.java index ff64135..87343ac 100644 --- a/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/ModelSample.java +++ b/sample/src/main/java/farshid_roohi/ir/sample/customrecyclerview/sample/Model.java @@ -1,13 +1,13 @@ package farshid_roohi.ir.sample.customrecyclerview.sample; -public class ModelSample { +public class Model { private int id; private String name; private String imageUrl; - public ModelSample(int id , String name , String imageUrl){ + public Model(int id , String name , String imageUrl){ this.id = id; this.name = name; this.imageUrl = imageUrl; diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index f52ea85..b41de76 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -11,7 +11,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - - - +