Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- row.setOnLongClickListener(new View.OnLongClickListener()
- {
- @Override
- public boolean onLongClick(View v) {
- PopupMenu popMenu = new PopupMenu(v.getContext(), v);
- popMenu.getMenuInflater().inflate(R.menu.picturetalk_popup_menu, popMenu.getMenu());
- popMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
- @Override
- public boolean onMenuItemClick(MenuItem menuItem) {
- switch (menuItem.getItemId()) {
- case R.id.edit:
- Intent intent = new Intent(getContext(), EditPicture.class);
- intent.putExtra("itemUUID", item.getId());
- String s = new String("");
- context.startActivity(intent);
- break;
- case R.id.remove:
- FileInteraction fileInteraction = new FileInteraction();
- fileInteraction.deleteFilesAndFolder(item.getImagePath());
- item.setTitle("");
- notifyDataSetChanged();
- break;
- default:
- //
- }
- return true;
- }
- });
- popMenu.show();
- return true;
- }
- });
- return row;
- public class EditPicture extends Activity {
- private EditText text;
- private Button applyBtn;
- private ArrayList<PictureItem> piArray;
- private PictureItem pi;
- private UUID itemID;
- private PictureTalkFragment ptf;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- itemID = (UUID) getIntent().getSerializableExtra("itemUUID");
- SetLocalArray(ptf.getArray()); //Nullpoint here, and i know why. But not how to get the allready created instance of this class
- getPictureItem();
- setContentView(R.layout.picturetalk_edit_pic);
- text = (EditText) findViewById(R.id.editName);
- text.setText(pi.getTitle());
- applyBtn = (Button) findViewById(R.id.applyChangeBtn);
- applyBtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- updatePictureItem();
- ptf.setArray(piArray);
- }
- });
- }
- private void updatePictureItem() {
- pi.setTitle(text.toString());
- piArray.add(pi);
- ptf.setArray(piArray);
- }
- private void SetLocalArray(ArrayList<PictureItem> array) {
- this.piArray = array;
- }
- private PictureItem getPictureItem() {
- pi = new PictureItem("", "");
- for (int i = 0; i < piArray.size(); i++) {
- if (itemID.equals(piArray.get(i))) {
- pi = piArray.get(i);
- piArray.remove(i);
- }
- }
- return pi;
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement