Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev

This commit is contained in:
kehaoyuan
2019-05-17 16:36:53 +08:00
6 changed files with 53 additions and 17 deletions

View File

@ -13,9 +13,12 @@ import com.gh.gamecenter.R
import com.gh.gamecenter.baselist.ListAdapter
import com.gh.gamecenter.databinding.ItemCategoryBinding
import com.gh.gamecenter.entity.CategoryEntity
import net.cachapa.expandablelayout.ExpandableLayout
class CategoryDirectoryAdapter(context: Context, var categoryTitle: String) : ListAdapter<CategoryEntity>(context) {
class CategoryDirectoryAdapter(context: Context, var categoryTitle: String)
: ListAdapter<CategoryEntity>(context) {
var recyclerView: RecyclerView? = null
var expandStatusMap: HashMap<Int, Boolean> = HashMap()
private var sixteenDp: Int = 0
@ -39,13 +42,19 @@ class CategoryDirectoryAdapter(context: Context, var categoryTitle: String) : Li
expandableStatusMap = expandStatusMap,
isExpended = expandStatusMap[position] != null && expandStatusMap[position] == true,
marginTop = sixteenDp,
categoryTitle = categoryTitle)
categoryTitle = categoryTitle,
expandedAction = { recyclerView?.smoothScrollToPosition(position) })
}
}
}
internal class CategoryViewHolder(var binding: ItemCategoryBinding) : RecyclerView.ViewHolder(binding.root) {
fun bindCategory(category: CategoryEntity, expandableStatusMap: HashMap<Int, Boolean>, isExpended: Boolean, marginTop: Int, categoryTitle: String) {
fun bindCategory(category: CategoryEntity,
expandableStatusMap: HashMap<Int, Boolean>,
isExpended: Boolean,
marginTop: Int,
categoryTitle: String,
expandedAction: () -> Unit) {
category.data?.let {
var subCategoryView: SubCategoryView? = null
@ -91,20 +100,21 @@ class CategoryDirectoryAdapter(context: Context, var categoryTitle: String) : Li
binding.containerExpandable.setExpanded(isExpended, false)
binding.containerExpandable.setOnExpansionUpdateListener { _, state ->
when (state) {
0 -> {
ExpandableLayout.State.COLLAPSED -> {
binding.ivToggle.setImageResource(R.drawable.ic_category_arrow_down)
expandableStatusMap[adapterPosition] = false
}
3 -> {
ExpandableLayout.State.EXPANDED -> {
binding.ivToggle.setImageResource(R.drawable.ic_category_arrow_up)
expandableStatusMap[adapterPosition] = true
expandedAction.invoke()
}
}
}
extraCategoryList.forEachIndexed { index, c ->
when (index % 3) {
0 -> {
ExpandableLayout.State.COLLAPSED -> {
subCategoryView = SubCategoryView(binding.root.context)
val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)
@ -117,8 +127,8 @@ class CategoryDirectoryAdapter(context: Context, var categoryTitle: String) : Li
subCategoryViewLinearLayout.addView(subCategoryView)
subCategoryView?.setLeftCategory(c)
}
1 -> subCategoryView?.setCenterCategory(c)
2 -> subCategoryView?.setRightCategory(c)
ExpandableLayout.State.COLLAPSING -> subCategoryView?.setCenterCategory(c)
ExpandableLayout.State.EXPANDED -> subCategoryView?.setRightCategory(c)
}
}
} else {

View File

@ -39,6 +39,7 @@ class CategoryDirectoryFragment : ListFragment<CategoryEntity, CategoryDirectory
super.onViewCreated(view, savedInstanceState)
setNavigationTitle(arguments?.getString(EntranceUtils.KEY_CATEGORY_TITLE))
mListRv.setBackgroundColor(Color.WHITE)
mAdapter.recyclerView = mListRv
mListRefresh?.isEnabled = false
mSkeleton = Skeleton.bind(mListSkeleton).shimmer(false).load(R.layout.fragment_category_skeleton).show()
}

View File

@ -14,7 +14,10 @@ data class GameEntity(
@SerializedName("_id")
var id: String = "",
var icon: String? = null,
var name: String? = null,
@SerializedName("name")
private var mName: String? = null, // 将 name 变成私有 mName 调用 name 时直接拼接成 mName + nameSuffix
@SerializedName("name_suffix")
var nameSuffix: String = "",
var brief: String? = null,
private var tag: ArrayList<String>? = null,
@ -110,13 +113,20 @@ data class GameEntity(
@IgnoredOnParcel
var gameLocation: GameLocation? = null
@IgnoredOnParcel
var name: String?
get() = mName + nameSuffix
set(value) {
mName = value
}
constructor(id: String) : this() {
this.id = id
}
constructor(id: String, name: String?) : this() {
this.id = id
this.name = name
this.mName = name
}
fun getTag(): ArrayList<String> {
@ -172,7 +182,7 @@ data class GameEntity(
val gameEntity = GameEntity()
gameEntity.id = id
gameEntity.icon = icon
gameEntity.name = name
gameEntity.mName = name
gameEntity.brief = brief
if (tag != null) {
gameEntity.tag = ArrayList(tag!!)

View File

@ -9,13 +9,16 @@ import android.support.v7.widget.RecyclerView
import android.view.View
import butterknife.BindView
import cn.jzvd.Jzvd
import cn.jzvd.JzvdMgr
import com.gh.base.fragment.BaseFragment
import com.gh.common.util.DownloadItemUtils
import com.gh.common.util.NetworkUtils
import com.gh.download.DownloadManager
import com.gh.gamecenter.R
import com.gh.gamecenter.entity.GameDetailEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.eventbus.EBDownloadStatus
import com.gh.gamecenter.eventbus.EBNetworkState
import com.gh.gamecenter.eventbus.EBPackage
import com.gh.gamecenter.eventbus.EBReuse
import com.gh.gamecenter.gamedetail.GameDetailFragment.OPEN_APPBAR
@ -121,6 +124,16 @@ class DescFragment : BaseFragment<Any>() {
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(networkState: EBNetworkState) {
val player = JzvdMgr.getCurrentJzvd()
if (!NetworkUtils.isNetworkConnected(requireContext())
&& player != null
&& player.currentState == Jzvd.CURRENT_STATE_PLAYING) {
toast("当前使用移动数据网络")
}
}
// 下载被删除事件
@Subscribe(threadMode = ThreadMode.MAIN)
fun onEventMainThread(status: EBDownloadStatus) {

View File

@ -44,9 +44,9 @@ class AnswerDetailContainerFragment : NormalFragment() {
mFragmentAdapter = AnswerDetailFragmentStatePagerAdapter(fragmentManager!!) {
AnswerDetailFragment().apply {
if (!mHasPassedOneTimeArgumentToChild) {
this.arguments?.putBoolean(EntranceUtils.KEY_SHOW_ANSWER_COMMENT, false)
this.arguments?.putBoolean(EntranceUtils.KEY_RECOMMENDS_CONTENTS, false)
if (mHasPassedOneTimeArgumentToChild) {
this@AnswerDetailContainerFragment.arguments?.putBoolean(EntranceUtils.KEY_SHOW_ANSWER_COMMENT, false)
this@AnswerDetailContainerFragment.arguments?.putBoolean(EntranceUtils.KEY_RECOMMENDS_CONTENTS, false)
}
// 将外部的 argument 传给里面的 fragment

View File

@ -135,9 +135,6 @@ class AnswerDetailFragment : NormalFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
mBinding.richEditor.addJavascriptInterface(JsInterface(), "imagelistener")
mBinding.richEditor.addJavascriptInterface(OnLinkClickListener(), "OnLinkClickListener")
if (mIsShowCommentManager) {
mBaseHandler.postDelayed({ mBinding.bottomController?.ivComment?.performClick() }, 500)
}
mSkeletonScreen = Skeleton.bind(mBinding.skeletonMask).load(R.layout.fragment_answer_detail_skeleton).shimmer(false).show()
}
@ -885,6 +882,11 @@ class AnswerDetailFragment : NormalFragment() {
mBinding.timeTv.text = String.format("编辑于 %s", NewsUtils.getFormattedTime(answerDetail.updateTime))
}
if (mIsShowCommentManager) {
mIsShowCommentManager = false
mBinding.bottomController?.ivComment?.performClick()
}
mBinding.scrollView.viewTreeObserver.addOnScrollChangedListener {
try {
if (mBinding.scrollView.scrollY > mBinding.titleContainer.top) {