I have the first fragment which has an imageView loaded in this way with Picasso:
ExifInterface exif = null;
float rotate = 0;
try
{
exif = new ExifInterface(absolutePath);
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_UNDEFINED);
switch (orientation) {
case ExifInterface.ORIENTATION_NORMAL:
rotate = 0;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
Picasso.with(getActivity())
.load(mMediaUri)
.resize(1280, 1280)
.rotate(rotate)
.centerCrop()
.transform(new RoundedTransformation())
.into(photo);
when I press next
button I do this and I go to the second fragment:
Bundle bundle = new Bundle();
bundle.putLong("primaryKey", primaryKey);
bundle.putString("uri", String.valueOf(mMediaUri));
bundle.putString("registration", registrationET.getText().toString().trim());
bundle.putString("makemodel", makemodelET.getText().toString().trim());
bundle.putString("manifacturer", manifacturerET.getText().toString().trim());
bundle.putString("category", categoryET.getText().toString().trim());
bundle.putString("class", classET.getText().toString().trim());
Fragment fragment = new AddAircraftSecondPartFragment();
fragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager();
manager.beginTransaction().replace(R.id.content_main, fragment).addToBackStack(null).commit();
The issue happens when I want to press back or I click on the Back
button: values on EditText
or TextView
are in the right way because I use this:
android:freezesText="true"
but I don't see the previous image loaded with Picasso in ImageView.
This is the code I've used to popBackStack()
:
private void pressBackButton()
{
FragmentManager manager = getActivity().getSupportFragmentManager();
manager.popBackStack();
}
so my question are:
popBackStack()
?Thank you for answers
1) You can move your image loading to overridden onResume() method of your fragment.
2) onResume() is called when fragment is "resumed"