Skip to content

Commit

Permalink
Rewrite details row with constraint layout
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Jul 7, 2024
1 parent 19bfaa6 commit eacbfe7
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,6 @@ protected MyDetailsOverviewRow doInBackground(BaseItemDto... params) {
String primaryImageUrl = imageHelper.getValue().getLogoImageUrl(mBaseItem, 600, true);
if (primaryImageUrl == null) {
primaryImageUrl = imageHelper.getValue().getPrimaryImageUrl(mBaseItem, false, null, posterHeight);
if (item.getRunTimeTicks() != null && item.getRunTimeTicks() > 0 && item.getUserData() != null && item.getUserData().getPlaybackPositionTicks() > 0)
mDetailsOverviewRow.setProgress(((int) (item.getUserData().getPlaybackPositionTicks() * 100.0 / item.getRunTimeTicks())));
}

mDetailsOverviewRow.setSummary(item.getOverview());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

Expand Down Expand Up @@ -116,12 +115,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
mItemList = binding.songs;
mScrollView = binding.scrollView;

//adjust left frame
RelativeLayout leftFrame = detailsBinding.leftFrame;
ViewGroup.LayoutParams params = leftFrame.getLayoutParams();
params.width = Utils.convertDpToPixel(requireContext(), 100);


mMetrics = new DisplayMetrics();
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
mBottomScrollThreshold = (int) (mMetrics.heightPixels * .6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.RelativeLayout;
import android.widget.ScrollView;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -76,11 +75,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
mItemList = binding.songs;
mScrollView = binding.scrollView;

//adjust left frame
RelativeLayout leftFrame = detailsBinding.leftFrame;
ViewGroup.LayoutParams params = leftFrame.getLayoutParams();
params.width = Utils.convertDpToPixel(requireContext(), 100);

mMetrics = new DisplayMetrics();
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
mBottomScrollThreshold = (int) (mMetrics.heightPixels * .6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class MyDetailsOverviewRow @JvmOverloads constructor(
val item: BaseItemDto,
var imageDrawable: String? = null,
var summary: String? = null,
var progress: Int = 0,
var infoItem1: InfoItem? = null,
var infoItem2: InfoItem? = null,
var infoItem3: InfoItem? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package org.jellyfin.androidtv.ui.presentation

import android.view.ViewGroup
import android.widget.RelativeLayout
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.leanback.widget.RowPresenter
import org.jellyfin.androidtv.ui.DetailRowView
import org.jellyfin.androidtv.ui.itemdetail.MyDetailsOverviewRow
import org.jellyfin.androidtv.util.InfoLayoutHelper
import org.jellyfin.androidtv.util.MarkdownRenderer
import org.jellyfin.androidtv.util.dp
import org.jellyfin.sdk.model.api.BaseItemKind

class MyDetailsOverviewRowPresenter(
Expand Down Expand Up @@ -38,24 +35,11 @@ class MyDetailsOverviewRowPresenter(

binding.mainImage.load(row.imageDrawable, null, null, 1.0, 0)

if (row.progress > 0 && row.imageDrawable != null) {
binding.fdProgress.progress = row.progress
binding.fdProgress.isVisible = true
}

setSummary(row.summary)

if (row.item.type == BaseItemKind.PERSON) {
binding.fdSummaryText.updateLayoutParams<RelativeLayout.LayoutParams> {
topMargin = 10
height = 185.dp(view.context)
}

binding.fdSummaryText.maxLines = 9
binding.fdGenreRow.isVisible = false
binding.leftFrame.updateLayoutParams<RelativeLayout.LayoutParams> {
width = 100.dp(view.context)
}
}

binding.fdButtonRow.removeAllViews()
Expand All @@ -69,11 +53,6 @@ class MyDetailsOverviewRowPresenter(

fun setTitle(title: String?) {
binding.fdTitle.text = title
if (binding.fdTitle.text.length > 28) {
binding.fdTitle.updateLayoutParams<RelativeLayout.LayoutParams> {
topMargin = 55.dp(view.context)
}
}
}

fun setSummary(summary: String?) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/drawable/expanded_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true">
<shape android:shape="rectangle">
<corners android:radius="?attr/cardRounding" />
<solid android:color="@color/black_transparent" />
</shape>
</item>
Expand Down
Loading

0 comments on commit eacbfe7

Please sign in to comment.