Show subreddit name and icon and username in ViewRPANBroadcastFragment.

This commit is contained in:
Alex Ning 2021-07-08 12:54:41 +08:00
parent 61d907308c
commit 231f3b6b09
2 changed files with 65 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -21,6 +22,8 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
@ -48,6 +51,7 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RPANBroadcast; import ml.docilealligator.infinityforreddit.RPANBroadcast;
@ -71,6 +75,12 @@ public class ViewRPANBroadcastFragment extends Fragment {
ConstraintLayout constraintLayout; ConstraintLayout constraintLayout;
@BindView(R.id.player_view_view_rpan_broadcast_fragment) @BindView(R.id.player_view_view_rpan_broadcast_fragment)
PlayerView playerView; PlayerView playerView;
@BindView(R.id.subreddit_icon_image_view_exo_rpan_broadcast_playback_control_view)
ImageView subredditIconImageView;
@BindView(R.id.subreddit_name_text_view_exo_rpan_broadcast_playback_control_view)
TextView subredditNameTextView;
@BindView(R.id.username_text_view_exo_rpan_broadcast_playback_control_view)
TextView usernameTextView;
@BindView(R.id.title_text_view_exo_rpan_broadcast_playback_control_view) @BindView(R.id.title_text_view_exo_rpan_broadcast_playback_control_view)
TextView titleTextView; TextView titleTextView;
@BindView(R.id.recycler_view_exo_rpan_broadcast_playback_control_view) @BindView(R.id.recycler_view_exo_rpan_broadcast_playback_control_view)
@ -229,6 +239,13 @@ public class ViewRPANBroadcastFragment extends Fragment {
} }
}); });
Glide.with(mActivity).load(rpanBroadcast.rpanPost.subredditIconUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(Glide.with(mActivity).load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
.into(subredditIconImageView);
subredditNameTextView.setText(rpanBroadcast.rpanPost.subredditName);
usernameTextView.setText(rpanBroadcast.rpanPost.username);
titleTextView.setText(rpanBroadcast.rpanPost.title); titleTextView.setText(rpanBroadcast.rpanPost.title);
recyclerView.setOnTouchListener(new View.OnTouchListener() { recyclerView.setOnTouchListener(new View.OnTouchListener() {

View File

@ -7,6 +7,54 @@
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintBottom_toTopOf="@id/title_text_view_exo_rpan_broadcast_playback_control_view"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1">
<ImageView
android:id="@+id/subreddit_icon_image_view_exo_rpan_broadcast_playback_control_view"
android:layout_width="24dp"
android:layout_height="24dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/subreddit_name_text_view_exo_rpan_broadcast_playback_control_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="@color/colorAccent"
app:layout_constraintBottom_toTopOf="@id/username_text_view_exo_rpan_broadcast_playback_control_view"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/barrier5" />
<TextView
android:id="@+id/username_text_view_exo_rpan_broadcast_playback_control_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="#02BAEE"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/barrier5" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="end"
app:constraint_referenced_ids="subreddit_icon_image_view_exo_rpan_broadcast_playback_control_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView <TextView
android:id="@+id/title_text_view_exo_rpan_broadcast_playback_control_view" android:id="@+id/title_text_view_exo_rpan_broadcast_playback_control_view"
android:layout_width="match_parent" android:layout_width="match_parent"