Skip to content

Commit

Permalink
update film empty field
Browse files Browse the repository at this point in the history
  • Loading branch information
youlookwhat committed Aug 25, 2020
1 parent 0232c8b commit 18e8fc3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

import android.app.Activity;
import android.content.Intent;

import androidx.databinding.ObservableField;

import android.os.Bundle;

import androidx.core.app.ActivityCompat;
import androidx.core.app.ActivityOptionsCompat;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
Expand All @@ -20,9 +24,12 @@
import com.example.jingbin.cloudreader.databinding.ActivityFilmDetailBinding;
import com.example.jingbin.cloudreader.databinding.HeaderFilmDetailBinding;
import com.example.jingbin.cloudreader.http.HttpClient;

import me.jingbin.bymvvm.rxbus.RxBus;

import com.example.jingbin.cloudreader.app.RxCodeConstants;
import com.example.jingbin.cloudreader.utils.CommonUtils;
import com.example.jingbin.cloudreader.utils.DataUtil;
import com.example.jingbin.cloudreader.utils.DensityUtil;
import com.example.jingbin.cloudreader.utils.ToastUtil;
import com.example.jingbin.cloudreader.ui.WebViewActivity;
Expand Down Expand Up @@ -155,10 +162,20 @@ public void onNext(final FilmDetailBean bean) {
private void transformData(final FilmDetailBean bean) {
if (bean.getData().getBasic().getActors() != null && bean.getData().getBasic().getActors().size() > 0) {
isShowActor.set(true);
// 即将上映缺失填充
String cast = bindingHeaderView.tvOneCasts.getText().toString();
if (TextUtils.isEmpty(cast)) {
bindingHeaderView.tvOneCasts.setText(DataUtil.getActorString(bean.getData().getBasic().getActors()));
}
FilmDetailBean.ActorsBean director = bean.getData().getBasic().getDirector();
if (director != null) {
director.setRoleName("导演");
bean.getData().getBasic().getActors().add(0, director);
// 即将上映缺失填充
String name = bindingHeaderView.tvOneDirectors.getText().toString();
if (TextUtils.isEmpty(name)) {
bindingHeaderView.tvOneDirectors.setText(director.getName());
}
}
setAdapter(bean.getData().getBasic().getActors());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.example.jingbin.cloudreader.R;
import com.example.jingbin.cloudreader.bean.AndroidBean;
import com.example.jingbin.cloudreader.bean.FilmDetailBean;
import com.example.jingbin.cloudreader.bean.GankIoDataBean;
import com.example.jingbin.cloudreader.bean.wanandroid.TreeBean;
import com.example.jingbin.cloudreader.http.cache.ACache;
Expand Down Expand Up @@ -177,4 +178,29 @@ public static void putTreeData(Context context, TreeBean treeBean) {
public static TreeBean getTreeData(Context context) {
return (TreeBean) ACache.get(context).getAsObject("TreeBean");
}

/**
* 详情内演员字段
*/
public static String getActorString(List<FilmDetailBean.ActorsBean> beans) {
StringBuilder text = new StringBuilder();
int i = 0;
if (beans != null) {
for (FilmDetailBean.ActorsBean bean : beans) {
if (i == 4) {
break;
}
String name = bean.getName();
if (!TextUtils.isEmpty(name)) {
i++;
text.append(" / ").append(name);
}
}
}
String toString = text.toString();
if (toString.contains(" / ")) {
toString = toString.substring(3);
}
return toString;
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/header_film_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="4"
android:text="@{subjectsBean.actors}"
android:textColor="@color/colorWhite" />

Expand Down

0 comments on commit 18e8fc3

Please sign in to comment.