Skip to content

Instantly share code, notes, and snippets.

View ashishkudale's full-sized avatar

Ashish Kudale ashishkudale

View GitHub Profile
public class Chapter {
public int id;
public String chapterName;
public String imageUrl;
}
public class Subject {
public int id;
public String subjectName;
public ArrayList<Chapter> chapters;
}
@ashishkudale
ashishkudale / prepareData method
Last active May 13, 2018 11:47
prepareData method with few data. Only for showing blog
private ArrayList<Subject> prepareData() {
ArrayList<Subject> subjects = new ArrayList<Subject>();
Subject physics = new Subject();
physics.id = 1;
physics.subjectName = "Physics";
physics.chapters = new ArrayList<Chapter>();
Chapter chapter1 = new Chapter();
chapter1.id = 1;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_margin="5dp"
android:layout_gravity="center"
@ashishkudale
ashishkudale / prepareData method
Last active May 13, 2018 12:10
prepareData complete method
private ArrayList<Subject> prepareData() {
ArrayList<Subject> subjects = new ArrayList<Subject>();
Subject physics = new Subject();
physics.id = 1;
physics.subjectName = "Physics";
physics.chapters = new ArrayList<Chapter>();
Chapter chapter1 = new Chapter();
chapter1.id = 1;
@ashishkudale
ashishkudale / single_subject.xml
Last active May 13, 2018 11:09
how a single subject will look like.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:orientation="vertical"
android:background="#FFFFFF"
android:layout_width="match_parent"
@ashishkudale
ashishkudale / activity_home.xml
Last active May 13, 2018 12:30
HomeActivity xml only consists of a single recycler view which contains both list.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ashishkudale.list_in_list.HomeActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvSubject"
@ashishkudale
ashishkudale / ChapterAdapter.java
Created May 11, 2018 10:58
Adapter for chapter list
public class ChapterAdapter extends RecyclerView.Adapter<ChapterAdapter.CustomViewHolder> {
private Context context;
private ArrayList<Chapter> chapters;
private LayoutInflater inflater;
public ChapterAdapter(Context context, ArrayList<Chapter> chapters) {
this.context = context;
this.chapters = chapters;
this.inflater = LayoutInflater.from(context);
@ashishkudale
ashishkudale / SubjectAdapter.java
Created May 11, 2018 11:00
Adapter for subject list
public class SubjectAdapter extends RecyclerView.Adapter<SubjectAdapter.ViewHolder> {
public ArrayList<Subject> subjects;
private Context context;
private LayoutInflater layoutInflater;
public SubjectAdapter(ArrayList<Subject> subjects, Context context) {
this.subjects = subjects;
this.context = context;
this.layoutInflater = LayoutInflater.from(context);
@ashishkudale
ashishkudale / HomeActivity.java
Last active May 13, 2018 12:36
implementation
public class HomeActivity extends AppCompatActivity {
private RecyclerView rvSubject;
private SubjectAdapter subjectAdapter;
private ArrayList<Subject> subjects;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);