@Override public void onActivityCreated(Bundle bundle) { super.onActivityCreated(bundle); answerLayout = new ArrayList<>(); Bundle args = getArguments(); etiquette = (Etiquette) args.getSerializable("data"); String op = args.getString("option"); if (etiquette.Scenario_Option_1.length() > 0) { min = etiquette.Scenario_Value_1; max = etiquette.Scenario_Value_1; addOption(etiquette.Scenario_Option_1, etiquette.Scenario_Value_1); } if (etiquette.Scenario_Option_2.length() > 0) { addOption(etiquette.Scenario_Option_2, etiquette.Scenario_Value_2); } if (etiquette.Scenario_Option_3.length() > 0) { addOption(etiquette.Scenario_Option_3, etiquette.Scenario_Value_3); } if (etiquette.Scenario_Option_4.length() > 0) { addOption(etiquette.Scenario_Option_4, etiquette.Scenario_Value_4); } if (etiquette.Scenario_Option_5.length() > 0) { addOption(etiquette.Scenario_Option_5, etiquette.Scenario_Value_5); } if (etiquette.Scenario_Option_6.length() > 0) { addOption(etiquette.Scenario_Option_6, etiquette.Scenario_Value_6); } if (etiquette.Scenario_Option_7.length() > 0) { addOption(etiquette.Scenario_Option_7, etiquette.Scenario_Value_7); } if (etiquette.Scenario_Option_8.length() > 0) { addOption(etiquette.Scenario_Option_8, etiquette.Scenario_Value_8); } if (etiquette.Scenario_Option_9.length() > 0) { addOption(etiquette.Scenario_Option_9, etiquette.Scenario_Value_9); } for (int i = 0; i < answerLayout.size(); i++) { View row = answerLayout.get(i); String temp = ((TextView) row.findViewById(R.id.optionValue)).getText().toString(); if (temp.equals(max + "%")) ((FrameLayout) row.findViewById(R.id.answerBackground)) .setBackgroundResource(R.drawable.option1); else if (temp.equals(min + "%")) ((FrameLayout) row.findViewById(R.id.answerBackground)) .setBackgroundResource(R.drawable.option4); } TextView choose = (TextView) getActivity().findViewById(R.id.choosenOption); choose.setText("YOU CHOSE OPTION \"" + op + "\""); TextView title = (TextView) getActivity().findViewById(R.id.titleText); title.setText(etiquette.Scenario_Description); TextView type = (TextView) getActivity().findViewById(R.id.typeText); type.setText(etiquette.Category_Name); TextView userName = (TextView) getActivity().findViewById(R.id.userName); userName.setText(etiquette.User_Full_Name); TextView views = (TextView) getActivity().findViewById(R.id.views); views.setText(etiquette.Scenario_Number_Of_Views); TextView time = (TextView) getActivity().findViewById(R.id.time); long t = System.currentTimeMillis() - etiquette.Scenario_Entry_Time; time.setText(t / 3600000 + "h"); if (etiquette.Scenario_Picture != null) { ImageView img = (ImageView) getActivity().findViewById(R.id.etiquetetImage); /// img.setImageBitmap(StringToBitMap(textList.get(position).Scenario_Picture)); Picasso.with(getActivity()).load(etiquette.Scenario_Picture).into(img); } if (etiquette.User_Picture != null) { ImageView img = (ImageView) getActivity().findViewById(R.id.userImage); // img.setImageBitmap(StringToBitMap(textList.get(position).User_Picture)); Picasso.with(getActivity()).load(etiquette.User_Picture).into(img); } ImageView rating = (ImageView) getActivity().findViewById(R.id.ratingImage); switch (etiquette.Scenario_Level) { case 0: rating.setImageResource(R.drawable._10); break; case 1: rating.setImageResource(R.drawable._5); break; case 2: rating.setImageResource(R.drawable._0); break; case 3: rating.setImageResource(R.drawable.__5); break; case 4: rating.setImageResource(R.drawable.__10); break; default: rating.setImageResource(R.drawable._0); break; } ImageView menu = (ImageView) getActivity().findViewById(R.id.drawMenu); menu.setOnClickListener(this); ImageButton submitComment = (ImageButton) getActivity().findViewById(R.id.submitComment); submitComment.setOnClickListener(this); ScrollView scroll = (ScrollView) getActivity().findViewById(R.id.answerScroll); LinearLayout moreComments = (LinearLayout) getActivity().findViewById(R.id.loadComments); moreComments.setOnClickListener(this); }
@Override public void onActivityCreated(Bundle bundle) { super.onActivityCreated(bundle); answerLayout = new ArrayList<>(); Bundle args = getArguments(); etiquette = (Etiquette) args.getSerializable("data"); String op = args.getString("option"); int totalComments = args.getInt("totalComments", 0); String json = args.getString("comments"); ((TextView) getActivity().findViewById(R.id.numberOfComments)).setText(totalComments + ""); Gson gson = new Gson(); CommentClass[] comments = gson.fromJson(json, CommentClass[].class); for (int i = 0; (i < comments.length) && (i < 2); i++) { LayoutInflater inflator = (LayoutInflater) getActivity().getSystemService(getActivity().LAYOUT_INFLATER_SERVICE); View row1 = inflator.inflate(R.layout.comment_list_item, null); Picasso.with(getActivity()) .load(comments[i].picture) .into(((RoundedImageView) row1.findViewById(R.id.userImage))); ((TextView) row1.findViewById(R.id.userName)).setText(comments[i].name); ((TextView) row1.findViewById(R.id.commentBody)).setText(comments[i].comment); LinearLayout l = (LinearLayout) getActivity().findViewById(R.id.fewComments); l.addView(row1); } if (etiquette.Scenario_Option_1.length() > 0) { min = etiquette.Scenario_Value_1; max = etiquette.Scenario_Value_1; addOption(etiquette.Scenario_Option_1, etiquette.Scenario_Value_1); } if (etiquette.Scenario_Option_2 != null) { addOption(etiquette.Scenario_Option_2, etiquette.Scenario_Value_2); } if (etiquette.Scenario_Option_3 != null) { addOption(etiquette.Scenario_Option_3, etiquette.Scenario_Value_3); } if (etiquette.Scenario_Option_4 != null) { addOption(etiquette.Scenario_Option_4, etiquette.Scenario_Value_4); } if (etiquette.Scenario_Option_5 != null) { addOption(etiquette.Scenario_Option_5, etiquette.Scenario_Value_5); } if (etiquette.Scenario_Option_6 != null) { addOption(etiquette.Scenario_Option_6, etiquette.Scenario_Value_6); } if (etiquette.Scenario_Option_7 != null) { addOption(etiquette.Scenario_Option_7, etiquette.Scenario_Value_7); } if (etiquette.Scenario_Option_8 != null) { addOption(etiquette.Scenario_Option_8, etiquette.Scenario_Value_8); } if (etiquette.Scenario_Option_9 != null) { addOption(etiquette.Scenario_Option_9, etiquette.Scenario_Value_9); } for (int i = 0; i < answerLayout.size(); i++) { View row = answerLayout.get(i); String temp = ((TextView) row.findViewById(R.id.optionValue)).getText().toString(); if (temp.equals(max + "%")) ((FrameLayout) row.findViewById(R.id.answerBackground)) .setBackgroundResource(R.drawable.option1); else if (temp.equals(min + "%")) ((FrameLayout) row.findViewById(R.id.answerBackground)) .setBackgroundResource(R.drawable.option4); } TextView choose = (TextView) getActivity().findViewById(R.id.choosenOption); choose.setText("YOU CHOSE OPTION \"" + op + "\""); TextView title = (TextView) getActivity().findViewById(R.id.titleText); title.setText(etiquette.Scenario_Description); TextView type = (TextView) getActivity().findViewById(R.id.typeText); type.setText(etiquette.Category_Name); TextView userName = (TextView) getActivity().findViewById(R.id.userName); userName.setText(etiquette.User_Full_Name); TextView views = (TextView) getActivity().findViewById(R.id.views); views.setText(etiquette.Scenario_Number_Of_Views); TextView time = (TextView) getActivity().findViewById(R.id.time); long t = System.currentTimeMillis() - etiquette.Scenario_Entry_Time; time.setText(t / 3600000 + "h"); if (etiquette.Scenario_Picture != null) { ImageView img = (ImageView) getActivity().findViewById(R.id.etiquetetImage); /// img.setImageBitmap(StringToBitMap(textList.get(position).Scenario_Picture)); Picasso.with(getActivity()).load(etiquette.Scenario_Picture).into(img); } if (etiquette.User_Picture != null) { ImageView img = (ImageView) getActivity().findViewById(R.id.userImage); // img.setImageBitmap(StringToBitMap(textList.get(position).User_Picture)); Picasso.with(getActivity()).load(etiquette.User_Picture).into(img); } ImageView rating = (ImageView) getActivity().findViewById(R.id.ratingImage); switch (etiquette.Scenario_Level) { case 0: rating.setImageResource(R.drawable._10); break; case 1: rating.setImageResource(R.drawable._5); break; case 2: rating.setImageResource(R.drawable._0); break; case 3: rating.setImageResource(R.drawable.__5); break; case 4: rating.setImageResource(R.drawable.__10); break; default: rating.setImageResource(R.drawable._0); break; } ImageView menu = (ImageView) getActivity().findViewById(R.id.drawMenu); menu.setOnClickListener(this); ImageButton submitComment = (ImageButton) getActivity().findViewById(R.id.submitComment); submitComment.setOnClickListener(this); ScrollView scroll = (ScrollView) getActivity().findViewById(R.id.answerScroll); LinearLayout moreComments = (LinearLayout) getActivity().findViewById(R.id.loadComments); moreComments.setOnClickListener(this); }