Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Live TV popups #3733

Merged
merged 2 commits into from
Jul 8, 2024
Merged

Conversation

nielsvanvelzen
Copy link
Member

Changes

  • Use context instead of activity reference
  • Use LayoutInflator via context
  • Set LifecycleOwner in LiveProgramDetailPoup because Compose requires that (and we use Compose via the info row)

Issues

Partially addresses #3732. Need to figure out a way to get actual guide data to test further....

@nielsvanvelzen nielsvanvelzen added bug Something isn't working live-tv Issue related to the live TV feature crash Bug causing app crashes labels Jul 8, 2024
@nielsvanvelzen nielsvanvelzen added this to the v0.17.0 milestone Jul 8, 2024
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.program_detail_popup, null);
int popupHeight = Utils.convertDpToPixel(activity, 400);
View layout = LayoutInflater.from(context).inflate(R.layout.program_detail_popup, null);

Check warning

Code scanning / Android Lint

Layout Inflation without a Parent Warning

Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element)
LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.new_program_record_popup, null);
int popupHeight = Utils.convertDpToPixel(activity, 330);
View layout = LayoutInflater.from(context).inflate(R.layout.new_program_record_popup, null);

Check warning

Code scanning / Android Lint

Layout Inflation without a Parent Warning

Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element)
TextView datetime = new TextView(mActivity);
datetime.setText(TimeUtils.getFriendlyDate(context, local)+ " @ "+android.text.format.DateFormat.getTimeFormat(mActivity).format(local)+ " ("+ DateUtils.getRelativeTimeSpanString(local.getTime())+")");
TextView datetime = new TextView(mContext);
datetime.setText(TimeUtils.getFriendlyDate(context, local)+ " @ "+android.text.format.DateFormat.getTimeFormat(mContext).format(local)+ " ("+ DateUtils.getRelativeTimeSpanString(local.getTime())+")");

Check warning

Code scanning / Android Lint

TextView Internationalization Warning

Do not concatenate text displayed with setText. Use resource string with placeholders.
TextView datetime = new TextView(activity);
datetime.setText(TimeUtils.getFriendlyDate(activity, local)+ " @ "+android.text.format.DateFormat.getTimeFormat(activity).format(local)+ " ("+ DateUtils.getRelativeTimeSpanString(local.getTime())+")");
TextView datetime = new TextView(context);
datetime.setText(TimeUtils.getFriendlyDate(context, local)+ " @ "+android.text.format.DateFormat.getTimeFormat(context).format(local)+ " ("+ DateUtils.getRelativeTimeSpanString(local.getTime())+")");

Check warning

Code scanning / Android Lint

TextView Internationalization Warning

Do not concatenate text displayed with setText. Use resource string with placeholders.
public LiveProgramDetailPopup(Activity activity, Lifecycle lifecycle, LiveTvGuide tvGuide, int width, EmptyLifecycleAwareResponse tuneAction) {
mActivity = activity;
this.lifecycle = lifecycle;
public LiveProgramDetailPopup(Context context, LifecycleOwner lifecycleOwner, LiveTvGuide tvGuide, int width, EmptyLifecycleAwareResponse tuneAction) {

Check warning

Code scanning / Android Lint

Lambda Parameters Last Warning

Functional interface parameters (such as parameter 2, "lifecycleOwner", in org.jellyfin.androidtv.ui.LiveProgramDetailPopup.LiveProgramDetailPopup) should be last to improve Kotlin interoperability; see https://kotlinlang.org/docs/reference/java-interop.html#sam-conversions
@@ -68,36 +67,35 @@

private Lazy<CustomMessageRepository> customMessageRepository = inject(CustomMessageRepository.class);

public RecordPopup(Activity activity, Lifecycle lifecycle, View anchorView, int left, int top, int width) {
mActivity = activity;
public RecordPopup(Context context, Lifecycle lifecycle, View anchorView, int left, int top, int width) {

Check notice

Code scanning / Android Lint

Unknown nullness Note

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations
@@ -68,36 +67,35 @@

private Lazy<CustomMessageRepository> customMessageRepository = inject(CustomMessageRepository.class);

public RecordPopup(Activity activity, Lifecycle lifecycle, View anchorView, int left, int top, int width) {
mActivity = activity;
public RecordPopup(Context context, Lifecycle lifecycle, View anchorView, int left, int top, int width) {

Check notice

Code scanning / Android Lint

Unknown nullness Note

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations
@@ -186,19 +185,19 @@
return !mProgramsDict.containsKey(channelId) ? new ArrayList<BaseItemDto>() : mProgramsDict.get(channelId);
}

public static void setTimelineRow(Activity activity, LinearLayout timelineRow, BaseItemDto program) {
public static void setTimelineRow(Context context, LinearLayout timelineRow, BaseItemDto program) {

Check notice

Code scanning / Android Lint

Unknown nullness Note

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations
@@ -186,19 +185,19 @@
return !mProgramsDict.containsKey(channelId) ? new ArrayList<BaseItemDto>() : mProgramsDict.get(channelId);
}

public static void setTimelineRow(Activity activity, LinearLayout timelineRow, BaseItemDto program) {
public static void setTimelineRow(Context context, LinearLayout timelineRow, BaseItemDto program) {

Check notice

Code scanning / Android Lint

Unknown nullness Note

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations
@@ -186,19 +185,19 @@
return !mProgramsDict.containsKey(channelId) ? new ArrayList<BaseItemDto>() : mProgramsDict.get(channelId);
}

public static void setTimelineRow(Activity activity, LinearLayout timelineRow, BaseItemDto program) {
public static void setTimelineRow(Context context, LinearLayout timelineRow, BaseItemDto program) {

Check notice

Code scanning / Android Lint

Unknown nullness Note

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations
@nielsvanvelzen nielsvanvelzen merged commit 8e0a184 into jellyfin:master Jul 8, 2024
5 checks passed
@nielsvanvelzen nielsvanvelzen deleted the livetv-popups branch July 8, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash Bug causing app crashes live-tv Issue related to the live TV feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants