Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. row.setOnLongClickListener(new View.OnLongClickListener()
  2.  
  3. {
  4. @Override
  5. public boolean onLongClick(View v) {
  6. PopupMenu popMenu = new PopupMenu(v.getContext(), v);
  7. popMenu.getMenuInflater().inflate(R.menu.picturetalk_popup_menu, popMenu.getMenu());
  8. popMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
  9. @Override
  10. public boolean onMenuItemClick(MenuItem menuItem) {
  11. switch (menuItem.getItemId()) {
  12.  
  13. case R.id.edit:
  14.  
  15. Intent intent = new Intent(getContext(), EditPicture.class);
  16. intent.putExtra("itemUUID", item.getId());
  17. String s = new String("");
  18. context.startActivity(intent);
  19. break;
  20.  
  21. case R.id.remove:
  22. FileInteraction fileInteraction = new FileInteraction();
  23. fileInteraction.deleteFilesAndFolder(item.getImagePath());
  24. item.setTitle("");
  25. notifyDataSetChanged();
  26. break;
  27.  
  28. default:
  29. //
  30.  
  31. }
  32. return true;
  33. }
  34. });
  35. popMenu.show();
  36. return true;
  37. }
  38. });
  39. return row;
  40.  
  41. public class EditPicture extends Activity {
  42.  
  43. private EditText text;
  44. private Button applyBtn;
  45. private ArrayList<PictureItem> piArray;
  46. private PictureItem pi;
  47. private UUID itemID;
  48. private PictureTalkFragment ptf;
  49.  
  50. @Override
  51. protected void onCreate(Bundle savedInstanceState) {
  52. super.onCreate(savedInstanceState);
  53. itemID = (UUID) getIntent().getSerializableExtra("itemUUID");
  54. SetLocalArray(ptf.getArray()); //Nullpoint here, and i know why. But not how to get the allready created instance of this class
  55. getPictureItem();
  56. setContentView(R.layout.picturetalk_edit_pic);
  57. text = (EditText) findViewById(R.id.editName);
  58. text.setText(pi.getTitle());
  59. applyBtn = (Button) findViewById(R.id.applyChangeBtn);
  60. applyBtn.setOnClickListener(new View.OnClickListener() {
  61. @Override
  62. public void onClick(View v) {
  63. updatePictureItem();
  64. ptf.setArray(piArray);
  65. }
  66. });
  67.  
  68.  
  69. }
  70.  
  71. private void updatePictureItem() {
  72.  
  73. pi.setTitle(text.toString());
  74. piArray.add(pi);
  75. ptf.setArray(piArray);
  76.  
  77. }
  78.  
  79. private void SetLocalArray(ArrayList<PictureItem> array) {
  80. this.piArray = array;
  81. }
  82.  
  83. private PictureItem getPictureItem() {
  84. pi = new PictureItem("", "");
  85.  
  86. for (int i = 0; i < piArray.size(); i++) {
  87. if (itemID.equals(piArray.get(i))) {
  88. pi = piArray.get(i);
  89. piArray.remove(i);
  90.  
  91. }
  92.  
  93. }
  94. return pi;
  95. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement