From 6ae6a4e14a91c68e0f016a2df5fe6432567631ee Mon Sep 17 00:00:00 2001 From: kehaoyuan Date: Sun, 6 Oct 2019 17:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=89=E7=8E=AF=E5=8A=A9=E6=89=8BV3.7.0-?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E8=A7=86=E9=A2=91=E5=8A=9F=E8=83=BD-?= =?UTF-8?q?=E5=89=8D=E7=AB=AF5=EF=BC=88=E9=97=AE=E7=AD=94=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=EF=BC=89(2)https://gitlab.ghzs.com/pm/halo-app-issues?= =?UTF-8?q?/issues/626?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gh/common/databind/BindingAdapters.java | 30 +- .../com/gh/common/history/HistoryDatabase.kt | 25 +- .../entity/PersonalHistoryEntity.kt | 2 + .../gamecenter/qa/article/MyArticleAdapter.kt | 4 +- .../qa/column/detail/hot/HotAdapter.kt | 4 +- .../detail/recommends/RecommendsAdapter.kt | 4 +- .../detail/unanswered/UnansweredAdapter.kt | 4 +- .../gh/gamecenter/qa/entity/AnswerEntity.kt | 4 + .../gh/gamecenter/qa/entity/ArticleEntity.kt | 4 + .../qa/entity/CommunityVideoEntity.kt | 10 + .../com/gh/gamecenter/qa/entity/Questions.kt | 2 +- .../qa/questions/detail/AnswerViewHolder.java | 65 ++-- .../AskQuestionsRecommendsViewHolder.java | 55 +-- .../com/gh/gamecenter/room/AppDatabase.java | 16 +- .../room/converter/CommunityVideoConverter.kt | 19 + .../community_video_play_icon.png | Bin 0 -> 3450 bytes app/src/main/res/layout/ask_answer_item.xml | 236 +++++++------ .../res/layout/ask_questions_hot_item.xml | 237 +++++++------ app/src/main/res/layout/ask_subject_item.xml | 240 +++++++------ .../res/layout/community_article_item.xml | 180 ++++++---- .../main/res/layout/personal_home_item.xml | 331 ++++++++++-------- app/src/main/res/values/colors.xml | 1 + 22 files changed, 857 insertions(+), 616 deletions(-) create mode 100644 app/src/main/java/com/gh/gamecenter/qa/entity/CommunityVideoEntity.kt create mode 100644 app/src/main/java/com/gh/gamecenter/room/converter/CommunityVideoConverter.kt create mode 100644 app/src/main/res/drawable-xxhdpi/community_video_play_icon.png diff --git a/app/src/main/java/com/gh/common/databind/BindingAdapters.java b/app/src/main/java/com/gh/common/databind/BindingAdapters.java index c9df9d35f3..8fd17db273 100644 --- a/app/src/main/java/com/gh/common/databind/BindingAdapters.java +++ b/app/src/main/java/com/gh/common/databind/BindingAdapters.java @@ -6,7 +6,6 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.widget.EditText; -import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -29,6 +28,7 @@ import com.gh.common.util.PlatformUtils; import com.gh.common.util.StringUtils; import com.gh.common.view.DownloadDialog; import com.gh.common.view.DownloadProgressBar; +import com.gh.common.view.DrawableView; import com.gh.download.DownloadManager; import com.gh.gamecenter.DownloadManagerActivity; import com.gh.gamecenter.R; @@ -41,7 +41,7 @@ import com.gh.gamecenter.entity.PluginLocation; import com.gh.gamecenter.entity.ServerCalendarEntity; import com.gh.gamecenter.eventbus.EBReuse; import com.gh.gamecenter.manager.PackagesManager; -import com.halo.assistant.HaloApp; +import com.gh.gamecenter.qa.entity.CommunityVideoEntity; import com.lightgame.download.DownloadEntity; import com.lightgame.download.FileUtils; import com.lightgame.utils.Utils; @@ -512,4 +512,30 @@ public class BindingAdapters { } } + + @BindingAdapter({"setCommunityImage", "setCommunityVideoImage"}) + public static void setCommunityImage(SimpleDraweeView imageView, List images, List videos) { + if (videos.size() > 0) { + CommunityVideoEntity videoEntity = videos.get(0); + ImageUtils.display(imageView, videoEntity.getPoster()); + imageView.setVisibility(View.VISIBLE); + } else if (images.size() > 0) { + imageView.setVisibility(View.VISIBLE); + ImageUtils.display(imageView, images.get(0)); + } else { + imageView.setVisibility(View.GONE); + } + } + + @BindingAdapter({"setCommunityVideoDuration"}) + public static void setCommunityVideoDuration(TextView mVideoDuration, List videos) { + if (videos != null && videos.size() > 0) { + CommunityVideoEntity videoEntity = videos.get(0); + mVideoDuration.setBackground(DrawableView.getOvalDrawable(R.color.black_alpha_80, 999F)); + mVideoDuration.setText(videoEntity.getDuration()); + mVideoDuration.setVisibility(View.VISIBLE); + } else { + mVideoDuration.setVisibility(View.GONE); + } + } } diff --git a/app/src/main/java/com/gh/common/history/HistoryDatabase.kt b/app/src/main/java/com/gh/common/history/HistoryDatabase.kt index 768b92dbdb..35fb75b9ae 100644 --- a/app/src/main/java/com/gh/common/history/HistoryDatabase.kt +++ b/app/src/main/java/com/gh/common/history/HistoryDatabase.kt @@ -17,15 +17,15 @@ import com.gh.gamecenter.room.dao.GameDao import com.gh.gamecenter.room.dao.NewsHistoryDao import com.halo.assistant.HaloApp -@Database(entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class], version = 3, exportSchema = false) -@TypeConverters(*[ - CountConverter::class, - CommunityConverter::class, - TimeConverter::class, - AnswerUserConverter::class, - ThumbnailConverter::class, - TagStyleListConverter::class, - StringArrayListConverter::class]) +@Database(entities = [AnswerEntity::class, ArticleEntity::class, NewsEntity::class, HistoryGameEntity::class], version = 4, exportSchema = false) +@TypeConverters(CountConverter::class, + CommunityConverter::class, + TimeConverter::class, + AnswerUserConverter::class, + ThumbnailConverter::class, + TagStyleListConverter::class, + StringArrayListConverter::class, + CommunityVideoConverter::class) abstract class HistoryDatabase : RoomDatabase() { @@ -42,9 +42,16 @@ abstract class HistoryDatabase : RoomDatabase() { } } + val MIGRATION_3_4: Migration = object : Migration(3, 4) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("Alter TABLE ArticleEntity add videos TEXT") + } + } + val instance by lazy { Room.databaseBuilder(HaloApp.getInstance().application, HistoryDatabase::class.java, "USER_TRACK_HISTORY_DATABASE") .addMigrations(MIGRATION_2_3) + .addMigrations(MIGRATION_3_4) .build() } } diff --git a/app/src/main/java/com/gh/gamecenter/entity/PersonalHistoryEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/PersonalHistoryEntity.kt index 781e55b3e2..3ccc1301b9 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/PersonalHistoryEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/PersonalHistoryEntity.kt @@ -1,5 +1,6 @@ package com.gh.gamecenter.entity +import com.gh.gamecenter.qa.entity.CommunityVideoEntity import com.google.gson.annotations.SerializedName data class PersonalHistoryEntity( @@ -12,6 +13,7 @@ data class PersonalHistoryEntity( val time: Long = 0, val title: String = "", val community: CommunityEntity = CommunityEntity(), + var videos: List = ArrayList(), var user: PersonalEntity? = null, @SerializedName("fold_users") var foldUsers: List? = null, diff --git a/app/src/main/java/com/gh/gamecenter/qa/article/MyArticleAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/article/MyArticleAdapter.kt index f208cb9bf8..cfe119a8c5 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/article/MyArticleAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/article/MyArticleAdapter.kt @@ -23,7 +23,7 @@ class MyArticleAdapter(context: Context, return ItemViewType.ITEM_BODY } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): androidx.recyclerview.widget.RecyclerView.ViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { val view: View return when (viewType) { ItemViewType.ITEM_FOOTER -> { @@ -41,7 +41,7 @@ class MyArticleAdapter(context: Context, return if (mEntityList.size == 0) 0 else mEntityList.size + 1 } - override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) { + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { if (holder is ArticleViewHolder) { val entity = mEntityList[position] holder.binding.data = entity diff --git a/app/src/main/java/com/gh/gamecenter/qa/column/detail/hot/HotAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/column/detail/hot/HotAdapter.kt index 3cf8d001fc..de312bd7e2 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/column/detail/hot/HotAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/column/detail/hot/HotAdapter.kt @@ -26,7 +26,7 @@ class HotAdapter(context: Context, return if (position == itemCount - 1) ItemViewType.ITEM_FOOTER else ItemViewType.ITEM_BODY } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): androidx.recyclerview.widget.RecyclerView.ViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { ItemViewType.ITEM_FOOTER -> { FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)) @@ -41,7 +41,7 @@ class HotAdapter(context: Context, return if (mEntityList == null || mEntityList.isEmpty()) 0 else mEntityList.size + ListAdapter.FOOTER_ITEM_COUNT } - override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) { + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { if (holder is AskQuestionsRecommendsViewHolder) { val answerEntity = mEntityList[position] if ("community_article" == answerEntity.type) { diff --git a/app/src/main/java/com/gh/gamecenter/qa/column/detail/recommends/RecommendsAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/column/detail/recommends/RecommendsAdapter.kt index c6d1e82ffc..c7b4e37a0e 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/column/detail/recommends/RecommendsAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/column/detail/recommends/RecommendsAdapter.kt @@ -26,7 +26,7 @@ class RecommendsAdapter(context: Context, return if (position == itemCount - 1) ItemViewType.ITEM_FOOTER else ItemViewType.ITEM_BODY } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): androidx.recyclerview.widget.RecyclerView.ViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { ItemViewType.ITEM_FOOTER -> { FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)) @@ -41,7 +41,7 @@ class RecommendsAdapter(context: Context, return if (mEntityList == null || mEntityList.isEmpty()) 0 else mEntityList.size + ListAdapter.FOOTER_ITEM_COUNT } - override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) { + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { if (holder is AskQuestionsRecommendsViewHolder) { val answerEntity = mEntityList[position] if ("community_article" == answerEntity.type) { diff --git a/app/src/main/java/com/gh/gamecenter/qa/column/detail/unanswered/UnansweredAdapter.kt b/app/src/main/java/com/gh/gamecenter/qa/column/detail/unanswered/UnansweredAdapter.kt index 3eba6a6481..4362ee03a4 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/column/detail/unanswered/UnansweredAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/column/detail/unanswered/UnansweredAdapter.kt @@ -21,7 +21,7 @@ class UnansweredAdapter(context: Context, return if (position == itemCount - 1) ItemViewType.ITEM_FOOTER else ItemViewType.ITEM_BODY } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): androidx.recyclerview.widget.RecyclerView.ViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { ItemViewType.ITEM_FOOTER -> { FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)) @@ -36,7 +36,7 @@ class UnansweredAdapter(context: Context, return if (mEntityList == null || mEntityList.isEmpty()) 0 else mEntityList.size + ListAdapter.FOOTER_ITEM_COUNT } - override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) { + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { if (holder is AskQuestionsNewViewHolder) { val questions = mEntityList[position] holder.initAskQuestionsNewViewHolder(questions) 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 370476e2ef..6657a3d958 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 @@ -8,6 +8,7 @@ import android.os.Parcelable import androidx.annotation.NonNull import com.gh.gamecenter.entity.UserEntity import com.gh.gamecenter.room.converter.AnswerUserConverter +import com.gh.gamecenter.room.converter.CommunityVideoConverter import com.gh.gamecenter.room.converter.ListStringConverter import com.gh.gamecenter.room.converter.QuestionsConverter import com.google.gson.annotations.SerializedName @@ -41,6 +42,9 @@ class AnswerEntity() : Parcelable { @TypeConverters(ListStringConverter::class) var images: List = ArrayList() + @TypeConverters(CommunityVideoConverter::class) + var videos: List = ArrayList() + var vote: Int = 0 @TypeConverters(AnswerUserConverter::class) 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 146ca64d8d..9c24561f14 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 @@ -4,8 +4,10 @@ import androidx.room.Entity import androidx.room.Ignore import androidx.room.PrimaryKey import android.os.Parcelable +import androidx.room.TypeConverters import com.gh.gamecenter.entity.CommunityEntity import com.gh.gamecenter.entity.UserEntity +import com.gh.gamecenter.room.converter.CommunityVideoConverter import com.google.gson.annotations.SerializedName import kotlinx.android.parcel.Parcelize @@ -21,6 +23,8 @@ data class ArticleEntity( var orderTag: Long = 0, @Ignore var images: List = ArrayList(), + @TypeConverters(CommunityVideoConverter::class) + var videos: List = ArrayList(), var count: Count = Count(), var community: CommunityEntity = CommunityEntity(), var time: TimeEntity? = TimeEntity(), diff --git a/app/src/main/java/com/gh/gamecenter/qa/entity/CommunityVideoEntity.kt b/app/src/main/java/com/gh/gamecenter/qa/entity/CommunityVideoEntity.kt new file mode 100644 index 0000000000..b148764594 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/qa/entity/CommunityVideoEntity.kt @@ -0,0 +1,10 @@ +package com.gh.gamecenter.qa.entity + +import android.os.Parcelable +import kotlinx.android.parcel.Parcelize + +@Parcelize +data class CommunityVideoEntity(val id: String = "", + val url: String = "", + val duration: String = "", + val poster: String = "") : Parcelable \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/entity/Questions.kt b/app/src/main/java/com/gh/gamecenter/qa/entity/Questions.kt index b4182a74f6..ddbf6548e5 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/entity/Questions.kt +++ b/app/src/main/java/com/gh/gamecenter/qa/entity/Questions.kt @@ -16,6 +16,6 @@ data class Questions(@SerializedName("_id") @SerializedName("answer_count") var answerCount: Int = 0, var description: String? = null, - var images: List = ArrayList(), + var images: ArrayList = ArrayList(), val time: Long = 0, val count: Count = Count()) : Parcelable \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/qa/questions/detail/AnswerViewHolder.java b/app/src/main/java/com/gh/gamecenter/qa/questions/detail/AnswerViewHolder.java index d05ace6740..d12b994fa7 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/questions/detail/AnswerViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/qa/questions/detail/AnswerViewHolder.java @@ -2,7 +2,9 @@ package com.gh.gamecenter.qa.questions.detail; import android.content.Context; import android.graphics.Paint; + import androidx.core.content.ContextCompat; + import android.view.View; import android.widget.TextView; @@ -12,10 +14,12 @@ import com.gh.base.OnListClickListener; import com.gh.common.util.ImageUtils; import com.gh.common.util.NewsUtils; import com.gh.common.util.NumberUtils; +import com.gh.common.view.DrawableView; import com.gh.gamecenter.PersonalHomeActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.entity.UserEntity; import com.gh.gamecenter.qa.entity.AnswerEntity; +import com.gh.gamecenter.qa.entity.CommunityVideoEntity; import java.util.List; @@ -49,6 +53,10 @@ public class AnswerViewHolder extends BaseRecyclerViewHolder { View mUserIconContainer; @BindView(R.id.ask_answer_item_end_desc) TextView mEndDescTv; + @BindView(R.id.ask_answer_item_video_duration) + TextView mVideoDuration; + @BindView(R.id.ask_answer_item_video_play) + View mVideoPlayIcon; public AnswerViewHolder(View itemView, OnListClickListener listClickListener) { super(itemView, listClickListener); @@ -74,22 +82,7 @@ public class AnswerViewHolder extends BaseRecyclerViewHolder { } else { ImageUtils.display(mBadgeIcon, ""); } - List images = entity.getImages(); - if (images.size() > 0) { - for (int i = 0; i < images.size(); i++) { - if (!images.get(i).contains(".gif")) { - mImg.setVisibility(View.VISIBLE); - ImageUtils.display(mImg, images.get(i)); - break; - } - if (i == images.size() - 1) { - mImg.setVisibility(View.GONE); - } - } - } else { - mImg.setVisibility(View.GONE); - } - + setAnswerImage(entity.getImages(), entity.getVideos()); if (entity.getTime() != null && entity.getTime() != 0) { mEndDescTv.setText(NewsUtils.getFormattedTime(entity.getTime())); } @@ -123,21 +116,7 @@ public class AnswerViewHolder extends BaseRecyclerViewHolder { } else { ImageUtils.display(mBadgeIcon, ""); } - List images = entity.getImages(); - if (images.size() > 0) { - for (int i = 0; i < images.size(); i++) { - if (!images.get(i).contains(".gif")) { - mImg.setVisibility(View.VISIBLE); - ImageUtils.display(mImg, images.get(i)); - break; - } - if (i == images.size() - 1) { - mImg.setVisibility(View.GONE); - } - } - } else { - mImg.setVisibility(View.GONE); - } + setAnswerImage(entity.getImages(), entity.getVideos()); skipPersonalHome(entity, entrance, "我的收藏-回答"); } @@ -152,8 +131,19 @@ public class AnswerViewHolder extends BaseRecyclerViewHolder { mCommunityName.setText(entity.getCommunityName()); mCommentCount.setText(String.format("%s 评论", NumberUtils.transSimpleCount(entity.getCommentCount()))); mVotecount.setText(itemView.getContext().getString(R.string.ask_vote_count, NumberUtils.transSimpleCount(entity.getVote()))); - List images = entity.getImages(); - if (images.size() > 0) { + setAnswerImage(entity.getImages(), entity.getVideos()); + } + + private void setAnswerImage(List images, List videos) { + if (videos.size() > 0) { + CommunityVideoEntity videoEntity = videos.get(0); + ImageUtils.display(mImg, videoEntity.getPoster()); + mVideoDuration.setBackground(DrawableView.getOvalDrawable(R.color.black_alpha_80, 999F)); + mVideoDuration.setText(videoEntity.getDuration()); + mVideoDuration.setVisibility(View.VISIBLE); + mVideoPlayIcon.setVisibility(View.VISIBLE); + mImg.setVisibility(View.VISIBLE); + } else if (images.size() > 0) { for (int i = 0; i < images.size(); i++) { if (!images.get(i).contains(".gif")) { mImg.setVisibility(View.VISIBLE); @@ -164,13 +154,18 @@ public class AnswerViewHolder extends BaseRecyclerViewHolder { mImg.setVisibility(View.GONE); } } + mVideoPlayIcon.setVisibility(View.GONE); + mVideoDuration.setVisibility(View.GONE); } else { mImg.setVisibility(View.GONE); + mVideoPlayIcon.setVisibility(View.GONE); + mVideoDuration.setVisibility(View.GONE); } } private void skipPersonalHome(AnswerEntity entity, String entrance, String path) { - mUsericon.setOnClickListener(v -> PersonalHomeActivity.startTargetActivity(itemView.getContext(), entity.getUser().getId(), entrance, path)); - mUsername.setOnClickListener(v -> PersonalHomeActivity.startTargetActivity(itemView.getContext(), entity.getUser().getId(), entrance, path)); + View.OnClickListener onClickListener = v -> PersonalHomeActivity.startTargetActivity(itemView.getContext(), entity.getUser().getId(), entrance, path); + mUsericon.setOnClickListener(onClickListener); + mUsername.setOnClickListener(onClickListener); } } diff --git a/app/src/main/java/com/gh/gamecenter/qa/recommends/AskQuestionsRecommendsViewHolder.java b/app/src/main/java/com/gh/gamecenter/qa/recommends/AskQuestionsRecommendsViewHolder.java index 95fda9edd5..314970fd41 100644 --- a/app/src/main/java/com/gh/gamecenter/qa/recommends/AskQuestionsRecommendsViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/qa/recommends/AskQuestionsRecommendsViewHolder.java @@ -10,11 +10,13 @@ import com.gh.base.OnListClickListener; import com.gh.common.util.ImageUtils; import com.gh.common.util.NewsUtils; import com.gh.common.util.NumberUtils; +import com.gh.common.view.DrawableView; import com.gh.gamecenter.PersonalHomeActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.entity.UserEntity; import com.gh.gamecenter.qa.entity.AnswerEntity; import com.gh.gamecenter.qa.entity.ArticleEntity; +import com.gh.gamecenter.qa.entity.CommunityVideoEntity; import java.util.List; @@ -46,6 +48,10 @@ public class AskQuestionsRecommendsViewHolder extends BaseRecyclerViewHolder images = entity.getImages(); - if (images.size() > 0) { - mAskImg.setVisibility(View.VISIBLE); - ImageUtils.display(mAskImg, images.get(0)); - } else { - mAskImg.setVisibility(View.GONE); - } - - mAskUsericon.setOnClickListener(v -> PersonalHomeActivity.startTargetActivity(context, entity.getUser().getId(), entrance, path)); - mAskUsername.setOnClickListener(v -> PersonalHomeActivity.startTargetActivity(context, entity.getUser().getId(), entrance, path)); + View.OnClickListener userClick = v -> PersonalHomeActivity.startTargetActivity(context, entity.getUser().getId(), entrance, path); + mAskUsericon.setOnClickListener(userClick); + mAskUsername.setOnClickListener(userClick); if (entity.getTime() != null && entity.getTime() != 0) { mAskEndDesc.setText(NewsUtils.getFormattedTime(entity.getTime())); @@ -112,21 +112,36 @@ public class AskQuestionsRecommendsViewHolder extends BaseRecyclerViewHolder images = entity.getImages(); - if (images.size() > 0) { - mAskImg.setVisibility(View.VISIBLE); - ImageUtils.display(mAskImg, images.get(0)); - } else { - mAskImg.setVisibility(View.GONE); - } - - mAskUsericon.setOnClickListener(v -> PersonalHomeActivity.startTargetActivity(context, entity.getUser().getId(), entrance, path)); - mAskUsername.setOnClickListener(v -> PersonalHomeActivity.startTargetActivity(context, entity.getUser().getId(), entrance, path)); + View.OnClickListener userClick = v -> PersonalHomeActivity.startTargetActivity(context, entity.getUser().getId(), entrance, path); + mAskUsericon.setOnClickListener(userClick); + mAskUsername.setOnClickListener(userClick); if (entity.getTime() != null && entity.getTime().getCreate() != 0) { mAskEndDesc.setText(NewsUtils.getFormattedTime(entity.getTime().getCreate())); } } + private void setAnswerImage( List images, List videos) { + if (videos.size() > 0) { + CommunityVideoEntity videoEntity = videos.get(0); + ImageUtils.display(mAskImg, videoEntity.getPoster()); + mVideoDuration.setBackground(DrawableView.getOvalDrawable(R.color.black_alpha_80, 999F)); + mVideoDuration.setText(videoEntity.getDuration()); + mVideoPlayIcon.setVisibility(View.VISIBLE); + mVideoDuration.setVisibility(View.VISIBLE); + mAskImg.setVisibility(View.VISIBLE); + } else if (images.size() > 0) { + mAskImg.setVisibility(View.VISIBLE); + ImageUtils.display(mAskImg, images.get(0)); + mVideoPlayIcon.setVisibility(View.GONE); + mVideoDuration.setVisibility(View.GONE); + } else { + mAskImg.setVisibility(View.GONE); + mVideoPlayIcon.setVisibility(View.GONE); + mVideoDuration.setVisibility(View.GONE); + } + } + } diff --git a/app/src/main/java/com/gh/gamecenter/room/AppDatabase.java b/app/src/main/java/com/gh/gamecenter/room/AppDatabase.java index 0abb2b685a..b44ce4aa2f 100644 --- a/app/src/main/java/com/gh/gamecenter/room/AppDatabase.java +++ b/app/src/main/java/com/gh/gamecenter/room/AppDatabase.java @@ -23,7 +23,11 @@ import com.gh.gamecenter.video.upload.UploadEntity; /** * Created by khy on 28/11/17. */ -@Database(entities = {LoginTokenEntity.class, UserInfoEntity.class, SignEntity.class, AnswerEntity.class, UploadEntity.class}, version = 10, exportSchema = false) +@Database(entities = {LoginTokenEntity.class, + UserInfoEntity.class, + SignEntity.class, + AnswerEntity.class, + UploadEntity.class}, version = 11, exportSchema = false) public abstract class AppDatabase extends RoomDatabase { public abstract AnswerDao answerDao(); @@ -107,6 +111,13 @@ public abstract class AppDatabase extends RoomDatabase { } }; + static final Migration MIGRATION_10_11 = new Migration(10, 11) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + database.execSQL("Alter TABLE ArticleEntity add videos TEXT"); + } + }; + private static AppDatabase buildDatabase(Context context) { return Room.databaseBuilder(context, AppDatabase.class, DATABASE_NAME) .addMigrations( @@ -116,7 +127,8 @@ public abstract class AppDatabase extends RoomDatabase { MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9, - MIGRATION_9_10) + MIGRATION_9_10, + MIGRATION_10_11) // 不允许主线程查询 .allowMainThreadQueries() // // 提供db升级的策略而不是强行销毁 diff --git a/app/src/main/java/com/gh/gamecenter/room/converter/CommunityVideoConverter.kt b/app/src/main/java/com/gh/gamecenter/room/converter/CommunityVideoConverter.kt new file mode 100644 index 0000000000..fa8bb29692 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/room/converter/CommunityVideoConverter.kt @@ -0,0 +1,19 @@ +package com.gh.gamecenter.room.converter + +import androidx.room.TypeConverter +import com.gh.common.util.toJson +import com.gh.common.util.toObject +import com.gh.gamecenter.qa.entity.CommunityVideoEntity + +class CommunityVideoConverter { + + @TypeConverter + fun toCommunityVideoString(data: List?): String { + return data?.toJson() ?: "" + } + + @TypeConverter + fun toCommunityVideoEntity(token: String?): List { + return token?.toObject() ?: arrayListOf() + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable-xxhdpi/community_video_play_icon.png b/app/src/main/res/drawable-xxhdpi/community_video_play_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..532d307ebc9a104de0aae22d446c249c2a92f893 GIT binary patch literal 3450 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 c0il%t0g5lK-(Zdr;M1& literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/ask_answer_item.xml b/app/src/main/res/layout/ask_answer_item.xml index f35535587c..ca2cd6ba68 100644 --- a/app/src/main/res/layout/ask_answer_item.xml +++ b/app/src/main/res/layout/ask_answer_item.xml @@ -1,132 +1,160 @@ - + + android:id="@+id/ask_answer_item_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="5dp" + android:ellipsize="end" + android:maxLines="2" + android:textColor="@color/black" + android:textSize="16sp" + android:textStyle="bold" + android:visibility="gone" + app:layout_constraintTop_toTopOf="parent" + app:layout_goneMarginTop="13dp" /> + android:id="@+id/ask_answer_item_usericon_container" + android:layout_width="22dp" + android:layout_height="22dp" + android:layout_marginTop="7dp" + app:layout_constraintLeft_toLeftOf="@id/ask_answer_item_constraintlayout" + app:layout_constraintTop_toBottomOf="@id/ask_answer_item_title"> + android:id="@+id/ask_answer_item_usericon" + style="@style/frescoCircleStyle" + android:layout_width="20dp" + android:layout_height="20dp" + fresco:roundAsCircle="true" /> + android:id="@+id/ask_answer_item_user_badge" + android:layout_width="10dp" + android:layout_height="10dp" + android:layout_alignParentRight="true" + android:layout_alignParentBottom="true" /> + android:id="@+id/ask_answer_item_username" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:layout_marginBottom="2dp" + android:maxLength="10" + android:textColor="@color/title" + android:textSize="14sp" + app:layout_constraintBottom_toBottomOf="@id/ask_answer_item_usericon_container" + app:layout_constraintLeft_toRightOf="@id/ask_answer_item_usericon_container" + app:layout_constraintTop_toTopOf="@id/ask_answer_item_usericon_container" /> + android:id="@+id/ask_answer_item_content" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="7dp" + android:ellipsize="end" + android:maxLines="3" + android:textColor="@color/title" + android:textSize="14sp" + app:layout_constraintTop_toBottomOf="@id/ask_answer_item_usericon_container" /> + android:id="@+id/ask_answer_item_img" + style="@style/frescoStyle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + app:layout_constraintTop_toBottomOf="@id/ask_answer_item_content" + app:viewAspectRatio="2.3" /> + + + + android:id="@+id/ask_answer_item_video_duration" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="8dp" + android:layout_marginBottom="8dp" + android:includeFontPadding="false" + android:paddingLeft="3dp" + android:paddingTop="4dp" + android:paddingRight="6dp" + android:paddingBottom="3dp" + android:textColor="@color/white" + android:textSize="12sp" + app:layout_constraintBottom_toBottomOf="@id/ask_answer_item_img" + app:layout_constraintRight_toRightOf="@id/ask_answer_item_img" /> + + + app:layout_constraintTop_toBottomOf="@id/ask_answer_item_img" /> + android:maxEms="15" + android:maxLines="1" + android:textColor="@color/hint" + android:textSize="11sp" + android:visibility="gone" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@id/ask_answer_item_img" /> + android:id="@+id/ask_answer_item_end_desc" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:singleLine="true" + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintRight_toRightOf="parent" + tools:text="末尾补充内容" /> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/ask_questions_hot_item.xml b/app/src/main/res/layout/ask_questions_hot_item.xml index 52e127ed45..99930d53ac 100644 --- a/app/src/main/res/layout/ask_questions_hot_item.xml +++ b/app/src/main/res/layout/ask_questions_hot_item.xml @@ -1,129 +1,156 @@ - + + android:id="@+id/ask_item_line" + android:layout_width="match_parent" + android:layout_height="@dimen/cutting_line" + android:background="@color/cutting_line" + android:visibility="gone" + app:layout_constraintTop_toTopOf="parent" /> + android:id="@+id/ask_item_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:background="?selectableItemBackground" + android:ellipsize="end" + android:maxLines="2" + android:textColor="@color/black" + android:textSize="16sp" + android:textStyle="bold" + app:layout_constraintTop_toBottomOf="@id/ask_item_line" + tools:text="本名李嘉恆,加拿大籍華人,出生於廣東省廣州" /> + android:id="@+id/ask_item_usericon_container" + android:layout_width="22dp" + android:layout_height="22dp" + android:layout_marginTop="5dp" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toBottomOf="@id/ask_item_title"> + android:id="@+id/ask_item_usericon" + style="@style/frescoCircleStyle" + android:layout_width="20dp" + android:layout_height="20dp" + fresco:roundAsCircle="true" /> - + android:id="@+id/ask_item_user_badge" + android:layout_width="10dp" + android:layout_height="10dp" + android:layout_alignParentRight="true" + android:layout_alignParentBottom="true" /> + + android:id="@+id/ask_item_username" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:layout_marginBottom="2dp" + android:maxLength="10" + android:textColor="@color/title" + android:textSize="14sp" + app:layout_constraintBottom_toBottomOf="@id/ask_item_usericon_container" + app:layout_constraintLeft_toRightOf="@id/ask_item_usericon_container" + app:layout_constraintTop_toTopOf="@id/ask_item_usericon_container" + tools:text="Kris Wu" /> + android:id="@+id/ask_item_content" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="5dp" + android:ellipsize="end" + android:maxLines="3" + android:textColor="@color/title" + android:textSize="14sp" + app:layout_constraintTop_toBottomOf="@id/ask_item_usericon_container" + tools:text="2012年在韓國出道,曾為韓國男子組合EXO成員及中國分隊EXO-M隊長。2014年解約回國後出演多部電影,開啟其演員生涯。2015年11月,發行首張中文單曲《Bad Girl》,開啟其個人歌手生涯。2016年11月,發行首張英文單曲《JULY》,正式開啟嘻哈音樂之路。" /> + android:id="@+id/ask_item_img" + style="@style/frescoStyle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + app:layout_constraintTop_toBottomOf="@id/ask_item_content" + app:viewAspectRatio="2.3" + fresco:roundedCornerRadius="4.5dp" /> + + + android:id="@+id/ask_item_video_duration" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="8dp" + android:layout_marginBottom="8dp" + android:includeFontPadding="false" + android:paddingLeft="6dp" + android:paddingTop="3dp" + android:paddingRight="6dp" + android:paddingBottom="3dp" + android:textSize="12sp" + android:textColor="@color/white" + app:layout_constraintBottom_toBottomOf="@id/ask_item_img" + app:layout_constraintRight_toRightOf="@id/ask_item_img" /> + android:id="@+id/ask_item_votecount" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toBottomOf="@id/ask_item_img" + tools:text="14" /> + android:id="@+id/ask_item_answercount" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_marginTop="10dp" + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintLeft_toRightOf="@id/ask_item_votecount" + app:layout_constraintTop_toBottomOf="@id/ask_item_img" + tools:text="16" /> - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/src/main/res/layout/ask_subject_item.xml b/app/src/main/res/layout/ask_subject_item.xml index f53a04d596..87e25f4f56 100644 --- a/app/src/main/res/layout/ask_subject_item.xml +++ b/app/src/main/res/layout/ask_subject_item.xml @@ -1,131 +1,161 @@ - + - + - + name="data" + type="com.gh.gamecenter.qa.entity.AnswerEntity" /> + - + + android:id="@+id/title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="7dp" + android:background="?selectableItemBackground" + android:ellipsize="end" + android:maxLines="2" + android:text="@{data.questions.title}" + android:textColor="@color/black" + android:textSize="16sp" + android:textStyle="bold" + app:layout_constraintTop_toTopOf="parent" /> + android:id="@+id/user_container" + android:layout_width="22dp" + android:layout_height="22dp" + android:layout_marginTop="7dp" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toBottomOf="@id/title"> + style="@style/frescoCircleStyle" + imageIcon="@{data.user.icon}" + android:layout_width="20dp" + android:layout_height="20dp" + fresco:roundAsCircle="true" /> - + imageIcon="@{data.user.auth.icon}" + android:layout_width="10dp" + android:layout_height="10dp" + android:layout_alignParentRight="true" + android:layout_alignParentBottom="true" /> + + android:id="@+id/user_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:layout_marginBottom="2dp" + android:maxLength="10" + android:text="@{data.user.name}" + android:textColor="@color/title" + android:textSize="14sp" + app:layout_constraintBottom_toBottomOf="@id/user_container" + app:layout_constraintLeft_toRightOf="@id/user_container" + app:layout_constraintTop_toTopOf="@id/user_container" /> + android:id="@+id/content" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="9dp" + android:ellipsize="end" + android:maxLines="3" + android:text="@{data.brief}" + android:textColor="@color/title" + android:textSize="14sp" + app:layout_constraintTop_toBottomOf="@id/user_container" /> + + android:id="@+id/image" + style="@style/frescoStyle" + setCommunityImage="@{data.images}" + setCommunityVideoImage="@{data.videos}" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + app:layout_constraintTop_toBottomOf="@id/content" + app:viewAspectRatio="2.3" /> + + + android:id="@+id/ask_item_video_duration" + setCommunityVideoDuration="@{data.videos}" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="8dp" + android:layout_marginBottom="8dp" + android:includeFontPadding="false" + android:paddingLeft="6dp" + android:paddingTop="3dp" + android:paddingRight="6dp" + android:paddingBottom="3dp" + android:textColor="@color/white" + android:textSize="12sp" + app:layout_constraintBottom_toBottomOf="@id/image" + app:layout_constraintRight_toRightOf="@id/image" /> + android:id="@+id/vote_count" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:text="@{data.vote + ` 赞同`}" + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toBottomOf="@id/image" /> + android:id="@+id/answer_count" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_marginTop="10dp" + android:text="@{data.commentCount + ` 评论`}" + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintLeft_toRightOf="@id/vote_count" + app:layout_constraintTop_toBottomOf="@id/image" /> - - + + + + diff --git a/app/src/main/res/layout/community_article_item.xml b/app/src/main/res/layout/community_article_item.xml index fceb3ef8d5..4db9e40a39 100644 --- a/app/src/main/res/layout/community_article_item.xml +++ b/app/src/main/res/layout/community_article_item.xml @@ -1,95 +1,127 @@ - + - + - + name="data" + type="com.gh.gamecenter.qa.entity.ArticleEntity" /> + - + + android:id="@+id/article_item_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:ellipsize="end" + android:maxLines="2" + android:text="@{data.title}" + android:textColor="@color/black" + android:textSize="16sp" + android:textStyle="bold" + android:visibility="visible" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + android:id="@+id/article_item_content" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="7dp" + android:ellipsize="end" + android:maxLines="3" + android:text="@{data.brief}" + android:textColor="@color/title" + android:textSize="14sp" + app:layout_constraintTop_toBottomOf="@id/article_item_title" /> + + android:id="@+id/article_item_img" + style="@style/frescoStyle" + setCommunityImage="@{data.images}" + setCommunityVideoImage="@{data.videos}" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + app:layout_constraintTop_toBottomOf="@id/article_item_content" + app:viewAspectRatio="2.3" /> + + + + + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toBottomOf="@id/article_item_img" /> + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintLeft_toRightOf="@id/article_item_vote_count" + app:layout_constraintTop_toBottomOf="@id/article_item_img" /> + android:textColor="@color/hint" + android:textSize="11sp" + android:visibility="visible" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@id/article_item_img" /> - - + + diff --git a/app/src/main/res/layout/personal_home_item.xml b/app/src/main/res/layout/personal_home_item.xml index f791b5f218..e73768bf98 100644 --- a/app/src/main/res/layout/personal_home_item.xml +++ b/app/src/main/res/layout/personal_home_item.xml @@ -1,187 +1,216 @@ - + - + - + - + + name="entity" + type="com.gh.gamecenter.entity.PersonalHistoryEntity" /> - + + android:id="@+id/constraint_layout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@drawable/reuse_listview_item_style" + android:paddingLeft="20dp" + android:paddingTop="5dp" + android:paddingRight="20dp" + android:paddingBottom="10dp"> + android:id="@+id/question_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="5dp" + android:background="?selectableItemBackground" + android:ellipsize="end" + android:maxLines="2" + android:text="@{(entity.type.contains(`question`) || entity.type.contains(`article`))?entity.title:entity.question.title}" + android:textColor="@color/black" + android:textSize="16sp" + android:textStyle="bold" + app:layout_constraintTop_toTopOf="parent" + tools:text="我光环丧堃怕过谁?" /> + android:id="@+id/user_icon_container" + android:layout_width="22dp" + android:layout_height="22dp" + android:layout_marginTop="7dp" + app:layout_constraintLeft_toLeftOf="@id/question_title" + app:layout_constraintTop_toBottomOf="@id/question_title"> + android:id="@+id/user_icon" + style="@style/frescoCircleStyle" + imageUrl="@{entity.user.icon}" + android:layout_width="20dp" + android:layout_height="20dp" + fresco:roundAsCircle="true" /> - + android:id="@+id/user_auth_icon" + imageUrl="@{entity.user.auth.icon}" + visibleGone="@{entity.user.auth == null? false: true}" + android:layout_width="10dp" + android:layout_height="10dp" + android:layout_alignParentRight="true" + android:layout_alignParentBottom="true" /> + + android:id="@+id/user_name" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="2dp" + android:paddingLeft="5dp" + android:textColor="@color/black" + android:textSize="13sp" + app:layout_constraintBottom_toBottomOf="@id/user_icon_container" + app:layout_constraintLeft_toRightOf="@id/user_icon_container" + app:layout_constraintTop_toTopOf="@id/user_icon_container" + tools:text="光环丧堃" /> + android:id="@+id/user_desc" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="@color/theme" + android:textSize="13sp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="@id/user_name" + app:layout_constraintLeft_toRightOf="@id/user_name" + app:layout_constraintTop_toTopOf="@id/user_name" + tools:text="等3人" + tools:visibility="visible" /> + android:id="@+id/user_command" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="12dp" + android:layout_marginBottom="2dp" + android:singleLine="true" + android:textColor="@color/hint" + android:textSize="13sp" + app:layout_constraintBottom_toBottomOf="@id/user_icon_container" + app:layout_constraintLeft_toRightOf="@id/user_desc" + app:layout_constraintTop_toTopOf="@id/user_icon_container" + tools:text="2018-10-11 发布了回答" /> + android:id="@+id/answer_content" + visibleGone="@{TextUtils.isEmpty(entity.brief)?false:true}" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="7dp" + android:ellipsize="end" + android:maxLines="3" + android:text="@{entity.brief}" + android:textColor="@color/title" + android:textSize="14sp" + app:layout_constraintTop_toBottomOf="@id/user_icon_container" + tools:text="1. 正文第5点,内容样式优化:头像右边要显示昵称,然后把时间放到右下角2. 增加过滤规则:只显示当前社区的内容,且不显示自己对自己的点赞3. 内容折叠规则:" /> + android:id="@+id/answer_image" + style="@style/frescoStyle" + setCommunityImage="@{entity.images}" + setCommunityVideoImage="@{entity.videos}" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + app:layout_constraintTop_toBottomOf="@id/answer_content" + app:viewAspectRatio="2.3" /> + + + android:id="@+id/ask_item_video_duration" + setCommunityVideoDuration="@{entity.videos}" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="8dp" + android:layout_marginBottom="8dp" + android:includeFontPadding="false" + android:paddingLeft="6dp" + android:paddingTop="3dp" + android:paddingRight="6dp" + android:paddingBottom="3dp" + android:textColor="@color/white" + android:textSize="12sp" + app:layout_constraintBottom_toBottomOf="@id/answer_image" + app:layout_constraintRight_toRightOf="@id/answer_image" /> + android:id="@+id/answer_vote_count" + visibleGone="@{entity.count.vote != -1}" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:text="@{NumberUtils.transSimpleCount(entity.count.vote) + ` 赞同`}" + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toBottomOf="@id/answer_image" + tools:text="0赞" /> + android:id="@+id/answer_comment_count" + visibleGone="@{entity.count.comment != -1}" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="10dp" + android:layout_marginTop="10dp" + android:text="@{entity.count.comment + ` 评论`}" + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintLeft_toRightOf="@id/answer_vote_count" + app:layout_constraintTop_toBottomOf="@id/answer_image" + tools:text="0评论" /> + android:id="@+id/answer_answer_count" + visibleGone="@{entity.count.answer != -1}" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:text="@{NumberUtils.transSimpleCount(entity.count.answer) + ` 回答`}" + android:textColor="@color/hint" + android:textSize="11sp" + app:layout_constraintLeft_toRightOf="@id/answer_comment_count" + app:layout_constraintTop_toBottomOf="@id/answer_image" + tools:text="0回答" /> - - + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 3332078393..738d9fbe08 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -76,6 +76,7 @@ #ecfaff @android:color/black + #80000000 @android:color/white #b3b3b3