|
@ -350,40 +350,36 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
holder.header.setOnClickListener(null); |
|
|
holder.header.setOnClickListener(null); |
|
|
holder.userExtraInfo.setOnClickListener(null); |
|
|
holder.userExtraInfo.setOnClickListener(null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
holder.overflowButton.setOnClickListener(new View.OnClickListener() { |
|
|
holder.overflowButton.setOnClickListener(view -> { |
|
|
@Override |
|
|
//Inflates the popup menu content
|
|
|
public void onClick(View view) { |
|
|
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
|
|
//Inflates the popup menu content
|
|
|
if (layoutInflater == null) { |
|
|
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
|
|
return; |
|
|
if (layoutInflater == null) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
View popUpContent = layoutInflater.inflate(R.layout.activity_topic_overflow_menu, null); |
|
|
|
|
|
|
|
|
|
|
|
//Creates the PopupWindow
|
|
|
|
|
|
final PopupWindow popUp = new PopupWindow(holder.overflowButton.getContext()); |
|
|
|
|
|
popUp.setContentView(popUpContent); |
|
|
|
|
|
popUp.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT); |
|
|
|
|
|
popUp.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT); |
|
|
|
|
|
popUp.setFocusable(true); |
|
|
|
|
|
|
|
|
|
|
|
TextView shareButton = popUpContent.findViewById(R.id.post_share_button); |
|
|
|
|
|
Drawable shareStartDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_share_white_24dp); |
|
|
|
|
|
shareButton.setCompoundDrawablesRelativeWithIntrinsicBounds(shareStartDrawable, null, null, null); |
|
|
|
|
|
shareButton.setOnClickListener(new View.OnClickListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); |
|
|
|
|
|
sendIntent.setType("text/plain"); |
|
|
|
|
|
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, currentPost.getPostURL()); |
|
|
|
|
|
context.startActivity(Intent.createChooser(sendIntent, "Share via")); |
|
|
|
|
|
popUp.dismiss(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
View popUpContent = layoutInflater.inflate(R.layout.activity_topic_overflow_menu, null); |
|
|
|
|
|
|
|
|
|
|
|
//Creates the PopupWindow
|
|
|
|
|
|
final PopupWindow popUp = new PopupWindow(holder.overflowButton.getContext()); |
|
|
|
|
|
popUp.setContentView(popUpContent); |
|
|
|
|
|
popUp.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT); |
|
|
|
|
|
popUp.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT); |
|
|
|
|
|
popUp.setFocusable(true); |
|
|
|
|
|
|
|
|
|
|
|
TextView shareButton = popUpContent.findViewById(R.id.post_share_button); |
|
|
|
|
|
Drawable shareStartDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_share_white_24dp); |
|
|
|
|
|
shareButton.setCompoundDrawablesRelativeWithIntrinsicBounds(shareStartDrawable, null, null, null); |
|
|
|
|
|
shareButton.setOnClickListener(v -> { |
|
|
|
|
|
Intent sendIntent = new Intent(Intent.ACTION_SEND); |
|
|
|
|
|
sendIntent.setType("text/plain"); |
|
|
|
|
|
sendIntent.putExtra(Intent.EXTRA_TEXT, currentPost.getPostURL()); |
|
|
|
|
|
context.startActivity(Intent.createChooser(sendIntent, "Share via")); |
|
|
|
|
|
popUp.dismiss(); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
final TextView editPostButton = popUpContent.findViewById(R.id.edit_post); |
|
|
final TextView editPostButton = popUpContent.findViewById(R.id.edit_post); |
|
|
|
|
|
Drawable editStartDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_edit_white_24dp); |
|
|
|
|
|
editPostButton.setCompoundDrawablesRelativeWithIntrinsicBounds(editStartDrawable, null, null, null); |
|
|
|
|
|
|
|
|
if (viewModel.isEditingPost() || currentPost.getPostEditURL() == null || currentPost.getPostEditURL().equals("")) { |
|
|
if (viewModel.isEditingPost() || currentPost.getPostEditURL() == null || currentPost.getPostEditURL().equals("")) { |
|
|
editPostButton.setVisibility(View.GONE); |
|
|
editPostButton.setVisibility(View.GONE); |
|
@ -393,33 +389,24 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
popUp.dismiss(); |
|
|
popUp.dismiss(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
TextView deletePostButton = popUpContent.findViewById(R.id.delete_post); |
|
|
TextView deletePostButton = popUpContent.findViewById(R.id.delete_post); |
|
|
|
|
|
|
|
|
if (currentPost.getPostDeleteURL() == null || currentPost.getPostDeleteURL().equals("")) { |
|
|
if (currentPost.getPostDeleteURL() == null || currentPost.getPostDeleteURL().equals("")) { |
|
|
deletePostButton.setVisibility(View.GONE); |
|
|
deletePostButton.setVisibility(View.GONE); |
|
|
} else { |
|
|
} else { |
|
|
Drawable deleteStartDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_delete_white_24dp); |
|
|
Drawable deleteStartDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_delete_white_24dp); |
|
|
deletePostButton.setCompoundDrawablesRelativeWithIntrinsicBounds(deleteStartDrawable, null, null, null); |
|
|
deletePostButton.setCompoundDrawablesRelativeWithIntrinsicBounds(deleteStartDrawable, null, null, null); |
|
|
popUpContent.findViewById(R.id.delete_post).setOnClickListener(new View.OnClickListener() { |
|
|
popUpContent.findViewById(R.id.delete_post).setOnClickListener(v -> { |
|
|
@Override |
|
|
new AlertDialog.Builder(holder.overflowButton.getContext()) |
|
|
public void onClick(View v) { |
|
|
.setTitle("Delete post") |
|
|
new AlertDialog.Builder(holder.overflowButton.getContext()) |
|
|
.setMessage("Do you really want to delete this post?") |
|
|
.setTitle("Delete post") |
|
|
.setIcon(android.R.drawable.ic_dialog_alert) |
|
|
.setMessage("Do you really want to delete this post?") |
|
|
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> viewModel.deletePost(currentPost.getPostDeleteURL())) |
|
|
.setIcon(android.R.drawable.ic_dialog_alert) |
|
|
.setNegativeButton(android.R.string.no, null).show(); |
|
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { |
|
|
popUp.dismiss(); |
|
|
|
|
|
}); |
|
|
@Override |
|
|
} |
|
|
public void onClick(DialogInterface dialog, int whichButton) { |
|
|
|
|
|
deleteTask.execute(currentPost.getPostDeleteURL()); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.setNegativeButton(android.R.string.no, null).show(); |
|
|
|
|
|
popUp.dismiss(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Displays the popup
|
|
|
//Displays the popup
|
|
|
popUp.showAsDropDown(holder.overflowButton); |
|
|
popUp.showAsDropDown(holder.overflowButton); |
|
|