【光环助手V5.5.0】游戏单-社区相关 https://git.ghzs.com/pm/halo-app-issues/-/issues/1595
This commit is contained in:
@ -22,12 +22,10 @@ import com.gh.common.view.RichEditor
|
||||
import com.gh.gamecenter.CropImageActivity
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GamesCollectionEntity
|
||||
import com.gh.gamecenter.entity.LocalVideoEntity
|
||||
import com.gh.gamecenter.entity.VideoEntity
|
||||
import com.gh.gamecenter.qa.editor.GameActivity
|
||||
import com.gh.gamecenter.qa.editor.InsertAnswerWrapperActivity
|
||||
import com.gh.gamecenter.qa.editor.InsertArticleWrapperActivity
|
||||
import com.gh.gamecenter.qa.editor.LocalMediaActivity
|
||||
import com.gh.gamecenter.qa.editor.*
|
||||
import com.gh.gamecenter.qa.entity.AnswerEntity
|
||||
import com.gh.gamecenter.qa.entity.ArticleEntity
|
||||
import com.gh.gamecenter.qa.entity.EditorInsertEntity
|
||||
@ -114,6 +112,14 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
INSERT_GAME_COLLECTION_CODE -> {
|
||||
val gameCollectionEntity = data?.getParcelableExtra<GamesCollectionEntity>(GamesCollectionEntity::class.java.simpleName)
|
||||
if (gameCollectionEntity != null) {
|
||||
mRichEditor.focusEditor()
|
||||
insertData = EditorInsertEntity.transform(gameCollectionEntity)
|
||||
mRichEditor.insertCustomStyleLink(insertData)
|
||||
}
|
||||
}
|
||||
REQUEST_CODE_IMAGE -> {
|
||||
if (data != null) mViewModel.uploadPic(data)
|
||||
}
|
||||
@ -248,7 +254,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
R.id.editor_paragraph_h4, R.id.editor_font_container, R.id.editor_paragraph_container,
|
||||
R.id.editor_paragraph_quote, R.id.editor_link_answer, R.id.editor_link_article,
|
||||
R.id.editor_link_game, R.id.editor_link_video, R.id.uploadVideoGuideClose,
|
||||
R.id.originalTipsClose
|
||||
R.id.originalTipsClose, R.id.editor_link_game_collection
|
||||
)
|
||||
fun onRichClick(view: View) {
|
||||
when (view.id) {
|
||||
@ -354,6 +360,12 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
INSERT_GAME_CODE
|
||||
)
|
||||
}
|
||||
R.id.editor_link_game_collection -> {
|
||||
startActivityForResult(
|
||||
InsertGameCollectionWrapperActivity.getIntent(this),
|
||||
INSERT_GAME_COLLECTION_CODE
|
||||
)
|
||||
}
|
||||
R.id.editor_link_video -> {
|
||||
chooseVideo()
|
||||
}
|
||||
@ -714,6 +726,7 @@ abstract class BaseRichEditorActivity<VM : BaseRichEditorViewModel> : ToolBarAct
|
||||
const val INSERT_ANSWER_CODE = 411
|
||||
const val INSERT_ARTICLE_CODE = 412
|
||||
const val INSERT_GAME_CODE = 413
|
||||
const val INSERT_GAME_COLLECTION_CODE = 414
|
||||
const val MAX_INPUT_TEXT_NUM = 10000
|
||||
const val MAX_MEDIA_COUNT = 20
|
||||
|
||||
|
||||
@ -251,6 +251,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_PARENT_TAG = "parent_tag";
|
||||
public static final String KEY_BLOCK_ID = "block_id";
|
||||
public static final String KEY_BLOCK_NAME = "block_name";
|
||||
public static final String KEY_INSERT_GAME_COLLECTION = "insert_game_collection";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
bundle.putBoolean(KEY_REQUIRE_REDIRECT, true);
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package com.gh.gamecenter.collection
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.gh.common.constant.ItemViewType
|
||||
@ -17,9 +20,10 @@ import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.entity.GamesCollectionEntity
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
|
||||
class GamesCollectionAdapter(context: Context,
|
||||
private val mViewModel: GamesCollectionViewModel
|
||||
): ListAdapter<GamesCollectionEntity>(context) {
|
||||
class GamesCollectionAdapter(
|
||||
context: Context,
|
||||
private val mViewModel: GamesCollectionViewModel
|
||||
) : ListAdapter<GamesCollectionEntity>(context) {
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return if (mEntityList == null || mEntityList.isEmpty()) return 0 else mEntityList.size + 1
|
||||
@ -27,15 +31,22 @@ class GamesCollectionAdapter(context: Context,
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (position == itemCount - 1) {
|
||||
ItemViewType.ITEM_FOOTER
|
||||
ItemViewType.ITEM_FOOTER
|
||||
} else {
|
||||
ItemViewType.ITEM_BODY
|
||||
ItemViewType.ITEM_BODY
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return when (viewType) {
|
||||
ItemViewType.ITEM_BODY -> GameCollectionItemViewHolder(DataBindingUtil.inflate(mLayoutInflater, R.layout.game_collection_item, parent, false))
|
||||
ItemViewType.ITEM_BODY -> GameCollectionItemViewHolder(
|
||||
DataBindingUtil.inflate(
|
||||
mLayoutInflater,
|
||||
R.layout.game_collection_item,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
|
||||
else -> FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false))
|
||||
}
|
||||
@ -59,19 +70,24 @@ class GamesCollectionAdapter(context: Context,
|
||||
tagIv.setBackgroundResource(R.drawable.ic_official_big)
|
||||
}
|
||||
}
|
||||
if (mViewModel.mIsInsertGameCollection) {
|
||||
when (mViewModel.type) {
|
||||
GamesCollectionFragment.TYPE_COLLECT -> {
|
||||
userIcon.visibility = View.VISIBLE
|
||||
userName.visibility = View.VISIBLE
|
||||
timeTv.visibility = View.GONE
|
||||
}
|
||||
|
||||
when (mViewModel.type) {
|
||||
GamesCollectionFragment.TYPE_COLLECT -> {
|
||||
userIcon.visibility = View.VISIBLE
|
||||
userName.visibility = View.VISIBLE
|
||||
timeTv.visibility = View.GONE
|
||||
}
|
||||
|
||||
GamesCollectionFragment.TYPE_USER -> {
|
||||
userIcon.visibility = View.GONE
|
||||
userName.visibility = View.GONE
|
||||
timeTv.visibility = View.VISIBLE
|
||||
GamesCollectionFragment.TYPE_USER -> {
|
||||
userIcon.visibility = View.GONE
|
||||
userName.visibility = View.GONE
|
||||
timeTv.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
} else {
|
||||
userIcon.visibility = View.VISIBLE
|
||||
userName.visibility = View.VISIBLE
|
||||
timeTv.visibility = View.GONE
|
||||
}
|
||||
|
||||
myselfTag.setOnClickListener {
|
||||
@ -89,6 +105,20 @@ class GamesCollectionAdapter(context: Context,
|
||||
gameThree.setOnClickListener {
|
||||
GameDetailActivity.startGameDetailActivity(mContext, itemEntity.games?.safelyGetInRelease(2)?.id, "")
|
||||
}
|
||||
root.setOnClickListener {
|
||||
if (mViewModel.mIsInsertGameCollection) {
|
||||
val entity = GamesCollectionEntity().apply {
|
||||
id = itemEntity.id
|
||||
title = itemEntity.title
|
||||
intro = itemEntity.intro
|
||||
}
|
||||
val intent = Intent().apply {
|
||||
putExtra(GamesCollectionEntity::class.java.simpleName, entity)
|
||||
}
|
||||
(mContext as AppCompatActivity).setResult(Activity.RESULT_OK, intent)
|
||||
(mContext as AppCompatActivity).finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,34 +4,35 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.gh.common.util.*
|
||||
import com.gh.common.util.EntranceUtils.KEY_TYPE
|
||||
import com.gh.common.util.EntranceUtils.KEY_USER_ID
|
||||
import com.gh.common.util.EntranceUtils.*
|
||||
import com.gh.common.view.SpacingItemDecoration
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.baselist.ListFragment
|
||||
import com.gh.gamecenter.entity.GamesCollectionEntity
|
||||
|
||||
class GamesCollectionFragment: ListFragment<GamesCollectionEntity, GamesCollectionViewModel>() {
|
||||
class GamesCollectionFragment : ListFragment<GamesCollectionEntity, GamesCollectionViewModel>() {
|
||||
|
||||
private var mUserId = ""
|
||||
private var mType = ""
|
||||
private var mIsInsertGameCollection = false
|
||||
private var mAdapter: GamesCollectionAdapter? = null
|
||||
|
||||
override fun provideListViewModel() = viewModelProvider<GamesCollectionViewModel>(
|
||||
GamesCollectionViewModel.Factory(mUserId, mType)
|
||||
GamesCollectionViewModel.Factory(mUserId, mType, mIsInsertGameCollection)
|
||||
)
|
||||
|
||||
override fun provideListAdapter() = mAdapter ?: GamesCollectionAdapter(requireContext(), mListViewModel).apply { mAdapter = this }
|
||||
|
||||
override fun getItemDecoration() = SpacingItemDecoration(notDecorateTheFirstItem = mType == TYPE_USER, top = 16F.dip2px(), )
|
||||
override fun getItemDecoration() = SpacingItemDecoration(notDecorateTheFirstItem = mType == TYPE_USER, top = 16F.dip2px())
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mUserId = arguments?.getString(KEY_USER_ID, "") ?: ""
|
||||
mType = arguments?.getString(KEY_TYPE, "") ?: ""
|
||||
mIsInsertGameCollection = arguments?.getBoolean(KEY_INSERT_GAME_COLLECTION, false) ?: false
|
||||
super.onCreate(savedInstanceState)
|
||||
mListRv?.run {
|
||||
overScrollMode = View.OVER_SCROLL_NEVER
|
||||
if (mType == TYPE_USER) setBackgroundColor(R.color.white.toColor())
|
||||
if (!mIsInsertGameCollection && mType == TYPE_USER) setBackgroundColor(R.color.white.toColor())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,13 +9,16 @@ import com.gh.gamecenter.retrofit.RetrofitManager
|
||||
import com.halo.assistant.HaloApp
|
||||
import io.reactivex.Single
|
||||
|
||||
class GamesCollectionViewModel(application: Application, var userId: String, var type: String) :
|
||||
class GamesCollectionViewModel(application: Application, var userId: String, var type: String, val mIsInsertGameCollection: Boolean = false) :
|
||||
ListViewModel<GamesCollectionEntity, GamesCollectionEntity>(application) {
|
||||
|
||||
override fun provideDataObservable(page: Int) = null
|
||||
|
||||
override fun provideDataSingle(page: Int): Single<MutableList<GamesCollectionEntity>> {
|
||||
return RetrofitManager.getInstance(getApplication()).api.getUserGameCollectionList(userId)
|
||||
val map = if (mIsInsertGameCollection) {
|
||||
hashMapOf("filter" to "display")
|
||||
} else mapOf()
|
||||
return RetrofitManager.getInstance(getApplication()).api.getUserGameCollectionList(userId, map)
|
||||
}
|
||||
|
||||
override fun mergeResultLiveData() {
|
||||
@ -24,9 +27,10 @@ class GamesCollectionViewModel(application: Application, var userId: String, var
|
||||
}
|
||||
}
|
||||
|
||||
class Factory(private val mUserId: String, private val mType: String) : ViewModelProvider.NewInstanceFactory() {
|
||||
class Factory(private val mUserId: String, private val mType: String, private val mIsInsertGameCollection: Boolean) :
|
||||
ViewModelProvider.NewInstanceFactory() {
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return GamesCollectionViewModel(HaloApp.getInstance().application, mUserId, mType) as T
|
||||
return GamesCollectionViewModel(HaloApp.getInstance().application, mUserId, mType, mIsInsertGameCollection) as T
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ class GameCollectionEditActivity : ToolBarActivity() {
|
||||
}
|
||||
mBinding.gameCollectionIntroduceEt.run {
|
||||
doOnTextChanged { text, start, _, _ ->
|
||||
if(PatternUtils.isHasWrap(text.toString())){
|
||||
if (PatternUtils.isHasWrap(text.toString())) {
|
||||
setText(PatternUtils.replaceWrap(text.toString()))
|
||||
setSelection(start)
|
||||
return@doOnTextChanged
|
||||
@ -172,7 +172,12 @@ class GameCollectionEditActivity : ToolBarActivity() {
|
||||
}
|
||||
}
|
||||
mViewModel.detailLiveData.observe(this) {
|
||||
mViewModel.gameCollectionPatch = it
|
||||
mViewModel.gameCollectionPatch?.apply {
|
||||
games = it.games
|
||||
tags = it.tags
|
||||
title = it.title
|
||||
intro = it.intro
|
||||
}
|
||||
mViewModel.gameCollectionPatch?.run {
|
||||
//TODO:initTags
|
||||
initData(false)
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
package com.gh.gamecenter.qa.editor
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.gh.base.BaseActivity_TabLayout
|
||||
import com.gh.common.util.EntranceUtils
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.collection.GamesCollectionFragment
|
||||
import com.gh.gamecenter.manager.UserManager
|
||||
|
||||
class InsertGameCollectionWrapperActivity : BaseActivity_TabLayout() {
|
||||
|
||||
override fun getLayoutId(): Int = R.layout.activity_tablayout_no_title_viewpager
|
||||
|
||||
override fun initFragmentList(fragments: MutableList<Fragment>?) {
|
||||
fragments?.add(
|
||||
GamesCollectionFragment().with(
|
||||
bundleOf(
|
||||
EntranceUtils.KEY_USER_ID to UserManager.getInstance().userId,
|
||||
EntranceUtils.KEY_TYPE to GamesCollectionFragment.TYPE_USER,
|
||||
EntranceUtils.KEY_INSERT_GAME_COLLECTION to true
|
||||
)
|
||||
)
|
||||
)
|
||||
fragments?.add(
|
||||
GamesCollectionFragment().with(
|
||||
bundleOf(
|
||||
EntranceUtils.KEY_USER_ID to UserManager.getInstance().userId,
|
||||
EntranceUtils.KEY_TYPE to GamesCollectionFragment.TYPE_COLLECT,
|
||||
EntranceUtils.KEY_INSERT_GAME_COLLECTION to true
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun initTabTitleList(tabTitleList: MutableList<String>?) {
|
||||
tabTitleList?.add("我的游戏单")
|
||||
tabTitleList?.add("收藏游戏单")
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getIntent(context: Context): Intent {
|
||||
return Intent(context, InsertGameCollectionWrapperActivity::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,12 +18,14 @@ import com.lightgame.utils.Utils
|
||||
/**
|
||||
* 富文本编辑框的链接回调
|
||||
*/
|
||||
class OnLinkClickListener(val context: Context,
|
||||
val title: String = "",
|
||||
val status: String = "",
|
||||
val entrance: String,
|
||||
val path: String,
|
||||
val mtaEvent: MtaEvent? = null) {
|
||||
class OnLinkClickListener(
|
||||
val context: Context,
|
||||
val title: String = "",
|
||||
val status: String = "",
|
||||
val entrance: String,
|
||||
val path: String,
|
||||
val mtaEvent: MtaEvent? = null
|
||||
) {
|
||||
@JavascriptInterface
|
||||
fun onClick(content: String) {
|
||||
AppExecutor.uiExecutor.execute {
|
||||
@ -31,25 +33,34 @@ class OnLinkClickListener(val context: Context,
|
||||
val insertEntity = GsonUtils.fromJson(content, EditorInsertEntity::class.java)
|
||||
when (insertEntity.type) {
|
||||
"answer" -> {
|
||||
val intent = SimpleAnswerDetailActivity.getIntent(context,
|
||||
insertEntity.id ?: "",
|
||||
entrance,
|
||||
"$path-链接")
|
||||
val intent = SimpleAnswerDetailActivity.getIntent(
|
||||
context,
|
||||
insertEntity.id ?: "",
|
||||
entrance,
|
||||
"$path-链接"
|
||||
)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
"community_article" -> {
|
||||
val community = CommunityEntity(insertEntity.communityId!!, "")
|
||||
val intent = ArticleDetailActivity.getIntent(context,
|
||||
community,
|
||||
insertEntity.id!!,
|
||||
entrance,
|
||||
"$path-链接")
|
||||
val intent = ArticleDetailActivity.getIntent(
|
||||
context,
|
||||
community,
|
||||
insertEntity.id!!,
|
||||
entrance,
|
||||
"$path-链接"
|
||||
)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
"game" -> {
|
||||
GameDetailActivity.startGameDetailActivity(context,
|
||||
insertEntity.id,
|
||||
BaseActivity.mergeEntranceAndPath(entrance, "$path-链接"))
|
||||
GameDetailActivity.startGameDetailActivity(
|
||||
context,
|
||||
insertEntity.id,
|
||||
BaseActivity.mergeEntranceAndPath(entrance, "$path-链接")
|
||||
)
|
||||
}
|
||||
"game_collection" -> {
|
||||
//TODO:跳转游戏单详情
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,7 +73,7 @@ class OnLinkClickListener(val context: Context,
|
||||
tryWithDefaultCatch {
|
||||
if (mtaEvent != null) MtaHelper.onEvent(mtaEvent.name, mtaEvent.key, mtaEvent.value)
|
||||
val videoEntity = GsonUtils.fromJson(content, MyVideoEntity::class.java)
|
||||
clickToastByStatus(videoEntity.status){
|
||||
clickToastByStatus(videoEntity.status) {
|
||||
FullScreenVideoActivity.start(context, title, videoEntity.url, videoEntity.poster)
|
||||
}
|
||||
}
|
||||
@ -71,7 +82,7 @@ class OnLinkClickListener(val context: Context,
|
||||
|
||||
@JavascriptInterface
|
||||
fun onVideoClick(url: String, poster: String) {
|
||||
clickToastByStatus(status){
|
||||
clickToastByStatus(status) {
|
||||
FullScreenVideoActivity.start(context, title, url, poster)
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,16 +3,19 @@ package com.gh.gamecenter.qa.entity
|
||||
import android.os.Parcelable
|
||||
import com.gh.common.util.eliminateDoubleQuote
|
||||
import com.gh.gamecenter.entity.GameEntity
|
||||
import com.gh.gamecenter.entity.GamesCollectionEntity
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class EditorInsertEntity(var id: String? = "",
|
||||
var communityId: String? = "",
|
||||
var type: String? = "",
|
||||
var title: String? = "",
|
||||
var brief: String? = "",
|
||||
var icon: String? = "",
|
||||
var tags: List<String>? = null) : Parcelable {
|
||||
data class EditorInsertEntity(
|
||||
var id: String? = "",
|
||||
var communityId: String? = "",
|
||||
var type: String? = "",
|
||||
var title: String? = "",
|
||||
var brief: String? = "",
|
||||
var icon: String? = "",
|
||||
var tags: List<String>? = null
|
||||
) : Parcelable {
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
@ -48,5 +51,16 @@ data class EditorInsertEntity(var id: String? = "",
|
||||
entity.icon = game.icon
|
||||
return entity
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun transform(game: GamesCollectionEntity): EditorInsertEntity {
|
||||
val entity = EditorInsertEntity()
|
||||
entity.id = game.id
|
||||
entity.type = "game_collection"
|
||||
entity.title = game.title
|
||||
entity.brief = game.intro
|
||||
entity.icon = "https://static-web.ghzs.com/website-static/images/icon_game_collection.png"
|
||||
return entity
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3305,5 +3305,5 @@ public interface ApiService {
|
||||
* 用户游戏单列表
|
||||
*/
|
||||
@GET("users/{user_id}/game_lists")
|
||||
Single<List<GamesCollectionEntity>> getUserGameCollectionList(@Path("user_id") String userId);
|
||||
Single<List<GamesCollectionEntity>> getUserGameCollectionList(@Path("user_id") String userId, @QueryMap Map<String, Object> params);
|
||||
}
|
||||
Reference in New Issue
Block a user