Transferee can help you complete the seamless transition from thumbnail view to original view, and elegantly browse multimedia in different formats such as ordinary pictures, long pictures, gifs, videos, etc.
Supported features:
If you have any questions, please submit Issues
demo.apk
step1.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
step2.
// 添加所有 module [包括 Transferee、GlideImageLoader、PicassoImageLoader、UniversalImageLoader]
implementation 'com.github.Hitomis:transferee:1.6.1'
// 单独添加核心 module Transferee, 之后至少还需要添加以下三种图片加载器中的一种
implementation 'com.github.Hitomis.transferee:Transferee:1.6.1'
// 添加 Glide 图片加载器
implementation 'com.github.Hitomis.transferee:GlideImageLoader:1.6.1'
// 添加 Picasso 图片加载器
implementation 'com.github.Hitomis.transferee:PicassoImageLoader:1.6.1'
// 添加 Universal 图片加载器
implementation 'com.github.Hitomis.transferee:UniversalImageLoader:1.6.1'
If used against a single ImageView, it would be very simple:
Transferee transfer = Transferee.getDefault(context);
transfer.apply(TransferConfig.build()
.setImageLoader(UniversalImageLoader.with(getApplicationContext()))
.setSourceUrlList(SourceConfig.getMixingSourceGroup())
.create()
).show());
// 离开页面不要忘记调用
transfer.destroy();
If you need more features, here is a complete usage example of transferee:
step 1: Create only one transferee example for one page (it is recommended to write it in the onCreate method)
transferee = Transferee.getDefault(context);
step 2: Create parameter configurator for transferee
TransferConfig config = TransferConfig.build()
.setSourceImageList(sourceUrlList) // 资源 url 集合, String 格式
.setSourceUriList(sourceUriList) // 资源 uri 集合, Uri 格式
.setMissPlaceHolder(R.mipmap.ic_empty_photo) // 资源加载前的占位图
.setErrorPlaceHolder(R.mipmap.ic_empty_photo) // 资源加载错误后的占位图
.setProgressIndicator(new ProgressPieIndicator()) // 资源加载进度指示器, 可以实现 IProgressIndicator 扩展
.setIndexIndicator(new NumberIndexIndicator()) // 资源数量索引指示器,可以实现 IIndexIndicator 扩展
.setImageLoader(GlideImageLoader.with(getApplicationContext())) // 图片加载器,可以实现 ImageLoader 扩展
.setBackgroundColor(Color.parseColor("#000000")) // 背景色
.setDuration(300) // 开启、关闭、手势拖拽关闭、显示、扩散消失等动画时长
.setOffscreenPageLimit(2) // 第一次初始化或者切换页面时预加载资源的数量,与 justLoadHitImage 属性冲突,默认为 1
.setCustomView(customView) // 自定义视图,将放在 transferee 的面板上
.setNowThumbnailIndex(index) // 缩略图在图组中的索引
.enableJustLoadHitPage(true) // 是否只加载当前显示在屏幕中的的资源,默认关闭
.enableDragClose(true) // 是否开启下拉手势关闭,默认开启
.enableDragHide(false) // 下拉拖拽关闭时,是否先隐藏页面上除主视图以外的其他视图,默认开启
.enableDragPause(false) // 下拉拖拽关闭时,如果当前是视频,是否暂停播放,默认关闭
.enableHideThumb(false) // 是否开启当 transferee 打开时,隐藏缩略图, 默认关闭
.enableScrollingWithPageChange(false) // 是否启动列表随着页面的切换而滚动你的列表,默认关闭
.setOnLongClickListener(new Transferee.OnTransfereeLongClickListener() { // 长按当前页面监听器
@Override
public void onLongClick(ImageView imageView, String imageUri, int pos) {
saveImageFile(imageUri); // 使用 transferee.getFile(imageUri) 获取缓存文件保存,视频不支持
}
})
.bindImageView(imageView, source) // 绑定一个 ImageView, 所有绑定方法只能调用一个
.bindListView(listView, R.id.iv_thumb) // 绑定一个 ListView, 所有绑定方法只能调用一个
.bindRecyclerView(recyclerView, R.id.iv_thumb) // 绑定一个 RecyclerView, 所有绑定方法只能调用一个
step 3: show transferee
transferee.apply(config).show();
step 4: When leaving the page, you need to destroy the resources in the transferee to prevent memory leaks (it is recommended to write it in the onDestroy method)
transferee.destroy()
property | illustrate |
---|---|
sourceUrlList | Collection of resource URLs to be previewed, String format |
sourceUriList | Resource uri collection to be previewed, Uri format |
nowThumbnailIndex | The index of the thumbnail in the picture group. If you bind ListView or RecyclerView, this attribute is required, otherwise it can be ignored; or it can be used to specify the position of the initial display page when opening transferee. |
offscreenPageLimit | The number of resources initially loaded when displaying transferee. The default is 1, which means 3 pictures are loaded for the first time (nowThumbnailIndex, nowThumbnailIndex + 1, nowThumbnailIndex - 1); the value is 2, which means 5 pictures are loaded. And so on |
missPlaceHolder | Default placeholder image, resource id format. The picture displayed by default when the resource is not loaded. |
missDrawable | Default placeholder image, Drawable format. The picture displayed by default when the resource is not loaded. |
errorPlaceHolder | Loading wrong placeholder image, resource id format. The picture displayed when the original picture is loaded incorrectly |
errorDrawable | Loading wrong placeholder image, Drawable format. The picture displayed when the original picture is loaded incorrectly |
backgroundColor | When transferee is displayed, transferee background color |
duration | The duration of animations such as opening, closing, gesture dragging to close, transparency animation display, diffusion disappearance, etc. |
justLoadHitPage | Whether to load only resources in the current page. If set to true, then only when transferee switches to the current page, the loading action of the current page will be triggered. Otherwise, the preloading and loading action of the current page will be done according to the value set by offscreenPageLimit. It is closed by default. |
enableDragClose | Whether to support dragging down to close, enabled by default |
enableDragHide | Whether to hide other views except the main view when dragging and closing. It is enabled by default. |
enableDragPause | Whether to pause video playback on the current page when dragging to close. It is closed by default. |
enableHideThumb | Whether to enable or hide thumbnails when transferee is enabled, enabled by default |
enableScrollingWithPageChange | Whether to start the list to scroll as the page switches, is only valid for binding RecyclerView/GridView/ListView. After startup, because the list will scroll in real time, the thumbnail view will not be empty, thus ensuring that the transferee is closed transitionally when it is closed. Animation, off by default |
progressIndicator | Resource loading progress indicator (ProgressPieIndicator and ProgressBarIndicator are built-in by default). You can implement the IProgressIndicator interface to define your own resource loading progress indicator. |
indexIndicator | Resource index indicator (CircleIndexIndicator and NumberIndexIndicator are built-in by default). You can implement the IIndexIndicator interface to define your own resource index indicator. |
imageLoader | Resource loader. You can implement the ImageLoader interface to define your own image loader. |
imageId | ImageView id in RecyclerView or ListView's ItemView |
customView | User-defined view, placed on the panel displayed by transferee |
listView | If you are using ListView or GridView to arrange and display pictures, you need to pass your ListView or GridView into the bindListView() method |
recyclerView | If you use RecyclerView to arrange and display pictures, you need to pass the RecyclerView into the bindRecyclerView() method |
imageView | If you only want to use the functions of this library for a single ImageView, or if a single ImageView on the interface is the cover of an album, then using bindImageView(...) or its overloaded method can meet your needs. |
method | illustrate |
---|---|
getDefault(context) | Get transferee instance |
apply(config) | Apply the configuration parameter object to the transferee instance |
show() | Open/show transferee |
show(listener) | Open/display transferee and monitor the display/close status |
isShown() | transferee whether to display |
dismiss() | Close transferee |
clear() | Clear all cached files such as pictures and videos |
destroy() | Destroy resources used by transferee to prevent memory leaks |
getImageFile(url) | Get the cached image corresponding to the url |
setOnTransfereeStateChangeListener(listener) | Set transferee to display/close the listener for status changes |
v1.6.1
v1.6.0
v1.5.2
v1.5.1
v1.5.0
v1.3.0
v1.2.0
v1.1.0
v1.0.0
v0.5
Copyright 2017 Vans, Inc.
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.