diff --git a/matisse/src/main/java/com/zhihu/matisse/internal/ui/BasePreviewActivity.java b/matisse/src/main/java/com/zhihu/matisse/internal/ui/BasePreviewActivity.java index 3c8b717cd..b612b6a91 100644 --- a/matisse/src/main/java/com/zhihu/matisse/internal/ui/BasePreviewActivity.java +++ b/matisse/src/main/java/com/zhihu/matisse/internal/ui/BasePreviewActivity.java @@ -46,6 +46,7 @@ public abstract class BasePreviewActivity extends AppCompatActivity implements V public static final String EXTRA_RESULT_BUNDLE = "extra_result_bundle"; public static final String EXTRA_RESULT_APPLY = "extra_result_apply"; public static final String EXTRA_RESULT_ORIGINAL_ENABLE = "extra_result_original_enable"; + public static final String CHECK_STATE = "checkState"; protected final SelectedItemCollection mSelectedCollection = new SelectedItemCollection(this); protected SelectionSpec mSpec; @@ -80,10 +81,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { if (savedInstanceState == null) { mSelectedCollection.onCreate(getIntent().getBundleExtra(EXTRA_DEFAULT_BUNDLE)); + mOriginalEnable = getIntent().getBooleanExtra(EXTRA_RESULT_ORIGINAL_ENABLE, false); } else { mSelectedCollection.onCreate(savedInstanceState); + mOriginalEnable = savedInstanceState.getBoolean(CHECK_STATE); } - mOriginalEnable = getIntent().getBooleanExtra(EXTRA_RESULT_ORIGINAL_ENABLE, false); mButtonBack = (TextView) findViewById(R.id.button_back); mButtonApply = (TextView) findViewById(R.id.button_apply); mSize = (TextView) findViewById(R.id.size); @@ -163,6 +165,7 @@ public void onClick(View v) { @Override protected void onSaveInstanceState(Bundle outState) { mSelectedCollection.onSaveInstanceState(outState); + outState.putBoolean("checkState", mOriginalEnable); super.onSaveInstanceState(outState); } @@ -252,7 +255,7 @@ private void updateOriginalState() { int selectedCount = mSelectedCollection.count(); if (selectedCount == 0) { // mOriginal.setChecked(false); - mOriginalEnable = false; +// mOriginalEnable = false; } else if (countOverMaxSize() > 0) { if (mOriginalEnable) { diff --git a/matisse/src/main/java/com/zhihu/matisse/ui/MatisseActivity.java b/matisse/src/main/java/com/zhihu/matisse/ui/MatisseActivity.java index cd083fdec..4f41f5126 100644 --- a/matisse/src/main/java/com/zhihu/matisse/ui/MatisseActivity.java +++ b/matisse/src/main/java/com/zhihu/matisse/ui/MatisseActivity.java @@ -73,6 +73,7 @@ public class MatisseActivity extends AppCompatActivity implements public static final String EXTRA_RESULT_ORIGINAL_ENABLE = "extra_result_original_enable"; private static final int REQUEST_CODE_PREVIEW = 23; private static final int REQUEST_CODE_CAPTURE = 24; + public static final String CHECK_STATE = "checkState"; private final AlbumCollection mAlbumCollection = new AlbumCollection(); private MediaStoreCompat mMediaStoreCompat; private SelectedItemCollection mSelectedCollection = new SelectedItemCollection(this); @@ -131,6 +132,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { mOriginalLayout.setOnClickListener(this); mSelectedCollection.onCreate(savedInstanceState); + if (savedInstanceState != null) { + mOriginalEnable=savedInstanceState.getBoolean(CHECK_STATE); + } updateBottomToolbar(); mAlbumsAdapter = new AlbumsAdapter(this, null, false); @@ -149,6 +153,7 @@ protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mSelectedCollection.onSaveInstanceState(outState); mAlbumCollection.onSaveInstanceState(outState); + outState.putBoolean("checkState",mOriginalEnable); } @Override