@Override public void onFinishEditDialog(String inputText) { PeopleDatabase db = new PeopleDatabase(getContext()); db.open(); db.addPersonToGroup(mGroup.getId(), inputText); mGroup.setPeople(db.getPeopleForGroup(mGroup.getId())); db.close(); adapter.notifyDataSetChanged(); }
@Override public void onPayClicked(int position) { PeopleDatabase database = new PeopleDatabase(getContext()); database.open(); int id = (int) adapter.getItemId(position); database.makePersonPay(id, mGroup.getId()); mGroup.setPeople(database.getPeopleForGroup(mGroup.getId())); database.close(); adapter.notifyDataSetChanged(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments().containsKey(ARG_GROUP)) { // Load the dummy content specified by the fragment // arguments. In a real-world scenario, use a Loader // to load content from a content provider. mGroup = getArguments().getParcelable(ARG_GROUP); if (mGroup != null) { Log.d("GroupDetailFragment", "mGroup old size is " + mGroup.size()); if (mGroup.size() == 0) { // double check to see if anyone is in the group PeopleDatabase db = new PeopleDatabase(getActivity()); db.open(); mGroup.addPeople(db.getPeopleForGroup(mGroup.getId())); db.close(); Log.d("GroupDetailFragment", "mGroup new size is " + mGroup.size()); } Activity activity = this.getActivity(); final String picPath = mGroup.getPicture(); Log.d("GroupDetailFragment", "picPath is " + picPath); if (picPath != null && !picPath.isEmpty()) { ImageView img = (ImageView) activity.findViewById(R.id.toolbar_image); try { Drawable pic = Drawable.createFromStream(activity.openFileInput(picPath), null); img.setImageDrawable(pic); Log.d("GroupDetailFragment", "set background"); } catch (IOException e) { e.printStackTrace(); } } CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout); if (appBarLayout != null) { appBarLayout.setTitle(mGroup.getName()); appBarLayout.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) {} }); } } } }