@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.delete) { dbhelper.deleteMarkByID(ChalkmarkID); Context context = getApplicationContext(); AlertDialog.Builder alertbox = new AlertDialog.Builder(context); alertbox.setMessage("The Mark Was Deleted"); SharedPreferences.Editor editor = mPreferences.edit(); editor.putInt("DefaultTab", 1); editor.commit(); Intent intent = new Intent().setClass(MessageDetails.this, ChalkMarkTabHost.class); startActivity(intent); finish(); } else if (item.getItemId() == R.id.map) { Intent i = new Intent(MessageDetails.this, MarkInfoMap.class); c = dbhelper.getByID(ChalkmarkID); c.moveToFirst(); Double latitude = dbhelper.getLat(c); Double longitude = dbhelper.getLon(c); i.putExtra(MarkInfoMap.EXTRA_LATITUDE, latitude); i.putExtra(MarkInfoMap.EXTRA_LONGITUDE, longitude); i.putExtra(MarkInfoMap.EXTRA_NAME, dbhelper.getFromName(c)); i.putExtra(MarkInfoMap.EXTRA_SUBJECT, dbhelper.getSubject(c)); dbhelper.close(); startActivity(i); } else if (item.getItemId() == R.id.unread) { // Make the Chalkmark unread c = dbhelper.getByID(ChalkmarkID); c.moveToFirst(); dbhelper.updateStatus(ChalkmarkID, "unread"); } else if (item.getItemId() == R.id.unread) { // Make the Chalkmark unread c = dbhelper.getByID(ChalkmarkID); c.moveToFirst(); dbhelper.updateStatus(ChalkmarkID, "unread"); } else if (item.getItemId() == R.id.repost) { c = dbhelper.getByID(ChalkmarkID); c.moveToFirst(); SharedPreferences.Editor editor = mPreferences.edit(); editor.putString("SavedSubject", dbhelper.getSubject(c)); editor.putString("SavedBody", dbhelper.getBody(c)); editor.putInt("SavedExpiration", 25); editor.putInt("SavedRadius", 1000); editor.putBoolean("SavedImageFlag", imageflag); editor.putString("RandomString", dbhelper.getImagePair(c)); editor.putFloat("MarkLat", (float) dbhelper.getLat(c)); editor.putFloat("MarkLon", (float) dbhelper.getLon(c)); editor.commit(); Intent i = new Intent(MessageDetails.this, MakeMark.class); startActivity(i); finish(); } return (super.onOptionsItemSelected(item)); }
@Override public void onDestroy() { super.onDestroy(); dbhelper.close(); }