diff --git a/daguerre/build.gradle b/daguerre/build.gradle index d78de9f..1d9f6a0 100644 --- a/daguerre/build.gradle +++ b/daguerre/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 27 - versionCode 7 - versionName "1.0.7" + versionCode 8 + versionName "1.0.8" vectorDrawables.useSupportLibrary = true } buildTypes { diff --git a/daguerre/src/main/java/com/jay/daguerre/internal/DaguerreActivity.java b/daguerre/src/main/java/com/jay/daguerre/internal/DaguerreActivity.java index 2e9b19d..a8b7735 100644 --- a/daguerre/src/main/java/com/jay/daguerre/internal/DaguerreActivity.java +++ b/daguerre/src/main/java/com/jay/daguerre/internal/DaguerreActivity.java @@ -73,7 +73,7 @@ public class DaguerreActivity extends AppCompatActivity MIME_TYPE, BUCKET_DISPLAY_NAME }; - private ArrayList mResources = new ArrayList<>(); + private ArrayList mResources = Media.getResourceStoreInstance().getResources(); private ArrayList mAlbums = new ArrayList<>(); private RecyclerView mRecyclerView; private ResourceItemAdapter mAdapter; @@ -297,7 +297,6 @@ public void onListItemClick(View itemView) { int adapterPosition = mRecyclerView.getChildViewHolder(itemView).getAdapterPosition(); Intent intent = new Intent(this, PreviewResourceActivity.class); intent.putExtra("position", adapterPosition); - intent.putExtra("images", mResources); ActivityOptionsCompat options = ActivityOptionsCompat .makeSceneTransitionAnimation(this, itemView.findViewById(R.id.image), "element"); diff --git a/daguerre/src/main/java/com/jay/daguerre/internal/Media.java b/daguerre/src/main/java/com/jay/daguerre/internal/Media.java index 42d012e..a837af0 100644 --- a/daguerre/src/main/java/com/jay/daguerre/internal/Media.java +++ b/daguerre/src/main/java/com/jay/daguerre/internal/Media.java @@ -1,9 +1,5 @@ package com.jay.daguerre.internal; -import android.os.Parcel; -import android.os.Parcelable; -import android.text.TextUtils; - import com.jay.daguerre.MimeType; import java.util.ArrayList; @@ -12,7 +8,7 @@ * Created by jay on 2017/11/23 下午3:29 */ final class Media { - static class Resource implements Parcelable { + static class Resource{ String id; String data = ""; //file path // long size; @@ -51,41 +47,6 @@ public boolean isGif() { return mineType != null && mineType.equals(MimeType.GIF); } - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(this.id); - dest.writeString(this.data); - dest.writeString(this.displayName); - dest.writeString(this.mineType); - dest.writeString(this.bucketDisplayName); - dest.writeByte(this.isChecked ? (byte) 1 : (byte) 0); - } - - protected Resource(Parcel in) { - this.id = in.readString(); - this.data = in.readString(); - this.displayName = in.readString(); - this.mineType = in.readString(); - this.bucketDisplayName = in.readString(); - this.isChecked = in.readByte() != 0; - } - - public static final Creator CREATOR = new Creator() { - @Override - public Resource createFromParcel(Parcel source) { - return new Resource(source); - } - - @Override - public Resource[] newArray(int size) { - return new Resource[size]; - } - }; } static class Album { @@ -94,4 +55,22 @@ static class Album { ArrayList resources = new ArrayList<>(); int resourceCount; } + + static ResourceStore getResourceStoreInstance() { + return ResourceStore.instance; + } + + static class ResourceStore{ + + private ArrayList mResources = new ArrayList<>(); + static ResourceStore instance = new ResourceStore(); + + private ResourceStore() { + + } + + ArrayList getResources() { + return mResources; + } + } } \ No newline at end of file diff --git a/daguerre/src/main/java/com/jay/daguerre/internal/PreviewResourceActivity.java b/daguerre/src/main/java/com/jay/daguerre/internal/PreviewResourceActivity.java index f5e3c28..bc9a02c 100644 --- a/daguerre/src/main/java/com/jay/daguerre/internal/PreviewResourceActivity.java +++ b/daguerre/src/main/java/com/jay/daguerre/internal/PreviewResourceActivity.java @@ -25,7 +25,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); int position = intent.getIntExtra("position", 0); - ArrayList images = getIntent().getParcelableArrayListExtra("images"); + ArrayList images = Media.getResourceStoreInstance().getResources(); setContentView(R.layout.daguerre_activity_preview_resource); Toolbar toolbar = findViewById(R.id.toolbar);