Use final where possible
This commit is contained in:
parent
d306513319
commit
87228673b4
132 changed files with 1024 additions and 1005 deletions
|
|
@ -42,7 +42,7 @@ public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
|||
@Override
|
||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
String themeKey = getString(R.string.theme_key);
|
||||
final String themeKey = getString(R.string.theme_key);
|
||||
startThemeKey = defaultPreferences
|
||||
.getString(themeKey, getString(R.string.default_theme_value));
|
||||
findPreference(themeKey).setOnPreferenceChangeListener(themePreferenceChange);
|
||||
|
|
@ -64,7 +64,7 @@ public class AppearanceSettingsFragment extends BasePreferenceFragment {
|
|||
if (preference.getKey().equals(captionSettingsKey) && CAPTIONING_SETTINGS_ACCESSIBLE) {
|
||||
try {
|
||||
startActivity(new Intent(Settings.ACTION_CAPTIONING_SETTINGS));
|
||||
} catch (ActivityNotFoundException e) {
|
||||
} catch (final ActivityNotFoundException e) {
|
||||
Toast.makeText(getActivity(), R.string.general_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public abstract class BasePreferenceFragment extends PreferenceFragmentCompat {
|
|||
|
||||
private void updateTitle() {
|
||||
if (getActivity() instanceof AppCompatActivity) {
|
||||
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
final ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle(getPreferenceScreen().getTitle());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import org.schabi.newpipe.util.ZipHelper;
|
|||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
|
@ -91,7 +90,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
}
|
||||
|
||||
if (preference.getKey().equals(youtubeRestrictedModeEnabledKey)) {
|
||||
Context context = getContext();
|
||||
final Context context = getContext();
|
||||
if (context != null) {
|
||||
DownloaderImpl.getInstance().updateYoutubeRestrictedModeCookies(context);
|
||||
} else {
|
||||
|
|
@ -105,7 +104,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
@Override
|
||||
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
|
||||
|
||||
String homeDir = getActivity().getApplicationInfo().dataDir;
|
||||
final String homeDir = getActivity().getApplicationInfo().dataDir;
|
||||
databasesDir = new File(homeDir + "/databases");
|
||||
newpipeDb = new File(homeDir + "/databases/newpipe.db");
|
||||
newpipeDbJournal = new File(homeDir + "/databases/newpipe.db-journal");
|
||||
|
|
@ -117,9 +116,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
|
||||
addPreferencesFromResource(R.xml.content_settings);
|
||||
|
||||
Preference importDataPreference = findPreference(getString(R.string.import_data));
|
||||
final Preference importDataPreference = findPreference(getString(R.string.import_data));
|
||||
importDataPreference.setOnPreferenceClickListener((Preference p) -> {
|
||||
Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
|
||||
final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
|
||||
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
|
||||
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, false)
|
||||
.putExtra(FilePickerActivityHelper.EXTRA_MODE,
|
||||
|
|
@ -128,9 +127,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
return true;
|
||||
});
|
||||
|
||||
Preference exportDataPreference = findPreference(getString(R.string.export_data));
|
||||
final Preference exportDataPreference = findPreference(getString(R.string.export_data));
|
||||
exportDataPreference.setOnPreferenceClickListener((Preference p) -> {
|
||||
Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
|
||||
final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class)
|
||||
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false)
|
||||
.putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, true)
|
||||
.putExtra(FilePickerActivityHelper.EXTRA_MODE,
|
||||
|
|
@ -175,12 +174,12 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
|
||||
if ((requestCode == REQUEST_IMPORT_PATH || requestCode == REQUEST_EXPORT_PATH)
|
||||
&& resultCode == Activity.RESULT_OK && data.getData() != null) {
|
||||
String path = Utils.getFileForUri(data.getData()).getAbsolutePath();
|
||||
final String path = Utils.getFileForUri(data.getData()).getAbsolutePath();
|
||||
if (requestCode == REQUEST_EXPORT_PATH) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US);
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US);
|
||||
exportDatabase(path + "/NewPipeData-" + sdf.format(new Date()) + ".zip");
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.override_current_data)
|
||||
.setPositiveButton(getString(R.string.finish),
|
||||
(DialogInterface d, int id) -> importDatabase(path))
|
||||
|
|
@ -196,7 +195,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
//checkpoint before export
|
||||
NewPipeDatabase.checkpoint();
|
||||
|
||||
ZipOutputStream outZip = new ZipOutputStream(
|
||||
final ZipOutputStream outZip = new ZipOutputStream(
|
||||
new BufferedOutputStream(
|
||||
new FileOutputStream(path)));
|
||||
ZipHelper.addFileToZip(outZip, newpipeDb.getPath(), "newpipe.db");
|
||||
|
|
@ -208,7 +207,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
|
||||
Toast.makeText(getContext(), R.string.export_complete_toast, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
onError(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -217,12 +216,11 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
ObjectOutputStream output = null;
|
||||
try {
|
||||
output = new ObjectOutputStream(new FileOutputStream(dst));
|
||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
final SharedPreferences pref
|
||||
= PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
output.writeObject(pref.getAll());
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
|
|
@ -230,7 +228,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
output.flush();
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
} catch (final IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
@ -241,14 +239,14 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
ZipFile zipFile = null;
|
||||
try {
|
||||
zipFile = new ZipFile(filePath);
|
||||
} catch (IOException ioe) {
|
||||
} catch (final IOException ioe) {
|
||||
Toast.makeText(getContext(), R.string.no_valid_zip_file, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
return;
|
||||
} finally {
|
||||
try {
|
||||
zipFile.close();
|
||||
} catch (Exception ignored) {
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +270,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
//If settings file exist, ask if it should be imported.
|
||||
if (ZipHelper.extractFileFromZip(filePath, newpipeSettings.getPath(),
|
||||
"newpipe.settings")) {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||
final AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||
alert.setTitle(R.string.import_settings);
|
||||
|
||||
alert.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
|
|
@ -291,7 +289,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
// restart app to properly load db
|
||||
System.exit(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
onError(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -300,13 +298,13 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
ObjectInputStream input = null;
|
||||
try {
|
||||
input = new ObjectInputStream(new FileInputStream(src));
|
||||
SharedPreferences.Editor prefEdit = PreferenceManager
|
||||
final SharedPreferences.Editor prefEdit = PreferenceManager
|
||||
.getDefaultSharedPreferences(getContext()).edit();
|
||||
prefEdit.clear();
|
||||
Map<String, ?> entries = (Map<String, ?>) input.readObject();
|
||||
for (Map.Entry<String, ?> entry : entries.entrySet()) {
|
||||
Object v = entry.getValue();
|
||||
String key = entry.getKey();
|
||||
final Map<String, ?> entries = (Map<String, ?>) input.readObject();
|
||||
for (final Map.Entry<String, ?> entry : entries.entrySet()) {
|
||||
final Object v = entry.getValue();
|
||||
final String key = entry.getKey();
|
||||
|
||||
if (v instanceof Boolean) {
|
||||
prefEdit.putBoolean(key, (Boolean) v);
|
||||
|
|
@ -321,18 +319,14 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
|
|||
}
|
||||
}
|
||||
prefEdit.commit();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
} catch (final IOException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
} catch (final IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
|||
|
||||
try {
|
||||
rawUri = URLDecoder.decode(rawUri, StandardCharsets.UTF_8.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
} catch (final UnsupportedEncodingException e) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
|||
}
|
||||
|
||||
private boolean hasInvalidPath(final String prefKey) {
|
||||
String value = defaultPreferences.getString(prefKey, null);
|
||||
final String value = defaultPreferences.getString(prefKey, null);
|
||||
return value == null || value.isEmpty();
|
||||
}
|
||||
|
||||
|
|
@ -152,20 +152,20 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
|||
}
|
||||
|
||||
try {
|
||||
Uri uri = Uri.parse(oldPath);
|
||||
final Uri uri = Uri.parse(oldPath);
|
||||
|
||||
context.getContentResolver()
|
||||
.releasePersistableUriPermission(uri, StoredDirectoryHelper.PERMISSION_FLAGS);
|
||||
context.revokeUriPermission(uri, StoredDirectoryHelper.PERMISSION_FLAGS);
|
||||
|
||||
Log.i(TAG, "Revoke old path permissions success on " + oldPath);
|
||||
} catch (Exception err) {
|
||||
} catch (final Exception err) {
|
||||
Log.e(TAG, "Error revoking old path permissions on " + oldPath, err);
|
||||
}
|
||||
}
|
||||
|
||||
private void showMessageDialog(@StringRes final int title, @StringRes final int message) {
|
||||
AlertDialog.Builder msg = new AlertDialog.Builder(ctx);
|
||||
final AlertDialog.Builder msg = new AlertDialog.Builder(ctx);
|
||||
msg.setTitle(title);
|
||||
msg.setMessage(message);
|
||||
msg.setPositiveButton(getString(R.string.finish), null);
|
||||
|
|
@ -179,8 +179,8 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
|||
+ "preference = [" + preference + "]");
|
||||
}
|
||||
|
||||
String key = preference.getKey();
|
||||
int request;
|
||||
final String key = preference.getKey();
|
||||
final int request;
|
||||
|
||||
if (key.equals(storageUseSafPreference)) {
|
||||
Toast.makeText(getContext(), R.string.download_choose_new_path,
|
||||
|
|
@ -194,7 +194,7 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
|||
return super.onPreferenceTreeClick(preference);
|
||||
}
|
||||
|
||||
Intent i;
|
||||
final Intent i;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
||||
&& NewPipeSettings.useStorageAccessFramework(ctx)) {
|
||||
i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
|
|
@ -229,7 +229,7 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
|||
return;
|
||||
}
|
||||
|
||||
String key;
|
||||
final String key;
|
||||
if (requestCode == REQUEST_DOWNLOAD_VIDEO_PATH) {
|
||||
key = downloadPathVideoPreference;
|
||||
} else if (requestCode == REQUEST_DOWNLOAD_AUDIO_PATH) {
|
||||
|
|
@ -262,19 +262,20 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
|
|||
context.grantUriPermission(context.getPackageName(), uri,
|
||||
StoredDirectoryHelper.PERMISSION_FLAGS);
|
||||
|
||||
StoredDirectoryHelper mainStorage = new StoredDirectoryHelper(context, uri, null);
|
||||
final StoredDirectoryHelper mainStorage
|
||||
= new StoredDirectoryHelper(context, uri, null);
|
||||
Log.i(TAG, "Acquiring tree success from " + uri.toString());
|
||||
|
||||
if (!mainStorage.canWrite()) {
|
||||
throw new IOException("No write permissions on " + uri.toString());
|
||||
}
|
||||
} catch (IOException err) {
|
||||
} catch (final IOException err) {
|
||||
Log.e(TAG, "Error acquiring tree from " + uri.toString(), err);
|
||||
showMessageDialog(R.string.general_error, R.string.no_available_dir);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
File target = Utils.getFileForUri(uri);
|
||||
final File target = Utils.getFileForUri(uri);
|
||||
if (!target.canWrite()) {
|
||||
showMessageDialog(R.string.download_to_sdcard_error_title,
|
||||
R.string.download_to_sdcard_error_message);
|
||||
|
|
|
|||
|
|
@ -60,14 +60,14 @@ public final class NewPipeSettings {
|
|||
|
||||
private static void getDir(final Context context, final int keyID,
|
||||
final String defaultDirectoryName) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
final String key = context.getString(keyID);
|
||||
String downloadPath = prefs.getString(key, null);
|
||||
final String downloadPath = prefs.getString(key, null);
|
||||
if ((downloadPath != null) && (!downloadPath.isEmpty())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences.Editor spEditor = prefs.edit();
|
||||
final SharedPreferences.Editor spEditor = prefs.edit();
|
||||
spEditor.putString(key, getNewPipeChildFolderPathForDir(getDir(defaultDirectoryName)));
|
||||
spEditor.apply();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,16 +96,16 @@ public class PeertubeInstanceListFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void initViews(@NonNull final View rootView) {
|
||||
TextView instanceHelpTV = rootView.findViewById(R.id.instanceHelpTV);
|
||||
final TextView instanceHelpTV = rootView.findViewById(R.id.instanceHelpTV);
|
||||
instanceHelpTV.setText(getString(R.string.peertube_instance_url_help,
|
||||
getString(R.string.peertube_instance_list_url)));
|
||||
|
||||
initButton(rootView);
|
||||
|
||||
RecyclerView listInstances = rootView.findViewById(R.id.instances);
|
||||
final RecyclerView listInstances = rootView.findViewById(R.id.instances);
|
||||
listInstances.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
|
||||
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(getItemTouchCallback());
|
||||
final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(getItemTouchCallback());
|
||||
itemTouchHelper.attachToRecyclerView(listInstances);
|
||||
|
||||
instanceListAdapter = new InstanceListAdapter(requireContext(), itemTouchHelper);
|
||||
|
|
@ -178,7 +178,7 @@ public class PeertubeInstanceListFragment extends Fragment {
|
|||
|
||||
private void updateTitle() {
|
||||
if (getActivity() instanceof AppCompatActivity) {
|
||||
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
final ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle(R.string.peertube_instance_url_title);
|
||||
}
|
||||
|
|
@ -186,14 +186,14 @@ public class PeertubeInstanceListFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void saveChanges() {
|
||||
JsonStringWriter jsonWriter = JsonWriter.string().object().array("instances");
|
||||
for (PeertubeInstance instance : instanceList) {
|
||||
final JsonStringWriter jsonWriter = JsonWriter.string().object().array("instances");
|
||||
for (final PeertubeInstance instance : instanceList) {
|
||||
jsonWriter.object();
|
||||
jsonWriter.value("name", instance.getName());
|
||||
jsonWriter.value("url", instance.getUrl());
|
||||
jsonWriter.end();
|
||||
}
|
||||
String jsonToSave = jsonWriter.end().end().done();
|
||||
final String jsonToSave = jsonWriter.end().end().done();
|
||||
sharedPreferences.edit().putString(savedInstanceListKey, jsonToSave).apply();
|
||||
}
|
||||
|
||||
|
|
@ -222,12 +222,12 @@ public class PeertubeInstanceListFragment extends Fragment {
|
|||
final EditText urlET = new EditText(c);
|
||||
urlET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
|
||||
urlET.setHint(R.string.peertube_instance_add_help);
|
||||
AlertDialog dialog = new AlertDialog.Builder(c)
|
||||
final AlertDialog dialog = new AlertDialog.Builder(c)
|
||||
.setTitle(R.string.peertube_instance_add_title)
|
||||
.setIcon(R.drawable.place_holder_peertube)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setPositiveButton(R.string.finish, (dialog1, which) -> {
|
||||
String url = urlET.getText().toString();
|
||||
final String url = urlET.getText().toString();
|
||||
addInstance(url);
|
||||
})
|
||||
.create();
|
||||
|
|
@ -236,13 +236,13 @@ public class PeertubeInstanceListFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void addInstance(final String url) {
|
||||
String cleanUrl = cleanUrl(url);
|
||||
final String cleanUrl = cleanUrl(url);
|
||||
if (cleanUrl == null) {
|
||||
return;
|
||||
}
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
Disposable disposable = Single.fromCallable(() -> {
|
||||
PeertubeInstance instance = new PeertubeInstance(cleanUrl);
|
||||
final Disposable disposable = Single.fromCallable(() -> {
|
||||
final PeertubeInstance instance = new PeertubeInstance(cleanUrl);
|
||||
instance.fetchInstanceMetaData();
|
||||
return instance;
|
||||
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
@ -273,7 +273,7 @@ public class PeertubeInstanceListFragment extends Fragment {
|
|||
return null;
|
||||
}
|
||||
// only allow if not already exists
|
||||
for (PeertubeInstance instance : instanceList) {
|
||||
for (final PeertubeInstance instance : instanceList) {
|
||||
if (instance.getUrl().equals(cleanUrl)) {
|
||||
Toast.makeText(getActivity(), R.string.peertube_instance_add_exists,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
|
@ -331,7 +331,7 @@ public class PeertubeInstanceListFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onSwiped(final RecyclerView.ViewHolder viewHolder, final int swipeDir) {
|
||||
int position = viewHolder.getAdapterPosition();
|
||||
final int position = viewHolder.getAdapterPosition();
|
||||
// do not allow swiping the selected instance
|
||||
if (instanceList.get(position).getUrl().equals(selectedInstance.getUrl())) {
|
||||
instanceListAdapter.notifyItemChanged(position);
|
||||
|
|
@ -372,7 +372,7 @@ public class PeertubeInstanceListFragment extends Fragment {
|
|||
@Override
|
||||
public InstanceListAdapter.TabViewHolder onCreateViewHolder(@NonNull final ViewGroup parent,
|
||||
final int viewType) {
|
||||
View view = inflater.inflate(R.layout.item_instance, parent, false);
|
||||
final View view = inflater.inflate(R.layout.item_instance, parent, false);
|
||||
return new InstanceListAdapter.TabViewHolder(view);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ public class SelectChannelFragment extends DialogFragment {
|
|||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.select_channel_fragment, container, false);
|
||||
final View v = inflater.inflate(R.layout.select_channel_fragment, container, false);
|
||||
recyclerView = v.findViewById(R.id.items_list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
SelectChannelAdapter channelAdapter = new SelectChannelAdapter();
|
||||
final SelectChannelAdapter channelAdapter = new SelectChannelAdapter();
|
||||
recyclerView.setAdapter(channelAdapter);
|
||||
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
|
|
@ -107,7 +107,7 @@ public class SelectChannelFragment extends DialogFragment {
|
|||
emptyView.setVisibility(View.GONE);
|
||||
|
||||
|
||||
SubscriptionManager subscriptionManager = new SubscriptionManager(getContext());
|
||||
final SubscriptionManager subscriptionManager = new SubscriptionManager(getContext());
|
||||
subscriptionManager.subscriptions().toObservable()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
@ -130,7 +130,7 @@ public class SelectChannelFragment extends DialogFragment {
|
|||
|
||||
private void clickedItem(final int position) {
|
||||
if (onSelectedListener != null) {
|
||||
SubscriptionEntity entry = subscriptions.get(position);
|
||||
final SubscriptionEntity entry = subscriptions.get(position);
|
||||
onSelectedListener
|
||||
.onChannelSelected(entry.getServiceId(), entry.getUrl(), entry.getName());
|
||||
}
|
||||
|
|
@ -199,14 +199,14 @@ public class SelectChannelFragment extends DialogFragment {
|
|||
@Override
|
||||
public SelectChannelItemHolder onCreateViewHolder(final ViewGroup parent,
|
||||
final int viewType) {
|
||||
View item = LayoutInflater.from(parent.getContext())
|
||||
final View item = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.select_channel_item, parent, false);
|
||||
return new SelectChannelItemHolder(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final SelectChannelItemHolder holder, final int position) {
|
||||
SubscriptionEntity entry = subscriptions.get(position);
|
||||
final SubscriptionEntity entry = subscriptions.get(position);
|
||||
holder.titleView.setText(entry.getName());
|
||||
holder.view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -76,12 +76,12 @@ public class SelectKioskFragment extends DialogFragment {
|
|||
@Override
|
||||
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.select_kiosk_fragment, container, false);
|
||||
final View v = inflater.inflate(R.layout.select_kiosk_fragment, container, false);
|
||||
recyclerView = v.findViewById(R.id.items_list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
try {
|
||||
selectKioskAdapter = new SelectKioskAdapter();
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
onError(e);
|
||||
}
|
||||
recyclerView.setAdapter(selectKioskAdapter);
|
||||
|
|
@ -135,9 +135,9 @@ public class SelectKioskFragment extends DialogFragment {
|
|||
private final List<Entry> kioskList = new Vector<>();
|
||||
|
||||
SelectKioskAdapter() throws Exception {
|
||||
for (StreamingService service : NewPipe.getServices()) {
|
||||
for (String kioskId : service.getKioskList().getAvailableKiosks()) {
|
||||
String name = String.format(getString(R.string.service_kiosk_string),
|
||||
for (final StreamingService service : NewPipe.getServices()) {
|
||||
for (final String kioskId : service.getKioskList().getAvailableKiosks()) {
|
||||
final String name = String.format(getString(R.string.service_kiosk_string),
|
||||
service.getServiceInfo().getName(),
|
||||
KioskTranslator.getTranslatedKioskName(kioskId, getContext()));
|
||||
kioskList.add(new Entry(ServiceHelper.getIcon(service.getServiceId()),
|
||||
|
|
@ -151,7 +151,7 @@ public class SelectKioskFragment extends DialogFragment {
|
|||
}
|
||||
|
||||
public SelectKioskItemHolder onCreateViewHolder(final ViewGroup parent, final int type) {
|
||||
View item = LayoutInflater.from(parent.getContext())
|
||||
final View item = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.select_kiosk_item, parent, false);
|
||||
return new SelectKioskItemHolder(item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class SelectPlaylistFragment extends DialogFragment {
|
|||
inflater.inflate(R.layout.select_playlist_fragment, container, false);
|
||||
recyclerView = v.findViewById(R.id.items_list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
SelectPlaylistAdapter playlistAdapter = new SelectPlaylistAdapter();
|
||||
final SelectPlaylistAdapter playlistAdapter = new SelectPlaylistAdapter();
|
||||
recyclerView.setAdapter(playlistAdapter);
|
||||
|
||||
progressBar = v.findViewById(R.id.progressBar);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class SettingsActivity extends AppCompatActivity
|
|||
super.onCreate(savedInstanceBundle);
|
||||
setContentView(R.layout.settings_layout);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
final Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
if (savedInstanceBundle == null) {
|
||||
|
|
@ -69,7 +69,7 @@ public class SettingsActivity extends AppCompatActivity
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
|
|
@ -80,7 +80,7 @@ public class SettingsActivity extends AppCompatActivity
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
final int id = item.getItemId();
|
||||
if (id == android.R.id.home) {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
|
||||
finish();
|
||||
|
|
@ -95,7 +95,7 @@ public class SettingsActivity extends AppCompatActivity
|
|||
@Override
|
||||
public boolean onPreferenceStartFragment(final PreferenceFragmentCompat caller,
|
||||
final Preference preference) {
|
||||
Fragment fragment = Fragment
|
||||
final Fragment fragment = Fragment
|
||||
.instantiate(this, preference.getFragment(), preference.getExtras());
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.setCustomAnimations(R.animator.custom_fade_in, R.animator.custom_fade_out,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public class UpdateSettingsFragment extends BasePreferenceFragment {
|
|||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
String updateToggleKey = getString(R.string.update_app_key);
|
||||
final String updateToggleKey = getString(R.string.update_app_key);
|
||||
findPreference(updateToggleKey).setOnPreferenceChangeListener(updatePreferenceChange);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
|||
// show a snackbar to let the user give permission
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& s.equals(getString(R.string.minimize_on_exit_key))) {
|
||||
String newSetting = sharedPreferences.getString(s, null);
|
||||
final String newSetting = sharedPreferences.getString(s, null);
|
||||
if (newSetting != null
|
||||
&& newSetting.equals(getString(R.string.minimize_on_exit_popup_key))
|
||||
&& !Settings.canDrawOverlays(getContext())) {
|
||||
|
|
@ -68,7 +68,7 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
|||
final boolean inexactSeek = getPreferenceManager().getSharedPreferences()
|
||||
.getBoolean(res.getString(R.string.use_inexact_seek_key), false);
|
||||
|
||||
for (String durationsValue : durationsValues) {
|
||||
for (final String durationsValue : durationsValues) {
|
||||
currentDurationValue =
|
||||
Integer.parseInt(durationsValue) / (int) DateUtils.SECOND_IN_MILLIS;
|
||||
if (inexactSeek && currentDurationValue % 10 == 5) {
|
||||
|
|
@ -81,7 +81,7 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
|||
res.getQuantityString(R.plurals.seconds,
|
||||
currentDurationValue),
|
||||
currentDurationValue));
|
||||
} catch (Resources.NotFoundException ignored) {
|
||||
} catch (final Resources.NotFoundException ignored) {
|
||||
// if this happens, the translation is missing,
|
||||
// and the english string will be displayed instead
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
|||
final int newDuration = selectedDuration / (int) DateUtils.SECOND_IN_MILLIS + 5;
|
||||
durations.setValue(Integer.toString(newDuration * (int) DateUtils.SECOND_IN_MILLIS));
|
||||
|
||||
Toast toast = Toast
|
||||
final Toast toast = Toast
|
||||
.makeText(getContext(),
|
||||
getString(R.string.new_seek_duration_toast, newDuration),
|
||||
Toast.LENGTH_LONG);
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ public class ChooseTabsFragment extends Fragment {
|
|||
return;
|
||||
}
|
||||
|
||||
Dialog.OnClickListener actionListener = (dialog, which) -> {
|
||||
final Dialog.OnClickListener actionListener = (dialog, which) -> {
|
||||
final ChooseTabListItem selected = availableTabs[which];
|
||||
addTab(selected.tabId);
|
||||
};
|
||||
|
|
@ -201,19 +201,19 @@ public class ChooseTabsFragment extends Fragment {
|
|||
|
||||
switch (type) {
|
||||
case KIOSK:
|
||||
SelectKioskFragment selectKioskFragment = new SelectKioskFragment();
|
||||
final SelectKioskFragment selectKioskFragment = new SelectKioskFragment();
|
||||
selectKioskFragment.setOnSelectedListener((serviceId, kioskId, kioskName) ->
|
||||
addTab(new Tab.KioskTab(serviceId, kioskId)));
|
||||
selectKioskFragment.show(requireFragmentManager(), "select_kiosk");
|
||||
return;
|
||||
case CHANNEL:
|
||||
SelectChannelFragment selectChannelFragment = new SelectChannelFragment();
|
||||
final SelectChannelFragment selectChannelFragment = new SelectChannelFragment();
|
||||
selectChannelFragment.setOnSelectedListener((serviceId, url, name) ->
|
||||
addTab(new Tab.ChannelTab(serviceId, url, name)));
|
||||
selectChannelFragment.show(requireFragmentManager(), "select_channel");
|
||||
return;
|
||||
case PLAYLIST:
|
||||
SelectPlaylistFragment selectPlaylistFragment = new SelectPlaylistFragment();
|
||||
final SelectPlaylistFragment selectPlaylistFragment = new SelectPlaylistFragment();
|
||||
selectPlaylistFragment.setOnSelectedListener(
|
||||
new SelectPlaylistFragment.OnSelectedListener() {
|
||||
@Override
|
||||
|
|
@ -238,7 +238,7 @@ public class ChooseTabsFragment extends Fragment {
|
|||
private ChooseTabListItem[] getAvailableTabs(final Context context) {
|
||||
final ArrayList<ChooseTabListItem> returnList = new ArrayList<>();
|
||||
|
||||
for (Tab.Type type : Tab.Type.values()) {
|
||||
for (final Tab.Type type : Tab.Type.values()) {
|
||||
final Tab tab = type.getTab();
|
||||
switch (type) {
|
||||
case BLANK:
|
||||
|
|
@ -329,7 +329,7 @@ public class ChooseTabsFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onSwiped(final RecyclerView.ViewHolder viewHolder, final int swipeDir) {
|
||||
int position = viewHolder.getAdapterPosition();
|
||||
final int position = viewHolder.getAdapterPosition();
|
||||
tabList.remove(position);
|
||||
selectedTabsAdapter.notifyItemRemoved(position);
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public abstract class Tab {
|
|||
|
||||
@Nullable
|
||||
public static Type typeFrom(final int tabId) {
|
||||
for (Type available : Type.values()) {
|
||||
for (final Type available : Type.values()) {
|
||||
if (available.getTabId() == tabId) {
|
||||
return available;
|
||||
}
|
||||
|
|
@ -481,7 +481,7 @@ public abstract class Tab {
|
|||
try {
|
||||
final StreamingService service = NewPipe.getService(kioskServiceId);
|
||||
kioskId = service.getKioskList().getDefaultKioskId();
|
||||
} catch (ExtractionException e) {
|
||||
} catch (final ExtractionException e) {
|
||||
ErrorActivity.reportError(context, e, null, null,
|
||||
ErrorActivity.ErrorInfo.make(UserAction.REQUESTED_KIOSK, "none",
|
||||
"Loading default kiosk from selected service", 0));
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public final class TabsJsonHelper {
|
|||
|
||||
final JsonArray tabsArray = outerJsonObject.getArray(JSON_TABS_ARRAY_KEY);
|
||||
|
||||
for (Object o : tabsArray) {
|
||||
for (final Object o : tabsArray) {
|
||||
if (!(o instanceof JsonObject)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ public final class TabsJsonHelper {
|
|||
returnTabs.add(tab);
|
||||
}
|
||||
}
|
||||
} catch (JsonParserException e) {
|
||||
} catch (final JsonParserException e) {
|
||||
throw new InvalidJsonException(e);
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ public final class TabsJsonHelper {
|
|||
|
||||
jsonWriter.array(JSON_TABS_ARRAY_KEY);
|
||||
if (tabList != null) {
|
||||
for (Tab tab : tabList) {
|
||||
for (final Tab tab : tabList) {
|
||||
tab.writeJsonOn(jsonWriter);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public final class TabsManager {
|
|||
final String savedJson = sharedPreferences.getString(savedTabsKey, null);
|
||||
try {
|
||||
return TabsJsonHelper.getTabsFromJson(savedJson);
|
||||
} catch (TabsJsonHelper.InvalidJsonException e) {
|
||||
} catch (final TabsJsonHelper.InvalidJsonException e) {
|
||||
Toast.makeText(context, R.string.saved_tabs_invalid_json, Toast.LENGTH_SHORT).show();
|
||||
return getDefaultTabs();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue