diff --git a/README.md b/README.md index dff332e..9c68b69 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Then, add the library in your app module `build.gradle` ```groovy dependencies{ - compile 'com.github.andremion:louvre:1.0.1' + compile 'com.github.andremion:louvre:1.2.0' } ``` @@ -96,6 +96,14 @@ Louvre.init(myActivity) .open(); ``` +You can also use a `Fragment` to open the **Louvre**. In this case, the `Fragment` will get the `onActivityResult` callback. + +```java +Louvre.init(myFragment) + .setRequestCode(LOUVRE_REQUEST_CODE) + .open(); +``` + But you can customize the picker: ######Setting the max images allowed to pick @@ -103,6 +111,13 @@ But you can customize the picker: louvre.setMaxSelection(10) ``` +######Setting the current selected items +```java +List selection; +... +louvre.setSelection(selection) +``` + ######Setting the media type to filter the query with a combination of one of these types: `Louvre.IMAGE_TYPE_BMP`, `Louvre.IMAGE_TYPE_JPEG`, `Louvre.IMAGE_TYPE_PNG` ```java louvre.setMediaTypeFilter(Louvre.IMAGE_TYPE_JPEG, Louvre.IMAGE_TYPE_PNG) @@ -116,8 +131,8 @@ See more at the [sample](https://github.com/andremion/Louvre/tree/master/sample) The Design package provides APIs to support adding material design components and patterns to your apps. * [CounterFab](https://github.com/andremion/CounterFab) A FloatingActionButton subclass that shows a counter badge on right top corner. -* [Picasso](https://github.com/square/picasso) -A powerful image downloading and caching library for Android +* [Glide](https://github.com/bumptech/glide) +An image loading and caching library for Android focused on smooth scrolling * [PhotoView](https://github.com/chrisbanes/PhotoView) Implementation of ImageView for Android that supports zooming, by various touch gestures. diff --git a/art/sample_optimized.gif b/art/sample_optimized.gif new file mode 100644 index 0000000..bcd5cd7 Binary files /dev/null and b/art/sample_optimized.gif differ diff --git a/build.gradle b/build.gradle index 3c72f6b..040aa91 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' } } @@ -18,21 +18,22 @@ allprojects { repositories { jcenter() maven { url "https://jitpack.io" } + maven { url "https://maven.google.com" } } project.ext { - compileSdkVersion = 25 - buildToolsVersion = '25.0.2' - minSdkVersion = 19 - targetSdkVersion = 25 + compileSdkVersion = 26 + buildToolsVersion = '26.0.0' + minSdkVersion = 16 + targetSdkVersion = 26 - versionCode = 2 - versionName = "1.0.1" + versionCode = 7 + versionName = "1.2.0" - supportLibraryVersion = '25.1.0' + supportLibraryVersion = '25.4.0' counterFabVersion = '1.0.1' - picassoVersion = '2.5.2' - photoViewVersion = '1.3.1' + glideVersion = '3.8.0' + photoViewVersion = '2.0.0' junitVersion = '4.12' espressoVersion = '2.2.+' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 04e285f..565af13 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Dec 28 10:00:20 PST 2015 +#Tue May 23 10:17:32 WEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/louvre/build.gradle b/louvre/build.gradle index 09a589e..f011b4f 100644 --- a/louvre/build.gradle +++ b/louvre/build.gradle @@ -26,7 +26,7 @@ dependencies { compile "com.android.support:design:$supportLibraryVersion" compile "com.android.support:recyclerview-v7:$supportLibraryVersion" compile "com.github.andremion:counterfab:$counterFabVersion" - compile "com.squareup.picasso:picasso:$picassoVersion" + compile "com.github.bumptech.glide:glide:$glideVersion" compile "com.github.chrisbanes:PhotoView:$photoViewVersion" testCompile "junit:junit:$junitVersion" diff --git a/louvre/src/main/java/com/andremion/louvre/Louvre.java b/louvre/src/main/java/com/andremion/louvre/Louvre.java index 9c3677b..fd0f3d8 100644 --- a/louvre/src/main/java/com/andremion/louvre/Louvre.java +++ b/louvre/src/main/java/com/andremion/louvre/Louvre.java @@ -18,15 +18,18 @@ import android.app.Activity; import android.content.Intent; +import android.net.Uri; import android.support.annotation.IntRange; import android.support.annotation.NonNull; import android.support.annotation.StringDef; +import android.support.v4.app.Fragment; import android.support.v7.app.AppCompatDelegate; import com.andremion.louvre.home.GalleryActivity; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.List; /** * A small customizable image picker. Useful to handle an image pick action built-in @@ -47,9 +50,11 @@ public class Louvre { @interface MediaType { } - private final Activity mActivity; + private Activity mActivity; + private Fragment mFragment; private int mRequestCode; private int mMaxSelection; + private List mSelection; private String[] mMediaTypeFilter; private Louvre(@NonNull Activity activity) { @@ -57,10 +62,19 @@ private Louvre(@NonNull Activity activity) { mRequestCode = -1; } + private Louvre(@NonNull Fragment fragment) { + mFragment = fragment; + mRequestCode = -1; + } + public static Louvre init(@NonNull Activity activity) { return new Louvre(activity); } + public static Louvre init(@NonNull Fragment fragment) { + return new Louvre(fragment); + } + /** * Set the request code to return on {@link Activity#onActivityResult(int, int, Intent)} */ @@ -77,6 +91,14 @@ public Louvre setMaxSelection(@IntRange(from = 0) int maxSelection) { return this; } + /** + * Set the current selected items + */ + public Louvre setSelection(@NonNull List selection) { + mSelection = selection; + return this; + } + /** * Set the media type to filter the query with a combination of one of these types: {@link #IMAGE_TYPE_BMP}, {@link #IMAGE_TYPE_JPEG}, {@link #IMAGE_TYPE_PNG} */ @@ -89,7 +111,11 @@ public void open() { if (mRequestCode == -1) { throw new IllegalArgumentException("You need to define a request code in setRequestCode(int) method"); } - GalleryActivity.startActivity(mActivity, mRequestCode, mMaxSelection, mMediaTypeFilter); + if (mActivity != null) { + GalleryActivity.startActivity(mActivity, mRequestCode, mMaxSelection, mSelection, mMediaTypeFilter); + } else { + GalleryActivity.startActivity(mFragment, mRequestCode, mMaxSelection, mSelection, mMediaTypeFilter); + } } } diff --git a/louvre/src/main/java/com/andremion/louvre/StoragePermissionActivity.java b/louvre/src/main/java/com/andremion/louvre/StoragePermissionActivity.java index c7421a6..e46b09b 100644 --- a/louvre/src/main/java/com/andremion/louvre/StoragePermissionActivity.java +++ b/louvre/src/main/java/com/andremion/louvre/StoragePermissionActivity.java @@ -33,7 +33,7 @@ */ public abstract class StoragePermissionActivity extends AppCompatActivity { - private static final int REQUEST_READ_EXTERNAL_STORAGE = 0; + private static final int REQUEST_READ_EXTERNAL_STORAGE = 4321; private static final int REQUEST_APP_SETTINGS = 1234; public void askForPermission() { @@ -102,18 +102,26 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { *

