diff --git a/README.md b/README.md index 7498b79..0ad7d17 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ### The easiest way to implement RecyclerView in just 1 Line. -Delicious Facts +Delicious Facts 🍭 -------- * Forget creation of tasteless `Adapters` & monotonous `findViewById` for your views in adapter. @@ -13,16 +13,16 @@ Delicious Facts * Manage properties of all view using single `SugarListener` or just set attributes for specific views. -Download via Gradle +Download via Gradle 💻 -------- Add it in your Project build.gradle at the end of repositories: ```groovy allprojects { -repositories { -maven { url 'https://jitpack.io' } -} + repositories { + maven { url 'https://jitpack.io' } + } } ``` @@ -30,14 +30,14 @@ maven { url 'https://jitpack.io' } Add the dependency in your App build.gradle: ```groovy dependencies { -implementation 'com.github.ThisIsNSH:CandyView:1.3' -// add these for internal functioning -implementation 'com.squareup.picasso:picasso:{latest version}' -implementation 'com.android.support:recyclerview-v7:{build version}' + implementation 'com.github.ThisIsNSH:CandyView:1.3' + // add these for internal functioning + implementation 'com.squareup.picasso:picasso:{latest version}' + implementation 'com.android.support:recyclerview-v7:{build version}' } ``` -Get Started +Get Started 🏁 -------- @@ -45,17 +45,17 @@ Get Started ```java class ExampleActivity extends Activity { -@Override -protected void onCreate(Bundle savedInstanceState) { -... + @Override + protected void onCreate(Bundle savedInstanceState) { + ... -// Initialize CandyView object -CandyView candyView = findViewById(R.id.candy); + // Initialize CandyView object + CandyView candyView = findViewById(R.id.candy); -// Create RecyclerView using make(Context content, int Layout, List Data, Model Class) -candyView.make(this, R.layout.adapter, dataList, Model.class); + // Create RecyclerView using make(Context content, int Layout, List Data, Model Class) + candyView.make(this, R.layout.adapter, dataList, Model.class); -} + } } ``` @@ -65,67 +65,67 @@ candyView.make(this, R.layout.adapter, dataList, Model.class); ```java class ExampleActivity extends Activity implements CandyView.SugarListener { -TextView textView; + TextView textView; -@Override -protected void onCreate(Bundle savedInstanceState) { -... -candyView.addSugarListener(this); -} + @Override + protected void onCreate(Bundle savedInstanceState) { + ... + candyView.addSugarListener(this); + } -@Override -public void onCandyMade() { + @Override + public void onCandyMade() { -// Initialize required adapter views -textView = (TextView) candyView.getViewById(R.id.text); + // Initialize required adapter views + textView = (TextView) candyView.getViewById(R.id.text); -} + } -@Override -public void onCandyRecycled(View view, int position) { + @Override + public void onCandyRecycled(View view, int position) { -// Set attributes of adapter views for all positions -textView.setTextColor(getResources().getColor(R.color.colorPrimary)); + // Set attributes of adapter views for all positions + textView.setTextColor(getResources().getColor(R.color.colorPrimary)); -// Set attributes of adapter views at a particular position -if (position == 1) -textView.setTextColor(getResources().getColor(R.color.colorAccent)); + // Set attributes of adapter views at a particular position + if (position == 1) + textView.setTextColor(getResources().getColor(R.color.colorAccent)); -} + } } ``` -#### Automatically Set Data +#### Automatically Set Data 🚀 #### 3. Create `Model Class` with variables having same names as IDs of views in adapter view. ```java public class Model { -// Declare data variables -String image; -String name; + // Declare data variables + String image; + String name; -public Model(String image, String name) { -this.image = image; -this.name = name; -} + public Model(String image, String name) { + this.image = image; + this.name = name; + } -// Getter & Setter for the variables -public String getImage() { -return image; -} + // Getter & Setter for the variables + public String getImage() { + return image; + } -public void setImage(String image) { -this.image = image; -} + public void setImage(String image) { + this.image = image; + } -public String getName() { -return name; -} + public String getName() { + return name; + } -public void setName(String name) { -this.name = name; -} + public void setName(String name) { + this.name = name; + } } ``` @@ -137,54 +137,65 @@ Make sure the variable name in `Model` and `ID` in layout.xml is same. ```XML - - - - - - - - - - - - - + + + + + + + + + + + + + ``` -Confused? +Confused 🤷‍♂️? Download Sample App. +-------- + + +Found a bug 🐛? -------- -* Download the sample app and test. +* Please create an issue with appropriate tags +* We welcome developers to fix the bug and open a PR +* Keep PR name as Fixes #Issue_Number + +Thank you ❤️ +-------- + +