Skip to content

Commit

Permalink
fix: 优化跟踪项预览加载
Browse files Browse the repository at this point in the history
  • Loading branch information
xz-dev committed Sep 22, 2020
1 parent 56e670d commit 3db126a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 26 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
minSdkVersion 21
targetSdkVersion 30
versionCode 49
versionName "0.1.4.9"
versionName "0.1.4.10"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
kapt {
arguments {
Expand Down Expand Up @@ -94,9 +94,9 @@ dependencies {
implementation 'com.akexorcist:localization:1.2.6'

// OkHttp
implementation 'com.squareup.okhttp3:okhttp:4.8.1'
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'com.squareup.okio:okio:2.8.0'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.8.1'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.9.0'

// Firebase
implementation 'com.google.firebase:firebase-core:17.5.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ open class AppItemAdapter(internal val mItemCardViewList: MutableList<ItemCardVi
holder.appPlaceholderImageView.visibility = View.GONE
holder.nameTextView.text = itemCardView.name
holder.typeTextView.text = itemCardView.type
holder.hubNameTextView.text = itemCardView.hubName.let { if (it.isNullOrEmpty()) { "Unknown" } else { it } }
val appIconImageView = holder.appIconImageView
when (this) {
is App ->
Expand All @@ -45,7 +44,6 @@ open class AppItemAdapter(internal val mItemCardViewList: MutableList<ItemCardVi
val hubIconUrl = HubDatabaseManager.getDatabase(this.appDatabase.hubUuid)
?.hubConfig?.info?.hubIconUrl
IconPalette.loadApplicationsIconView(appIconImageView, hubIconUrl)
holder.hubNameTextView.visibility = View.GONE
}
}
setAppStatusUI(holder, this)
Expand All @@ -63,17 +61,14 @@ open class AppItemAdapter(internal val mItemCardViewList: MutableList<ItemCardVi
fun setItemList(newList: MutableList<ItemCardView>) {
val operationSteps = list1ToList2(mItemCardViewList, newList)
for (operationStep in operationSteps) {
when (operationStep.operation) {
add -> {
operationStep as ListAddOperationStep<*>
onAddItem(operationStep.index, operationStep.element as ItemCardView)
}
del -> {
operationStep as ListDelOperationStep
when (operationStep) {
is ListDelOperationStep -> {
onItemDismiss(operationStep.index)
}
swap -> {
operationStep as ListSwapOperationStep
is ListAddOperationStep<*> -> {
onAddItem(operationStep.index, operationStep.element as ItemCardView)
}
is ListSwapOperationStep -> {
onItemMove(operationStep.rowIndex, operationStep.newIndex)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@ import net.xzos.upgradeall.utils.file.FileUtil
import net.xzos.upgradeall.utils.getByHolder


class AppListItemAdapter(private val appListPageViewModel: AppListPageViewModel
class AppListItemAdapter(
private val appListPageViewModel: AppListPageViewModel
) : AppItemAdapter(appListPageViewModel.appCardViewList.value ?: mutableListOf(),
appListPageViewModel.needUpdateAppsLiveData) {
override fun onBindViewHolder(holder: CardViewRecyclerViewHolder, position: Int) {
val itemCardView = mItemCardViewList[position]
itemCardView.extraData.app?.run {
holder.hubNameTextView.text = itemCardView.hubName.let {
if (it.isNullOrEmpty()) {
"Unknown"
} else {
it
}
}
}
super.onBindViewHolder(holder, position)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CardViewRecyclerViewHolder {
val holder = super.onCreateViewHolder(parent, viewType)
Expand Down
12 changes: 4 additions & 8 deletions app/src/main/java/net/xzos/upgradeall/utils/ListUtils.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package net.xzos.upgradeall.utils

const val add = "ADD"
const val del = "DEL"
const val swap = "SWAP"

open class ListOperationStepBase internal constructor(val operation: String)
open class ListOperationStepBase

class ListAddOperationStep<E> internal constructor(val index: Int, val element: E)
: ListOperationStepBase(add)
: ListOperationStepBase()

class ListDelOperationStep internal constructor(val index: Int)
: ListOperationStepBase(del)
: ListOperationStepBase()

class ListSwapOperationStep internal constructor(val rowIndex: Int, val newIndex: Int)
: ListOperationStepBase(swap)
: ListOperationStepBase()

fun <E> list1ToList2(list1: List<E>, list2: List<E>): List<ListOperationStepBase> {
if (list1 == list2) return emptyList()
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.4.0'
ext.kotlin_version = '1.4.10'
ext.protobuf_version = '0.8.12'
ext.protoc_version = '3.13.0'
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ class GrpcApi {
val hubUuid = hubData.hubUuid
val auth = hubData.auth
val appIdList = hubData.getAppIdList()
for (appIdL in appIdList.chunked(50))
callGetAppRelease(hubUuid, auth, appIdL.toHashSet())
for (appIdL in appIdList.chunked(15))
GlobalScope.launch {
callGetAppRelease(hubUuid, auth, appIdL.toHashSet())
}
}

private suspend fun callGetAppRelease(
Expand Down

0 comments on commit 3db126a

Please sign in to comment.