/**
* 存图片的路径
*/
@Override
protected void onSaveInstanceState(Bundle outState) {
if (sdImageFile != null) {
Timber.i("onSaveInstanceState -- not -- null");
outState.putString(UPLOAD_PHOTO_STATUS, sdImageFile.getAbsolutePath());
}
outState.putString(UPLOAD_PHOTO_LIST_ID, listId);
Timber.i("onSaveInstanceState----outState");
super.onSaveInstanceState(outState);
}
/**
* 取图片的路径
*/
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Timber.i("onRestoreInstanceState");
String photoStatus = savedInstanceState.getString(UPLOAD_PHOTO_STATUS);
if (sdImageFile == null && !TextUtils.isEmpty(photoStatus)) {
Timber.i("new File(photoStatus);");
sdImageFile = new File(photoStatus);
}
String photoListId = savedInstanceState.getString(UPLOAD_PHOTO_LIST_ID);
if (TextUtils.isEmpty(listId) && !TextUtils.isEmpty(photoListId)) {
Timber.i("new File(photoListId);");
listId = photoListId;
}
}
onSaveInstanceState保存数据,onRestoreInstanceState取数据
最新推荐文章于 2022-10-18 08:02:34 发布