Code cleanup

This commit is contained in:
litetex 2021-12-24 21:32:13 +01:00
parent f3be89b503
commit 4a061f20ed
4 changed files with 7 additions and 35 deletions

View File

@ -1,6 +1,5 @@
package org.schabi.newpipe.settings;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -51,16 +50,11 @@ public class SelectKioskFragment extends DialogFragment {
private SelectKioskAdapter selectKioskAdapter = null;
private OnSelectedListener onSelectedListener = null;
private OnCancelListener onCancelListener = null;
public void setOnSelectedListener(final OnSelectedListener listener) {
onSelectedListener = listener;
}
public void setOnCancelListener(final OnCancelListener listener) {
onCancelListener = listener;
}
/*//////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////*/
@ -91,14 +85,6 @@ public class SelectKioskFragment extends DialogFragment {
// Handle actions
//////////////////////////////////////////////////////////////////////////*/
@Override
public void onCancel(@NonNull final DialogInterface dialogInterface) {
super.onCancel(dialogInterface);
if (onCancelListener != null) {
onCancelListener.onCancel();
}
}
private void clickedItem(final SelectKioskAdapter.Entry entry) {
if (onSelectedListener != null) {
onSelectedListener.onKioskSelected(entry.serviceId, entry.kioskId, entry.kioskName);
@ -114,10 +100,6 @@ public class SelectKioskFragment extends DialogFragment {
void onKioskSelected(int serviceId, String kioskId, String kioskName);
}
public interface OnCancelListener {
void onCancel();
}
private class SelectKioskAdapter
extends RecyclerView.Adapter<SelectKioskAdapter.SelectKioskItemHolder> {
private final List<Entry> kioskList = new Vector<>();

View File

@ -44,8 +44,6 @@ import java.util.List;
import static org.schabi.newpipe.settings.tabs.Tab.typeFrom;
public class ChooseTabsFragment extends Fragment {
private static final int MENU_ITEM_RESTORE_ID = 123456;
private TabsManager tabsManager;
private final List<Tab> tabList = new ArrayList<>();
@ -110,21 +108,14 @@ public class ChooseTabsFragment extends Fragment {
@NonNull final MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
final MenuItem restoreItem = menu.add(Menu.NONE, MENU_ITEM_RESTORE_ID, Menu.NONE,
R.string.restore_defaults);
final MenuItem restoreItem = menu.add(R.string.restore_defaults);
restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(),
R.drawable.ic_settings_backup_restore));
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
if (item.getItemId() == MENU_ITEM_RESTORE_ID) {
restoreItem.setOnMenuItemClickListener(ev -> {
restoreDefaults();
return true;
}
return super.onOptionsItemSelected(item);
});
}
/*//////////////////////////////////////////////////////////////////////////

View File

@ -6,14 +6,14 @@
android:orientation="vertical"
tools:context="org.schabi.newpipe.MainActivity">
<include
android:id="@+id/settings_toolbar_layout"
layout="@layout/toolbar_layout" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/settings_fragment_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize" />
<include
layout="@layout/toolbar_layout"
android:id="@+id/settings_toolbar_layout"/>
</RelativeLayout>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:key="general_preferences"
android:title="@string/settings_category_updates_title">
<SwitchPreferenceCompat