changes in dialog according to ownership

- owner will see permission and delete icon
- other wont see permission and will see like button
This commit is contained in:
Aran Zaiger 2016-07-08 02:42:25 +03:00
parent db003f82d7
commit 84df7e0437

View file

@ -20,6 +20,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -182,10 +183,18 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
Note note = eventMarkerMap.get(marker); Note note = eventMarkerMap.get(marker);
final Dialog noteViewDialog = new Dialog(getActivity()); final Dialog noteViewDialog = new Dialog(getActivity());
noteViewDialog.setContentView(R.layout.note_display_full); noteViewDialog.setContentView(R.layout.note_display_full);
boolean isOwner = note.getOwnerId() == mainActivity.getUserId();
if (isOwner)
noteViewDialog.setTitle("I wrote...");
else
noteViewDialog.setTitle("Someone wrote..."); noteViewDialog.setTitle("Someone wrote...");
noteViewDialog.show(); noteViewDialog.show();
//get note_view_full layout elements //get note_view_full layout elements
final TextView title = (TextView) noteViewDialog.findViewById(R.id.ndf_title_textview); final TextView title = (TextView) noteViewDialog.findViewById(R.id.ndf_title_textview);
final TextView body = (TextView) noteViewDialog.findViewById(R.id.ndf_body_textview); final TextView body = (TextView) noteViewDialog.findViewById(R.id.ndf_body_textview);
@ -194,6 +203,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
final TextView likes = (TextView) noteViewDialog.findViewById(R.id.ndf_likes_textview); final TextView likes = (TextView) noteViewDialog.findViewById(R.id.ndf_likes_textview);
final TextView tags = (TextView) noteViewDialog.findViewById(R.id.ndf_tags_textview); final TextView tags = (TextView) noteViewDialog.findViewById(R.id.ndf_tags_textview);
final TextView permission = (TextView) noteViewDialog.findViewById(R.id.ndf_permission_textview); final TextView permission = (TextView) noteViewDialog.findViewById(R.id.ndf_permission_textview);
final ImageView avatar = (ImageView) noteViewDialog.findViewById(R.id.note_user_avatar);
final ImageButton deleteBtn = (ImageButton) noteViewDialog.findViewById(R.id.ndf_delete_imagebutton); final ImageButton deleteBtn = (ImageButton) noteViewDialog.findViewById(R.id.ndf_delete_imagebutton);
@ -203,7 +213,15 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
location.setText("Tags: " + note.getAddress()); location.setText("Tags: " + note.getAddress());
likes.setText("Likes: " + note.getLikes()); likes.setText("Likes: " + note.getLikes());
tags.setText(note.getTags().toString()); tags.setText(note.getTags().toString());
// avatar.setImageBitmap();
if (isOwner) {
permission.setText("Permission: " + (note.isPublic() ? "Public" : "Private")); permission.setText("Permission: " + (note.isPublic() ? "Public" : "Private"));
}
else{
deleteBtn.setBackgroundResource(R.drawable.like_icon);
}
// deleteBtn.setOnClickListener(new View.OnClickListener() { // deleteBtn.setOnClickListener(new View.OnClickListener() {