Rename fields in WikivoyageSearchResult

This commit is contained in:
Alex Sytnyk 2018-04-02 16:57:25 +03:00
parent d1f4ac1c6f
commit 194f926af2
4 changed files with 25 additions and 25 deletions

View file

@ -102,7 +102,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
}
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);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
@ -130,7 +130,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
return;
}
if (selectedLang == null) {
selectedLang = searchResult.getLang().get(0);
selectedLang = searchResult.getLangs().get(0);
}
selectedLangTv.setText(selectedLang);

View file

@ -100,12 +100,12 @@ public class WikivoyageDbHelper {
Collections.sort(list, new Comparator<WikivoyageSearchResult>() {
@Override
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);
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);
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) {
return -1;
} else if (c2) {
@ -125,18 +125,18 @@ public class WikivoyageDbHelper {
WikivoyageSearchResult prev = wikivoyage.get(rs.cityId);
if (prev != null) {
int insInd = prev.langs.size();
if (rs.getLang().get(0).equals(baseLng)) {
if (rs.langs.get(0).equals(baseLng)) {
insInd = 0;
} else if (rs.getLang().get(0).equals("en")) {
if (!prev.getLang().get(0).equals(baseLng)) {
} else if (rs.langs.get(0).equals("en")) {
if (!prev.langs.get(0).equals(baseLng)) {
insInd = 0;
} else {
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.searchTerm.add(insInd, rs.searchTerm.get(0));
prev.searchTerms.add(insInd, rs.searchTerms.get(0));
} else {
wikivoyage.put(rs.cityId, rs);
}
@ -175,9 +175,9 @@ public class WikivoyageDbHelper {
private WikivoyageSearchResult readSearchResult(SQLiteCursor cursor) {
WikivoyageSearchResult res = new WikivoyageSearchResult();
res.searchTerm.add(cursor.getString(0));
res.searchTerms.add(cursor.getString(0));
res.cityId = cursor.getLong(1);
res.articleTitle.add(cursor.getString(2));
res.articleTitles.add(cursor.getString(2));
res.langs.add(cursor.getString(3));
return res;

View file

@ -8,9 +8,9 @@ import java.util.List;
public class WikivoyageSearchResult implements Parcelable {
List<String> searchTerm = new ArrayList<>();
List<String> searchTerms = new ArrayList<>();
long cityId;
List<String> articleTitle = new ArrayList<>();
List<String> articleTitles = new ArrayList<>();
List<String> langs = new ArrayList<>();
WikivoyageSearchResult() {
@ -18,25 +18,25 @@ public class WikivoyageSearchResult implements Parcelable {
}
private WikivoyageSearchResult(Parcel in) {
searchTerm = in.createStringArrayList();
searchTerms = in.createStringArrayList();
cityId = in.readLong();
articleTitle = in.createStringArrayList();
articleTitles = in.createStringArrayList();
langs = in.createStringArrayList();
}
public List<String> getSearchTerm() {
return searchTerm;
public List<String> getSearchTerms() {
return searchTerms;
}
public long getCityId() {
return cityId;
}
public List<String> getArticleTitle() {
return articleTitle;
public List<String> getArticleTitles() {
return articleTitles;
}
public List<String> getLang() {
public List<String> getLangs() {
return langs;
}
@ -47,9 +47,9 @@ public class WikivoyageSearchResult implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeStringList(searchTerm);
dest.writeStringList(searchTerms);
dest.writeLong(cityId);
dest.writeStringList(articleTitle);
dest.writeStringList(articleTitles);
dest.writeStringList(langs);
}

View file

@ -63,8 +63,8 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
holder.icon.setImageDrawable(
iconsCache.getIcon(R.drawable.ic_action_placeholder_city, R.color.icon_color)
);
holder.title.setText(item.getArticleTitle().get(0));
holder.description.setText(item.getLang().get(0));
holder.title.setText(item.getArticleTitles().get(0));
holder.description.setText(item.getLangs().get(0));
holder.divider.setVisibility(lastItem ? View.GONE : View.VISIBLE);
holder.shadow.setVisibility(lastItem ? View.VISIBLE : View.GONE);
}