:watermelon: Album and Gallery for Android platform.
Album is a Material Design style album, it provides three functions: album, camera and gallery.
White StatusBar, the left is the effect of 5.0-(Containing 5.0), the right is the effect of 6.0+(Containing 6.0):
Effect on landscape screen:
implementation 'com.yanzhenjie:album:2.1.3'Developers must configure AlbumLoader to make Album work normally, and AlbumLoader is used to load thumbnails of images and videos.
This is an example:
public class MediaLoader implements AlbumLoader {
@Override
public void load(ImageView imageView, AlbumFile albumFile) {
load(imageView, albumFile.getPath());
}
@Override
public void load(ImageView imageView, String url) {
Glide.with(imageView.getContext())
.load(url)
.error(R.drawable.placeholder)
.placeholder(R.drawable.placeholder)
.crossFade()
.into(imageView);
}
}The example uses Glide to load thumbnails of pictures and videos. Please remember to configure the AlbumLoader you just implemented.
Album.initialize(AlbumConfig.newBuilder(this)
.setAlbumLoader(new MediaLoader())
...
.build());……If developer want to crop the image, please use Durban.
…Album.camera(this) // Camera function.
.image() // Take Picture.
.filePath() // File save path, not required.
.onResult(new Action<String>() {
@Override
public void onAction(@NonNull String result) {
}
})
.onCancel(new Action<String>() {
@Override
public void onAction(@NonNull String result) {
}
})
.start();If developer want to crop the image, please use Durban.
Album.camera(this)
.video() // Record Video.
.filePath()
.quality(1) // Video quality, [0, 1].
.limitDuration(Long.MAX_VALUE) // The longest duration of the video is in milliseconds.
.limitBytes(Long.MAX_VALUE) // Maximum size of the video, in bytes.
.onResult(new Action<String>() {
@Override
public void onAction(@NonNull String result) {
}
})
.onCancel(new Action<String>() {
@Override
public void onAction(@NonNull String result) {
}
})
.start();// Preview AlbumFile:
Album.galleryAlbum(this)
...
// Preview path:
Album.gallery(this)
.checkedList(imageList) // List of image to view: ArrayList<String>.
.checkable(true) // Whether there is a selection function.
.onResult(new Action<ArrayList<String>>() { // If checkable(false), action not required.
@Override
public void onAction(@NonNull ArrayList<String> result) {
}
})
.onCancel(new Action<String>() {
@Override
public void onAction(@NonNull String result) {
}
})
.start();If
checkable(false), listener not required, theCheckBoxand theFinishButtonwill be not appear.
The user may click or long press on the preview image and the developer can listen to both events:
Album.gallery(this)
...
.itemClick(new ItemAction<String>() {
@Override
public void onAction(Context context, String item) {
}
})
.itemLongClick(new ItemAction<String>() {
@Override
public void onAction(Context context, String item) {
}
})
.start();AlbumFile is the result of the selection of images and videos, The properties of the image and video are different, and their different attributes are listed below.
……Through Widget, developer can configure the title, color of StatusBar, color of NavigationBar and so on.
// Such as image video mix:
Album.album(this)
.multipleChoice()
.widget(...)
...
// Image selection:
Album.image(this)
.multipleChoice()
.widget(...)
...
// Video selection:
Album.video(this)
.multipleChoice()
.widget(...)
...
// Gallery, preview AlbumFile:
Album.galleryAlbum(this)
.widget(...)
...
// Gallery, preview path:
Album.gallery(this)
.widget(...)
...So we only need to pass in a Widget parameter just fine:
…Album defaults to English and changes with the system language. Unfortunately, Album only supports English, Simplified Chinese, Traditional Chinese and Portuguese. However, developers can copy the items in Album's string.xml into your project for translation, the best thing is that you can contribute and submit pull requests to perfect Album.
Developers can specify Album's language:
Album.initialize(AlbumConfig.newBuilder(this)
...
.setLocale(Locale.ENGLISH)
.build());Before submitting pull requests, contributors must abide by the agreement .
If you are using ProGuard you might need to add the following options:
-dontwarn com.yanzhenjie.album.**
-dontwarn com.yanzhenjie.mediascanner.**Copyright 2017 Yan Zhenjie
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.No open issues yet, or sync has not completed.