Skip to content

Commit 114a8da

Browse files
committed
Another commit
1 parent f49ddc4 commit 114a8da

28 files changed

Lines changed: 619 additions & 96 deletions

‎.idea/misc.xml‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/vcs.xml‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package com.example.yoga.sqliteexample.Adapter;
2+
3+
import android.app.Activity;
4+
import android.support.v7.widget.RecyclerView;
5+
import android.view.LayoutInflater;
6+
import android.view.View;
7+
import android.view.ViewGroup;
8+
import android.widget.LinearLayout;
9+
import android.widget.TextView;
10+
import android.widget.Toast;
11+
12+
import com.example.yoga.sqliteexample.Model.Person;
13+
import com.example.yoga.sqliteexample.R;
14+
15+
import java.util.List;
16+
17+
18+
/**
19+
* Created by YOGA on 11/15/2016.
20+
*/
21+
22+
public class BillRecyclerViewAdapter extends RecyclerView.Adapter<BillRecyclerViewAdapter.ViewHolder> {
23+
private List<String> placeList, dateList;
24+
private List<Person> payerList;
25+
private Activity activity;
26+
27+
28+
public interface BillRecyclerInterface {
29+
void setBillDetailFragment();
30+
}
31+
32+
public BillRecyclerViewAdapter(Activity activity, List<String> placeList, List<String> dateList, List<Person> payerList) {
33+
this.activity = activity;
34+
this.placeList = placeList;
35+
this.dateList = dateList;
36+
this.payerList = payerList;
37+
}
38+
39+
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
40+
public TextView mTitle;
41+
public TextView textView_line1, textView_line2, textView_line3;
42+
private Activity activity;
43+
private BillRecyclerInterface mListener;
44+
45+
public ViewHolder(LinearLayout v, Activity activity) {
46+
super(v);
47+
v.setOnClickListener(this);
48+
49+
this.activity = activity;
50+
try {
51+
mListener = (BillRecyclerInterface) activity;
52+
} catch (ClassCastException e) {
53+
throw new ClassCastException(activity.toString() + " must implement OnArticleSelectedListener");
54+
}
55+
56+
mTitle = (TextView) v.findViewById(R.id.textView_title);
57+
textView_line1 = (TextView) v.findViewById(R.id.textView_line1);
58+
textView_line2 = (TextView) v.findViewById(R.id.textView_line2);
59+
textView_line3 = (TextView) v.findViewById(R.id.textView_line3);
60+
}
61+
62+
@Override
63+
public void onClick(View v) {
64+
// Toast.makeText(activity, "Clicked", Toast.LENGTH_SHORT).show();
65+
mListener.setBillDetailFragment();
66+
}
67+
}
68+
69+
70+
71+
@Override
72+
public BillRecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
73+
// create a new view
74+
View v = LayoutInflater.from(parent.getContext())
75+
.inflate(R.layout.listview_layout, parent, false);
76+
// set the view's size, margins, paddings and layout parameters
77+
ViewHolder vh = new ViewHolder((LinearLayout) v, activity);
78+
return vh;
79+
}
80+
81+
@Override
82+
public int getItemCount() {
83+
return placeList.size();
84+
}
85+
86+
// Replace the contents of a view (invoked by the layout manager)
87+
@Override
88+
public void onBindViewHolder(BillRecyclerViewAdapter.ViewHolder holder, int position) {
89+
char c = Character.toUpperCase(placeList.get(position).charAt(0));
90+
holder.mTitle.setText(String.valueOf(c));
91+
holder.textView_line1.setText(placeList.get(position));
92+
holder.textView_line2.setText(dateList.get(position));
93+
holder.textView_line3.setText(payerList.get(position).getName());
94+
}
95+
96+
97+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.example.yoga.sqliteexample.Adapter;
2+
3+
import android.app.Activity;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.support.v7.widget.RecyclerView;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.LinearLayout;
10+
import android.widget.TextView;
11+
12+
import com.example.yoga.sqliteexample.Model.Person;
13+
import com.example.yoga.sqliteexample.R;
14+
15+
16+
import java.util.List;
17+
18+
/**
19+
* Created by YOGA on 11/20/2016.
20+
*/
21+
22+
public class PersonRecyclerViewAdapter extends RecyclerView.Adapter<PersonRecyclerViewAdapter.ViewHolder> {
23+
Activity activity;
24+
List<String> nameList, emailList;
25+
26+
27+
public PersonRecyclerViewAdapter(Activity activity, List<String> nameList, List<String> emailList) {
28+
this.activity = activity;
29+
this.nameList = nameList;
30+
this.emailList = emailList;
31+
}
32+
33+
@Override
34+
public PersonRecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
35+
// create a new view
36+
View v = LayoutInflater.from(parent.getContext())
37+
.inflate(R.layout.person_listitem, parent, false);
38+
// set the view's size, margins, paddings and layout parameters
39+
ViewHolder vh = new PersonRecyclerViewAdapter.ViewHolder((LinearLayout) v, activity);
40+
return vh;
41+
}
42+
43+
@Override
44+
public void onBindViewHolder(ViewHolder holder, int position) {
45+
holder.person_listitem_textView_email.setText(emailList.get(position));
46+
holder.person_listitem_textView_name.setText(nameList.get(position));
47+
}
48+
49+
50+
@Override
51+
public int getItemCount() {
52+
return nameList.size();
53+
}
54+
55+
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
56+
AppCompatActivity appCompatActivity;
57+
TextView person_listitem_textView_name, person_listitem_textView_email;
58+
public ViewHolder(LinearLayout itemView, Activity activity) {
59+
super(itemView);
60+
if (activity instanceof AppCompatActivity) {
61+
this.appCompatActivity = (AppCompatActivity) activity;
62+
}
63+
64+
person_listitem_textView_name = (TextView) itemView.findViewById(R.id.person_listitem_textView_name);
65+
person_listitem_textView_email = (TextView) itemView.findViewById(R.id.person_listitem_textView_email);
66+
}
67+
68+
@Override
69+
public void onClick(View v) {
70+
71+
}
72+
}
73+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.example.yoga.sqliteexample.Decoration;
2+
3+
import android.content.Context;
4+
import android.content.res.TypedArray;
5+
import android.graphics.Canvas;
6+
import android.graphics.drawable.Drawable;
7+
import android.support.v4.content.ContextCompat;
8+
import android.support.v7.widget.RecyclerView;
9+
import android.view.View;
10+
11+
/**
12+
* Created by YOGA on 11/16/2016.
13+
*/
14+
15+
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
16+
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
17+
18+
private Drawable divider;
19+
20+
/**
21+
* Default divider will be used
22+
*/
23+
public DividerItemDecoration(Context context) {
24+
final TypedArray styledAttributes = context.obtainStyledAttributes(ATTRS);
25+
divider = styledAttributes.getDrawable(0);
26+
styledAttributes.recycle();
27+
}
28+
29+
/**
30+
* Custom divider will be used
31+
*/
32+
public DividerItemDecoration(Context context, int resId) {
33+
divider = ContextCompat.getDrawable(context, resId);
34+
}
35+
36+
@Override
37+
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
38+
int left = parent.getPaddingLeft();
39+
int right = parent.getWidth() - parent.getPaddingRight();
40+
41+
int childCount = parent.getChildCount();
42+
for (int i = 0; i < childCount; i++) {
43+
View child = parent.getChildAt(i);
44+
45+
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
46+
47+
int top = child.getBottom() + params.bottomMargin;
48+
int bottom = top + divider.getIntrinsicHeight();
49+
50+
divider.setBounds(left, top, right, bottom);
51+
divider.draw(c);
52+
}
53+
}
54+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.example.yoga.sqliteexample.Decoration;
2+
3+
import android.graphics.Rect;
4+
import android.support.v7.widget.RecyclerView;
5+
import android.view.View;
6+
7+
/**
8+
* Created by YOGA on 11/16/2016.
9+
*/
10+
11+
public class VerticalSpaceItemDecoration extends RecyclerView.ItemDecoration {
12+
private final int verticalSpaceHeight;
13+
14+
public VerticalSpaceItemDecoration(int verticalSpaceHeight) {
15+
this.verticalSpaceHeight = verticalSpaceHeight;
16+
}
17+
18+
@Override
19+
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
20+
RecyclerView.State state) {
21+
if (parent.getChildAdapterPosition(view) != parent.getAdapter().getItemCount() - 1) {
22+
outRect.bottom = verticalSpaceHeight;
23+
}
24+
}
25+
}

