fix: 修复一些闪退
This commit is contained in:
parent
20807bb061
commit
96cb8acfef
|
|
@ -174,7 +174,7 @@ public class RecyclerFloorAdapter extends BaseSingleTypeAdapter<SubFloorListBean
|
|||
})
|
||||
.setInitMenuCallback(menu -> {
|
||||
PluginManager.INSTANCE.initPluginMenu(menu, PluginManager.MENU_SUB_POST_ITEM);
|
||||
if (TextUtils.equals(AccountUtil.getLoginInfo().getUid(), postInfo.getAuthor().getId())) {
|
||||
if (AccountUtil.isLoggedIn() && TextUtils.equals(AccountUtil.getLoginInfo().getUid(), postInfo.getAuthor().getId())) {
|
||||
menu.findItem(R.id.menu_delete).setVisible(true);
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -30,14 +30,23 @@ abstract class BaseMultiTypeDelegateAdapter<Item> @JvmOverloads constructor(
|
|||
|
||||
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
|
||||
holder.setItemOnClickListener {
|
||||
onItemClickListener?.onClick(holder, getItem(position), position)
|
||||
if (position in 0 until itemCount) onItemClickListener?.onClick(
|
||||
holder,
|
||||
getItem(position),
|
||||
position
|
||||
)
|
||||
}
|
||||
holder.setItemOnLongClickListener {
|
||||
onItemLongClickListener?.onLongClick(holder, getItem(position), position) ?: false
|
||||
if (position !in 0 until itemCount) false
|
||||
else onItemLongClickListener?.onLongClick(holder, getItem(position), position) ?: false
|
||||
}
|
||||
onItemChildClickListeners.forEach {
|
||||
holder.setOnClickListener(it.key) { _ ->
|
||||
it.value?.onItemChildClick(holder, getItem(position), position)
|
||||
if (position in 0 until itemCount) it.value?.onItemChildClick(
|
||||
holder,
|
||||
getItem(position),
|
||||
position
|
||||
)
|
||||
}
|
||||
}
|
||||
convert(holder, getItem(position), position, getItemViewType(position))
|
||||
|
|
|
|||
|
|
@ -6,13 +6,44 @@ import androidx.compose.runtime.Stable
|
|||
@Stable
|
||||
class StableHolder<T>(val item: T) {
|
||||
operator fun component1(): T = item
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as StableHolder<*>
|
||||
|
||||
if (item != other.item) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return item?.hashCode() ?: 0
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
class ImmutableHolder<T>(val item: T) {
|
||||
operator fun component1(): T = item
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as ImmutableHolder<*>
|
||||
|
||||
if (item != other.item) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return item?.hashCode() ?: 0
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> wrapStable(item: T): StableHolder<T> = StableHolder(item)
|
||||
|
||||
fun <T> wrapImmutable(item: T): ImmutableHolder<T> = ImmutableHolder(item)
|
||||
fun <T> wrapImmutable(item: T): ImmutableHolder<T> = ImmutableHolder(item)
|
||||
|
||||
fun <T> List<T>.wrapImmutable(): List<ImmutableHolder<T>> = map { wrapImmutable(it) }
|
||||
|
|
@ -22,6 +22,7 @@ import com.huanchengfly.tieba.post.activities.ThreadActivity
|
|||
import com.huanchengfly.tieba.post.adapters.RecyclerFloorAdapter
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.SubFloorListBean
|
||||
import com.huanchengfly.tieba.post.api.retrofit.exception.getErrorMessage
|
||||
import com.huanchengfly.tieba.post.components.MyLinearLayoutManager
|
||||
import com.huanchengfly.tieba.post.components.dividers.ThreadDivider
|
||||
import com.huanchengfly.tieba.post.components.transformations.RadiusTransformation
|
||||
|
|
@ -184,7 +185,7 @@ class FloorFragment : BaseBottomSheetDialogFragment() {
|
|||
.floor(tid, pn, pid, spid)
|
||||
.enqueue(object : Callback<SubFloorListBean> {
|
||||
override fun onFailure(call: Call<SubFloorListBean>, t: Throwable) {
|
||||
Toast.makeText(attachContext, t.message, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(attachContext, t.getErrorMessage(), Toast.LENGTH_SHORT).show()
|
||||
refreshLayout.finishRefresh(false)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ import kotlin.properties.ReadWriteProperty
|
|||
import kotlin.reflect.KProperty
|
||||
|
||||
|
||||
open class AppPreferencesUtils(context: Context) {
|
||||
private val preferencesDataStore: DataStore<Preferences> = context.dataStore
|
||||
open class AppPreferencesUtils(private val context: Context) {
|
||||
private val preferencesDataStore: DataStore<Preferences>
|
||||
get() = context.dataStore
|
||||
private val coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||
|
||||
var userLikeLastRequestUnix by DataStoreDelegates.long(defaultValue = 0L)
|
||||
|
|
|
|||
Loading…
Reference in New Issue