Skip to content

Commit

Permalink
2.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
iielse committed Nov 25, 2021
1 parent 0377bc0 commit 8f97154
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 391 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies {
implementation 'com.google.android.exoplayer:exoplayer:2.16.1'

implementation project(':imageviewer')
// implementation 'com.github.iielse:imageviewer:2.1.8'
// implementation 'com.github.iielse:imageviewer:2.1.9'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ object ViewerHelper {
// viewer 构造的基本元素
val builder = ImageViewerBuilder(
context = context,
initKey = clickedData.id,
dataProvider = myDataProvider(clickedData),
imageLoader = MyImageLoader(),
transformer = MyTransformer()
initKey = clickedData.id, // 被点击的图片id
dataProvider = myDataProvider(clickedData), // 数据提供者. 和调用者业务强绑定
imageLoader = MyImageLoader(), // 自定义实现
transformer = MyTransformer() // 固定写法. 实现 ViewerTransitionHelper 确定 进场退场动画
)

MyViewerCustomizer().process(context, builder) // 添加自定义业务逻辑和UI处理

if (fullScreen) {
if (fullScreen) { //
builder.setViewerFactory(object : ImageViewerDialogFragment.Factory() {
override fun build() = FullScreenImageViewerDialogFragment()
})
}) // 对弹窗增加自定义内容
}
return builder
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import java.lang.IllegalStateException
import kotlin.math.max
import kotlin.math.min

// 模拟服务器
// 模拟数据源仓库 操作管理
class Api(
private val data: MutableList<MyData>
private val data: MutableList<MyData> // 源数据
) {
// 模拟网络请求或者本地db查询 上一页
fun asyncQueryBefore(id: Long, pageSize: Int, callback: (List<MyData>) -> Unit) {
Expand All @@ -37,9 +37,10 @@ class Api(
}, 100)
}

// 模拟删除
fun asyncDelete(item: List<MyData>, callback: ()->Unit) {
require( isMainThread())
data.removeAll(item) // 模拟服务器把数据删掉了
data.removeAll(item) // 模拟把数据删掉了
Handler(Looper.getMainLooper()).postDelayed({
callback()
}, 200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class TestRepository {
requestMore = { request(false) }
)

// 分页加载
fun request(initial: Boolean) {
val requestKey = if (initial) -1 else state.nextKey?.toLong()
api.asyncQueryAfter(requestKey, PAGE_SIZE) {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ ext {
buildToolsVersion= "30.0.3"
minSdkVersion = 21
targetSdkVersion = 31
versionCode = 218
versionName = "2.1.8"
versionCode = 219
versionName = "2.1.9"
}
Loading

0 comments on commit 8f97154

Please sign in to comment.