From fcd97b66df1220ce1fb0ee288fbf8cbdea334255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E4=B9=85?= <1484288157@qq.com> Date: Thu, 20 Aug 2020 10:53:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=89=E7=8E=AF=E5=8A=A9=E6=89=8BV4.2.0-?= =?UTF-8?q?=E8=AE=BA=E5=9D=9B=E8=AF=A6=E6=83=85=E5=8A=9F=E8=83=BD=20https:?= =?UTF-8?q?//gitlab.ghzs.com/pm/halo-app-issues/-/issues/956?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gh/common/util/EntranceUtils.java | 7 +- .../com/gh/gamecenter/GameDetailActivity.java | 8 + .../gh/gamecenter/entity/ForumDetailEntity.kt | 22 + .../java/com/gh/gamecenter/entity/MeEntity.kt | 2 +- .../eventbus/EBForumFollowChange.java | 2 +- .../detail/ForumArticleAskListAdapter.kt | 26 +- .../detail/ForumArticleAskListFragment.kt | 21 +- .../detail/ForumArticleAskListViewModel.kt | 28 +- .../forum/detail/ForumDetailActivity.kt | 3 +- .../forum/detail/ForumDetailFragment.kt | 211 +++++-- .../forum/detail/ForumDetailViewModel.kt | 77 +++ .../forum/follow/ForumMyFollowAdapter.kt | 8 +- .../forum/follow/ForumMyFollowFragment.kt | 17 +- .../home/ForumArticleAskItemViewHolder.kt | 16 +- .../forum/home/ForumArticleListAdapter.kt | 6 +- .../forum/home/ForumFollowAdapter.kt | 2 +- .../forum/home/ForumHomeFragment.kt | 26 +- .../gamecenter/forum/select/ForumAdapter.kt | 14 +- .../forum/select/ForumSelectFragment.kt | 13 +- .../BaseAnswerOrArticleItemViewHolder.kt | 6 +- .../gh/gamecenter/qa/entity/AnswerEntity.kt | 4 +- .../gh/gamecenter/qa/entity/ArticleEntity.kt | 5 +- .../retrofit/service/ApiService.java | 27 + .../main/res/layout/fragment_forum_detail.xml | 554 ++++++++++-------- 24 files changed, 723 insertions(+), 382 deletions(-) create mode 100644 app/src/main/java/com/gh/gamecenter/entity/ForumDetailEntity.kt create mode 100644 app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailViewModel.kt diff --git a/app/src/main/java/com/gh/common/util/EntranceUtils.java b/app/src/main/java/com/gh/common/util/EntranceUtils.java index 42cb89b739..787e874ed1 100644 --- a/app/src/main/java/com/gh/common/util/EntranceUtils.java +++ b/app/src/main/java/com/gh/common/util/EntranceUtils.java @@ -8,9 +8,6 @@ import android.os.Bundle; import android.os.Parcelable; import android.text.TextUtils; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; - import com.gh.common.avoidcallback.AvoidOnResultManager; import com.gh.common.avoidcallback.Callback; import com.gh.gamecenter.BuildConfig; @@ -26,6 +23,9 @@ import org.json.JSONObject; import java.util.Iterator; import java.util.Set; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + /** * @author CsHeng @@ -196,6 +196,7 @@ public class EntranceUtils { public static final String KEY_KAIFU_SELECT_TIME = "kaifuSelectTime"; public static final String KEY_POSTER_PATH = "posterPath"; public static final String KEY_BLACK_THEME = "blackTheme"; + public static final String KEY_BBS_ID = "bbs_id"; public static void jumpActivity(Context context, Bundle bundle) { bundle.putBoolean(KEY_REQUIRE_REDIRECT, true); diff --git a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java index e97b276276..af3396de15 100644 --- a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java @@ -197,6 +197,14 @@ public class GameDetailActivity extends NormalActivity { context.startActivity(getTargetIntent(context, GameDetailActivity.class, GameDetailFragment.class, bundle)); } + public static void startGameDetailByShortcut(Context context, String gameId, int tab, String entrance) { + Bundle bundle = new Bundle(); + bundle.putString(EntranceUtils.KEY_GAMEID, gameId); + bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance); + bundle.putInt(EntranceUtils.KEY_TARGET, tab); + context.startActivity(getTargetIntent(context, GameDetailActivity.class, GameDetailFragment.class, bundle)); + } + /** * 启动游戏详情页面并定位到 介绍tab,并打开视频流 */ diff --git a/app/src/main/java/com/gh/gamecenter/entity/ForumDetailEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/ForumDetailEntity.kt new file mode 100644 index 0000000000..e5f673fb47 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/entity/ForumDetailEntity.kt @@ -0,0 +1,22 @@ +package com.gh.gamecenter.entity + +import com.gh.gamecenter.gamedetail.entity.ZoneEntity +import com.google.gson.annotations.SerializedName + +data class ForumDetailEntity( + @SerializedName("_id") + var id: String = "", + var name: String = "", + @SerializedName("game_id") + var gameId: String = "", + @SerializedName("game_name") + var gameName: String = "", + @SerializedName("game_icon") + var gameIcon: String = "", + var background: String = "", + var moderator: ArrayList = arrayListOf(), + var topLink: ArrayList = arrayListOf(), + @SerializedName("zone_tab") + var zone: ZoneEntity? = null, + var me: MeEntity = MeEntity() +) \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/entity/MeEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/MeEntity.kt index 4891a4a489..29a369cf86 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/MeEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/MeEntity.kt @@ -62,7 +62,7 @@ class MeEntity(@SerializedName("is_community_voted") @SerializedName("is_version_requested") var isVersionRequested: Boolean = false, - @SerializedName("is_follower") + @SerializedName("is_follower",alternate = ["is_follow"]) var isFollower: Boolean = false, // 是否已经关注该用户 @SerializedName("is_favorite") diff --git a/app/src/main/java/com/gh/gamecenter/eventbus/EBForumFollowChange.java b/app/src/main/java/com/gh/gamecenter/eventbus/EBForumFollowChange.java index 20bb58be3c..b61e619f08 100644 --- a/app/src/main/java/com/gh/gamecenter/eventbus/EBForumFollowChange.java +++ b/app/src/main/java/com/gh/gamecenter/eventbus/EBForumFollowChange.java @@ -5,7 +5,7 @@ import com.gh.gamecenter.entity.ForumEntity; public class EBForumFollowChange { ForumEntity forumEntity; - boolean isFollow = false; + boolean isFollow; public EBForumFollowChange(ForumEntity forumEntity, boolean isFollow) { this.forumEntity = forumEntity; diff --git a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListAdapter.kt index 2bcf277308..fc96c43d03 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListAdapter.kt @@ -11,6 +11,7 @@ import com.gh.gamecenter.R import com.gh.gamecenter.adapter.viewholder.FooterViewHolder import com.gh.gamecenter.baselist.ListAdapter import com.gh.gamecenter.databinding.CommunityAnswerItemBinding +import com.gh.gamecenter.entity.CommunityEntity import com.gh.gamecenter.forum.home.ForumArticleAskItemViewHolder import com.gh.gamecenter.manager.UserManager import com.gh.gamecenter.qa.answer.detail.AnswerDetailActivity @@ -19,7 +20,7 @@ import com.gh.gamecenter.qa.entity.AnswerEntity import com.gh.gamecenter.qa.entity.Questions import com.gh.gamecenter.qa.questions.detail.QuestionsDetailActivity -class ForumArticleAskListAdapter(context: Context, val mEntrance: String, val path: String) : ListAdapter(context) { +class ForumArticleAskListAdapter(context: Context, val bbsId: String, val mEntrance: String, val path: String) : ListAdapter(context) { override fun areItemsTheSame(oldItem: AnswerEntity?, newItem: AnswerEntity?): Boolean { return oldItem?.id == newItem?.id @@ -49,30 +50,21 @@ class ForumArticleAskListAdapter(context: Context, val mEntrance: String, val pa when (getItemViewType(position)) { ItemViewType.ITEM_BODY -> { val answer = mEntityList[position] - if ("community_article" == answer.type) { - val questions = Questions() - questions.title = answer.articleTitle - answer.questions = questions - } + val questions = Questions() + questions.title = answer.articleTitle + answer.questions = questions + if (path == "精华") answer.type = "community_article" + if (path == "问答") answer.type = "question" val answerViewHolder = holder as ForumArticleAskItemViewHolder val binding = answerViewHolder.binding binding.forumNameLl.visibility = View.GONE answerViewHolder.bindForumAnswerItem(answer, mEntrance, path) - binding.title.setOnClickListener { - if ("community_article" == answer.type) { - mContext.startActivity(ArticleDetailActivity.getIntent(mContext, UserManager.getInstance().community, answer.id!!, mEntrance, path)) - } else { - val questions = answer.questions - mContext.startActivity(QuestionsDetailActivity.getIntent(mContext, questions.id, "", path)) - } - } - answerViewHolder.itemView.setOnClickListener { if ("community_article" == answer.type) { - mContext.startActivity(ArticleDetailActivity.getIntent(mContext, UserManager.getInstance().community, answer.id!!, mEntrance, path)) + mContext.startActivity(ArticleDetailActivity.getIntent(mContext, CommunityEntity(bbsId), answer.id!!, mEntrance, path)) } else { - mContext.startActivity(AnswerDetailActivity.getIntent(mContext, answer.id, "", path)) + mContext.startActivity(QuestionsDetailActivity.getIntent(mContext, answer.id, mEntrance, path)) } } } diff --git a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListFragment.kt b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListFragment.kt index bc17d3a60a..05972b7e46 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListFragment.kt @@ -6,6 +6,7 @@ import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import com.gh.common.util.EntranceUtils import com.gh.common.util.dip2px +import com.gh.common.util.viewModelProvider import com.gh.common.view.divider.HorizontalDividerItemDecoration import com.gh.gamecenter.R import com.gh.gamecenter.baselist.ListAdapter @@ -13,20 +14,30 @@ import com.gh.gamecenter.baselist.ListFragment import com.gh.gamecenter.eventbus.EBTypeChange import com.gh.gamecenter.qa.CommunityFragment import com.gh.gamecenter.qa.entity.AnswerEntity +import com.halo.assistant.HaloApp import org.greenrobot.eventbus.EventBus class ForumArticleAskListFragment : ListFragment() { private var mAdapter: ForumArticleAskListAdapter? = null + private var mViewModel: ForumArticleAskListViewModel? = null private var mPath = "" + private var bbsId: String = "" override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) + bbsId = arguments?.getString(EntranceUtils.KEY_BBS_ID, "") ?: "" mPath = arguments?.getString(EntranceUtils.KEY_PATH) ?: "" + super.onCreate(savedInstanceState) mListRv.overScrollMode = View.OVER_SCROLL_NEVER mListRv.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white)) } + override fun provideListViewModel(): ForumArticleAskListViewModel { + val factory = ForumArticleAskListViewModel.Factory(bbsId, mPath) + mViewModel = viewModelProvider(factory) + return mViewModel!! + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) mListRv.addOnScrollListener(object : RecyclerView.OnScrollListener() { @@ -41,9 +52,15 @@ class ForumArticleAskListFragment : ListFragment { return mAdapter - ?: ForumArticleAskListAdapter(requireContext(), mEntrance, mPath).apply { mAdapter = this } + ?: ForumArticleAskListAdapter(requireContext(), bbsId, mEntrance, mPath).apply { mAdapter = this } } override fun getItemDecoration(): RecyclerView.ItemDecoration { diff --git a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListViewModel.kt b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListViewModel.kt index 8898738d0f..49a8ab703f 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumArticleAskListViewModel.kt @@ -1,17 +1,41 @@ package com.gh.gamecenter.forum.detail import android.app.Application +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import com.gh.common.util.UrlFilterUtils import com.gh.gamecenter.baselist.ListViewModel +import com.gh.gamecenter.forum.home.ForumArticleListViewModel import com.gh.gamecenter.qa.entity.AnswerEntity import com.gh.gamecenter.retrofit.RetrofitManager +import com.halo.assistant.HaloApp import io.reactivex.Observable -class ForumArticleAskListViewModel(application: Application) : ListViewModel(application) { +class ForumArticleAskListViewModel(application: Application, val bbsId: String = "", val mPath: String = "") : ListViewModel(application) { + + var sort: String = "time.create" + override fun provideDataObservable(page: Int): Observable> { - return RetrofitManager.getInstance(getApplication()).api.getCommunitiesRecommendNewest("5a605c3501edfe00213dd061", page) + return when (mPath) { + "全部" -> { + RetrofitManager.getInstance(getApplication()).api.getAllForumList(bbsId, UrlFilterUtils.getFilterQuery(sort, "-1"), page) + } + "精华" -> { + RetrofitManager.getInstance(getApplication()).api.getEssenceForumList(bbsId, page) + } + else -> { + RetrofitManager.getInstance(getApplication()).api.getAskForumList(bbsId, page) + } + } } override fun mergeResultLiveData() { mResultLiveData.addSource(mListLiveData) { mResultLiveData.postValue(it) } } + + class Factory(private val bbsId: String, val path: String) : ViewModelProvider.NewInstanceFactory() { + override fun create(modelClass: Class): T { + return ForumArticleAskListViewModel(HaloApp.getInstance().application, bbsId, path) as T + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailActivity.kt b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailActivity.kt index e90d92d208..d2a340f8e2 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailActivity.kt @@ -25,8 +25,9 @@ class ForumDetailActivity : BaseActivity() { } companion object { - fun getIntent(context: Context, entrance: String): Intent { + fun getIntent(context: Context, bbsId: String, entrance: String): Intent { val intent = Intent(context, ForumDetailActivity::class.java) + intent.putExtra(EntranceUtils.KEY_BBS_ID, bbsId) intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance) return intent } diff --git a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailFragment.kt b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailFragment.kt index a558d98646..9203c437da 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailFragment.kt @@ -15,7 +15,9 @@ import androidx.appcompat.widget.Toolbar import androidx.core.content.ContextCompat import androidx.core.os.bundleOf import androidx.core.view.ViewCompat +import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import butterknife.OnClick @@ -27,42 +29,53 @@ import com.gh.base.fragment.BaseLazyTabFragment import com.gh.common.dialog.TrackableDialog import com.gh.common.util.* import com.gh.common.view.CustomOrderDrawChildLinearLayout +import com.gh.gamecenter.GameDetailActivity import com.gh.gamecenter.R +import com.gh.gamecenter.databinding.FragmentForumDetailBinding +import com.gh.gamecenter.entity.ForumDetailEntity +import com.gh.gamecenter.entity.ForumEntity import com.gh.gamecenter.entity.LinkEntity +import com.gh.gamecenter.entity.UserEntity +import com.gh.gamecenter.eventbus.EBForumFollowChange import com.gh.gamecenter.eventbus.EBTypeChange +import com.gh.gamecenter.gamedetail.GameDetailFragment +import com.gh.gamecenter.gamedetail.history.HistoryApkListViewModel import com.gh.gamecenter.manager.UserManager +import com.gh.gamecenter.mvvm.Status import com.gh.gamecenter.qa.CommunityFragment import com.gh.gamecenter.qa.article.edit.ArticleEditActivity import com.gh.gamecenter.qa.questions.edit.QuestionEditActivity import com.google.android.material.appbar.AppBarLayout +import com.halo.assistant.HaloApp +import kotlinx.android.synthetic.main.dialog_download.* import kotterknife.bindView +import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.ThreadMode import kotlin.math.abs class ForumDetailFragment : BaseLazyTabFragment() { - private val mToolbar by bindView(R.id.toolbar) - private val mTitleTv by bindView(R.id.titleTv) - private val mFilterContainer by bindView(R.id.filterContainer) - private val mForumFilter by bindView(R.id.forumFilter) - private val mFilterArrow by bindView(R.id.filterArrow) - private val mForumIconSmall by bindView(R.id.forumThumbSmall) - private val mAppBarLayout by bindView(R.id.appbar) - private val mForumTopContentRv by bindView(R.id.forumTopContentRv) - private val mModeratorContainer by bindView(R.id.moderatorContainer) - private val mEditButton by bindView(R.id.community_edit) + private val mReuseLoading by bindView(R.id.reuse_ll_loading) + private val mReuseNoConnection by bindView(R.id.reuse_no_connection) private var mAllForumArticleAskListFragment: ForumArticleAskListFragment? = null private var mEssenceForumArticleAskListFragment: ForumArticleAskListFragment? = null private var mAskForumArticleAskListFragment: ForumArticleAskListFragment? = null + private var bbsId: String = "" + private var mViewModel: ForumDetailViewModel? = null + private var mForumDetail: ForumDetailEntity? = null + private lateinit var mBinding: FragmentForumDetailBinding private var mFilter = "最新发布" override fun initFragmentList(fragments: MutableList) { - mAllForumArticleAskListFragment = ForumArticleAskListFragment().with(bundleOf(EntranceUtils.KEY_ENTRANCE to "论坛详情", EntranceUtils.KEY_PATH to "全部")) as ForumArticleAskListFragment? - mEssenceForumArticleAskListFragment = ForumArticleAskListFragment().with(bundleOf(EntranceUtils.KEY_ENTRANCE to "论坛详情", EntranceUtils.KEY_PATH to "精华")) as ForumArticleAskListFragment? - mAskForumArticleAskListFragment = ForumArticleAskListFragment().with(bundleOf(EntranceUtils.KEY_ENTRANCE to "论坛详情", EntranceUtils.KEY_PATH to "问答")) as ForumArticleAskListFragment? + mAllForumArticleAskListFragment = ForumArticleAskListFragment().with(bundleOf(EntranceUtils.KEY_ENTRANCE to "论坛详情", + EntranceUtils.KEY_PATH to "全部", EntranceUtils.KEY_BBS_ID to bbsId)) as ForumArticleAskListFragment? + mEssenceForumArticleAskListFragment = ForumArticleAskListFragment().with(bundleOf(EntranceUtils.KEY_ENTRANCE to "论坛详情", + EntranceUtils.KEY_PATH to "精华", EntranceUtils.KEY_BBS_ID to bbsId)) as ForumArticleAskListFragment? + mAskForumArticleAskListFragment = ForumArticleAskListFragment().with(bundleOf(EntranceUtils.KEY_ENTRANCE to "论坛详情", + EntranceUtils.KEY_PATH to "问答", EntranceUtils.KEY_BBS_ID to bbsId)) as ForumArticleAskListFragment? fragments.add(mAllForumArticleAskListFragment!!) fragments.add(mEssenceForumArticleAskListFragment!!) fragments.add(mAskForumArticleAskListFragment!!) @@ -74,66 +87,113 @@ class ForumDetailFragment : BaseLazyTabFragment() { tabTitleList.add(TAB_TITLE_ASK) } - override fun getLayoutId(): Int = R.layout.fragment_forum_detail + override fun getInflatedLayout(): View { + mBinding = DataBindingUtil.inflate(layoutInflater, R.layout.fragment_forum_detail, null, false) + return mBinding.root + } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + bbsId = arguments?.getString(EntranceUtils.KEY_BBS_ID, "") ?: "" + val factory = ForumDetailViewModel.Factory(HaloApp.getInstance().application, bbsId) + mViewModel = viewModelProvider(factory) + mViewModel?.forumDetail?.observe(this, Observer { + mReuseLoading.visibility = View.GONE + if (it.status == Status.SUCCESS) { + mBinding.communityEdit.visibility = View.VISIBLE + mBinding.forumContainer.visibility = View.VISIBLE + mReuseNoConnection.visibility = View.GONE + if (it.data != null) { + mForumDetail = it.data + initUI() + } + } else { + mBinding.communityEdit.visibility = View.GONE + mBinding.forumContainer.visibility = View.GONE + mReuseNoConnection.visibility = View.VISIBLE + } + }) + } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - ViewCompat.setOnApplyWindowInsetsListener(mAppBarLayout) { _, insets -> - (mToolbar.layoutParams as ViewGroup.MarginLayoutParams).topMargin = insets.systemWindowInsetTop + ViewCompat.setOnApplyWindowInsetsListener(mBinding.appbar) { _, insets -> + (mBinding.toolbar.layoutParams as ViewGroup.MarginLayoutParams).topMargin = insets.systemWindowInsetTop insets.consumeSystemWindowInsets() } - mToolbar.setNavigationOnClickListener { requireActivity().finish() } + mBinding.toolbar.setNavigationOnClickListener { requireActivity().finish() } - mForumTopContentRv.apply { + mBinding.forumTopContentRv.apply { layoutManager = LinearLayoutManager(requireContext()) } - mAppBarLayout.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset -> + mBinding.appbar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset -> if (!isAdded) return@OnOffsetChangedListener val absVerticalOffset = abs(verticalOffset) val total = appBarLayout.totalScrollRange if (absVerticalOffset > total / 2) { - if (mTitleTv.text.isNullOrEmpty()) { - mTitleTv.text = "剑与远征" - mForumIconSmall.visibility = View.VISIBLE + if (mBinding.titleTv.text.isNullOrEmpty()) { + mBinding.titleTv.text = mForumDetail?.name ?: "" + mBinding.forumThumbSmall.visibility = View.VISIBLE updateToolbarStyle(isToolbarWhite = true) } } else { - if (!mTitleTv.text.isNullOrEmpty()) { - mTitleTv.text = "" - mForumIconSmall.visibility = View.GONE + if (!mBinding.titleTv.text.isNullOrEmpty()) { + mBinding.titleTv.text = "" + mBinding.forumThumbSmall.visibility = View.GONE updateToolbarStyle(isToolbarWhite = false) } } if (absVerticalOffset == total) { - mToolbar.setTitleTextColor(ContextCompat.getColor(requireContext(), R.color.black)) + mBinding.toolbar.setTitleTextColor(ContextCompat.getColor(requireContext(), R.color.black)) } }) - - mForumTopContentRv.apply { - layoutManager = LinearLayoutManager(requireContext()) - adapter = ForumTopLinkAdapter(requireContext(), arrayListOf(LinkEntity(), LinkEntity(), LinkEntity())) + mViewPager.doOnPageSelected { + mBinding.filterContainer.goneIf(it != 0) } - - - initModeratorHeadView(arrayListOf("https://resource.ghzs.com/image/user/icon/5f1be0d898973f0015759a32.jpg", - "https://resource.ghzs.com/image/community/answer/5d9537e18519df764f74a7a1.jpeg", - "https://resource.ghzs.com/image/community/answer/5d95374d477ad375711d2896.jpeg", - "https://resource.ghzs.com/image/community/answer/5d9537a436563c74f87515c6.jpeg")) } - @OnClick(R.id.filterContainer, R.id.community_edit, R.id.moderatorTv) + private fun initUI() { + mForumDetail?.apply { + mBinding.entity = this + initModeratorHeadView(moderator) + if (topLink.isNotEmpty()) { + mBinding.forumTopContentRv.visibility = View.VISIBLE + mBinding.forumTopContentRv.apply { + layoutManager = LinearLayoutManager(requireContext()) + adapter = ForumTopLinkAdapter(requireContext(), topLink) + } + } + if (background.isEmpty()) { + mBinding.toolbar.setNavigationIcon(R.drawable.ic_back_gamedetail) + mBinding.forumBackground.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.white)) + mBinding.forumNameTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.text_333333)) + mBinding.followTv.background = ContextCompat.getDrawable(requireContext(), if (me.isFollower) R.drawable.bg_shape_f5_radius_999 else R.drawable.bg_forum_follow) + mBinding.followTv.setTextColor(ContextCompat.getColor(requireContext(), if (me.isFollower) R.color.text_999999 else R.color.theme_font)) + } else { + mBinding.toolbar.setNavigationIcon(R.drawable.ic_back_gamedetail_white) + ImageUtils.display(mBinding.forumBackground, background) + mBinding.forumNameTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.white)) + mBinding.followTv.setTextColor(ContextCompat.getColor(requireContext(), R.color.white)) + mBinding.followTv.background = ContextCompat.getDrawable(requireContext(), R.drawable.bg_forum_detail_follow) + } + } + } + + @OnClick(R.id.filterContainer, R.id.community_edit, R.id.moderatorTv, R.id.reuse_no_connection, R.id.gameZoneTv, R.id.followTv, R.id.forumThumbBig, R.id.forumThumbSmall) fun onViewClick(view: View) { when (view.id) { R.id.filterContainer -> { showFilterPopupWindow { mFilter = it - mForumFilter.text = mFilter + mBinding.forumFilter.text = mFilter + if (mAllForumArticleAskListFragment != null && mViewPager.currentItem == 0) { + mAllForumArticleAskListFragment?.onRefresh(mFilter) + } } } R.id.community_edit -> { @@ -142,18 +202,65 @@ class ForumDetailFragment : BaseLazyTabFragment() { R.id.moderatorTv -> { requireContext().startActivity(ModeratorListActivity.getIntent(requireContext(), mEntrance, "论坛详情")) } + R.id.reuse_no_connection -> { + mReuseLoading.visibility = View.VISIBLE + mViewModel?.getForumDetail() + } + R.id.gameZoneTv -> { + if (mForumDetail?.zone != null) { + GameDetailActivity.startGameDetailByShortcut(requireContext(), mForumDetail?.gameId + ?: "", GameDetailFragment.INDEX_TRENDES, mEntrance) + } + } + R.id.forumThumbBig, R.id.forumThumbSmall -> { + GameDetailActivity.startGameDetailActivity(requireContext(), mForumDetail?.gameId + ?: "", mEntrance) + } + R.id.followTv -> { + debounceActionWithInterval(R.id.followTv) { + ifLogin(mEntrance) { + val forumEntity = ForumEntity(mForumDetail?.id + ?: "", mForumDetail?.gameId ?: "", mForumDetail?.gameName + ?: "", mForumDetail?.gameIcon ?: "") + + if (mForumDetail?.me?.isFollower == true) { + mViewModel?.unFollowForum { + mForumDetail?.me?.isFollower = false + initUI() + EventBus.getDefault().post(EBForumFollowChange(forumEntity, false)) + } + } else { + mViewModel?.followForum { + mForumDetail?.me?.isFollower = true + ToastUtils.showToast("关注成功") + initUI() + EventBus.getDefault().post(EBForumFollowChange(forumEntity, true)) + } + } + } + } + } } } private fun updateToolbarStyle(isToolbarWhite: Boolean) { - mTitleTv.setTextColor(ContextCompat.getColor(requireContext(), if (isToolbarWhite) R.color.black else R.color.white)) - mToolbar.setBackgroundColor(ContextCompat.getColor(requireContext(), if (isToolbarWhite) R.color.white else R.color.transparent)) + mBinding.titleTv.setTextColor(ContextCompat.getColor(requireContext(), if (isToolbarWhite) R.color.black else R.color.white)) + mBinding.toolbar.setBackgroundColor(ContextCompat.getColor(requireContext(), if (isToolbarWhite) R.color.white else R.color.transparent)) DisplayUtils.setStatusBarColor(requireActivity(), if (isToolbarWhite) R.color.white else R.color.transparent, true) - DisplayUtils.setLightStatusBar(requireActivity(), isToolbarWhite) + if (mForumDetail?.background?.isEmpty() == false) { + if (isToolbarWhite) { + DisplayUtils.setLightStatusBar(requireActivity(), true) + mBinding.toolbar.setNavigationIcon(R.drawable.ic_back_gamedetail) + } else { + DisplayUtils.setLightStatusBar(requireActivity(), false) + mBinding.toolbar.setNavigationIcon(R.drawable.ic_back_gamedetail_white) + } + } } - private fun initModeratorHeadView(datas: List) { - datas.forEachIndexed { index, url -> + private fun initModeratorHeadView(datas: List) { + mBinding.moderatorContainer.removeAllViews() + datas.forEachIndexed { index, user -> val headView = SimpleDraweeView(requireContext()) val roundingParams = RoundingParams().apply { roundAsCircle = true @@ -172,8 +279,8 @@ class ForumDetailFragment : BaseLazyTabFragment() { if (index != 0) { params.leftMargin = (-8f).dip2px() } - ImageUtils.display(headView, url) - mModeratorContainer.addView(headView) + ImageUtils.display(headView, user.icon) + mBinding.moderatorContainer.addView(headView) } } @@ -213,10 +320,10 @@ class ForumDetailFragment : BaseLazyTabFragment() { } } popupWindow.setOnDismissListener { - mFilterArrow.rotation = 0f + mBinding.filterArrow.rotation = 0f } - mFilterArrow.rotation = 180f - popupWindow.showAutoOrientation(mFilterContainer) + mBinding.filterArrow.rotation = 180f + popupWindow.showAutoOrientation(mBinding.filterContainer) } @@ -271,15 +378,15 @@ class ForumDetailFragment : BaseLazyTabFragment() { } private fun setPutQuestionButtonStatus(visibility: Int) { - if (mEditButton.visibility == visibility) return + if (mBinding.communityEdit.visibility == visibility) return if (visibility == View.GONE) { val animation = AnimationUtils.loadAnimation(context, R.anim.button_anim_exit) - mEditButton.startAnimation(animation) + mBinding.communityEdit.startAnimation(animation) } else { val animation = AnimationUtils.loadAnimation(context, R.anim.button_anim_enter) - mEditButton.startAnimation(animation) + mBinding.communityEdit.startAnimation(animation) } - mEditButton.visibility = visibility + mBinding.communityEdit.visibility = visibility } companion object { diff --git a/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailViewModel.kt b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailViewModel.kt new file mode 100644 index 0000000000..97482cfee6 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/forum/detail/ForumDetailViewModel.kt @@ -0,0 +1,77 @@ +package com.gh.gamecenter.forum.detail + +import android.annotation.SuppressLint +import android.app.Application +import androidx.lifecycle.AndroidViewModel +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import com.gh.gamecenter.entity.ForumDetailEntity +import com.gh.gamecenter.mvvm.Resource +import com.gh.gamecenter.retrofit.BiResponse +import com.gh.gamecenter.retrofit.Response +import com.gh.gamecenter.retrofit.RetrofitManager +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.schedulers.Schedulers +import okhttp3.ResponseBody +import retrofit2.HttpException + +class ForumDetailViewModel(application: Application, val bbsId: String) : AndroidViewModel(application) { + + private val mApi = RetrofitManager.getInstance(application).api + var forumDetail = MutableLiveData>() + + init { + getForumDetail() + } + + fun getForumDetail() { + mApi.getForumDetail(bbsId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(object : Response() { + override fun onResponse(response: ForumDetailEntity?) { + super.onResponse(response) + forumDetail.postValue(Resource.success(response)) + } + + override fun onFailure(e: HttpException?) { + super.onFailure(e) + forumDetail.postValue(Resource.error(e)) + } + }) + } + + @SuppressLint("CheckResult") + fun followForum(onSuccess: () -> Unit) { + RetrofitManager.getInstance(getApplication()).api + .followForum(bbsId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(object : BiResponse() { + override fun onSuccess(data: ResponseBody) { + onSuccess.invoke() + } + }) + } + + @SuppressLint("CheckResult") + fun unFollowForum(onSuccess: () -> Unit) { + RetrofitManager.getInstance(getApplication()).api + .unFollowForum(bbsId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(object : BiResponse() { + override fun onSuccess(data: ResponseBody) { + onSuccess.invoke() + } + }) + } + + + class Factory(private val mApplication: Application, private val bbsId: String) : ViewModelProvider.NewInstanceFactory() { + override fun create(modelClass: Class): T { + return ForumDetailViewModel(mApplication, bbsId) as T + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/forum/follow/ForumMyFollowAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/follow/ForumMyFollowAdapter.kt index 1babaf15b0..88b29ad3d1 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/follow/ForumMyFollowAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/follow/ForumMyFollowAdapter.kt @@ -44,7 +44,7 @@ class ForumMyFollowAdapter(context: Context, val mViewModel: ForumMyFollowViewMo } followViewHolder.itemView.setOnClickListener { MtaHelper.onEvent("论坛首页", "我关注的论坛", forumEntity.gameName) - mContext.startActivity(ForumDetailActivity.getIntent(mContext, "我的关注")) + mContext.startActivity(ForumDetailActivity.getIntent(mContext, forumEntity.id, "我的关注")) } } @@ -69,10 +69,10 @@ class ForumMyFollowAdapter(context: Context, val mViewModel: ForumMyFollowViewMo "取消关注" -> { MtaHelper.onEvent("论坛首页", "我关注的论坛", "取消关注") mViewModel.unFollowForum(entity.id) { - val index = entityList.indexOf(entity) +// val index = entityList.indexOf(entity) EventBus.getDefault().post(EBForumFollowChange(entity, false)) - entityList.remove(entity) - notifyItemRangeRemoved(index, 1) +// entityList.remove(entity) +// notifyItemRangeRemoved(index, 1) } } } diff --git a/app/src/main/java/com/gh/gamecenter/forum/follow/ForumMyFollowFragment.kt b/app/src/main/java/com/gh/gamecenter/forum/follow/ForumMyFollowFragment.kt index 1c5416cc2b..1adb37e836 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/follow/ForumMyFollowFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/follow/ForumMyFollowFragment.kt @@ -61,11 +61,16 @@ class ForumMyFollowFragment : NormalFragment() { @Subscribe(threadMode = ThreadMode.MAIN) fun onFollowForumChange(forumFollowChange: EBForumFollowChange) { - AppExecutor.uiExecutor.executeWithDelay(Runnable { - if (mAdapter?.entityList?.isEmpty() == true) { - mListRv.visibility = View.GONE - mNoneData.visibility = View.VISIBLE - } - }, 50) + val entityList = mAdapter?.entityList ?: arrayListOf() + val index = entityList.indexOfFirst { it.id == forumFollowChange.forumEntity.id } + val findEntity = entityList.find { it.id == forumFollowChange.forumEntity.id } + if (!forumFollowChange.isFollow) { + entityList.remove(findEntity) + mAdapter?.notifyItemRangeRemoved(index, 1) + } + if (mAdapter?.entityList?.isEmpty() == true) { + mListRv.visibility = View.GONE + mNoneData.visibility = View.VISIBLE + } } } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleAskItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleAskItemViewHolder.kt index 874393de67..1296f47bea 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleAskItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleAskItemViewHolder.kt @@ -1,6 +1,7 @@ package com.gh.gamecenter.forum.home +import android.view.View import androidx.core.content.ContextCompat import com.gh.base.BaseActivity import com.gh.common.util.* @@ -31,11 +32,13 @@ class ForumArticleAskItemViewHolder(val binding: CommunityAnswerItemBinding) : B binding.entity = entity binding.executePendingBindings() - binding.forumNameTv.text = entity.bbsName - if (entity.type == "answer") { + binding.forumNameTv.text = entity.bbs.name + if (entity.type == "question") { + binding.content.visibility = View.GONE val title = " ${entity.questions.title}" binding.title.text = SpanBuilder(title).image(0, 1, R.drawable.ic_ask_label).build() } else { + binding.content.visibility = View.VISIBLE binding.title.text = entity.questions.title } @@ -66,8 +69,13 @@ class ForumArticleAskItemViewHolder(val binding: CommunityAnswerItemBinding) : B if (entity.type == "community_article") { binNormalView(entity) } else { - commentCount.text = "我来回答" - commentCount.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(itemView.context, R.drawable.community_question_answer_edit), null, null, null) + if (entity.commentCount>0){ + commentCount.text = entity.commentCount.toString() + commentCount.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(itemView.context, R.drawable.community_question_answer_count), null, null, null) + }else { + commentCount.text = "我来回答" + commentCount.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(itemView.context, R.drawable.community_question_answer_edit), null, null, null) + } voteCount.text = "邀请回答" voteIcon.setImageDrawable(ContextCompat.getDrawable(itemView.context, R.drawable.community_invite_follow)) } diff --git a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt index 6bcf8525a5..767de4ff74 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/home/ForumArticleListAdapter.kt @@ -14,6 +14,7 @@ import com.gh.gamecenter.R import com.gh.gamecenter.adapter.viewholder.FooterViewHolder import com.gh.gamecenter.baselist.ListAdapter import com.gh.gamecenter.databinding.CommunityAnswerItemBinding +import com.gh.gamecenter.entity.CommunityEntity import com.gh.gamecenter.forum.detail.ForumDetailActivity import com.gh.gamecenter.manager.UserManager import com.gh.gamecenter.qa.article.detail.ArticleDetailActivity @@ -53,12 +54,11 @@ class ForumArticleListAdapter(context: Context, val mEntrance: String, val path: ItemViewType.ITEM_BODY -> { val viewHolder = holder as ForumArticleAskItemViewHolder val articleEntity = mEntityList[position] - val questions = Questions() - questions.title = articleEntity.title + articleEntity.community = CommunityEntity(articleEntity.bbs.id, articleEntity.bbs.name) viewHolder.bindForumArticleItem(articleEntity, mEntrance, path) viewHolder.itemView.setOnClickListener { MtaHelper.onEvent("论坛首页", viewHolder.getKey(BaseActivity.mergeEntranceAndPath(mEntrance, path)), "${articleEntity.title}(${articleEntity.id})") - mContext.startActivity(ArticleDetailActivity.getIntent(mContext, UserManager.getInstance().community, articleEntity.id, "", path)) + mContext.startActivity(ArticleDetailActivity.getIntent(mContext, articleEntity.community, articleEntity.id, "", path)) } } ItemViewType.ITEM_FOOTER -> { diff --git a/app/src/main/java/com/gh/gamecenter/forum/home/ForumFollowAdapter.kt b/app/src/main/java/com/gh/gamecenter/forum/home/ForumFollowAdapter.kt index 3b033a399a..2f768c2c8d 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/home/ForumFollowAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/home/ForumFollowAdapter.kt @@ -67,7 +67,7 @@ class ForumFollowAdapter(context: Context) : BaseRecyclerAdapter(context) { - private val mDatas: ArrayList = arrayListOf() + val datas: ArrayList = arrayListOf() fun setListData(datas: List) { if (datas.isNotEmpty()) { - mDatas.clear() - mDatas.addAll(datas) + this.datas.clear() + this.datas.addAll(datas) notifyDataSetChanged() } } @@ -36,15 +34,15 @@ class ForumAdapter(context: Context, val mViewModel: ForumSelectViewModel?) : Ba return ForumItemViewHolder(ForumItemBinding.bind(mLayoutInflater.inflate(R.layout.forum_item, parent, false))) } - override fun getItemCount(): Int = mDatas.size + override fun getItemCount(): Int = datas.size override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { if (holder is ForumItemViewHolder) { - val forumEntity = mDatas[position] + val forumEntity = datas[position] holder.binding.entity = forumEntity holder.itemView.setOnClickListener { MtaHelper.onEvent("论坛首页", "选择论坛", forumEntity.gameName) - mContext.startActivity(ForumDetailActivity.getIntent(mContext, "论坛-选择论坛")) + mContext.startActivity(ForumDetailActivity.getIntent(mContext, forumEntity.id, "论坛-选择论坛")) } holder.binding.followTv.setOnClickListener { mContext.ifLogin("论坛-选择论坛") { diff --git a/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectFragment.kt b/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectFragment.kt index 521ec19948..1ad7c6cac5 100644 --- a/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/forum/select/ForumSelectFragment.kt @@ -9,9 +9,12 @@ import androidx.recyclerview.widget.RecyclerView import com.gh.common.util.viewModelProvider import com.gh.gamecenter.R import com.gh.gamecenter.entity.ForumCategoryEntity +import com.gh.gamecenter.eventbus.EBForumFollowChange import com.gh.gamecenter.mvvm.Status import com.gh.gamecenter.normal.NormalFragment import kotterknife.bindView +import org.greenrobot.eventbus.Subscribe +import org.greenrobot.eventbus.ThreadMode class ForumSelectFragment : NormalFragment() { @@ -76,7 +79,7 @@ class ForumSelectFragment : NormalFragment() { } mForumRv.apply { layoutManager = LinearLayoutManager(requireContext()) - mForumAdapter = ForumAdapter(requireContext(),mViewModel) + mForumAdapter = ForumAdapter(requireContext(), mViewModel) adapter = mForumAdapter } @@ -90,4 +93,12 @@ class ForumSelectFragment : NormalFragment() { } } } + + @Subscribe(threadMode = ThreadMode.MAIN) + fun onFollowForumChange(forumFollowChange: EBForumFollowChange) { + val entityList = mForumAdapter?.datas ?: arrayListOf() + val findEntity = entityList.find { it.id == forumFollowChange.forumEntity.id } + findEntity?.isFollow=forumFollowChange.isFollow + mForumAdapter?.notifyDataSetChanged() + } } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt b/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt index 56b0d60fbd..9ed70ea84e 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/answer/BaseAnswerOrArticleItemViewHolder.kt @@ -75,7 +75,7 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH fun getEventId(entrance: String): String { return when (entrance) { "论坛首页+(关注)", "论坛首页+(推荐)" -> "论坛首页" - "论坛详情+(全部)", "论坛详情+(精华)","论坛详情+(问答)" -> "论坛详情" + "论坛详情+(全部)", "论坛详情+(精华)", "论坛详情+(问答)" -> "论坛详情" else -> entrance } } @@ -95,8 +95,8 @@ open class BaseAnswerOrArticleItemViewHolder(itemView: View) : BaseRecyclerViewH binNormalView(entity.transformAnswerEntity()) forumNameTv.setOnClickListener { - MtaHelper.onEvent(getEventId(entrance), getKey(entrance), if (entity.bbsName.isEmpty()) entity.community.name else entity.bbsName) - itemView.context.startActivity(ForumDetailActivity.getIntent(itemView.context, entrance)) + MtaHelper.onEvent(getEventId(entrance), getKey(entrance), if (entity.bbs.name.isEmpty()) entity.community.name else entity.bbs.name) + itemView.context.startActivity(ForumDetailActivity.getIntent(itemView.context, entity.community.id, entrance)) } commentCountContainer.setOnClickListener { diff --git a/app/src/main/java/com/gh/gamecenter/qa/entity/AnswerEntity.kt b/app/src/main/java/com/gh/gamecenter/qa/entity/AnswerEntity.kt index 5d6628ee3a..705597353c 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/entity/AnswerEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/entity/AnswerEntity.kt @@ -10,6 +10,7 @@ import androidx.room.TypeConverters import com.gh.common.annotation.SyncIgnore import com.gh.common.annotation.SyncPage import com.gh.common.syncpage.SyncFieldConstants +import com.gh.gamecenter.entity.CommunityEntity import com.gh.gamecenter.entity.MeEntity import com.gh.gamecenter.entity.UserEntity import com.gh.gamecenter.room.converter.AnswerUserConverter @@ -92,8 +93,7 @@ class AnswerEntity() : Parcelable { var answerId: String = "" @Ignore - @SerializedName("bbs_name") - var bbsName:String="" + var bbs: CommunityEntity = CommunityEntity() fun getPassVideos(): List { val passVideos = arrayListOf() diff --git a/app/src/main/java/com/gh/gamecenter/qa/entity/ArticleEntity.kt b/app/src/main/java/com/gh/gamecenter/qa/entity/ArticleEntity.kt index ac47f32f6f..54417bd6c5 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/entity/ArticleEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/entity/ArticleEntity.kt @@ -39,8 +39,7 @@ data class ArticleEntity( @Ignore var commentable: Boolean = true, @Ignore - @SerializedName("bbs_name") - var bbsName: String = "" + var bbs: CommunityEntity = CommunityEntity() ) : Parcelable { fun getPassVideos(): List { @@ -69,7 +68,7 @@ data class ArticleEntity( answer.me = me answer.commentable = commentable answer.communityName = community.name - answer.bbsName = bbsName + answer.bbs = bbs return answer } } diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java index 72d5fd1675..198ee66f74 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java @@ -15,6 +15,7 @@ import com.gh.gamecenter.entity.ConcernEntity; import com.gh.gamecenter.entity.DeviceDialogEntity; import com.gh.gamecenter.entity.FollowersOrFansEntity; import com.gh.gamecenter.entity.ForumCategoryEntity; +import com.gh.gamecenter.entity.ForumDetailEntity; import com.gh.gamecenter.entity.ForumEntity; import com.gh.gamecenter.entity.FunctionalGroupEntity; import com.gh.gamecenter.entity.GameColumnCollection; @@ -2541,4 +2542,30 @@ public interface ApiService { */ @GET("bbses/recommends/contents") Observable> getForumRecommendsArticle(@Query("sort") String sort); + + /** + * 获取论坛详情 + */ + @GET("bbses/{bbs_id}") + Observable getForumDetail(@Path("bbs_id") String bbsId); + + /** + * 获取论坛全部Tab内容(社区文章+问题) + */ + @GET("bbses/{bbs_id}/contents") + Observable> getAllForumList(@Path("bbs_id") String bbsId, @Query("sort") String sort, @Query("page") int page); + + /** + * 获取论坛精华Tab内容(社区文章) + */ + @GET("bbses/{bbs_id}/jinghua") + Observable> getEssenceForumList(@Path("bbs_id") String bbsId, @Query("page") int page); + + /** + * 获取论坛问答Tab内容(问题) + */ + @GET("bbses/{bbs_id}/questions?view=digest") + Observable> getAskForumList(@Path("bbs_id") String bbsId, @Query("page") int page); + + } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_forum_detail.xml b/app/src/main/res/layout/fragment_forum_detail.xml index f3d6adc2a3..61b4d83b51 100644 --- a/app/src/main/res/layout/fragment_forum_detail.xml +++ b/app/src/main/res/layout/fragment_forum_detail.xml @@ -1,289 +1,331 @@ - + - + + + + + + android:layout_height="match_parent"> - - + android:orientation="vertical" + android:visibility="gone" + tools:visibility="visible"> - + android:gravity="center" + app:layout_behavior="com.gh.common.view.FixAppBarLayoutBehavior"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:fitsSystemWindows="true" + app:contentScrim="@color/white" + app:layout_scrollFlags="scroll|exitUntilCollapsed" + app:scrimAnimationDuration="0" + app:scrimVisibleHeightTrigger="80dp" + app:titleEnabled="false"> + android:layout_height="wrap_content" + android:gravity="center_horizontal" + android:orientation="vertical" + app:layout_collapseMode="pin"> - + - + + + + + + + + + + + + + + + + + + + + + + + + android:layout_marginTop="-8dp" + android:layout_marginBottom="12dp" + android:background="@drawable/background_shape_white_radius_5_top_only" + android:visibility="gone" /> + + - - + - + + - + + + + + + - - - - + android:background="@android:color/white"> - + + + + + android:layout_alignParentRight="true" + android:layout_centerVertical="true" + android:layout_marginTop="8dp" + android:layout_marginRight="18dp" + android:layout_marginBottom="8dp" + android:background="@drawable/bg_shape_f5_radius_999" + android:orientation="horizontal" + android:paddingLeft="12dp" + android:paddingTop="8dp" + android:paddingRight="10dp" + android:paddingBottom="8dp"> - - - - + - + + + + - - - \ No newline at end of file + + + + + + + + + + + \ No newline at end of file