mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Code cleanup
This commit is contained in:
parent
f3be89b503
commit
4a061f20ed
@ -1,6 +1,5 @@
|
|||||||
package org.schabi.newpipe.settings;
|
package org.schabi.newpipe.settings;
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -51,16 +50,11 @@ public class SelectKioskFragment extends DialogFragment {
|
|||||||
private SelectKioskAdapter selectKioskAdapter = null;
|
private SelectKioskAdapter selectKioskAdapter = null;
|
||||||
|
|
||||||
private OnSelectedListener onSelectedListener = null;
|
private OnSelectedListener onSelectedListener = null;
|
||||||
private OnCancelListener onCancelListener = null;
|
|
||||||
|
|
||||||
public void setOnSelectedListener(final OnSelectedListener listener) {
|
public void setOnSelectedListener(final OnSelectedListener listener) {
|
||||||
onSelectedListener = listener;
|
onSelectedListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnCancelListener(final OnCancelListener listener) {
|
|
||||||
onCancelListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Init
|
// Init
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
@ -91,14 +85,6 @@ public class SelectKioskFragment extends DialogFragment {
|
|||||||
// Handle actions
|
// 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) {
|
private void clickedItem(final SelectKioskAdapter.Entry entry) {
|
||||||
if (onSelectedListener != null) {
|
if (onSelectedListener != null) {
|
||||||
onSelectedListener.onKioskSelected(entry.serviceId, entry.kioskId, entry.kioskName);
|
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);
|
void onKioskSelected(int serviceId, String kioskId, String kioskName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnCancelListener {
|
|
||||||
void onCancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SelectKioskAdapter
|
private class SelectKioskAdapter
|
||||||
extends RecyclerView.Adapter<SelectKioskAdapter.SelectKioskItemHolder> {
|
extends RecyclerView.Adapter<SelectKioskAdapter.SelectKioskItemHolder> {
|
||||||
private final List<Entry> kioskList = new Vector<>();
|
private final List<Entry> kioskList = new Vector<>();
|
||||||
|
@ -44,8 +44,6 @@ import java.util.List;
|
|||||||
import static org.schabi.newpipe.settings.tabs.Tab.typeFrom;
|
import static org.schabi.newpipe.settings.tabs.Tab.typeFrom;
|
||||||
|
|
||||||
public class ChooseTabsFragment extends Fragment {
|
public class ChooseTabsFragment extends Fragment {
|
||||||
private static final int MENU_ITEM_RESTORE_ID = 123456;
|
|
||||||
|
|
||||||
private TabsManager tabsManager;
|
private TabsManager tabsManager;
|
||||||
|
|
||||||
private final List<Tab> tabList = new ArrayList<>();
|
private final List<Tab> tabList = new ArrayList<>();
|
||||||
@ -110,21 +108,14 @@ public class ChooseTabsFragment extends Fragment {
|
|||||||
@NonNull final MenuInflater inflater) {
|
@NonNull final MenuInflater inflater) {
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
|
||||||
final MenuItem restoreItem = menu.add(Menu.NONE, MENU_ITEM_RESTORE_ID, Menu.NONE,
|
final MenuItem restoreItem = menu.add(R.string.restore_defaults);
|
||||||
R.string.restore_defaults);
|
|
||||||
restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
restoreItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(),
|
restoreItem.setIcon(AppCompatResources.getDrawable(requireContext(),
|
||||||
R.drawable.ic_settings_backup_restore));
|
R.drawable.ic_settings_backup_restore));
|
||||||
}
|
restoreItem.setOnMenuItemClickListener(ev -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
|
||||||
if (item.getItemId() == MENU_ITEM_RESTORE_ID) {
|
|
||||||
restoreDefaults();
|
restoreDefaults();
|
||||||
return true;
|
return true;
|
||||||
}
|
});
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context="org.schabi.newpipe.MainActivity">
|
tools:context="org.schabi.newpipe.MainActivity">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/settings_toolbar_layout"
|
||||||
|
layout="@layout/toolbar_layout" />
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/settings_fragment_holder"
|
android:id="@+id/settings_fragment_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="?attr/actionBarSize" />
|
android:layout_marginTop="?attr/actionBarSize" />
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/toolbar_layout"
|
|
||||||
android:id="@+id/settings_toolbar_layout"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:key="general_preferences"
|
|
||||||
android:title="@string/settings_category_updates_title">
|
android:title="@string/settings_category_updates_title">
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
|
Loading…
Reference in New Issue
Block a user