//package com.gh.gamecenter.qa.article
//
//import android.content.Intent
//import android.os.Bundle
//import android.view.View
//import androidx.recyclerview.widget.RecyclerView
//import com.gh.gamecenter.common.constant.Constants
//import com.gh.common.util.EntranceUtils
//import com.gh.gamecenter.common.utils.viewModelProvider
//import com.gh.gamecenter.common.view.VerticalItemDecoration
//import com.gh.gamecenter.common.baselist.ListFragment
//import com.gh.gamecenter.common.baselist.LoadStatus
//import com.gh.gamecenter.common.baselist.LoadType
//import com.gh.gamecenter.common.eventbus.EBReuse
//import com.gh.gamecenter.eventbus.EBTypeChange
//import com.gh.gamecenter.forum.home.CommunityHomeFragment
//import com.gh.gamecenter.login.user.UserManager
//import com.gh.gamecenter.qa.CommunityFragment
//import com.gh.gamecenter.qa.article.edit.ArticleEditActivity
//import com.gh.gamecenter.qa.entity.ArticleEntity
//import org.greenrobot.eventbus.EventBus
//import org.greenrobot.eventbus.Subscribe
//import org.greenrobot.eventbus.ThreadMode
//
//class SimpleArticleListFragment : ListFragment<ArticleEntity, SimpleArticleListViewModel>() {
//
//    private var mAdapter: SimpleArticleListAdapter? = null
//    private lateinit var mViewModel: SimpleArticleListViewModel
//
//    private var mCommunityId: String? = null
//
//    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
//        super.onActivityResult(requestCode, resultCode, data)
//        if (CommunityManager.getInstance().community.id != mCommunityId) {
//            mCommunityId = CommunityManager.getInstance().community.id
//            onRefresh()
//        }
//    }
//
//    override fun onCreate(savedInstanceState: Bundle?) {
//        mCommunityId = CommunityManager.getInstance().community.id
//        mViewModel = provideListViewModel()
//        mViewModel.sortType = arguments?.getString(EntranceUtils.KEY_TYPE) ?: ""
//
//        super.onCreate(savedInstanceState)
//    }
//
//    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
//        super.onViewCreated(view, savedInstanceState)
//        setNavigationTitle("社区文章")
//
//        mListRv.addOnScrollListener(object : RecyclerView.OnScrollListener() {
//            override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
//                if (dy > Constants.FOLLOW_HINT_TRIGGER_HEIGHT) {
//                    EventBus.getDefault().post(EBTypeChange(CommunityHomeFragment.EB_HIDE_QUESTION_BUTTON, CommunityFragment.INDEX_ALL))
//                } else if (dy < -Constants.FOLLOW_HINT_TRIGGER_HEIGHT) {
//                    EventBus.getDefault().post(EBTypeChange(CommunityHomeFragment.EB_SHOW_QUESTION_BUTTON, CommunityFragment.INDEX_ALL))
//                }
//            }
//        })
//    }
//
//    override fun getItemDecoration(): RecyclerView.ItemDecoration {
//        return VerticalItemDecoration(requireContext(), 8F, true)
//    }
//
//    override fun provideListViewModel(): SimpleArticleListViewModel {
//        return viewModelProvider()
//    }
//
//    override fun provideListAdapter(): SimpleArticleListAdapter {
//        return mAdapter ?: SimpleArticleListAdapter(requireContext()).apply { mAdapter = this }
//    }
//
//    fun scrollToTop(smooth: Boolean) {
//        mListRv.stopScroll()
//        if (smooth) {
//            mLayoutManager.smoothScrollToPosition(mListRv, null, 0)
//        } else {
//            mLayoutManager.scrollToPosition(0)
//        }
//    }
//
//    @Subscribe(threadMode = ThreadMode.MAIN)
//    fun onEventMainThread(reuse: EBReuse) {
//        if (ArticleEditActivity.ARTICLE_POSTED_TAG == reuse.type) {
//            mAdapter?.loadChange(LoadStatus.INIT)
//            mBaseHandler.postDelayed({ mListViewModel.load(LoadType.REFRESH) }, 100)
//        }
//    }
//
//    override fun provideSyncAdapter(): RecyclerView.Adapter<*>? {
//        return mAdapter
//    }
//
//    override fun addSyncPageObserver(): Boolean {
//        return true
//    }
//}