*/ private void showExplanation() { - Snackbar.make(getWindow().getDecorView(), getString(R.string.activity_gallery_permission_request_explanation), Snackbar.LENGTH_INDEFINITE) + Snackbar.make(findSuitableView(), getString(R.string.activity_gallery_permission_request_explanation), Snackbar.LENGTH_INDEFINITE) .setAction(R.string.activity_gallery_permission_request_settings, new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(); - intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - Uri uri = Uri.fromParts("package", getPackageName(), null); - intent.setData(uri); + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, + Uri.fromParts("package", getPackageName(), null)); + intent.addCategory(Intent.CATEGORY_DEFAULT); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(intent, REQUEST_APP_SETTINGS); } }) .show(); } + private View findSuitableView() { + View view = findViewById(R.id.coordinator_layout); + if (view == null) { + view = getWindow().getDecorView(); + } + return view; + } + } diff --git a/louvre/src/main/java/com/andremion/louvre/home/GalleryActivity.java b/louvre/src/main/java/com/andremion/louvre/home/GalleryActivity.java index 032f9fc..e04e15e 100644 --- a/louvre/src/main/java/com/andremion/louvre/home/GalleryActivity.java +++ b/louvre/src/main/java/com/andremion/louvre/home/GalleryActivity.java @@ -16,8 +16,8 @@ package com.andremion.louvre.home; -import android.annotation.TargetApi; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; @@ -26,7 +26,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; -import android.support.v4.app.SharedElementCallback; +import android.support.v4.app.Fragment; import android.support.v7.widget.Toolbar; import android.transition.Transition; import android.transition.TransitionInflater; @@ -40,6 +40,7 @@ import com.andremion.louvre.util.transition.TransitionCallback; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; public class GalleryActivity extends StoragePermissionActivity implements GalleryFragment.Callbacks, View.OnClickListener { @@ -57,33 +58,53 @@ public class GalleryActivity extends StoragePermissionActivity implements Galler * @param activity Context to launch activity from. * @param requestCode If >= 0, this code will be returned in onActivityResult() when the activity exits. * @param maxSelection The max count of image selection + * @param selection The current image selection * @param mediaTypeFilter The media types that will display */ public static void startActivity(@NonNull Activity activity, int requestCode, - @IntRange(from = 0) int maxSelection, String... mediaTypeFilter) { - Intent intent = new Intent(activity, GalleryActivity.class); + @IntRange(from = 0) int maxSelection, + List selection, + String... mediaTypeFilter) { + Intent intent = buildIntent(activity, maxSelection, selection, mediaTypeFilter); + activity.startActivityForResult(intent, requestCode); + } + + /** + * Start the Gallery Activity with additional launch information. + * + * @param fragment Context to launch fragment from. + * @param requestCode If >= 0, this code will be returned in onActivityResult() when the fragment exits. + * @param maxSelection The max count of image selection + * @param selection The current image selection + * @param mediaTypeFilter The media types that will display + */ + public static void startActivity(@NonNull Fragment fragment, int requestCode, + @IntRange(from = 0) int maxSelection, + List selection, + String... mediaTypeFilter) { + Intent intent = buildIntent(fragment.getContext(), maxSelection, selection, mediaTypeFilter); + fragment.startActivityForResult(intent, requestCode); + } + + @NonNull + private static Intent buildIntent(@NonNull Context context, @IntRange(from = 0) int maxSelection, List selection, String[] mediaTypeFilter) { + Intent intent = new Intent(context, GalleryActivity.class); if (maxSelection > 0) { intent.putExtra(EXTRA_MAX_SELECTION, maxSelection); } + if (selection != null) { + intent.putExtra(EXTRA_SELECTION, new LinkedList<>(selection)); + } if (mediaTypeFilter != null && mediaTypeFilter.length > 0) { intent.putExtra(EXTRA_MEDIA_TYPE_FILTER, mediaTypeFilter); } - activity.startActivityForResult(intent, requestCode); + return intent; } public static List getSelection(Intent data) { return data.getParcelableArrayListExtra(EXTRA_SELECTION); } - private final Transition.TransitionListener mSharedElementExitListener = - new TransitionCallback() { - @Override - public void onTransitionEnd(Transition transition) { - setExitSharedElementCallback((SharedElementCallback) null); - updateFabVisibility(); - } - }; - private GalleryFragment mFragment; private ViewGroup mContentView; private CounterFab mFab; @@ -94,21 +115,23 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { setContentView(R.layout.activity_gallery); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - setupTransition(); - } + setupTransition(); mContentView = (ViewGroup) findViewById(R.id.coordinator_layout); + mFab = (CounterFab) findViewById(R.id.fab_done); + mFab.setOnClickListener(this); + mFragment = (GalleryFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_gallery); mFragment.setMaxSelection(getIntent().getIntExtra(EXTRA_MAX_SELECTION, DEFAULT_MAX_SELECTION)); + if (getIntent().hasExtra(EXTRA_SELECTION)) { + //noinspection unchecked + mFragment.setSelection((List) getIntent().getSerializableExtra(EXTRA_SELECTION)); + } if (getIntent().hasExtra(EXTRA_MEDIA_TYPE_FILTER)) { mFragment.setMediaTypeFilter(getIntent().getStringArrayExtra(EXTRA_MEDIA_TYPE_FILTER)); } - mFab = (CounterFab) findViewById(R.id.fab_done); - mFab.setOnClickListener(this); - if (savedInstanceState == null) { setResult(RESULT_CANCELED); askForPermission(); @@ -117,22 +140,30 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { } } - @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setupTransition() { - TransitionInflater inflater = TransitionInflater.from(this); - getWindow().setExitTransition(inflater.inflateTransition(R.transition.gallery_exit)); - getWindow().setReenterTransition(inflater.inflateTransition(R.transition.gallery_reenter)); - Transition sharedElementExitTransition = inflater.inflateTransition(R.transition.shared_element); - // Listener to reset shared element exit transition callbacks. - sharedElementExitTransition.addListener(mSharedElementExitListener); - getWindow().setSharedElementExitTransition(sharedElementExitTransition); - } - - private void updateFabVisibility() { - if (mFab.isShown()) { - mFab.hide(); - } else { - mFab.show(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + TransitionInflater inflater = TransitionInflater.from(this); + Transition exitTransition = inflater.inflateTransition(R.transition.gallery_exit); + exitTransition.addListener(new TransitionCallback() { + @Override + public void onTransitionStart(Transition transition) { + mFab.hide(); + } + }); + getWindow().setExitTransition(exitTransition); + Transition reenterTransition = inflater.inflateTransition(R.transition.gallery_reenter); + reenterTransition.addListener(new TransitionCallback() { + @Override + public void onTransitionEnd(Transition transition) { + mFab.show(); + } + + @Override + public void onTransitionCancel(Transition transition) { + mFab.show(); + } + }); + getWindow().setReenterTransition(reenterTransition); } } @@ -178,11 +209,11 @@ public void onBucketClick(String label) { @Override public void onMediaClick(@NonNull View imageView, @NonNull View checkView, long bucketId, int position) { if (getIntent().hasExtra(EXTRA_MEDIA_TYPE_FILTER)) { - PreviewActivity.startActivity(this, PREVIEW_REQUEST_CODE, imageView, checkView, bucketId, position, mFragment.getRawSelection(), + PreviewActivity.startActivity(this, PREVIEW_REQUEST_CODE, imageView, checkView, bucketId, position, mFragment.getSelection(), getIntent().getIntExtra(EXTRA_MAX_SELECTION, DEFAULT_MAX_SELECTION), getIntent().getStringArrayExtra(EXTRA_MEDIA_TYPE_FILTER)); } else { - PreviewActivity.startActivity(this, PREVIEW_REQUEST_CODE, imageView, checkView, bucketId, position, mFragment.getRawSelection(), + PreviewActivity.startActivity(this, PREVIEW_REQUEST_CODE, imageView, checkView, bucketId, position, mFragment.getSelection(), getIntent().getIntExtra(EXTRA_MAX_SELECTION, DEFAULT_MAX_SELECTION)); } } @@ -196,7 +227,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { } if (requestCode == PREVIEW_REQUEST_CODE) { - mFragment.setSelection(PreviewActivity.getRawSelection(data)); + mFragment.setSelection(PreviewActivity.getSelection(data)); } else { super.onActivityResult(requestCode, resultCode, data); } diff --git a/louvre/src/main/java/com/andremion/louvre/home/GalleryAdapter.java b/louvre/src/main/java/com/andremion/louvre/home/GalleryAdapter.java index eaa213d..5022160 100644 --- a/louvre/src/main/java/com/andremion/louvre/home/GalleryAdapter.java +++ b/louvre/src/main/java/com/andremion/louvre/home/GalleryAdapter.java @@ -35,17 +35,13 @@ import com.andremion.louvre.R; import com.andremion.louvre.util.AnimationHelper; -import com.squareup.picasso.MemoryPolicy; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; import java.io.File; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; -import java.util.Map; /** * {@link RecyclerView.Adapter} subclass used to bind {@link Cursor} items from {@link MediaStore} into {@link RecyclerView} @@ -79,7 +75,7 @@ interface Callbacks { void onWillExceedMaxSelection(); } - private final LinkedHashMap mSelection; + private final List mSelection; @Nullable private Callbacks mCallbacks; @@ -91,7 +87,7 @@ interface Callbacks { private Cursor mData; GalleryAdapter() { - mSelection = new LinkedHashMap<>(); + mSelection = new LinkedList<>(); setHasStableIds(true); } @@ -143,11 +139,6 @@ public int getItemViewType(int position) { return mViewType; } - @Override - public void onAttachedToRecyclerView(RecyclerView recyclerView) { - // TODO: 18/01/2017 onAttachedToRecyclerView - } - @Override public GalleryAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, @ViewType int viewType) { if (VIEW_TYPE_MEDIA == viewType) { @@ -165,10 +156,9 @@ public void onBindViewHolder(@NonNull GalleryAdapter.ViewHolder holder, int posi String imageTransitionName = holder.itemView.getContext().getString(R.string.activity_gallery_image_transition, data.toString()); String checkboxTransitionName = holder.itemView.getContext().getString(R.string.activity_gallery_checkbox_transition, data.toString()); ViewCompat.setTransitionName(holder.mImageView, imageTransitionName); - Picasso.with(holder.mImageView.getContext()) + Glide.with(holder.mImageView.getContext()) .load(data) - .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) - .fit() + .skipMemoryCache(true) .centerCrop() .placeholder(R.color.gallery_item_background) .into(holder.mImageView); @@ -219,21 +209,13 @@ public void onBindViewHolder(GalleryAdapter.ViewHolder holder, int position, Lis } List getSelection() { - List selected = new ArrayList<>(); - for (Map.Entry entry : mSelection.entrySet()) { - selected.add(entry.getValue()); - } - return selected; + return new LinkedList<>(mSelection); } - LinkedHashMap getRawSelection() { - return new LinkedHashMap<>(mSelection); - } - - void setSelection(@NonNull HashMap selection) { + void setSelection(@NonNull List selection) { if (!mSelection.equals(selection)) { mSelection.clear(); - mSelection.putAll(selection); + mSelection.addAll(selection); notifySelectionChanged(); } } @@ -242,13 +224,12 @@ void selectAll() { if (mData == null) { return; } - LinkedHashMap selectionToAdd = new LinkedHashMap<>(); + List selectionToAdd = new LinkedList<>(); int count = mData.getCount(); for (int position = 0; position < count; position++) { if (!isSelected(position)) { - long id = getItemId(position); Uri data = getData(position); - selectionToAdd.put(id, data); + selectionToAdd.add(data); } } if (mSelection.size() + selectionToAdd.size() > mMaxSelection) { @@ -256,7 +237,7 @@ void selectAll() { mCallbacks.onWillExceedMaxSelection(); } } else { - mSelection.putAll(selectionToAdd); + mSelection.addAll(selectionToAdd); notifySelectionChanged(); } } @@ -282,8 +263,8 @@ private void notifySelectionChanged() { } private boolean isSelected(int position) { - long itemId = getItemId(position); - return mSelection.containsKey(itemId); + Uri data = getData(position); + return mSelection.contains(data); } private String getLabel(int position) { @@ -388,14 +369,14 @@ public void onClick(View v) { } private boolean handleChangeSelection(int position) { - final long itemId = getItemId(position); + Uri data = getData(position); if (!isSelected(position)) { if (mSelection.size() == mMaxSelection) { return false; } - mSelection.put(itemId, getData(position)); + mSelection.add(data); } else { - mSelection.remove(itemId); + mSelection.remove(data); } return true; } diff --git a/louvre/src/main/java/com/andremion/louvre/home/GalleryFragment.java b/louvre/src/main/java/com/andremion/louvre/home/GalleryFragment.java index 3a0b450..8682c0f 100644 --- a/louvre/src/main/java/com/andremion/louvre/home/GalleryFragment.java +++ b/louvre/src/main/java/com/andremion/louvre/home/GalleryFragment.java @@ -16,18 +16,22 @@ package com.andremion.louvre.home; +import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.support.annotation.IntRange; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; +import android.support.v4.app.SharedElementCallback; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; +import android.transition.Transition; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -41,10 +45,9 @@ import com.andremion.louvre.preview.PreviewActivity; import com.andremion.louvre.util.ItemOffsetDecoration; import com.andremion.louvre.util.transition.MediaSharedElementCallback; +import com.andremion.louvre.util.transition.TransitionCallback; import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; public class GalleryFragment extends Fragment implements MediaLoader.Callbacks, GalleryAdapter.Callbacks { @@ -64,6 +67,7 @@ public interface Callbacks { private final MediaLoader mMediaLoader; private final GalleryAdapter mAdapter; + private View mEmptyView; private GridLayoutManager mLayoutManager; private RecyclerView mRecyclerView; private Callbacks mCallbacks; @@ -131,12 +135,19 @@ public boolean onOptionsItemSelected(MenuItem item) { public void onBucketLoadFinished(@Nullable Cursor data) { mAdapter.swapData(GalleryAdapter.VIEW_TYPE_BUCKET, data); getActivity().invalidateOptionsMenu(); + updateEmptyState(); } @Override public void onMediaLoadFinished(@Nullable Cursor data) { mAdapter.swapData(GalleryAdapter.VIEW_TYPE_MEDIA, data); getActivity().invalidateOptionsMenu(); + updateEmptyState(); + } + + private void updateEmptyState() { + mRecyclerView.setVisibility(mAdapter.getItemCount() > 0 ? View.VISIBLE : View.INVISIBLE); + mEmptyView.setVisibility(mAdapter.getItemCount() > 0 ? View.INVISIBLE : View.VISIBLE); } @Override @@ -151,6 +162,8 @@ public void onDetach() { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_gallery, container, false); + mEmptyView = view.findViewById(android.R.id.empty); + mLayoutManager = new GridLayoutManager(getContext(), 1); mAdapter.setLayoutManager(mLayoutManager); @@ -173,6 +186,10 @@ public boolean onPreDraw() { } }); + if (savedInstanceState != null) { + updateEmptyState(); + } + return view; } @@ -185,6 +202,28 @@ public void onActivityReenter(int resultCode, Intent data) { mSharedElementCallback = new MediaSharedElementCallback(); getActivity().setExitSharedElementCallback(mSharedElementCallback); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + // Listener to reset shared element exit transition callbacks. + getActivity().getWindow().getSharedElementExitTransition().addListener(new TransitionCallback() { + @Override + public void onTransitionEnd(Transition transition) { + removeCallback(); + } + + @Override + public void onTransitionCancel(Transition transition) { + removeCallback(); + } + + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + private void removeCallback() { + if (getActivity() != null) { + getActivity().getWindow().getSharedElementExitTransition().removeListener(this); + getActivity().setExitSharedElementCallback((SharedElementCallback) null); + } + } + }); + } //noinspection ConstantConditions getActivity().supportPostponeEnterTransition(); @@ -255,11 +294,7 @@ public List getSelection() { return new ArrayList<>(mAdapter.getSelection()); } - public LinkedHashMap getRawSelection() { - return new LinkedHashMap<>(mAdapter.getRawSelection()); - } - - public void setSelection(@NonNull HashMap selection) { + public void setSelection(@NonNull List selection) { mAdapter.setSelection(selection); } diff --git a/louvre/src/main/java/com/andremion/louvre/preview/PreviewActivity.java b/louvre/src/main/java/com/andremion/louvre/preview/PreviewActivity.java index e0e2b62..110e846 100644 --- a/louvre/src/main/java/com/andremion/louvre/preview/PreviewActivity.java +++ b/louvre/src/main/java/com/andremion/louvre/preview/PreviewActivity.java @@ -47,8 +47,7 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import static android.support.v7.widget.RecyclerView.NO_POSITION; @@ -63,12 +62,12 @@ public class PreviewActivity extends AppCompatActivity implements MediaLoader.Ca public static void startActivity(@NonNull Activity activity, int requestCode, @NonNull View imageView, @NonNull View checkView, @IntRange(from = 0) long bucketId, @IntRange(from = 0) int position, - LinkedHashMap selection, int maxSelection, String... mediaTypeFilter) { + List selection, int maxSelection, String... mediaTypeFilter) { Intent intent = new Intent(activity, PreviewActivity.class); intent.putExtra(EXTRA_BUCKET_ID, bucketId); intent.putExtra(EXTRA_POSITION, position); - intent.putExtra(EXTRA_SELECTION, selection); + intent.putExtra(EXTRA_SELECTION, new LinkedList<>(selection)); intent.putExtra(EXTRA_MAX_SELECTION, maxSelection); intent.putExtra(EXTRA_MEDIA_TYPE_FILTER, mediaTypeFilter); @@ -92,7 +91,9 @@ private static Pair[] concatToSystemSharedElements(@NonNull Activity activity, @ View statusBackground = decorView.findViewById(android.R.id.statusBarBackground); View navigationBarBackground = decorView.findViewById(android.R.id.navigationBarBackground); - sharedElements.add(Pair.create(statusBackground, ViewCompat.getTransitionName(statusBackground))); + if (statusBackground != null) { + sharedElements.add(Pair.create(statusBackground, ViewCompat.getTransitionName(statusBackground))); + } if (navigationBarBackground != null) { sharedElements.add(Pair.create(navigationBarBackground, ViewCompat.getTransitionName(navigationBarBackground))); } @@ -109,9 +110,9 @@ public static int getPosition(int resultCode, Intent data) { return NO_POSITION; } - public static HashMap getRawSelection(Intent data) { + public static List getSelection(Intent data) { //noinspection unchecked - return (HashMap) data.getExtras().get(EXTRA_SELECTION); + return (List) data.getExtras().get(EXTRA_SELECTION); } private MediaLoader mMediaLoader; @@ -139,7 +140,7 @@ protected void onCreate(Bundle savedInstanceState) { setEnterSharedElementCallback(sharedElementCallback); //noinspection unchecked - HashMap selection = (HashMap) getIntent().getExtras().get(EXTRA_SELECTION); + List selection = (List) getIntent().getExtras().get(EXTRA_SELECTION); assert selection != null; int maxSelection = getIntent().getExtras().getInt(EXTRA_MAX_SELECTION); @@ -177,6 +178,11 @@ private void setupTransition() { public void onTransitionEnd(Transition transition) { mAdapter.setDontAnimate(false); } + + @Override + public void onTransitionCancel(Transition transition) { + mAdapter.setDontAnimate(false); + } }); getWindow().setSharedElementEnterTransition(sharedElementEnterTransition); } @@ -250,7 +256,7 @@ private void setResult() { Intent data = new Intent(); data.putExtra(EXTRA_POSITION, position); - data.putExtra(EXTRA_SELECTION, mAdapter.getRawSelection()); + data.putExtra(EXTRA_SELECTION, new LinkedList<>(mAdapter.getSelection())); setResult(RESULT_OK, data); setCheckboxTransitionName(position); diff --git a/louvre/src/main/java/com/andremion/louvre/preview/PreviewAdapter.java b/louvre/src/main/java/com/andremion/louvre/preview/PreviewAdapter.java index 86b403d..9d07bc0 100644 --- a/louvre/src/main/java/com/andremion/louvre/preview/PreviewAdapter.java +++ b/louvre/src/main/java/com/andremion/louvre/preview/PreviewAdapter.java @@ -34,14 +34,15 @@ import com.andremion.louvre.R; import com.andremion.louvre.util.transition.MediaSharedElementCallback; -import com.squareup.picasso.Callback; -import com.squareup.picasso.MemoryPolicy; -import com.squareup.picasso.Picasso; -import com.squareup.picasso.RequestCreator; +import com.bumptech.glide.DrawableRequestBuilder; +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.resource.drawable.GlideDrawable; +import com.bumptech.glide.request.RequestListener; +import com.bumptech.glide.request.target.Target; import java.io.File; -import java.util.HashMap; -import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; import static android.view.View.NO_ID; @@ -58,7 +59,7 @@ interface Callbacks { private final LayoutInflater mInflater; private final CheckedTextView mCheckbox; private final MediaSharedElementCallback mSharedElementCallback; - private final HashMap mSelection; + private final List mSelection; @Nullable private PreviewAdapter.Callbacks mCallbacks; private int mMaxSelection; @@ -68,7 +69,7 @@ interface Callbacks { private boolean mDontAnimate; private int mCurrentPosition = RecyclerView.NO_POSITION; - PreviewAdapter(@NonNull FragmentActivity activity, @NonNull CheckedTextView checkbox, @NonNull MediaSharedElementCallback sharedElementCallback, @NonNull HashMap selection) { + PreviewAdapter(@NonNull FragmentActivity activity, @NonNull CheckedTextView checkbox, @NonNull MediaSharedElementCallback sharedElementCallback, @NonNull List selection) { mActivity = activity; mInflater = LayoutInflater.from(activity); mCheckbox = checkbox; @@ -138,20 +139,20 @@ private long getItemId(int position) { private void onViewBound(ViewHolder holder, int position, Uri data) { String imageTransitionName = holder.imageView.getContext().getString(R.string.activity_gallery_image_transition, data.toString()); ViewCompat.setTransitionName(holder.imageView, imageTransitionName); - RequestCreator request = Picasso.with(mActivity) + DrawableRequestBuilder request = Glide.with(mActivity) .load(data) - .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) - .fit() - .centerInside(); + .skipMemoryCache(true) + .fitCenter() + .listener(new ImageLoadingCallback(position)); if (mDontAnimate) { - request.noFade(); + request.dontAnimate(); } - request.into(holder.imageView, new ImageLoadingCallback(position)); + request.into(holder.imageView); } private boolean isSelected(int position) { - long itemId = getItemId(position); - return mSelection.containsKey(itemId); + Uri data = getData(position); + return mSelection.contains(data); } private void startPostponedEnterTransition(int position) { @@ -197,19 +198,19 @@ void selectCurrentItem() { } } - LinkedHashMap getRawSelection() { - return new LinkedHashMap<>(mSelection); + List getSelection() { + return new LinkedList<>(mSelection); } private boolean handleChangeSelection(int position) { - final long itemId = getItemId(position); + Uri data = getData(position); if (!isSelected(position)) { if (mSelection.size() == mMaxSelection) { return false; } - mSelection.put(itemId, getData(position)); + mSelection.add(data); } else { - mSelection.remove(itemId); + mSelection.remove(data); } return true; } @@ -226,7 +227,7 @@ private static class ViewHolder { } - private class ImageLoadingCallback implements Callback { + private class ImageLoadingCallback implements RequestListener { final int mPosition; @@ -235,15 +236,16 @@ private class ImageLoadingCallback implements Callback { } @Override - public void onSuccess() { + public boolean onResourceReady(GlideDrawable resource, Uri model, Target target, boolean isFromMemoryCache, boolean isFirstResource) { startPostponedEnterTransition(mPosition); + return false; } @Override - public void onError() { + public boolean onException(Exception e, Uri model, Target target, boolean isFirstResource) { startPostponedEnterTransition(mPosition); + return false; } - } } diff --git a/louvre/src/main/java/com/andremion/louvre/util/FabBehavior.java b/louvre/src/main/java/com/andremion/louvre/util/FabBehavior.java index 3cc1cef..3eec092 100644 --- a/louvre/src/main/java/com/andremion/louvre/util/FabBehavior.java +++ b/louvre/src/main/java/com/andremion/louvre/util/FabBehavior.java @@ -48,7 +48,7 @@ public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, Floating public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); - if (Math.abs(dyConsumed) > 0 && child.isShown()) { + if (Math.abs(dyConsumed) > 0 && child.getVisibility() == View.VISIBLE) { child.hide(); } } diff --git a/louvre/src/main/res/drawable-hdpi/ic_no_images_black_48dp.png b/louvre/src/main/res/drawable-hdpi/ic_no_images_black_48dp.png new file mode 100644 index 0000000..2ed61eb Binary files /dev/null and b/louvre/src/main/res/drawable-hdpi/ic_no_images_black_48dp.png differ diff --git a/louvre/src/main/res/drawable-mdpi/ic_no_images_black_48dp.png b/louvre/src/main/res/drawable-mdpi/ic_no_images_black_48dp.png new file mode 100644 index 0000000..160d531 Binary files /dev/null and b/louvre/src/main/res/drawable-mdpi/ic_no_images_black_48dp.png differ diff --git a/louvre/src/main/res/drawable-xhdpi/ic_no_images_black_48dp.png b/louvre/src/main/res/drawable-xhdpi/ic_no_images_black_48dp.png new file mode 100644 index 0000000..b520a36 Binary files /dev/null and b/louvre/src/main/res/drawable-xhdpi/ic_no_images_black_48dp.png differ diff --git a/louvre/src/main/res/drawable-xxhdpi/ic_no_images_black_48dp.png b/louvre/src/main/res/drawable-xxhdpi/ic_no_images_black_48dp.png new file mode 100644 index 0000000..08da045 Binary files /dev/null and b/louvre/src/main/res/drawable-xxhdpi/ic_no_images_black_48dp.png differ diff --git a/louvre/src/main/res/drawable-xxxhdpi/ic_no_images_black_48dp.png b/louvre/src/main/res/drawable-xxxhdpi/ic_no_images_black_48dp.png new file mode 100644 index 0000000..5e34758 Binary files /dev/null and b/louvre/src/main/res/drawable-xxxhdpi/ic_no_images_black_48dp.png differ diff --git a/louvre/src/main/res/drawable/ic_no_images.xml b/louvre/src/main/res/drawable/ic_no_images.xml new file mode 100644 index 0000000..3098b61 --- /dev/null +++ b/louvre/src/main/res/drawable/ic_no_images.xml @@ -0,0 +1,21 @@ + + + diff --git a/louvre/src/main/res/layout/activity_gallery.xml b/louvre/src/main/res/layout/activity_gallery.xml index ea1fcab..98d5de3 100644 --- a/louvre/src/main/res/layout/activity_gallery.xml +++ b/louvre/src/main/res/layout/activity_gallery.xml @@ -20,13 +20,13 @@ android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" - android:theme="?attr/appbarTheme"> + android:theme="?attr/appbarTheme" + android:transitionGroup="true"> + android:layout_height="wrap_content" /> diff --git a/louvre/src/main/res/layout/activity_preview.xml b/louvre/src/main/res/layout/activity_preview.xml index 290da54..7300ea1 100644 --- a/louvre/src/main/res/layout/activity_preview.xml +++ b/louvre/src/main/res/layout/activity_preview.xml @@ -6,6 +6,8 @@ android:layout_height="match_parent" tools:context="com.andremion.louvre.preview.PreviewActivity"> + + - + android:clipChildren="false"> + + + + + + \ No newline at end of file diff --git a/louvre/src/main/res/layout/page_item_preview.xml b/louvre/src/main/res/layout/page_item_preview.xml index 14df5b6..f1bc711 100644 --- a/louvre/src/main/res/layout/page_item_preview.xml +++ b/louvre/src/main/res/layout/page_item_preview.xml @@ -1,5 +1,5 @@ - + - diff --git a/louvre/src/main/res/transition-v21/gallery_reenter.xml b/louvre/src/main/res/transition-v21/gallery_reenter.xml index f62f78a..7b749f1 100644 --- a/louvre/src/main/res/transition-v21/gallery_reenter.xml +++ b/louvre/src/main/res/transition-v21/gallery_reenter.xml @@ -15,13 +15,22 @@ --> + + + + + + - + + diff --git a/louvre/src/main/res/values-es/strings.xml b/louvre/src/main/res/values-es/strings.xml new file mode 100644 index 0000000..e7a8d6e --- /dev/null +++ b/louvre/src/main/res/values-es/strings.xml @@ -0,0 +1,15 @@ + + + Permiso de almacenamiento necesario. Por favor habilitar en los ajustes del teléfono. + Ajustes + Seleccionar todo + Limpiar + No hay fotos. + Has alcanzado el número máximo de fotos. + Usted excederá el número máximo de fotos. + Todas las fotos + + %d seleccionado + %d seleccionados + + diff --git a/louvre/src/main/res/values-v19/themes.xml b/louvre/src/main/res/values-v19/themes.xml new file mode 100644 index 0000000..273f8d9 --- /dev/null +++ b/louvre/src/main/res/values-v19/themes.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/louvre/src/main/res/values/strings.xml b/louvre/src/main/res/values/strings.xml index 4c60282..2393b4a 100644 --- a/louvre/src/main/res/values/strings.xml +++ b/louvre/src/main/res/values/strings.xml @@ -6,6 +6,7 @@ Settings Select All Clear + No images. You have reached the max number of photos. You will exceed the max number of photos. All Media diff --git a/louvre/src/main/res/values/themes.xml b/louvre/src/main/res/values/themes.xml index 2c026d0..f66f537 100644 --- a/louvre/src/main/res/values/themes.xml +++ b/louvre/src/main/res/values/themes.xml @@ -14,7 +14,7 @@ \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 2763fab..6b482bc 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -10,6 +10,7 @@ android { versionCode project.ext.versionCode versionName project.ext.versionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + vectorDrawables.useSupportLibrary = true } buildTypes { release { diff --git a/sample/src/main/java/com/andremion/louvre/sample/MainActivity.java b/sample/src/main/java/com/andremion/louvre/sample/MainActivity.java index 5dac191..6fbea67 100644 --- a/sample/src/main/java/com/andremion/louvre/sample/MainActivity.java +++ b/sample/src/main/java/com/andremion/louvre/sample/MainActivity.java @@ -17,6 +17,7 @@ package com.andremion.louvre.sample; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; @@ -29,11 +30,14 @@ import com.andremion.louvre.home.GalleryActivity; import com.andremion.louvre.util.ItemOffsetDecoration; +import java.util.List; + public class MainActivity extends AppCompatActivity { private static final int LOUVRE_REQUEST_CODE = 0; private MainAdapter mAdapter; + private List mSelection; @Override protected void onCreate(Bundle savedInstanceState) { @@ -63,15 +67,27 @@ public boolean onPreDraw() { fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - NumberPickerDialog.show(getSupportFragmentManager(), LOUVRE_REQUEST_CODE); + NumberPickerDialog.show(getSupportFragmentManager(), LOUVRE_REQUEST_CODE, mSelection); } }); } + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + //noinspection unchecked + mSelection = (List) getLastCustomNonConfigurationInstance(); + } + + @Override + public Object onRetainCustomNonConfigurationInstance() { + return mSelection; + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == LOUVRE_REQUEST_CODE && resultCode == RESULT_OK) { - mAdapter.swapData(GalleryActivity.getSelection(data)); + mAdapter.swapData(mSelection = GalleryActivity.getSelection(data)); return; } super.onActivityResult(requestCode, resultCode, data); diff --git a/sample/src/main/java/com/andremion/louvre/sample/MainAdapter.java b/sample/src/main/java/com/andremion/louvre/sample/MainAdapter.java index 129a88a..07f3ae5 100644 --- a/sample/src/main/java/com/andremion/louvre/sample/MainAdapter.java +++ b/sample/src/main/java/com/andremion/louvre/sample/MainAdapter.java @@ -24,8 +24,7 @@ import android.view.ViewGroup; import android.widget.ImageView; -import com.squareup.picasso.MemoryPolicy; -import com.squareup.picasso.Picasso; +import com.bumptech.glide.Glide; import java.util.ArrayList; import java.util.List; @@ -48,10 +47,9 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { @Override public void onBindViewHolder(ViewHolder holder, int position) { Uri data = mData.get(position); - Picasso.with(holder.mImageView.getContext()) + Glide.with(holder.mImageView.getContext()) .load(data) - .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) - .fit() + .skipMemoryCache(true) .centerCrop() .placeholder(R.color.gallery_item_background) .into(holder.mImageView); diff --git a/sample/src/main/java/com/andremion/louvre/sample/MediaTypeFilterDialog.java b/sample/src/main/java/com/andremion/louvre/sample/MediaTypeFilterDialog.java index 9b31caa..4b58ed2 100644 --- a/sample/src/main/java/com/andremion/louvre/sample/MediaTypeFilterDialog.java +++ b/sample/src/main/java/com/andremion/louvre/sample/MediaTypeFilterDialog.java @@ -18,8 +18,10 @@ import android.app.Dialog; import android.content.DialogInterface; +import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentManager; import android.support.v7.app.AlertDialog; @@ -28,6 +30,7 @@ import com.andremion.louvre.Louvre; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import static android.content.ContentValues.TAG; @@ -36,12 +39,16 @@ public class MediaTypeFilterDialog extends DialogFragment implements DialogInter private static final String ARG_REQUEST_CODE = "request_code_arg"; private static final String ARG_MAX_SELECTION = "max_selection_arg"; + private static final String ARG_SELECTION = "selection_arg"; - public static void show(@NonNull FragmentManager fragmentManager, int requestCode, int maxSelection) { + public static void show(@NonNull FragmentManager fragmentManager, int requestCode, int maxSelection, @Nullable List selection) { MediaTypeFilterDialog dialog = new MediaTypeFilterDialog(); Bundle args = new Bundle(); args.putInt(ARG_REQUEST_CODE, requestCode); args.putInt(ARG_MAX_SELECTION, maxSelection); + if (selection != null) { + args.putSerializable(ARG_SELECTION, new LinkedList<>(selection)); + } dialog.setArguments(args); dialog.show(fragmentManager, TAG); } @@ -74,10 +81,11 @@ public void onClick(DialogInterface dialog, int which, boolean isChecked) { @Override public void onClick(DialogInterface dialog, int which) { - //noinspection WrongConstant + //noinspection WrongConstant,ConstantConditions,unchecked Louvre.init(getActivity()) .setRequestCode(getArguments().getInt(ARG_REQUEST_CODE)) .setMaxSelection(getArguments().getInt(ARG_MAX_SELECTION)) + .setSelection((List) getArguments().get(ARG_SELECTION)) .setMediaTypeFilter(parseToArray(mSelectedTypes)) .open(); } diff --git a/sample/src/main/java/com/andremion/louvre/sample/NumberPickerDialog.java b/sample/src/main/java/com/andremion/louvre/sample/NumberPickerDialog.java index 0cdf465..5977f19 100644 --- a/sample/src/main/java/com/andremion/louvre/sample/NumberPickerDialog.java +++ b/sample/src/main/java/com/andremion/louvre/sample/NumberPickerDialog.java @@ -18,25 +18,34 @@ import android.app.Dialog; import android.content.DialogInterface; +import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentManager; import android.support.v7.app.AlertDialog; import android.widget.NumberPicker; +import java.util.LinkedList; +import java.util.List; + public class NumberPickerDialog extends DialogFragment implements DialogInterface.OnClickListener { private static final String TAG = NumberPickerDialog.class.getSimpleName(); private static final String ARG_REQUEST_CODE = "request_code_arg"; + private static final String ARG_SELECTION = "selection_arg"; private static final int MIN_VALUE = 1; private static final int MAX_VALUE = 100; private static final int INITIAL_VALUE = 10; - public static void show(@NonNull FragmentManager fragmentManager, int requestCode) { + public static void show(@NonNull FragmentManager fragmentManager, int requestCode, @Nullable List selection) { NumberPickerDialog dialog = new NumberPickerDialog(); Bundle args = new Bundle(); args.putInt(ARG_REQUEST_CODE, requestCode); + if (selection != null) { + args.putSerializable(ARG_SELECTION, new LinkedList<>(selection)); + } dialog.setArguments(args); dialog.show(fragmentManager, TAG); } @@ -61,8 +70,10 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { @Override public void onClick(DialogInterface dialog, int which) { + //noinspection unchecked MediaTypeFilterDialog.show(getFragmentManager(), getArguments().getInt(ARG_REQUEST_CODE), - mNumberPicker.getValue()); + mNumberPicker.getValue(), + (List) getArguments().getSerializable(ARG_SELECTION)); } } diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index 4a1d664..d26ee60 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:fitsSystemWindows="true" tools:context="com.andremion.louvre.sample.MainActivity"> + Seleccione la selección máxima + Seleccione el filtro de tipo de medio + diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index a6542e9..2bba943 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - Louvre + Louvre Select the maximum selection Select the media type filter