@Override public void onClick(View view) { if (view.getId() == R.id.drawMenu) { DrawerLayout d = (DrawerLayout) getActivity().findViewById(R.id.drawer); NavigationView navigationView = (NavigationView) getActivity().findViewById(R.id.navigation_view); d.openDrawer(navigationView); } else if (view.getId() == R.id.submitComment) { String text = ((EditText) getActivity().findViewById(R.id.commentText)).getText().toString(); if (text.length() < 1) { Toast.makeText(getActivity(), "Enter comment", Toast.LENGTH_SHORT).show(); return; } else { View v = getActivity().getCurrentFocus(); if (v != null) { InputMethodManager inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow( view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } AddComment com = new AddComment(); Map<String, String> params = new HashMap<>(); params.put("Scenario_Id", etiquette.Etiquette_Id); params.put("Comment", text); params.put("User_Name", MainActivity.userName); com.addComment(getActivity(), params); ((EditText) getActivity().findViewById(R.id.commentText)).setText(""); // Toast.makeText(getActivity(), "Comment added", Toast.LENGTH_SHORT).show(); } } else if (view.getId() == R.id.loadComments) { Bundle args = new Bundle(); args.putString("data", etiquette.Etiquette_Id); CommentsFragment newFrag = new CommentsFragment(); newFrag.setArguments(args); android.support.v4.app.FragmentTransaction trans = getActivity().getSupportFragmentManager().beginTransaction(); trans.addToBackStack(null); trans.replace(R.id.fragment_container, newFrag, "CommentsFragment").commit(); } }
@Override public void onMoreCommentsSelected(int position) { InstagramPhoto selectedPhoto = photos.get(position); CommentsFragment commentsFragment = CommentsFragment.newInstance(); getFragmentManager().beginTransaction().add(android.R.id.content, commentsFragment).commit(); // commentsFragment.show(getFragmentManager(), "tag"); }