fix: 修复部分闪退问题
This commit is contained in:
parent
41b658ed3d
commit
6a12257fb1
|
|
@ -57,6 +57,7 @@ import retrofit2.Call
|
||||||
import retrofit2.Callback
|
import retrofit2.Callback
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
|
|
||||||
|
//TODO: 重写,去除两次加载
|
||||||
@SuppressLint("NonConstantResourceId")
|
@SuppressLint("NonConstantResourceId")
|
||||||
class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment.OnActionsListener {
|
class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment.OnActionsListener {
|
||||||
@BindView(R.id.toolbar)
|
@BindView(R.id.toolbar)
|
||||||
|
|
@ -206,10 +207,10 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
}
|
}
|
||||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||||
Glide.with(this@ThreadActivity)
|
Glide.with(this@ThreadActivity)
|
||||||
.resumeRequests()
|
.resumeRequests()
|
||||||
} else {
|
} else {
|
||||||
Glide.with(this@ThreadActivity)
|
Glide.with(this@ThreadActivity)
|
||||||
.pauseRequests()
|
.pauseRequests()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -231,7 +232,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
}
|
}
|
||||||
val videoPlayerStandard: VideoPlayerStandard? = view.findViewById(R.id.video_player)
|
val videoPlayerStandard: VideoPlayerStandard? = view.findViewById(R.id.video_player)
|
||||||
if (videoPlayerStandard != null && Jzvd.CURRENT_JZVD != null &&
|
if (videoPlayerStandard != null && Jzvd.CURRENT_JZVD != null &&
|
||||||
videoPlayerStandard.jzDataSource.containsTheUrl(Jzvd.CURRENT_JZVD.jzDataSource.currentUrl)) {
|
videoPlayerStandard.jzDataSource.containsTheUrl(Jzvd.CURRENT_JZVD.jzDataSource.currentUrl)) {
|
||||||
if (Jzvd.CURRENT_JZVD != null && Jzvd.CURRENT_JZVD.screen != Jzvd.SCREEN_FULLSCREEN) {
|
if (Jzvd.CURRENT_JZVD != null && Jzvd.CURRENT_JZVD.screen != Jzvd.SCREEN_FULLSCREEN) {
|
||||||
Jzvd.releaseAllVideos()
|
Jzvd.releaseAllVideos()
|
||||||
}
|
}
|
||||||
|
|
@ -361,8 +362,8 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
threadMainPostAdapter.dataBean = dataBean
|
threadMainPostAdapter.dataBean = dataBean
|
||||||
delegateAdapter.addAdapter(threadMainPostAdapter)
|
delegateAdapter.addAdapter(threadMainPostAdapter)
|
||||||
if (!dataBean?.postList?.filter {
|
if (!dataBean?.postList?.filter {
|
||||||
it.floor != "1"
|
it.floor != "1"
|
||||||
}.isNullOrEmpty()) {
|
}.isNullOrEmpty()) {
|
||||||
threadHeaderAdapter.title = getString(R.string.title_thread_header, dataBean?.thread?.replyNum)
|
threadHeaderAdapter.title = getString(R.string.title_thread_header, dataBean?.thread?.replyNum)
|
||||||
threadHeaderAdapter.seeLz = seeLz
|
threadHeaderAdapter.seeLz = seeLz
|
||||||
delegateAdapter.addAdapter(threadHeaderAdapter)
|
delegateAdapter.addAdapter(threadHeaderAdapter)
|
||||||
|
|
@ -431,21 +432,21 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
tip = true
|
tip = true
|
||||||
if (pid != maxPostId) {
|
if (pid != maxPostId) {
|
||||||
Util.createSnackbar(recyclerView, getString(R.string.tip_collect, postListItemBean.floor), Snackbar.LENGTH_LONG)
|
Util.createSnackbar(recyclerView, getString(R.string.tip_collect, postListItemBean.floor), Snackbar.LENGTH_LONG)
|
||||||
.setAction(R.string.button_load_new) { refreshByPid(maxPostId!!) }
|
.setAction(R.string.button_load_new) { refreshByPid(maxPostId!!) }
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FROM_HISTORY == from && "1" != postListItemBean.floor -> {
|
FROM_HISTORY == from && "1" != postListItemBean.floor -> {
|
||||||
tip = true
|
tip = true
|
||||||
Util.createSnackbar(recyclerView, getString(R.string.tip_from_history, postListItemBean.floor), Snackbar.LENGTH_LONG)
|
Util.createSnackbar(recyclerView, getString(R.string.tip_from_history, postListItemBean.floor), Snackbar.LENGTH_LONG)
|
||||||
.setAction(R.string.button_load_top) {
|
.setAction(R.string.button_load_top) {
|
||||||
if (page <= 1) {
|
if (page <= 1) {
|
||||||
recyclerView.scrollToPosition(0)
|
recyclerView.scrollToPosition(0)
|
||||||
} else {
|
} else {
|
||||||
refreshLayout.autoRefresh()
|
refreshLayout.autoRefresh()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.show()
|
}
|
||||||
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -615,19 +616,27 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
|
|
||||||
private fun updateHistory(async: Boolean = false) {
|
private fun updateHistory(async: Boolean = false) {
|
||||||
if (dataBean != null && dataBean!!.thread != null) {
|
if (dataBean != null && dataBean!!.thread != null) {
|
||||||
val postListItemBean = lastVisibleItem
|
val postListItemBean = try {
|
||||||
|
lastVisibleItem
|
||||||
|
} catch (t: Throwable) {
|
||||||
|
try {
|
||||||
|
firstVisibleItem
|
||||||
|
} catch (t: Throwable) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
var extras = ""
|
var extras = ""
|
||||||
if (postListItemBean != null) {
|
if (postListItemBean != null) {
|
||||||
extras = ThreadHistoryInfoBean()
|
extras = ThreadHistoryInfoBean()
|
||||||
.setPid(postListItemBean.id)
|
.setPid(postListItemBean.id)
|
||||||
.setSeeLz(seeLz)
|
.setSeeLz(seeLz)
|
||||||
.toString()
|
.toString()
|
||||||
}
|
}
|
||||||
val history = History()
|
val history = History()
|
||||||
.setData(threadId)
|
.setData(threadId)
|
||||||
.setExtras(extras)
|
.setExtras(extras)
|
||||||
.setTitle(dataBean!!.thread?.title)
|
.setTitle(dataBean!!.thread?.title)
|
||||||
.setType(HistoryUtil.TYPE_THREAD)
|
.setType(HistoryUtil.TYPE_THREAD)
|
||||||
if (dataBean!!.thread?.author != null) {
|
if (dataBean!!.thread?.author != null) {
|
||||||
history.avatar = dataBean!!.thread?.author?.portrait
|
history.avatar = dataBean!!.thread?.author?.portrait
|
||||||
history.username = dataBean!!.thread?.author?.nameShow
|
history.username = dataBean!!.thread?.author?.nameShow
|
||||||
|
|
@ -644,27 +653,27 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
private fun exit(): Boolean {
|
private fun exit(): Boolean {
|
||||||
if (collect) {
|
if (collect) {
|
||||||
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 : CommonAPICallback<CommonResponse> {
|
||||||
override fun onSuccess(data: CommonResponse) {
|
override fun onSuccess(data: CommonResponse) {
|
||||||
Toast.makeText(this@ThreadActivity, R.string.toast_collect_update_success, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@ThreadActivity, R.string.toast_collect_update_success, Toast.LENGTH_SHORT).show()
|
||||||
dialog.cancel()
|
dialog.cancel()
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(code: Int, error: String) {
|
override fun onFailure(code: Int, error: String) {
|
||||||
Toast.makeText(this@ThreadActivity, getString(R.string.toast_collect_update_error, error), Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@ThreadActivity, getString(R.string.toast_collect_update_error, error), Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}, true)
|
}, true)
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.button_no) { dialog: DialogInterface, _ ->
|
.setNegativeButton(R.string.button_no) { dialog: DialogInterface, _ ->
|
||||||
dialog.cancel()
|
dialog.cancel()
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
.setNeutralButton(R.string.button_cancel, null)
|
.setNeutralButton(R.string.button_cancel, null)
|
||||||
.create()
|
.create()
|
||||||
.show()
|
.show()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
@ -683,20 +692,20 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
when (v.id) {
|
when (v.id) {
|
||||||
R.id.thread_reply_bar -> if (dataBean != null && dataBean!!.thread != null) {
|
R.id.thread_reply_bar -> if (dataBean != null && dataBean!!.thread != null) {
|
||||||
startActivity(Intent(this@ThreadActivity, ReplyActivity::class.java)
|
startActivity(Intent(this@ThreadActivity, ReplyActivity::class.java)
|
||||||
.putExtra("data", ReplyInfoBean(dataBean!!.thread?.id,
|
.putExtra("data", ReplyInfoBean(dataBean!!.thread?.id,
|
||||||
dataBean!!.forum?.id,
|
dataBean!!.forum?.id,
|
||||||
dataBean!!.forum?.name,
|
dataBean!!.forum?.name,
|
||||||
dataBean!!.anti?.tbs,
|
dataBean!!.anti?.tbs,
|
||||||
dataBean!!.user?.nameShow).setPn(dataBean!!.page?.offset).toString()))
|
dataBean!!.user?.nameShow).setPn(dataBean!!.page?.offset).toString()))
|
||||||
}
|
}
|
||||||
R.id.toolbar -> recyclerView.scrollToPosition(0)
|
R.id.toolbar -> recyclerView.scrollToPosition(0)
|
||||||
R.id.thread_bottom_bar_more_btn -> {
|
R.id.thread_bottom_bar_more_btn -> {
|
||||||
MIUIThreadMenuFragment(
|
MIUIThreadMenuFragment(
|
||||||
seeLz,
|
seeLz,
|
||||||
collect,
|
collect,
|
||||||
replyAdapter.isPureRead,
|
replyAdapter.isPureRead,
|
||||||
sort,
|
sort,
|
||||||
canDelete()
|
canDelete()
|
||||||
).apply {
|
).apply {
|
||||||
setOnActionsListener(this@ThreadActivity)
|
setOnActionsListener(this@ThreadActivity)
|
||||||
show(supportFragmentManager, "Menu")
|
show(supportFragmentManager, "Menu")
|
||||||
|
|
@ -822,12 +831,12 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun launch(
|
fun launch(
|
||||||
context: Context,
|
context: Context,
|
||||||
threadId: String,
|
threadId: String,
|
||||||
postId: String? = null,
|
postId: String? = null,
|
||||||
seeLz: Boolean? = null,
|
seeLz: Boolean? = null,
|
||||||
from: String? = null,
|
from: String? = null,
|
||||||
maxPid: String? = null
|
maxPid: String? = null
|
||||||
) {
|
) {
|
||||||
context.goToActivity<ThreadActivity> {
|
context.goToActivity<ThreadActivity> {
|
||||||
putExtra(EXTRA_THREAD_ID, threadId)
|
putExtra(EXTRA_THREAD_ID, threadId)
|
||||||
|
|
@ -926,17 +935,17 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
|
|
||||||
override fun onJumpPage() {
|
override fun onJumpPage() {
|
||||||
val dialog = EditTextDialog(this)
|
val dialog = EditTextDialog(this)
|
||||||
.setInputType(InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_NORMAL)
|
.setInputType(InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_NORMAL)
|
||||||
.setHelperText(String.format(getString(R.string.tip_jump_page), page, totalPage))
|
.setHelperText(String.format(getString(R.string.tip_jump_page), page, totalPage))
|
||||||
.setOnSubmitListener { page: String? ->
|
.setOnSubmitListener { page: String? ->
|
||||||
val pn = Integer.valueOf(page!!)
|
val pn = Integer.valueOf(page!!)
|
||||||
if (pn in 1..totalPage) {
|
if (pn in 1..totalPage) {
|
||||||
this.page = pn
|
this.page = pn
|
||||||
refresh(false)
|
refresh(false)
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this@ThreadActivity, R.string.toast_jump_page_too_big, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this@ThreadActivity, R.string.toast_jump_page_too_big, Toast.LENGTH_SHORT).show()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
dialog.setTitle(R.string.title_jump_page)
|
dialog.setTitle(R.string.title_jump_page)
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
|
||||||
lateinit var mRecyclerView: RecyclerView
|
lateinit var mRecyclerView: RecyclerView
|
||||||
|
|
||||||
@BindView(R.id.refresh)
|
@BindView(R.id.refresh)
|
||||||
lateinit var mRefreshLayout: SmartRefreshLayout
|
var mRefreshLayout: SmartRefreshLayout? = null
|
||||||
|
|
||||||
private val virtualLayoutManager: VirtualLayoutManager by lazy {
|
private val virtualLayoutManager: VirtualLayoutManager by lazy {
|
||||||
VirtualLayoutManager(
|
VirtualLayoutManager(
|
||||||
|
|
@ -62,13 +62,13 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
|
||||||
if (preload) {
|
if (preload) {
|
||||||
PreLoader.listenData<ForumPageBean>(preloadId, DataHolder())
|
PreLoader.listenData<ForumPageBean>(preloadId, DataHolder())
|
||||||
} else if (mDataBean == null) {
|
} else if (mDataBean == null) {
|
||||||
mRefreshLayout.autoRefresh()
|
mRefreshLayout?.autoRefresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFragmentVisibleChange(isVisible: Boolean) {
|
override fun onFragmentVisibleChange(isVisible: Boolean) {
|
||||||
if (isVisible && mDataBean == null) {
|
if (isVisible && mDataBean == null) {
|
||||||
mRefreshLayout.autoRefresh()
|
mRefreshLayout?.autoRefresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,8 +147,8 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
mRefreshLayout.setOnRefreshListener { refresh() }
|
mRefreshLayout?.setOnRefreshListener { refresh() }
|
||||||
mRefreshLayout.setOnLoadMoreListener { loadMore() }
|
mRefreshLayout?.setOnLoadMoreListener { loadMore() }
|
||||||
mRecyclerView.apply {
|
mRecyclerView.apply {
|
||||||
layoutManager = virtualLayoutManager
|
layoutManager = virtualLayoutManager
|
||||||
adapter = delegateAdapter
|
adapter = delegateAdapter
|
||||||
|
|
@ -179,14 +179,14 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
|
||||||
.forumPageAsync(forumName!!, page + 1, sortType, classifyId)
|
.forumPageAsync(forumName!!, page + 1, sortType, classifyId)
|
||||||
.doIfSuccess {
|
.doIfSuccess {
|
||||||
page += 1
|
page += 1
|
||||||
mRefreshLayout.finishLoadMore()
|
mRefreshLayout?.finishLoadMore()
|
||||||
mDataBean = it
|
mDataBean = it
|
||||||
pageSize = it.page?.pageSize?.toInt() ?: 0
|
pageSize = it.page?.pageSize?.toInt() ?: 0
|
||||||
forumAdapter.addData(it)
|
forumAdapter.addData(it)
|
||||||
mRefreshLayout.setNoMoreData(it.page?.hasMore == "0")
|
mRefreshLayout?.setNoMoreData(it.page?.hasMore == "0")
|
||||||
}
|
}
|
||||||
.doIfFailure {
|
.doIfFailure {
|
||||||
mRefreshLayout.finishLoadMore(false)
|
mRefreshLayout?.finishLoadMore(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -208,10 +208,10 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
|
||||||
(attachContext as OnRefreshedListener).onFailure(errorCode, t.message)
|
(attachContext as OnRefreshedListener).onFailure(errorCode, t.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mRefreshLayout.finishRefresh(false)
|
mRefreshLayout?.finishRefresh(false)
|
||||||
if (errorCode == -1) {
|
if (errorCode == -1) {
|
||||||
Util.showNetworkErrorSnackbar(mRecyclerView) {
|
Util.showNetworkErrorSnackbar(mRecyclerView) {
|
||||||
mRefreshLayout.autoRefresh()
|
mRefreshLayout?.autoRefresh()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -232,24 +232,24 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
|
||||||
(attachContext as OnRefreshedListener).onSuccess(forumPageBean)
|
(attachContext as OnRefreshedListener).onSuccess(forumPageBean)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mRefreshLayout.finishRefresh()
|
mRefreshLayout?.finishRefresh()
|
||||||
mDataBean = forumPageBean
|
mDataBean = forumPageBean
|
||||||
pageSize = forumPageBean.page?.pageSize?.toInt()!!
|
pageSize = forumPageBean.page?.pageSize?.toInt()!!
|
||||||
forumAdapter.setData(forumPageBean)
|
forumAdapter.setData(forumPageBean)
|
||||||
mRefreshLayout.setNoMoreData(mDataBean!!.page?.hasMore == "0")
|
mRefreshLayout?.setNoMoreData(mDataBean!!.page?.hasMore == "0")
|
||||||
reloadAdapters()
|
reloadAdapters()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRefresh() {
|
override fun onRefresh() {
|
||||||
mRefreshLayout.autoRefresh()
|
mRefreshLayout?.autoRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSwitch(which: Int) {
|
override fun onSwitch(which: Int) {
|
||||||
if (isGood && mDataBean != null) {
|
if (isGood && mDataBean != null) {
|
||||||
classifyId = mDataBean!!.forum?.goodClassify?.get(which)?.classId!!
|
classifyId = mDataBean!!.forum?.goodClassify?.get(which)?.classId!!
|
||||||
mRefreshLayout.autoRefresh()
|
mRefreshLayout?.autoRefresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,7 +265,7 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
|
||||||
internal inner class DataHolder : DataListener<ForumPageBean?> {
|
internal inner class DataHolder : DataListener<ForumPageBean?> {
|
||||||
override fun onDataArrived(forumPageBean: ForumPageBean?) {
|
override fun onDataArrived(forumPageBean: ForumPageBean?) {
|
||||||
if (forumPageBean == null) {
|
if (forumPageBean == null) {
|
||||||
mRefreshLayout.autoRefresh()
|
mRefreshLayout?.autoRefresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!isGood) {
|
if (!isGood) {
|
||||||
|
|
@ -273,11 +273,11 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
|
||||||
(attachContext as OnRefreshedListener).onSuccess(forumPageBean)
|
(attachContext as OnRefreshedListener).onSuccess(forumPageBean)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mRefreshLayout.finishRefresh()
|
mRefreshLayout?.finishRefresh()
|
||||||
mDataBean = forumPageBean
|
mDataBean = forumPageBean
|
||||||
pageSize = forumPageBean.page?.pageSize?.toInt()!!
|
pageSize = forumPageBean.page?.pageSize?.toInt()!!
|
||||||
forumAdapter.setData(forumPageBean)
|
forumAdapter.setData(forumPageBean)
|
||||||
mRefreshLayout.setNoMoreData(mDataBean!!.page?.hasMore == "0")
|
mRefreshLayout?.setNoMoreData(mDataBean!!.page?.hasMore == "0")
|
||||||
reloadAdapters()
|
reloadAdapters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import com.huanchengfly.tieba.post.models.ThreadHistoryInfoBean
|
||||||
import com.huanchengfly.tieba.post.models.database.History
|
import com.huanchengfly.tieba.post.models.database.History
|
||||||
import com.huanchengfly.tieba.post.utils.DateTimeUtils
|
import com.huanchengfly.tieba.post.utils.DateTimeUtils
|
||||||
import com.huanchengfly.tieba.post.utils.HistoryUtil
|
import com.huanchengfly.tieba.post.utils.HistoryUtil
|
||||||
import kotlin.properties.Delegates
|
|
||||||
|
|
||||||
class HistoryFragment : BaseFragment(), OnItemClickListener<History>, Refreshable {
|
class HistoryFragment : BaseFragment(), OnItemClickListener<History>, Refreshable {
|
||||||
@BindView(R.id.recycler_view)
|
@BindView(R.id.recycler_view)
|
||||||
|
|
@ -31,7 +30,7 @@ class HistoryFragment : BaseFragment(), OnItemClickListener<History>, Refreshabl
|
||||||
private val todayHistoryAdapter: HistoryAdapter by lazy { HistoryAdapter(attachContext) }
|
private val todayHistoryAdapter: HistoryAdapter by lazy { HistoryAdapter(attachContext) }
|
||||||
private val beforeHistoryAdapter: HistoryAdapter by lazy { HistoryAdapter(attachContext) }
|
private val beforeHistoryAdapter: HistoryAdapter by lazy { HistoryAdapter(attachContext) }
|
||||||
|
|
||||||
private var type by Delegates.notNull<Int>()
|
private var type = 0
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val PARAM_TYPE = "type"
|
const val PARAM_TYPE = "type"
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ class SearchForumFragment : BaseFragment(), ISearchFragment, OnItemClickListener
|
||||||
@BindView(R.id.fragment_search_recycler_view)
|
@BindView(R.id.fragment_search_recycler_view)
|
||||||
lateinit var recyclerView: RecyclerView
|
lateinit var recyclerView: RecyclerView
|
||||||
|
|
||||||
|
private var loaded: Boolean = false
|
||||||
private var keyword: String? = null
|
private var keyword: String? = null
|
||||||
private val layoutManager: VirtualLayoutManager by lazy { VirtualLayoutManager(attachContext) }
|
private val layoutManager: VirtualLayoutManager by lazy { VirtualLayoutManager(attachContext) }
|
||||||
private val delegateAdapter: DelegateAdapter by lazy { DelegateAdapter(layoutManager) }
|
private val delegateAdapter: DelegateAdapter by lazy { DelegateAdapter(layoutManager) }
|
||||||
|
|
@ -55,7 +56,7 @@ class SearchForumFragment : BaseFragment(), ISearchFragment, OnItemClickListener
|
||||||
refreshLayout?.autoRefresh()
|
refreshLayout?.autoRefresh()
|
||||||
} else {
|
} else {
|
||||||
mData = null
|
mData = null
|
||||||
delegateAdapter.clear()
|
if (loaded) delegateAdapter.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,6 +106,7 @@ class SearchForumFragment : BaseFragment(), ISearchFragment, OnItemClickListener
|
||||||
private fun reloadAdapters() {
|
private fun reloadAdapters() {
|
||||||
delegateAdapter.clear()
|
delegateAdapter.clear()
|
||||||
if (mData != null) {
|
if (mData != null) {
|
||||||
|
loaded = true
|
||||||
if (mData!!.exactMatch != null) {
|
if (mData!!.exactMatch != null) {
|
||||||
exactMatchAdapter.setData(listOf(mData!!.exactMatch!!))
|
exactMatchAdapter.setData(listOf(mData!!.exactMatch!!))
|
||||||
delegateAdapter.addAdapter(HeaderDelegateAdapter(
|
delegateAdapter.addAdapter(HeaderDelegateAdapter(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue