Rename fields in WikivoyageSearchResult
This commit is contained in:
parent
d1f4ac1c6f
commit
194f926af2
4 changed files with 25 additions and 25 deletions
|
@ -102,7 +102,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
}
|
}
|
||||||
|
|
||||||
final PopupMenu popup = new PopupMenu(view.getContext(), view, Gravity.END);
|
final PopupMenu popup = new PopupMenu(view.getContext(), view, Gravity.END);
|
||||||
for (final String lang : searchResult.getLang()) {
|
for (final String lang : searchResult.getLangs()) {
|
||||||
MenuItem item = popup.getMenu().add(lang);
|
MenuItem item = popup.getMenu().add(lang);
|
||||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -130,7 +130,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (selectedLang == null) {
|
if (selectedLang == null) {
|
||||||
selectedLang = searchResult.getLang().get(0);
|
selectedLang = searchResult.getLangs().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedLangTv.setText(selectedLang);
|
selectedLangTv.setText(selectedLang);
|
||||||
|
|
|
@ -100,12 +100,12 @@ public class WikivoyageDbHelper {
|
||||||
Collections.sort(list, new Comparator<WikivoyageSearchResult>() {
|
Collections.sort(list, new Comparator<WikivoyageSearchResult>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(WikivoyageSearchResult o1, WikivoyageSearchResult o2) {
|
public int compare(WikivoyageSearchResult o1, WikivoyageSearchResult o2) {
|
||||||
boolean c1 = CollatorStringMatcher.cmatches(collator, searchQuery, o1.articleTitle.get(0),
|
boolean c1 = CollatorStringMatcher.cmatches(collator, searchQuery, o1.articleTitles.get(0),
|
||||||
StringMatcherMode.CHECK_ONLY_STARTS_WITH);
|
StringMatcherMode.CHECK_ONLY_STARTS_WITH);
|
||||||
boolean c2 = CollatorStringMatcher.cmatches(collator, searchQuery, o2.articleTitle.get(0),
|
boolean c2 = CollatorStringMatcher.cmatches(collator, searchQuery, o2.articleTitles.get(0),
|
||||||
StringMatcherMode.CHECK_ONLY_STARTS_WITH);
|
StringMatcherMode.CHECK_ONLY_STARTS_WITH);
|
||||||
if (c1 == c2) {
|
if (c1 == c2) {
|
||||||
return collator.compare(o1.articleTitle.get(0), o2.articleTitle.get(0));
|
return collator.compare(o1.articleTitles.get(0), o2.articleTitles.get(0));
|
||||||
} else if (c1) {
|
} else if (c1) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (c2) {
|
} else if (c2) {
|
||||||
|
@ -125,18 +125,18 @@ public class WikivoyageDbHelper {
|
||||||
WikivoyageSearchResult prev = wikivoyage.get(rs.cityId);
|
WikivoyageSearchResult prev = wikivoyage.get(rs.cityId);
|
||||||
if (prev != null) {
|
if (prev != null) {
|
||||||
int insInd = prev.langs.size();
|
int insInd = prev.langs.size();
|
||||||
if (rs.getLang().get(0).equals(baseLng)) {
|
if (rs.langs.get(0).equals(baseLng)) {
|
||||||
insInd = 0;
|
insInd = 0;
|
||||||
} else if (rs.getLang().get(0).equals("en")) {
|
} else if (rs.langs.get(0).equals("en")) {
|
||||||
if (!prev.getLang().get(0).equals(baseLng)) {
|
if (!prev.langs.get(0).equals(baseLng)) {
|
||||||
insInd = 0;
|
insInd = 0;
|
||||||
} else {
|
} else {
|
||||||
insInd = 1;
|
insInd = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prev.articleTitle.add(insInd, rs.articleTitle.get(0));
|
prev.articleTitles.add(insInd, rs.articleTitles.get(0));
|
||||||
prev.langs.add(insInd, rs.langs.get(0));
|
prev.langs.add(insInd, rs.langs.get(0));
|
||||||
prev.searchTerm.add(insInd, rs.searchTerm.get(0));
|
prev.searchTerms.add(insInd, rs.searchTerms.get(0));
|
||||||
} else {
|
} else {
|
||||||
wikivoyage.put(rs.cityId, rs);
|
wikivoyage.put(rs.cityId, rs);
|
||||||
}
|
}
|
||||||
|
@ -175,9 +175,9 @@ public class WikivoyageDbHelper {
|
||||||
private WikivoyageSearchResult readSearchResult(SQLiteCursor cursor) {
|
private WikivoyageSearchResult readSearchResult(SQLiteCursor cursor) {
|
||||||
WikivoyageSearchResult res = new WikivoyageSearchResult();
|
WikivoyageSearchResult res = new WikivoyageSearchResult();
|
||||||
|
|
||||||
res.searchTerm.add(cursor.getString(0));
|
res.searchTerms.add(cursor.getString(0));
|
||||||
res.cityId = cursor.getLong(1);
|
res.cityId = cursor.getLong(1);
|
||||||
res.articleTitle.add(cursor.getString(2));
|
res.articleTitles.add(cursor.getString(2));
|
||||||
res.langs.add(cursor.getString(3));
|
res.langs.add(cursor.getString(3));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -8,9 +8,9 @@ import java.util.List;
|
||||||
|
|
||||||
public class WikivoyageSearchResult implements Parcelable {
|
public class WikivoyageSearchResult implements Parcelable {
|
||||||
|
|
||||||
List<String> searchTerm = new ArrayList<>();
|
List<String> searchTerms = new ArrayList<>();
|
||||||
long cityId;
|
long cityId;
|
||||||
List<String> articleTitle = new ArrayList<>();
|
List<String> articleTitles = new ArrayList<>();
|
||||||
List<String> langs = new ArrayList<>();
|
List<String> langs = new ArrayList<>();
|
||||||
|
|
||||||
WikivoyageSearchResult() {
|
WikivoyageSearchResult() {
|
||||||
|
@ -18,25 +18,25 @@ public class WikivoyageSearchResult implements Parcelable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private WikivoyageSearchResult(Parcel in) {
|
private WikivoyageSearchResult(Parcel in) {
|
||||||
searchTerm = in.createStringArrayList();
|
searchTerms = in.createStringArrayList();
|
||||||
cityId = in.readLong();
|
cityId = in.readLong();
|
||||||
articleTitle = in.createStringArrayList();
|
articleTitles = in.createStringArrayList();
|
||||||
langs = in.createStringArrayList();
|
langs = in.createStringArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSearchTerm() {
|
public List<String> getSearchTerms() {
|
||||||
return searchTerm;
|
return searchTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCityId() {
|
public long getCityId() {
|
||||||
return cityId;
|
return cityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getArticleTitle() {
|
public List<String> getArticleTitles() {
|
||||||
return articleTitle;
|
return articleTitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getLang() {
|
public List<String> getLangs() {
|
||||||
return langs;
|
return langs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ public class WikivoyageSearchResult implements Parcelable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeStringList(searchTerm);
|
dest.writeStringList(searchTerms);
|
||||||
dest.writeLong(cityId);
|
dest.writeLong(cityId);
|
||||||
dest.writeStringList(articleTitle);
|
dest.writeStringList(articleTitles);
|
||||||
dest.writeStringList(langs);
|
dest.writeStringList(langs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
holder.icon.setImageDrawable(
|
holder.icon.setImageDrawable(
|
||||||
iconsCache.getIcon(R.drawable.ic_action_placeholder_city, R.color.icon_color)
|
iconsCache.getIcon(R.drawable.ic_action_placeholder_city, R.color.icon_color)
|
||||||
);
|
);
|
||||||
holder.title.setText(item.getArticleTitle().get(0));
|
holder.title.setText(item.getArticleTitles().get(0));
|
||||||
holder.description.setText(item.getLang().get(0));
|
holder.description.setText(item.getLangs().get(0));
|
||||||
holder.divider.setVisibility(lastItem ? View.GONE : View.VISIBLE);
|
holder.divider.setVisibility(lastItem ? View.GONE : View.VISIBLE);
|
||||||
holder.shadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
|
holder.shadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue