Skip to content

Commit

Permalink
优化布局显示
Browse files Browse the repository at this point in the history
  • Loading branch information
HanteIsHante committed May 9, 2017
1 parent 45a72a6 commit c51f167
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.hante.thirdopen.R;
import com.example.hante.thirdopen.mvp.douban.bean.DouBanInTheaters;

Expand Down Expand Up @@ -44,6 +46,7 @@ public void onBindViewHolder(DouBanViewHolder holder, int position) {
holder.mTitle.setText(subjectsBean.getTitle());
holder.mContent.setText(subjectsBean.getGenres().toString());
holder.mAverage.setText(String.valueOf(subjectsBean.getRating().getAverage()));
Glide.with(mContext).load(subjectsBean.getImages().getLarge()).into(holder.mMoviePhoto);
holder.mPhotoItem.setAdapter(new DouBanPhotoItemAdapter(mContext, subjectsBean.getCasts()));
}

Expand All @@ -66,6 +69,7 @@ class DouBanViewHolder extends RecyclerView.ViewHolder {
private TextView mTitle;
private TextView mContent;
private RecyclerView mPhotoItem;
private ImageView mMoviePhoto;
private TextView mAverage;

DouBanViewHolder(View itemView) {
Expand All @@ -74,6 +78,7 @@ class DouBanViewHolder extends RecyclerView.ViewHolder {
mContent = (TextView) itemView.findViewById(R.id.movie_content);
mAverage = (TextView) itemView.findViewById(R.id.average);
mPhotoItem = (RecyclerView) itemView.findViewById(R.id.start_name_list);
mMoviePhoto = (ImageView)itemView.findViewById(R.id.movie_photo);
LinearLayoutManager lm = new LinearLayoutManager(mContext);
lm.setOrientation(LinearLayoutManager.HORIZONTAL);
mPhotoItem.setLayoutManager(lm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public void onBindViewHolder(DouBanPhotoViewHolder holder, int position) {
DouBanInTheaters.SubjectsBean.CastsBean castsBean = castsBeanList.get(position);
holder.mName.setText(castsBean.getName());
if (castsBean.getAvatars() != null) {
String medium = castsBean.getAvatars().getMedium();
String medium = castsBean.getAvatars().getLarge();
if ( medium != null && !"".equalsIgnoreCase(medium)) {
Glide.with(mContext)
.load(castsBean.getAvatars().getMedium())
.load(castsBean.getAvatars().getLarge())
.error(mContext.getResources().getDrawable(R.mipmap.nocover))
.into(holder.mPhoto);
}
Expand Down
37 changes: 31 additions & 6 deletions app/src/main/res/layout/douban_movies_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
android:id="@+id/start_name_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="11dp"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="@+id/movie_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/movie_content"
tools:ignore="RtlHardcoded" />
tools:ignore="RtlHardcoded"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="@+id/textView2"
android:layout_marginTop="12dp"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintHorizontal_bias="0.0" />

<TextView
android:id="@+id/textView"
Expand All @@ -73,4 +73,29 @@
app:layout_constraintLeft_toRightOf="@+id/textView"
app:layout_constraintTop_toTopOf="@+id/textView"
tools:ignore="HardcodedText,RtlHardcoded" />

<ImageView
android:id="@+id/movie_photo"
android:layout_width="120dp"
android:layout_height="180dp"
android:layout_marginLeft="0dp"
android:layout_marginTop="10dp"
android:scaleType="fitCenter"
app:layout_constraintLeft_toLeftOf="@+id/movie_content"
app:layout_constraintTop_toBottomOf="@+id/movie_content"
app:srcCompat="@mipmap/nocover"
tools:ignore="ContentDescription,RtlHardcoded" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="20dp"
android:text="演员表:"
android:textSize="16sp"
android:textStyle="italic"
app:layout_constraintLeft_toLeftOf="@+id/movie_photo"
app:layout_constraintTop_toBottomOf="@+id/movie_photo"
tools:ignore="HardcodedText,RtlHardcoded" />
</android.support.constraint.ConstraintLayout>

0 comments on commit c51f167

Please sign in to comment.