refactor: 移除无用代码
This commit is contained in:
parent
00c52645ef
commit
26733cf6c3
|
|
@ -31,7 +31,7 @@ import com.huanchengfly.tieba.post.adapters.ThreadHeaderAdapter
|
||||||
import com.huanchengfly.tieba.post.adapters.ThreadMainPostAdapter
|
import com.huanchengfly.tieba.post.adapters.ThreadMainPostAdapter
|
||||||
import com.huanchengfly.tieba.post.adapters.ThreadReplyAdapter
|
import com.huanchengfly.tieba.post.adapters.ThreadReplyAdapter
|
||||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||||
import com.huanchengfly.tieba.post.api.interfaces.CommonAPICallback
|
import com.huanchengfly.tieba.post.api.interfaces.CommonCallback
|
||||||
import com.huanchengfly.tieba.post.api.models.AgreeBean
|
import com.huanchengfly.tieba.post.api.models.AgreeBean
|
||||||
import com.huanchengfly.tieba.post.api.models.CommonResponse
|
import com.huanchengfly.tieba.post.api.models.CommonResponse
|
||||||
import com.huanchengfly.tieba.post.api.models.ThreadContentBean
|
import com.huanchengfly.tieba.post.api.models.ThreadContentBean
|
||||||
|
|
@ -616,7 +616,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collect(commonAPICallback: CommonAPICallback<CommonResponse>?, update: Boolean) {
|
private fun collect(commonCallback: CommonCallback<CommonResponse>?, update: Boolean) {
|
||||||
if (dataBean == null || threadId == null) return
|
if (dataBean == null || threadId == null) return
|
||||||
val postListItemBean = firstVisibleItem ?: return
|
val postListItemBean = firstVisibleItem ?: return
|
||||||
TiebaApi.getInstance()
|
TiebaApi.getInstance()
|
||||||
|
|
@ -624,9 +624,9 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
.enqueue(object : Callback<CommonResponse> {
|
.enqueue(object : Callback<CommonResponse> {
|
||||||
override fun onFailure(call: Call<CommonResponse>, t: Throwable) {
|
override fun onFailure(call: Call<CommonResponse>, t: Throwable) {
|
||||||
if (t is TiebaException) {
|
if (t is TiebaException) {
|
||||||
commonAPICallback?.onFailure(t.code, t.message)
|
commonCallback?.onFailure(t.code, t.message)
|
||||||
} else {
|
} else {
|
||||||
commonAPICallback?.onFailure(-1, t.message)
|
commonCallback?.onFailure(-1, t.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -634,7 +634,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
call: Call<CommonResponse>,
|
call: Call<CommonResponse>,
|
||||||
response: Response<CommonResponse>
|
response: Response<CommonResponse>
|
||||||
) {
|
) {
|
||||||
commonAPICallback?.onSuccess(response.body()!!)
|
commonCallback?.onSuccess(response.body()!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
@ -686,7 +686,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
DialogUtil.build(this)
|
DialogUtil.build(this)
|
||||||
.setMessage(R.string.message_update_store_floor)
|
.setMessage(R.string.message_update_store_floor)
|
||||||
.setPositiveButton(R.string.button_yes) { dialog: DialogInterface, _ ->
|
.setPositiveButton(R.string.button_yes) { dialog: DialogInterface, _ ->
|
||||||
collect(object : CommonAPICallback<CommonResponse> {
|
collect(object : CommonCallback<CommonResponse> {
|
||||||
override fun onSuccess(data: CommonResponse) {
|
override fun onSuccess(data: CommonResponse) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this@ThreadActivity,
|
this@ThreadActivity,
|
||||||
|
|
@ -994,7 +994,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
collect(object : CommonAPICallback<CommonResponse> {
|
collect(object : CommonCallback<CommonResponse> {
|
||||||
override fun onSuccess(data: CommonResponse) {
|
override fun onSuccess(data: CommonResponse) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this@ThreadActivity,
|
this@ThreadActivity,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package com.huanchengfly.tieba.post.api.interfaces;
|
|
||||||
|
|
||||||
public interface CommonAPICallback<T> {
|
|
||||||
void onSuccess(T data);
|
|
||||||
|
|
||||||
void onFailure(int code, String error);
|
|
||||||
}
|
|
||||||
|
|
@ -4,10 +4,10 @@ import kotlinx.coroutines.Deferred
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
interface ApiResult<Data> {
|
sealed interface ApiResult<Data> {
|
||||||
class Success<Data>(val data: Data) : ApiResult<Data>
|
data class Success<Data>(val data: Data) : ApiResult<Data>
|
||||||
|
|
||||||
class Failure<Data>(val error: Throwable) : ApiResult<Data>
|
data class Failure<Data>(val error: Throwable) : ApiResult<Data>
|
||||||
}
|
}
|
||||||
|
|
||||||
val ApiResult<*>.isSuccessful: Boolean
|
val ApiResult<*>.isSuccessful: Boolean
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,7 @@ private class KeyEventManager<V : View> : View.OnKeyListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <V : View> V.bindKeyEvent(keyCode: Int, action: (V) -> Unit) {
|
fun <V : View> V.bindKeyEvent(keyCode: Int, action: (V) -> Unit) {
|
||||||
val keyEventManager: KeyEventManager<V>
|
val keyEventManager = getKeyEventManager()
|
||||||
if (onKeyListener !is KeyEventManager<*>) {
|
|
||||||
keyEventManager = KeyEventManager()
|
|
||||||
setOnKeyListener(keyEventManager)
|
|
||||||
} else {
|
|
||||||
keyEventManager = onKeyListener as KeyEventManager<V>
|
|
||||||
}
|
|
||||||
keyEventManager.bindKeyEvent(keyCode, action)
|
keyEventManager.bindKeyEvent(keyCode, action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue