优化管理员修改问题,修复资讯中心三张图片的Item无法显示问题
This commit is contained in:
@ -3,10 +3,8 @@ package com.gh.gamecenter.info;
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.gh.base.OnListClickListener;
|
||||
import com.gh.common.constant.ItemViewType;
|
||||
@ -113,20 +111,6 @@ class OriginalAdapter extends ListAdapter<NewsEntity> {
|
||||
|
||||
NewsEntity newsEntity = mEntityList.get(position);
|
||||
viewHolder.setClickData(newsEntity);
|
||||
DisplayMetrics outMetrics = new DisplayMetrics();
|
||||
int width = (outMetrics.widthPixels - DisplayUtils.dip2px(mContext, 56)) / 3;
|
||||
int height = (int) (width * 3 / 4f);
|
||||
|
||||
LinearLayout.LayoutParams lparams1 = new LinearLayout.LayoutParams(width, height);
|
||||
viewHolder.thumb1.setLayoutParams(lparams1);
|
||||
|
||||
LinearLayout.LayoutParams lparams2 = new LinearLayout.LayoutParams(width, height);
|
||||
lparams2.leftMargin = DisplayUtils.dip2px(mContext, 8);
|
||||
viewHolder.thumb2.setLayoutParams(lparams2);
|
||||
|
||||
LinearLayout.LayoutParams lparams3 = new LinearLayout.LayoutParams(width, height);
|
||||
lparams3.leftMargin = DisplayUtils.dip2px(mContext, 8);
|
||||
viewHolder.thumb3.setLayoutParams(lparams3);
|
||||
|
||||
viewHolder.title.setText(newsEntity.getTitle());
|
||||
ImageUtils.display(viewHolder.thumb1, newsEntity.getThumbnail().getUrl().get(0));
|
||||
|
||||
@ -33,7 +33,7 @@ class QuestionEditActivity : BaseActivity() {
|
||||
|
||||
private lateinit var mBinding: ActivityQuestionsEditBinding
|
||||
|
||||
private var mViewModel: QuestionEditViewModel? = null
|
||||
private lateinit var mViewModel: QuestionEditViewModel
|
||||
|
||||
private var mProcessingDialog: WaitingDialogFragment? = null
|
||||
private var mUploadImageCancelDialog: Dialog? = null
|
||||
@ -77,7 +77,7 @@ class QuestionEditActivity : BaseActivity() {
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (data != null && requestCode == MEDIA_STORE_REQUEST) {
|
||||
mViewModel?.uploadPic(data)
|
||||
mViewModel.uploadPic(data)
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,31 +92,31 @@ class QuestionEditActivity : BaseActivity() {
|
||||
if (intent != null) {
|
||||
val detailEntity = intent.getParcelableExtra<QuestionsDetailEntity>(QuestionsDetailEntity.TAG)
|
||||
if (detailEntity != null) { // 问题编辑
|
||||
mViewModel?.questionEntity = detailEntity
|
||||
mViewModel?.content = detailEntity.description
|
||||
mViewModel?.picList?.postValue(detailEntity.images as MutableList<String>?)
|
||||
mViewModel?.isManagerPatch = intent.getBooleanExtra(QuestionsDetailEntity.TAG, false)
|
||||
if (mViewModel?.title.isNullOrEmpty()) mViewModel?.title = detailEntity.title
|
||||
mViewModel.questionEntity = detailEntity
|
||||
mViewModel.content = detailEntity.description
|
||||
mViewModel.picList.postValue(detailEntity.images as MutableList<String>?)
|
||||
mViewModel.isManagerPatch = intent.getBooleanExtra(EntranceUtils.KEY_QUESTION_MANAGER_PATCH, false)
|
||||
if (mViewModel.title.isNullOrEmpty()) mViewModel.title = detailEntity.title
|
||||
} else { // 新增问题
|
||||
var searchKey = intent.getStringExtra(EntranceUtils.KEY_QUESTIONS_SEARCH_KEY)
|
||||
if (!searchKey.isNullOrEmpty() && searchKey.length > QuestionEditViewModel.QUESTION_TITLE_MAX_LENGTH)
|
||||
searchKey = searchKey.substring(0, QuestionEditViewModel.QUESTION_TITLE_MAX_LENGTH)
|
||||
if (mViewModel?.title.isNullOrEmpty()) mViewModel?.title = searchKey
|
||||
if (mViewModel.title.isNullOrEmpty()) mViewModel.title = searchKey
|
||||
}
|
||||
}
|
||||
|
||||
// Navigation
|
||||
if (mViewModel?.questionEntity != null) {
|
||||
setNavigationTitle("编辑问题")
|
||||
} else {
|
||||
setNavigationTitle(UserManager.getInstance().community.name)
|
||||
when {
|
||||
mViewModel.isManagerPatch -> setNavigationTitle("修改问题")
|
||||
mViewModel.questionEntity != null -> setNavigationTitle("编辑问题")
|
||||
else -> setNavigationTitle(UserManager.getInstance().community.name)
|
||||
}
|
||||
|
||||
mViewModel?.getDefaultTag()
|
||||
mViewModel.getDefaultTag()
|
||||
|
||||
// TitleTip
|
||||
if (mViewModel?.questionEntity == null) {
|
||||
val titleTipAdapter = QuestionTitleTipAdapter(this, mBinding.questionseditTitle, mViewModel?.communityId)
|
||||
if (mViewModel.questionEntity == null) {
|
||||
val titleTipAdapter = QuestionTitleTipAdapter(this, mBinding.questionseditTitle, mViewModel.communityId)
|
||||
mBinding.questionseditTitle.setAdapter(titleTipAdapter)
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ class QuestionEditActivity : BaseActivity() {
|
||||
mBinding.questionseditContent.addTextChangedListener(LimitTextWatcher(mBinding.questionseditContent))
|
||||
|
||||
// Pic List
|
||||
val picAdapter = QuestionsEditPicAdapter(this, mViewModel!!)
|
||||
val picAdapter = QuestionsEditPicAdapter(this, mViewModel)
|
||||
mBinding.suggestPicRv.layoutManager = object : GridLayoutManager(this, 5) {
|
||||
override fun canScrollVertically(): Boolean {
|
||||
return false
|
||||
@ -136,18 +136,18 @@ class QuestionEditActivity : BaseActivity() {
|
||||
mBinding.suggestPicRv.adapter = picAdapter
|
||||
|
||||
// Process dialog
|
||||
mViewModel?.processDialog?.observe(this, Observer { it ->
|
||||
mViewModel.processDialog.observe(this, Observer { it ->
|
||||
if (it?.isShow!!) {
|
||||
if (mProcessingDialog != null && mProcessingDialog?.isVisible!!) {
|
||||
mProcessingDialog?.uploadWaitingHint(it.msg)
|
||||
} else {
|
||||
mProcessingDialog = WaitingDialogFragment.newInstance(it.msg, false)
|
||||
mProcessingDialog?.show(supportFragmentManager, null) {
|
||||
if (mViewModel?.uploadImageSubscription != null && !mViewModel?.uploadImageSubscription!!.isDisposed) {
|
||||
if (mViewModel.uploadImageSubscription != null && !mViewModel.uploadImageSubscription!!.isDisposed) {
|
||||
mUploadImageCancelDialog = DialogUtils.showAlertDialog(this, "提示"
|
||||
, "图片正在上传中,确定取消吗?"
|
||||
, "确定", "取消", {
|
||||
mViewModel?.uploadImageSubscription!!.dispose()
|
||||
mViewModel.uploadImageSubscription!!.dispose()
|
||||
mUploadImageCancelDialog?.dismiss()
|
||||
mProcessingDialog?.dismiss()
|
||||
}, null)
|
||||
@ -160,31 +160,31 @@ class QuestionEditActivity : BaseActivity() {
|
||||
}
|
||||
})
|
||||
|
||||
mViewModel?.titleTags?.observe(this, Observer<List<String>> {
|
||||
mViewModel.titleTags.observe(this, Observer<List<String>> {
|
||||
if (supportFragmentManager.findFragmentByTag(TagsSelectFragment::javaClass.name) == null) {
|
||||
val dialog = BaseDialogWrapperFragment.getInstance(TagsSelectFragment.getInstance(), false)
|
||||
dialog.show(supportFragmentManager, TagsSelectFragment::javaClass.name)
|
||||
}
|
||||
})
|
||||
|
||||
mViewModel?.picList?.observe(this, Observer { it ->
|
||||
mViewModel.picList.observe(this, Observer { it ->
|
||||
if (it != null) picAdapter.notifyPicList(it)
|
||||
})
|
||||
|
||||
// 增加提问时, 如果searchKey不为空 光标跳到最后
|
||||
mBaseHandler.postDelayed({
|
||||
if (mViewModel?.questionEntity == null) {
|
||||
if (mViewModel.questionEntity == null) {
|
||||
mBinding.questionseditTitle.setSelection(mBinding.questionseditTitle.text.toString().length)
|
||||
}
|
||||
}, 50)
|
||||
}
|
||||
|
||||
override fun onMenuItemClick(menuItem: MenuItem?): Boolean {
|
||||
if (mViewModel!!.isManagerPatch) {
|
||||
mViewModel?.selectedTags?.addAll(mViewModel?.questionEntity?.tags!!)
|
||||
if (mViewModel.isManagerPatch) {
|
||||
mViewModel.selectedTags.addAll(mViewModel.questionEntity?.tags!!)
|
||||
// todo 直接提交
|
||||
} else {
|
||||
mViewModel?.checkTitleAndLoadTitleTag()
|
||||
mViewModel.checkTitleAndLoadTitleTag()
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -232,13 +232,18 @@ class QuestionEditActivity : BaseActivity() {
|
||||
// 退出提示
|
||||
override fun onBackPressed() {
|
||||
// 需要检查的内容,其中任意一个不为空都要打开提示弹窗
|
||||
val imgList = mViewModel?.picList?.value
|
||||
val imgList = mViewModel.picList.value
|
||||
val title = mBinding.questionseditTitle.text.toString().trim()
|
||||
val content = mBinding.questionseditContent.text.toString().trim()
|
||||
|
||||
if (imgList != null && imgList.size > 0 || title.isNotEmpty() || content.isNotEmpty()) {
|
||||
if (mViewModel.isManagerPatch) {
|
||||
DialogUtils.showCancelAlertDialog(this, "提示"
|
||||
, if (mViewModel?.questionEntity == null) "确定放弃提问吗?" else "确定放弃编辑吗?"
|
||||
, "确定退出修改?已编辑的内容将丢失"
|
||||
, "继续编辑", " 退出", null) { finish() }
|
||||
return
|
||||
} else if (imgList != null && imgList.size > 0 || title.isNotEmpty() || content.isNotEmpty()) {
|
||||
DialogUtils.showCancelAlertDialog(this, "提示"
|
||||
, if (mViewModel.questionEntity == null) "确定放弃提问吗?" else "确定放弃编辑吗?"
|
||||
, "再想想", " 放弃", null) { finish() }
|
||||
return
|
||||
}
|
||||
|
||||
@ -52,7 +52,8 @@ class TagsSelectFragment : BaseFragment<String>() {
|
||||
private val mTagFl by bindView<FlexboxLayout>(R.id.questions_edit_tag)
|
||||
private val mAddTagBtn by bindView<View>(R.id.questions_edit_tag_add)
|
||||
private val mPostBtn by bindView<View>(R.id.questions_edit_tag_positive)
|
||||
private val mCancelBtn by bindView<View>(R.id.questions_edit_tag_cancel)
|
||||
private val mCancelBtn by bindView<TextView>(R.id.questions_edit_tag_cancel)
|
||||
private val mTitle by bindView<TextView>(R.id.questions_edit_tag_title)
|
||||
|
||||
private var mViewModel: QuestionEditViewModel? = null
|
||||
|
||||
@ -75,6 +76,11 @@ class TagsSelectFragment : BaseFragment<String>() {
|
||||
mViewModel?.questionEntity = arguments?.getParcelable(QuestionsDetailEntity::class.java.simpleName)
|
||||
}
|
||||
|
||||
if (mViewModel != null && mViewModel?.isManagerPatch!!) {
|
||||
mCancelBtn.text = "取消"
|
||||
mTitle.text = "修改标签"
|
||||
}
|
||||
|
||||
initTags()
|
||||
|
||||
mViewModel?.postLiveData?.observe(this, Observer {
|
||||
@ -104,7 +110,12 @@ class TagsSelectFragment : BaseFragment<String>() {
|
||||
}
|
||||
|
||||
mPostBtn.setOnClickListener {
|
||||
mViewModel?.postQuestion()
|
||||
if (mViewModel?.isManagerPatch!!
|
||||
&& mViewModel?.questionEntity?.tags == mViewModel?.selectedTags) {
|
||||
toast("标签没有变化")
|
||||
} else {
|
||||
mViewModel?.postQuestion()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,12 +2,14 @@ package com.gh.gamecenter.qa.questions.edit.manager
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.gh.common.constant.ItemViewType
|
||||
import com.gh.gamecenter.R
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder
|
||||
import com.gh.gamecenter.baselist.ListAdapter
|
||||
import com.gh.gamecenter.baselist.NormalListViewModel
|
||||
import com.gh.gamecenter.databinding.QuestionHistoryItemBinding
|
||||
import com.gh.gamecenter.qa.entity.QuestionsDetailEntity
|
||||
|
||||
class HistoryAdapter(context: Context,
|
||||
@ -22,8 +24,15 @@ class HistoryAdapter(context: Context,
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val view = mLayoutInflater . inflate (R.layout.refresh_footerview, parent, false)
|
||||
return FooterViewHolder(view)
|
||||
val view: View
|
||||
return if (viewType == ItemViewType.ITEM_FOOTER) {
|
||||
view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)
|
||||
FooterViewHolder(view)
|
||||
} else {
|
||||
view = mLayoutInflater.inflate(R.layout.question_history_item, parent, false)
|
||||
HistoryItemViewHolder(QuestionHistoryItemBinding.bind(view))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = if (mEntityList.isEmpty()) 0 else mEntityList.size + TOP_ITEM_COUNT
|
||||
@ -31,6 +40,8 @@ class HistoryAdapter(context: Context,
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
if (holder is FooterViewHolder) {
|
||||
holder.initFooterViewHolder(mViewModel, mIsLoading, mIsNetworkError, mIsOver)
|
||||
} else if (holder is HistoryItemViewHolder) {
|
||||
holder.binding.data = mEntityList[position]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
package com.gh.gamecenter.qa.questions.edit.manager
|
||||
|
||||
import com.gh.base.BaseRecyclerViewHolder
|
||||
import com.gh.gamecenter.databinding.QuestionHistoryItemBinding
|
||||
|
||||
class HistoryItemViewHolder(val binding: QuestionHistoryItemBinding) : BaseRecyclerViewHolder<Any>(binding.root)
|
||||
@ -29,22 +29,25 @@
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id = "@+id/news_image2_thumb1"
|
||||
style = "@style/frescoStyle"
|
||||
android:layout_width = "88dp"
|
||||
android:layout_height = "66dp" />
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "66dp"
|
||||
android:layout_weight = "1" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id = "@+id/news_image2_thumb2"
|
||||
style = "@style/frescoStyle"
|
||||
android:layout_width = "88dp"
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "66dp"
|
||||
android:layout_marginLeft = "8dp" />
|
||||
android:layout_marginLeft = "8dp"
|
||||
android:layout_weight = "1" />
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id = "@+id/news_image2_thumb3"
|
||||
style = "@style/frescoStyle"
|
||||
android:layout_width = "88dp"
|
||||
android:layout_width = "0dp"
|
||||
android:layout_height = "66dp"
|
||||
android:layout_marginLeft = "8dp" />
|
||||
android:layout_marginLeft = "8dp"
|
||||
android:layout_weight = "1" />
|
||||
|
||||
</LinearLayout >
|
||||
|
||||
|
||||
@ -1,6 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "match_parent" >
|
||||
<layout >
|
||||
|
||||
</android.support.constraint.ConstraintLayout >
|
||||
<data >
|
||||
|
||||
<variable
|
||||
name = "data"
|
||||
type = "com.gh.gamecenter.qa.entity.QuestionsDetailEntity" />
|
||||
</data >
|
||||
|
||||
<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:background = "@drawable/reuse_listview_item_style"
|
||||
android:paddingBottom = "13dp"
|
||||
android:paddingLeft = "21dp"
|
||||
android:paddingRight = "10dp"
|
||||
android:paddingTop = "18dp" >
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/question_history_item_title"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:ellipsize = "end"
|
||||
android:maxLines = "2"
|
||||
android:text = "@{data.title}"
|
||||
android:textColor = "@color/black"
|
||||
android:textSize = "15sp"
|
||||
android:textStyle = "bold" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/question_history_item_answer_count"
|
||||
android:layout_width = "match_parent"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_below = "@id/question_history_item_title"
|
||||
android:layout_marginTop = "15dp"
|
||||
android:textColor = "@color/hint"
|
||||
android:textSize = "11sp" />
|
||||
|
||||
<TextView
|
||||
android:id = "@+id/question_history_item_community_name"
|
||||
android:layout_width = "wrap_content"
|
||||
android:layout_height = "wrap_content"
|
||||
android:layout_alignParentRight = "true"
|
||||
android:layout_below = "@id/question_history_item_title"
|
||||
android:layout_marginRight = "11dp"
|
||||
android:layout_marginTop = "15dp"
|
||||
android:gravity = "right"
|
||||
android:maxEms = "15"
|
||||
android:maxLines = "1"
|
||||
android:text = "@{data.communityName}"
|
||||
android:textColor = "@color/hint"
|
||||
android:textSize = "11sp"
|
||||
android:visibility = "gone" />
|
||||
|
||||
</RelativeLayout >
|
||||
</layout >
|
||||
|
||||
Reference in New Issue
Block a user