app/src/main/java/com/example/yoga/sqliteexample/fragments/AddBillFragment.java renamed to app/src/main/java/com/example/yoga/sqliteexample/Fragment/AddBillFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.yoga.sqliteexample.fragments;
1+
package com.example.yoga.sqliteexample.Fragment;
22

33
import android.app.Activity;
44
import android.app.Fragment;

app/src/main/java/com/example/yoga/sqliteexample/fragments/AddItemFragment.java renamed to app/src/main/java/com/example/yoga/sqliteexample/Fragment/AddItemFragment.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.yoga.sqliteexample.fragments;
1+
package com.example.yoga.sqliteexample.Fragment;
22

33
import android.app.Fragment;
44
import android.os.Bundle;
@@ -12,6 +12,12 @@
1212
* Created by YOGA on 11/7/2016.
1313
*/
1414
public class AddItemFragment extends Fragment {
15+
16+
17+
18+
19+
20+
1521
@Override
1622
public View onCreateView(LayoutInflater inflater, ViewGroup container,
1723
Bundle savedInstanceState) {

app/src/main/java/com/example/yoga/sqliteexample/fragments/AddPersonFragment.java renamed to app/src/main/java/com/example/yoga/sqliteexample/Fragment/AddPersonFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.yoga.sqliteexample.fragments;
1+
package com.example.yoga.sqliteexample.Fragment;
22

33
import android.app.Activity;
44
import android.app.Fragment;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.example.yoga.sqliteexample.Fragment;
2+
3+
4+
import android.app.Fragment;
5+
import android.app.FragmentManager;
6+
import android.content.Context;
7+
import android.os.Bundle;
8+
import android.support.v7.app.ActionBar;
9+
import android.support.v7.app.AppCompatActivity;
10+
import android.util.Log;
11+
import android.view.LayoutInflater;
12+
import android.view.MenuItem;
13+
import android.view.View;
14+
import android.view.ViewGroup;
15+
16+
import com.example.yoga.sqliteexample.MainPage;
17+
import com.example.yoga.sqliteexample.R;
18+
19+
/**
20+
* Created by YOGA on 11/19/2016.
21+
*/
22+
23+
public class BillDetailFragment extends Fragment {
24+
public static final String TAG = "BillDetailFragment";
25+
26+
@Override
27+
public void onAttach(Context context) {
28+
super.onAttach(context);
29+
}
30+
31+
private void printFragmentStackName() {
32+
FragmentManager fm = getFragmentManager();
33+
Log.i(TAG, "Finding fragments.");
34+
int count = getFragmentManager().getBackStackEntryCount();
35+
Log.d(TAG, "back stack count = " + String.valueOf(count));
36+
for(int entry = 0; entry < fm.getBackStackEntryCount(); entry++){
37+
Log.i(TAG, "Found fragment: " + fm.getBackStackEntryAt(entry).getName());
38+
}
39+
}
40+
41+
@Override
42+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
43+
View myView = inflater.inflate(R.layout.fragment_bill_detail, container, false);
44+
printFragmentStackName();
45+
return myView;
46+
}
47+
48+
}

0 commit comments

Comments
 (0)