Thingse/app/src/main/java/com/daneshzaki/thingse/EditSomething.java
//handle return from camera or gallery (for choose pic)
handle return from camera or gallery (for choose pic)
handle return from camera or gallery ( for choose pic )
@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data)
	{
		Log.i("EditSomething", "request code="+requestCode);
		Log.i("EditSomething", "result code="+resultCode);
		if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE)
		{
			if (resultCode == RESULT_OK)
			{
				picLocation = fileUri.toString().replaceFirst("file://", "");
				Log.i("EditSomething", "*** picLocation = " + picLocation);
				Toast.makeText(this, "Image saved to:\n" + picLocation, Toast.LENGTH_SHORT).show();
				scaleAndSetPic(picLocation);
			}
			else if (resultCode == RESULT_CANCELED)
			{
				Log.i("EditSomething", "user cancelled camera use");
			}
			else
			{
				Log.i("EditSomething", "camera capture failed!!!!!!!!!!");
				return;
			}
		}
		else if (requestCode == CHOOSE_IMAGE_ACTIVITY_REQUEST_CODE)
		{
			if (resultCode == RESULT_OK)
			{
				Uri selPicUri = Uri.parse(data.getDataString());
				String selPicLocation = "";
				selPicLocation = getFilePathFromContentUri(selPicUri, this.getContentResolver());
				Log.i("EditSomething", "gallery image location is " + selPicLocation);
				Crop.of(selPicUri, selPicUri).asSquare().start(this);
				picLocation = copySelectedImageToThingse(selPicLocation);
				Toast.makeText(this, "Image selected is :\n" + picLocation, Toast.LENGTH_SHORT).show();
				isFromGallery = true;
				scaleAndSetPic(picLocation);
			}
			else if (requestCode == Crop.REQUEST_CROP && resultCode == RESULT_OK)
			{
				Log.i("EditSomething", "Crop returned...");
				picLocation = fileUri.toString();
				Log.i("EditSomething", "*** picLocation = " + picLocation);
			}
			else if (resultCode == RESULT_CANCELED)
			{
				Log.i("EditSomething", "image selection cancelled" );
			}
			else
			{
				Log.i("EditSomething", "image selection failed!!!!!!!!!!");
				return;
			}
		}
	}
@ Override protected void onActivityResult ( int requestCode , int resultCode , Intent data ) { Log . i ( "EditSomething" , "request code=" + requestCode ) ; Log . i ( "EditSomething" , "result code=" + resultCode ) ; if ( requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE ) { if ( resultCode == RESULT_OK ) { picLocation = fileUri . toString ( ) . replaceFirst ( "file://" , "" ) ; Log . i ( "EditSomething" , "*** picLocation = " + picLocation ) ; Toast . makeText ( this , "Image saved to:\n" + picLocation , Toast . LENGTH_SHORT ) . show ( ) ; scaleAndSetPic ( picLocation ) ; } else if ( resultCode == RESULT_CANCELED ) { Log . i ( "EditSomething" , "user cancelled camera use" ) ; } else { Log . i ( "EditSomething" , "camera capture failed!!!!!!!!!!" ) ; return ; } } else if ( requestCode == CHOOSE_IMAGE_ACTIVITY_REQUEST_CODE ) { if ( resultCode == RESULT_OK ) { Uri selPicUri = Uri . parse ( data . getDataString ( ) ) ; String selPicLocation = "" ; selPicLocation = getFilePathFromContentUri ( selPicUri , this . getContentResolver ( ) ) ; Log . i ( "EditSomething" , "gallery image location is " + selPicLocation ) ; Crop . of ( selPicUri , selPicUri ) . asSquare ( ) . start ( this ) ; picLocation = copySelectedImageToThingse ( selPicLocation ) ; Toast . makeText ( this , "Image selected is :\n" + picLocation , Toast . LENGTH_SHORT ) . show ( ) ; isFromGallery = true ; scaleAndSetPic ( picLocation ) ; } else if ( requestCode == Crop . REQUEST_CROP && resultCode == RESULT_OK ) { Log . i ( "EditSomething" , "Crop returned..." ) ; picLocation = fileUri . toString ( ) ; Log . i ( "EditSomething" , "*** picLocation = " + picLocation ) ; } else if ( resultCode == RESULT_CANCELED ) { Log . i ( "EditSomething" , "image selection cancelled" ) ; } else { Log . i ( "EditSomething" , "image selection failed!!!!!!!!!!" ) ; return ; } } }
handle return from camera or gallery (for choose pic)
handle return from camera or gallery ( for choose pic )
//if returning from camera //6 Sep 2015 // Image captured and saved to fileUri specified in the Intent //6 Sep 2015 //scale and set pic // User cancelled the image capture // Image capture failed, advise user //if returning from gallery (choosing pic) //parse and retrieve the selected image's location //crop the image //28-aug-2015 //copy selected image to thingse folder // Image chosen path //to stop image scaling Feb 10 2016 //6 Sep 2015 //scale and set pic //6 sep 2015 - crop the image // User cancelled the image capture // Image capture failed, advise user