EmailViewHolder.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package com.noahvogt.miniprojekt.ui.slideshow;
  2. import android.view.LayoutInflater;
  3. import android.view.View;
  4. import android.view.ViewGroup;
  5. import android.widget.EditText;
  6. import android.widget.TextView;
  7. import android.widget.Toast;
  8. import com.noahvogt.miniprojekt.MainActivity;
  9. import com.noahvogt.miniprojekt.ui.show.MessageShowFragment;
  10. import com.noahvogt.miniprojekt.R;
  11. import androidx.appcompat.app.AlertDialog;
  12. import androidx.drawerlayout.widget.DrawerLayout;
  13. import androidx.fragment.app.DialogFragment;
  14. import androidx.fragment.app.Fragment;
  15. import androidx.fragment.app.FragmentManager;
  16. import androidx.navigation.Navigation;
  17. import androidx.navigation.ui.AppBarConfiguration;
  18. import androidx.recyclerview.widget.RecyclerView;
  19. /* adds the content to the View of RecyclerView*/
  20. public class EmailViewHolder extends RecyclerView.ViewHolder {
  21. private final TextView fromItemView;
  22. private final TextView subjectItemView;
  23. private final TextView dateItemView;
  24. public final TextView messageItemView;
  25. private AppBarConfiguration mAppBarConfiguration;
  26. private EmailViewHolder(View itemView, ViewGroup parent) {
  27. super(itemView);
  28. fromItemView = itemView.findViewById(R.id.textView);
  29. subjectItemView = itemView.findViewById(R.id.subject);
  30. dateItemView = itemView.findViewById(R.id.date);
  31. messageItemView = itemView.findViewById(R.id.message);
  32. itemView.setOnClickListener(new View.OnClickListener() {
  33. @Override
  34. public void onClick(View v) {
  35. Toast.makeText(v.getContext(), "clicked ViewHolder ", Toast.LENGTH_LONG).show();
  36. /* Fragment fragment = new MessageShowFragment();
  37. if (!fragment.isAdded()){
  38. Toast.makeText(v.getContext(), "is not Added ", Toast.LENGTH_LONG).show();
  39. FragmentManager fragmentManager = fragment.getParentFragmentManager();
  40. fragmentManager.beginTransaction()
  41. .add(R.id.nav_show, MessageShowFragment.class, null)
  42. .commit();
  43. }
  44. */
  45. }
  46. });
  47. }
  48. public void bind(String from, String subject, String date, String message) {
  49. fromItemView.setText(from);
  50. subjectItemView.setText(subject);
  51. dateItemView.setText(date);
  52. messageItemView.setText(message);
  53. }
  54. public static EmailViewHolder create(ViewGroup parent) {
  55. View view = LayoutInflater.from(parent.getContext())
  56. .inflate(R.layout.fragment_home, parent, false);
  57. return new EmailViewHolder(view, parent);
  58. }
  59. /* public void createNewEmailDialog(){
  60. // define View window
  61. AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(itemView.getContext());
  62. // init text field variables
  63. newemail_name = emailPopupView.findViewById(R.id.popup_material_name_asking_text);
  64. newemail_email = emailPopupView.findViewById(R.id.popup_material_email_asking_text);
  65. newemail_password = emailPopupView.findViewById(R.id.popup_material_password_asking_text);
  66. // init button variables
  67. Button newemail_save_button = (Button) emailPopupView.findViewById(R.id.saveButton);
  68. // may not be private
  69. Button newemail_cancel_button = (Button) emailPopupView.findViewById(R.id.cancelButton);
  70. // open View window
  71. dialogBuilder.setView(emailPopupView);
  72. dialog = dialogBuilder.create();
  73. dialog.show();
  74. // store user input
  75. newemail_save_button.setOnClickListener(new View.OnClickListener() {
  76. @Override
  77. public void onClick(View v) {
  78. // store user input (only needed for DEBUGGING)
  79. String name = newemail_name.getText().toString();
  80. String email = newemail_email.getText().toString();
  81. String password = newemail_password.getText().toString();
  82. if (!mailFunctions.validateEmail(newemail_email) | !mailFunctions.validateName(newemail_name) | !mailFunctions.validatePassword(newemail_password)) {
  83. return;
  84. }
  85. // show all strings the user gave, this will later be stored to a secure database and checked for validation
  86. showToast(name);
  87. showToast(email);
  88. showToast(password);
  89. showSnackbar(emailPopupView,"save button clicked");
  90. }
  91. });
  92. */
  93. }