private void showEditDialog(final ViewHolder holder) { if (LOG) { MtkLog.v(TAG, "showEditDialog(" + holder + ")"); } if (holder == null) { return; } final LayoutInflater inflater = LayoutInflater.from(this); final View v = inflater.inflate(R.layout.bookmark_edit_dialog, null); final EditText titleView = (EditText) v.findViewById(R.id.title); final EditText dataView = (EditText) v.findViewById(R.id.data); titleView.setText(holder.mTitle); dataView.setText(holder.mData); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.edit); builder.setView(v); builder.setIcon(R.drawable.ic_menu_display_bookmark); builder.setPositiveButton( android.R.string.ok, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { mBookmark.update( holder.mId, titleView.getText().toString(), dataView.getText().toString(), 0); } }); builder.setNegativeButton(android.R.string.cancel, null); final AlertDialog dialog = builder.create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.setInverseBackgroundForced(true); dialog.show(); }
@Override public boolean onContextItemSelected(final MenuItem item) { final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case MENU_DELETE_ONE: mBookmark.delete(info.id); return true; case MENU_EDIT: final Object obj = info.targetView.getTag(); if (obj instanceof ViewHolder) { showEditDialog((ViewHolder) obj); } else { MtkLog.w(TAG, "wrong context item info " + info); } return true; default: return super.onContextItemSelected(item); } }
@Override public void onItemClick( final AdapterView<?> parent, final View view, final int position, final long id) { final Object o = view.getTag(); if (o instanceof ViewHolder) { final ViewHolder holder = (ViewHolder) o; finish(); final Intent intent = new Intent(this, MovieActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); String mime = "video/*"; if (!(holder.mMimetype == null || "".equals(holder.mMimetype.trim()))) { mime = holder.mMimetype; } intent.setDataAndType(Uri.parse(holder.mData), mime); startActivity(intent); } if (LOG) { MtkLog.v(TAG, "onItemClick(" + position + ", " + id + ")"); } }