mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-11 09:50:32 +00:00
fix requested changes part 1
This commit is contained in:
parent
ac2fa74c8f
commit
a079a0c901
@ -13,6 +13,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.reactivestreams.Subscriber;
|
import org.reactivestreams.Subscriber;
|
||||||
import org.reactivestreams.Subscription;
|
import org.reactivestreams.Subscription;
|
||||||
@ -27,6 +28,7 @@ import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
|||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.OnClickGesture;
|
import org.schabi.newpipe.util.OnClickGesture;
|
||||||
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -241,7 +243,7 @@ public class StatisticsPlaylistFragment
|
|||||||
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue()));
|
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue()));
|
||||||
headerBackgroundButton.setOnClickListener(view ->
|
headerBackgroundButton.setOnClickListener(view ->
|
||||||
NavigationHelper.playOnBackgroundPlayer(activity, getPlayQueue()));
|
NavigationHelper.playOnBackgroundPlayer(activity, getPlayQueue()));
|
||||||
sortButton.setOnClickListener(view -> toogleSortMode());
|
sortButton.setOnClickListener(view -> toggleSortMode());
|
||||||
|
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
@ -268,16 +270,16 @@ public class StatisticsPlaylistFragment
|
|||||||
// Utils
|
// Utils
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
private void toogleSortMode() {
|
private void toggleSortMode() {
|
||||||
if(sortMode == StatisticSortMode.LAST_PLAYED) {
|
if(sortMode == StatisticSortMode.LAST_PLAYED) {
|
||||||
sortMode = StatisticSortMode.MOST_PLAYED;
|
sortMode = StatisticSortMode.MOST_PLAYED;
|
||||||
setTitle(getString(R.string.title_most_played));
|
setTitle(getString(R.string.title_most_played));
|
||||||
sortButtonIcon.setImageResource(getIconByAttr(R.attr.history));
|
sortButtonIcon.setImageResource(ThemeHelper.getIconByAttr(R.attr.history, getContext()));
|
||||||
sortButtonText.setText(R.string.title_last_played);
|
sortButtonText.setText(R.string.title_last_played);
|
||||||
} else {
|
} else {
|
||||||
sortMode = StatisticSortMode.LAST_PLAYED;
|
sortMode = StatisticSortMode.LAST_PLAYED;
|
||||||
setTitle(getString(R.string.title_last_played));
|
setTitle(getString(R.string.title_last_played));
|
||||||
sortButtonIcon.setImageResource(getIconByAttr(R.attr.filter));
|
sortButtonIcon.setImageResource(ThemeHelper.getIconByAttr(R.attr.filter, getContext()));
|
||||||
sortButtonText.setText(R.string.title_most_played);
|
sortButtonText.setText(R.string.title_most_played);
|
||||||
}
|
}
|
||||||
startLoading(true);
|
startLoading(true);
|
||||||
@ -332,16 +334,24 @@ public class StatisticsPlaylistFragment
|
|||||||
.get(index);
|
.get(index);
|
||||||
if(infoItem instanceof StreamStatisticsEntry) {
|
if(infoItem instanceof StreamStatisticsEntry) {
|
||||||
final StreamStatisticsEntry entry = (StreamStatisticsEntry) infoItem;
|
final StreamStatisticsEntry entry = (StreamStatisticsEntry) infoItem;
|
||||||
final Disposable onDelte = recordManager.deleteStreamHistory(entry.streamId)
|
final Disposable onDelete = recordManager.deleteStreamHistory(entry.streamId)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
howManyDelted -> Snackbar.make(getView(), R.string.one_item_deleted,
|
howManyDelted -> {
|
||||||
Snackbar.LENGTH_SHORT).show(),
|
if(getView() != null) {
|
||||||
|
Snackbar.make(getView(), R.string.one_item_deleted,
|
||||||
|
Snackbar.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getContext(),
|
||||||
|
R.string.one_item_deleted,
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
},
|
||||||
throwable -> showSnackBarError(throwable,
|
throwable -> showSnackBarError(throwable,
|
||||||
UserAction.DELETE_FROM_HISTORY, "none",
|
UserAction.DELETE_FROM_HISTORY, "none",
|
||||||
"Deleting item failed", R.string.general_error));
|
"Deleting item failed", R.string.general_error));
|
||||||
|
|
||||||
disposables.add(onDelte);
|
disposables.add(onDelete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,10 +373,5 @@ public class StatisticsPlaylistFragment
|
|||||||
}
|
}
|
||||||
return new SinglePlayQueue(streamInfoItems, index);
|
return new SinglePlayQueue(streamInfoItems, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getIconByAttr(final int attr) {
|
|
||||||
return getContext().obtainStyledAttributes(new int[] {attr})
|
|
||||||
.getResourceId(0, -1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +59,10 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
|
|||||||
.setTitle(R.string.delete_view_history_alert)
|
.setTitle(R.string.delete_view_history_alert)
|
||||||
.setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss()))
|
.setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss()))
|
||||||
.setPositiveButton(R.string.delete, ((dialog, which) -> {
|
.setPositiveButton(R.string.delete, ((dialog, which) -> {
|
||||||
final Disposable onDelte = recordManager.deleteWholeStreamHistory()
|
final Disposable onDelete = recordManager.deleteWholeStreamHistory()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
howManyDelted -> Toast.makeText(getActivity(),
|
howManyDeleted -> Toast.makeText(getActivity(),
|
||||||
R.string.view_history_deleted,
|
R.string.view_history_deleted,
|
||||||
Toast.LENGTH_SHORT).show(),
|
Toast.LENGTH_SHORT).show(),
|
||||||
throwable -> ErrorActivity.reportError(getContext(),
|
throwable -> ErrorActivity.reportError(getContext(),
|
||||||
@ -74,7 +74,7 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
|
|||||||
"Delete view history",
|
"Delete view history",
|
||||||
R.string.general_error)));
|
R.string.general_error)));
|
||||||
|
|
||||||
disposables.add(onDelte);
|
disposables.add(onDelete);
|
||||||
}))
|
}))
|
||||||
.create()
|
.create()
|
||||||
.show();
|
.show();
|
||||||
@ -85,10 +85,10 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
|
|||||||
.setTitle(R.string.delete_search_history_alert)
|
.setTitle(R.string.delete_search_history_alert)
|
||||||
.setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss()))
|
.setNegativeButton(R.string.cancel, ((dialog, which) -> dialog.dismiss()))
|
||||||
.setPositiveButton(R.string.delete, ((dialog, which) -> {
|
.setPositiveButton(R.string.delete, ((dialog, which) -> {
|
||||||
final Disposable onDelte = recordManager.deleteWholeSearchHistory()
|
final Disposable onDelete = recordManager.deleteWholeSearchHistory()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(
|
.subscribe(
|
||||||
howManyDelted -> Toast.makeText(getActivity(),
|
howManyDeleted -> Toast.makeText(getActivity(),
|
||||||
R.string.search_history_deleted,
|
R.string.search_history_deleted,
|
||||||
Toast.LENGTH_SHORT).show(),
|
Toast.LENGTH_SHORT).show(),
|
||||||
throwable -> ErrorActivity.reportError(getContext(),
|
throwable -> ErrorActivity.reportError(getContext(),
|
||||||
@ -100,7 +100,7 @@ public class HistorySettingsFragment extends BasePreferenceFragment {
|
|||||||
"Delete search history",
|
"Delete search history",
|
||||||
R.string.general_error)));
|
R.string.general_error)));
|
||||||
|
|
||||||
disposables.add(onDelte);
|
disposables.add(onDelete);
|
||||||
}))
|
}))
|
||||||
.create()
|
.create()
|
||||||
.show();
|
.show();
|
||||||
|
@ -190,4 +190,16 @@ public class ThemeHelper {
|
|||||||
String defaultTheme = context.getResources().getString(R.string.default_theme_value);
|
String defaultTheme = context.getResources().getString(R.string.default_theme_value);
|
||||||
return PreferenceManager.getDefaultSharedPreferences(context).getString(themeKey, defaultTheme);
|
return PreferenceManager.getDefaultSharedPreferences(context).getString(themeKey, defaultTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will get the R.drawable.* resource to which attr is currently pointing to.
|
||||||
|
*
|
||||||
|
* @param attr a R.attribute.* resource value
|
||||||
|
* @param context the context to use
|
||||||
|
* @return a R.drawable.* resource value
|
||||||
|
*/
|
||||||
|
public static int getIconByAttr(final int attr, final Context context) {
|
||||||
|
return context.obtainStyledAttributes(new int[] {attr})
|
||||||
|
.getResourceId(0, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user