/** Clear saved reports */ public void clearCachedData() { // delete reports new ListReportModel().deleteReport(); // delete checkins data new ListCheckinModel().deleteCheckin(); // delete comment data new ListCommentModel().deleteComments(); // delete fetched photos ImageManager.deleteImages(this); // delete pending photos ImageManager.deletePendingImages(this); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // The preferences returned if the request code is what we had given // earlier in startSubActivity switch (requestCode) { case REQUEST_CODE_CAMERA: setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); // pull it out of landscape mode break; case REQUEST_CODE_IMAGE: if (resultCode != RESULT_OK) { return; } Uri uri = data.getData(); Bitmap b = null; try { b = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri); } catch (FileNotFoundException e) { break; } catch (IOException e) { break; } ByteArrayOutputStream byteArrayos = new ByteArrayOutputStream(); try { b.compress(CompressFormat.JPEG, 75, byteArrayos); byteArrayos.flush(); } catch (OutOfMemoryError e) { break; } catch (IOException e) { break; } filename = "android_pic_upload" + randomString() + ".jpg"; ImageManager.writeImage(byteArrayos.toByteArray(), filename); UshahidiService.fileName = filename; selectedPhoto.setText(UshahidiService.fileName); break; case VIEW_MAP: if (resultCode != RESULT_OK) { return; } bundle = null; extras = data.getExtras(); if (extras != null) bundle = extras.getBundle("locations"); if (bundle != null && !bundle.isEmpty()) { incidentLocation.setText(bundle.getString("location")); AddIncident.latitude = bundle.getDouble("latitude"); AddIncident.longitude = bundle.getDouble("longitude"); } break; } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.view_checkins); mapView = (MapView) findViewById(R.id.loc_map); image = (ImageView) findViewById(R.id.checkin_img); photo = (TextView) findViewById(R.id.checkin_photo); photoLayout = (LinearLayout) findViewById(R.id.img_layout); photoLayout.setVisibility(View.GONE); Bundle incidents = getIntent().getExtras(); photo.setVisibility(View.GONE); extras = incidents.getBundle("checkins"); photosBundle = new Bundle(); checkinLatitude = extras.getString("latitude"); checkinLongitude = extras.getString("longitude"); activityTitle = (TextView) findViewById(R.id.title_text); if (activityTitle != null) activityTitle.setText(getTitle()); name = (TextView) findViewById(R.id.checkin_title); name.setTextColor(Color.BLACK); name.setText(extras.getString("name")); date = (TextView) findViewById(R.id.date); date.setTextColor(Color.BLACK); date.setText(extras.getString("date")); message = (TextView) findViewById(R.id.checkin_description); message.setTextColor(Color.BLACK); message.setText(extras.getString("message")); fileName = extras.getString("photo"); if (!TextUtils.isEmpty(fileName)) { photoLayout.setVisibility(View.VISIBLE); photo.setVisibility(View.VISIBLE); image.setImageDrawable(ImageManager.getImages(UshahidiPref.savePath, fileName)); } mapController = mapView.getController(); defaultLocation = getPoint(Double.parseDouble(checkinLatitude), Double.parseDouble(checkinLongitude)); centerLocation(defaultLocation); }