Skip to content

Commit

Permalink
[LoadingDialog] Apply some review comments and make title customizable.
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiGr committed Sep 16, 2023
1 parent 378079c commit a66ce46
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,10 +790,10 @@ public void onResume(@NonNull final LifecycleOwner owner) {
}
}

}, () -> {
}, () ->
// this branch is executed if there is no activity context
inFlight(false);
});
inFlight(false)
);
}

<T> Single<T> pleaseWait(final Single<T> single) {
Expand All @@ -813,7 +813,7 @@ <T> Single<T> pleaseWait(final Single<T> single) {
@SuppressLint("CheckResult")
private void openDownloadDialog(final int currentServiceId, final String currentUrl) {
inFlight(true);
final LoadingDialog loadingDialog = new LoadingDialog();
final LoadingDialog loadingDialog = new LoadingDialog(R.string.loading_metadata_title);
loadingDialog.show(getParentFragmentManager(), "loadingDialog");
disposables.add(ExtractorHelper.getStreamInfo(currentServiceId, currentUrl, true)
.subscribeOn(Schedulers.io())
Expand Down
28 changes: 10 additions & 18 deletions app/src/main/java/org/schabi/newpipe/download/LoadingDialog.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.schabi.newpipe.download;

import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
Expand All @@ -9,6 +8,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.DialogFragment;

Expand All @@ -17,11 +17,18 @@
import org.schabi.newpipe.databinding.DownloadLoadingDialogBinding;
import org.schabi.newpipe.util.PermissionHelper;


/**
* This dialog shows a loading indicator and a customizable title.
*/
public class LoadingDialog extends DialogFragment {
private static final String TAG = "LoadingDialog";
private static final boolean DEBUG = MainActivity.DEBUG;
private DownloadLoadingDialogBinding dialogLoadingBinding;
private final @StringRes int title;

public LoadingDialog(final @StringRes int title) {
this.title = title;
}

@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
Expand Down Expand Up @@ -62,29 +69,14 @@ private void initToolbar(final Toolbar toolbar) {
if (DEBUG) {
Log.d(TAG, "initToolbar() called with: toolbar = [" + toolbar + "]");
}
toolbar.setTitle("Loading Metadata...");
toolbar.setTitle(requireContext().getString(title));
toolbar.setNavigationOnClickListener(v -> dismiss());

}

@Override
public void onDismiss(@NonNull final DialogInterface dialog) {
super.onDismiss(dialog);
}

@Override
public void onDestroy() {
super.onDestroy();
}

@Override
public void onDestroyView() {
dialogLoadingBinding = null;
super.onDestroyView();
}

@Override
public void onSaveInstanceState(@NonNull final Bundle outState) {
super.onSaveInstanceState(outState);
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<string name="duration_live">Live</string>
<string name="downloads">Downloads</string>
<string name="downloads_title">Downloads</string>
<string name="loading_title">Loading Metadata…</string>
<string name="loading_metadata_title">Loading Metadata…</string>
<string name="error_report_title">Error report</string>
<string name="all">All</string>
<string name="channels">Channels</string>
Expand Down

0 comments on commit a66ce46

Please sign in to comment.