fix: 修复贴中数字无法显示

This commit is contained in:
HuanChengFly 2020-08-20 15:55:09 +08:00
parent 3345d30894
commit 9e50d48999
3 changed files with 53 additions and 86 deletions

View File

@ -17,34 +17,43 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.request.RequestOptions;
import com.huanchengfly.tieba.post.R;
import com.huanchengfly.tieba.post.activities.BaseActivity;
import com.huanchengfly.tieba.post.activities.ReplyActivity;
import com.huanchengfly.tieba.post.api.TiebaApi;
import com.huanchengfly.tieba.post.api.models.CommonResponse;
import com.huanchengfly.tieba.post.api.models.SubFloorListBean;
import com.huanchengfly.tieba.post.api.models.ThreadContentBean;
import com.huanchengfly.tieba.post.R;
import com.huanchengfly.tieba.post.activities.ReplyActivity;
import com.huanchengfly.tieba.post.activities.BaseActivity;
import com.huanchengfly.tieba.post.components.spans.MyURLSpan;
import com.huanchengfly.tieba.post.components.spans.MyUserSpan;
import com.huanchengfly.tieba.post.fragments.ConfirmDialogFragment;
import com.huanchengfly.tieba.post.fragments.MenuDialogFragment;
import com.huanchengfly.tieba.post.models.PhotoViewBean;
import com.huanchengfly.tieba.post.models.ReplyInfoBean;
import com.huanchengfly.tieba.post.utils.*;
import com.huanchengfly.tieba.post.utils.AccountUtil;
import com.huanchengfly.tieba.post.utils.EmotionUtil;
import com.huanchengfly.tieba.post.utils.ImageUtil;
import com.huanchengfly.tieba.post.utils.NavigationHelper;
import com.huanchengfly.tieba.post.utils.StringUtil;
import com.huanchengfly.tieba.post.utils.ThemeUtil;
import com.huanchengfly.tieba.post.utils.Util;
import com.huanchengfly.tieba.post.widgets.MyLinearLayout;
import com.huanchengfly.tieba.post.widgets.VoicePlayerView;
import com.huanchengfly.tieba.post.widgets.theme.TintTextView;
import com.othershe.baseadapter.ViewHolder;
import com.othershe.baseadapter.base.CommonBaseAdapter;
import org.jetbrains.annotations.NotNull;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RecyclerFloorAdapter extends CommonBaseAdapter<SubFloorListBean.PostInfo> {
public static final String TAG = "RecyclerFloorAdapter";
private static final int TEXT_VIEW_TYPE_CONTENT = 0;
@ -331,7 +340,8 @@ public class RecyclerFloorAdapter extends CommonBaseAdapter<SubFloorListBean.Pos
List<View> views = new ArrayList<>();
for (ThreadContentBean.ContentBean contentBean : postListItemBean.getContent()) {
switch (contentBean.getType()) {
case "0": {
case "0":
case "9": {
if (appendTextToLastTextView(views, contentBean.getText())) {
TextView textView = createTextView(TEXT_VIEW_TYPE_CONTENT);
textView.setLayoutParams(getLayoutParams(contentBean));

View File

@ -12,19 +12,24 @@ import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import com.allen.library.SuperTextView;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
import com.huanchengfly.tieba.post.BaseApplication;
import com.huanchengfly.tieba.post.R;
import com.huanchengfly.tieba.post.activities.BaseActivity;
import com.huanchengfly.tieba.post.activities.ReplyActivity;
import com.huanchengfly.tieba.post.api.TiebaApi;
import com.huanchengfly.tieba.post.api.models.CommonResponse;
import com.huanchengfly.tieba.post.api.models.ThreadContentBean;
import com.huanchengfly.tieba.post.BaseApplication;
import com.huanchengfly.tieba.post.R;
import com.huanchengfly.tieba.post.activities.ReplyActivity;
import com.huanchengfly.tieba.post.activities.BaseActivity;
import com.huanchengfly.tieba.post.components.spans.MyImageSpan;
import com.huanchengfly.tieba.post.components.spans.MyURLSpan;
import com.huanchengfly.tieba.post.components.spans.MyUserSpan;
@ -34,21 +39,36 @@ import com.huanchengfly.tieba.post.fragments.FloorFragment;
import com.huanchengfly.tieba.post.fragments.MenuDialogFragment;
import com.huanchengfly.tieba.post.models.PhotoViewBean;
import com.huanchengfly.tieba.post.models.ReplyInfoBean;
import com.huanchengfly.tieba.post.utils.*;
import com.huanchengfly.tieba.post.widgets.MyLinearLayout;
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
import com.huanchengfly.tieba.post.utils.AccountUtil;
import com.huanchengfly.tieba.post.utils.BlockUtil;
import com.huanchengfly.tieba.post.utils.DisplayUtil;
import com.huanchengfly.tieba.post.utils.EmotionUtil;
import com.huanchengfly.tieba.post.utils.ImageUtil;
import com.huanchengfly.tieba.post.utils.NavigationHelper;
import com.huanchengfly.tieba.post.utils.StringUtil;
import com.huanchengfly.tieba.post.utils.ThemeUtil;
import com.huanchengfly.tieba.post.utils.Util;
import com.huanchengfly.tieba.post.widgets.MyImageView;
import com.huanchengfly.tieba.post.widgets.MyLinearLayout;
import com.huanchengfly.tieba.post.widgets.VideoPlayerStandard;
import com.huanchengfly.tieba.post.widgets.VoicePlayerView;
import com.huanchengfly.tieba.post.widgets.theme.TintTextView;
import com.othershe.baseadapter.ViewHolder;
import com.othershe.baseadapter.base.MultiBaseAdapter;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import java.util.*;
import static com.huanchengfly.tieba.post.activities.PhotoViewActivity.OBJ_TYPE_THREAD_PAGE;
import static com.huanchengfly.tieba.post.utils.Util.alphaColor;
@ -300,6 +320,7 @@ public class RecyclerThreadAdapter extends MultiBaseAdapter<ThreadContentBean.Po
builder.append(emojiText);
break;
case "4":
case "9":
builder.append(contentBean.getText());
break;
default:
@ -761,7 +782,8 @@ public class RecyclerThreadAdapter extends MultiBaseAdapter<ThreadContentBean.Po
List<View> views = new ArrayList<>();
for (ThreadContentBean.ContentBean contentBean : postListItemBean.getContent()) {
switch (contentBean.getType()) {
case "0": {
case "0":
case "9": {
if (appendTextToLastTextView(views, contentBean.getText())) {
TextView textView = createTextView(TEXT_VIEW_TYPE_CONTENT);
textView.setLayoutParams(getLayoutParams(contentBean, postListItemBean.getFloor()));

View File

@ -34,12 +34,12 @@ import androidx.appcompat.widget.AppCompatDrawableManager;
import com.google.android.material.snackbar.Snackbar;
import com.gyf.immersionbar.OSUtils;
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
import com.huanchengfly.tieba.post.R;
import com.huanchengfly.tieba.post.BundleConfig;
import com.huanchengfly.tieba.post.IntentConfig;
import com.huanchengfly.tieba.post.R;
import com.huanchengfly.tieba.post.components.dialogs.CopyTextDialog;
import com.huanchengfly.tieba.post.fragments.MenuDialogFragment;
import com.huanchengfly.tieba.post.ui.theme.utils.ThemeUtils;
import java.lang.reflect.Field;
import java.util.ArrayList;
@ -238,71 +238,6 @@ public class Util {
return greifyColor(color, 0.25f);
}
/*
@DrawableRes
public static int getLevelIconRes(String levelStr) {
int drawable = -1;
if (levelStr == null) return drawable;
switch (levelStr) {
case "1":
drawable = R.drawable.level_1;
break;
case "2":
drawable = R.drawable.level_2;
break;
case "3":
drawable = R.drawable.level_3;
break;
case "4":
drawable = R.drawable.level_4;
break;
case "5":
drawable = R.drawable.level_5;
break;
case "6":
drawable = R.drawable.level_6;
break;
case "7":
drawable = R.drawable.level_7;
break;
case "8":
drawable = R.drawable.level_8;
break;
case "9":
drawable = R.drawable.level_9;
break;
case "10":
drawable = R.drawable.level_10;
break;
case "11":
drawable = R.drawable.level_11;
break;
case "12":
drawable = R.drawable.level_12;
break;
case "13":
drawable = R.drawable.level_13;
break;
case "14":
drawable = R.drawable.level_14;
break;
case "15":
drawable = R.drawable.level_15;
break;
case "16":
drawable = R.drawable.level_16;
break;
case "17":
drawable = R.drawable.level_17;
break;
case "18":
drawable = R.drawable.level_18;
break;
}
return drawable;
}
*/
public static @ColorInt
int getColorByAttr(Context context, @AttrRes int attr, @ColorRes int defaultColor) {
int[] attrs = new int[]{attr};