1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-25 04:22:30 +01:00

Code rework

This commit is contained in:
litetex 2021-12-27 18:57:17 +01:00
parent 0f45c69388
commit d59314801c
2 changed files with 24 additions and 13 deletions

View File

@ -5,6 +5,7 @@ import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.XmlRes;
import androidx.preference.PreferenceManager;
import org.xmlpull.v1.XmlPullParser;
@ -111,7 +112,7 @@ public class PreferenceParser {
private PreferenceSearchItem parseSearchResult(
final XmlPullParser xpp,
final String breadcrumbs,
final int searchIndexItemResId
@XmlRes final int searchIndexItemResId
) {
final String key = readString(getAttribute(xpp, "key"));
final String[] entries = readStringArray(getAttribute(xpp, "entries"));
@ -130,7 +131,6 @@ public class PreferenceParser {
entries,
entryValues),
TextUtils.join(",", entries),
readString(getAttribute(xpp, NS_SEARCH, "keywords")),
breadcrumbs,
searchIndexItemResId
);

View File

@ -1,6 +1,7 @@
package org.schabi.newpipe.settings.preferencesearch;
import androidx.annotation.NonNull;
import androidx.annotation.XmlRes;
import java.util.Arrays;
import java.util.List;
@ -10,18 +11,35 @@ import java.util.Objects;
* Represents a preference-item inside the search.
*/
public class PreferenceSearchItem {
/**
* Key of the setting/preference. E.g. used inside {@link android.content.SharedPreferences}.
*/
@NonNull
private final String key;
/**
* Title of the setting, e.g. 'Default resolution' or 'Show higher resolutions'.
*/
@NonNull
private final String title;
/**
* Summary of the setting, e.g. '480p' or 'Only some devices can play 2k/4k'.
*/
@NonNull
private final String summary;
/**
* Possible entries of the setting, e.g. 480p,720p,...
*/
@NonNull
private final String entries;
@NonNull
private final String keywords;
/**
* Breadcrumbs - a hint where the setting is located e.g. 'Video and Audio > Player'
*/
@NonNull
private final String breadcrumbs;
/**
* The xml-resource where this item was found/built from.
*/
@XmlRes
private final int searchIndexItemResId;
public PreferenceSearchItem(
@ -29,15 +47,13 @@ public class PreferenceSearchItem {
@NonNull final String title,
@NonNull final String summary,
@NonNull final String entries,
@NonNull final String keywords,
@NonNull final String breadcrumbs,
final int searchIndexItemResId
@XmlRes final int searchIndexItemResId
) {
this.key = Objects.requireNonNull(key);
this.title = Objects.requireNonNull(title);
this.summary = Objects.requireNonNull(summary);
this.entries = Objects.requireNonNull(entries);
this.keywords = Objects.requireNonNull(keywords);
this.breadcrumbs = Objects.requireNonNull(breadcrumbs);
this.searchIndexItemResId = searchIndexItemResId;
}
@ -62,10 +78,6 @@ public class PreferenceSearchItem {
return breadcrumbs;
}
public String getKeywords() {
return keywords;
}
public int getSearchIndexItemResId() {
return searchIndexItemResId;
}
@ -79,8 +91,7 @@ public class PreferenceSearchItem {
getTitle(),
getSummary(),
getEntries(),
getBreadcrumbs(),
getKeywords());
getBreadcrumbs());
}