Show the "is part of" in corresponding language in wikivoyage search list

This commit is contained in:
Alex Sytnyk 2018-04-18 22:50:32 +03:00
parent a9c4a74824
commit 4c7779c813
3 changed files with 8 additions and 7 deletions

View file

@ -184,7 +184,7 @@ public class TravelDbHelper {
rs.cityId = cursor.getLong(0); rs.cityId = cursor.getLong(0);
rs.articleTitles.add(cursor.getString(1)); rs.articleTitles.add(cursor.getString(1));
rs.langs.add(cursor.getString(2)); rs.langs.add(cursor.getString(2));
rs.isPartOf = cursor.getString(3); rs.isPartOf.add(cursor.getString(3));
rs.imageTitle = cursor.getString(4); rs.imageTitle = cursor.getString(4);
res.add(rs); res.add(rs);
} while (cursor.moveToNext()); } while (cursor.moveToNext());
@ -237,6 +237,7 @@ public class TravelDbHelper {
} }
prev.articleTitles.add(insInd, rs.articleTitles.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.isPartOf.add(insInd, rs.isPartOf.get(0));
} else { } else {
wikivoyage.put(rs.cityId, rs); wikivoyage.put(rs.cityId, rs);
} }
@ -287,11 +288,11 @@ public class TravelDbHelper {
rs.cityId = cursor.getLong(0); rs.cityId = cursor.getLong(0);
rs.articleTitles.add(cursor.getString(1)); rs.articleTitles.add(cursor.getString(1));
rs.langs.add(cursor.getString(2)); rs.langs.add(cursor.getString(2));
rs.isPartOf = cursor.getString(3); rs.isPartOf.add(cursor.getString(3));
List<WikivoyageSearchResult> l = navMap.get(rs.isPartOf); List<WikivoyageSearchResult> l = navMap.get(rs.isPartOf.get(0));
if (l == null) { if (l == null) {
l = new ArrayList<>(); l = new ArrayList<>();
navMap.put(rs.isPartOf, l); navMap.put(rs.isPartOf.get(0), l);
} }
l.add(rs); l.add(rs);
} while (cursor.moveToNext()); } while (cursor.moveToNext());

View file

@ -12,7 +12,7 @@ public class WikivoyageSearchResult {
long cityId; long cityId;
List<String> articleTitles = new ArrayList<>(); List<String> articleTitles = new ArrayList<>();
List<String> langs = new ArrayList<>(); List<String> langs = new ArrayList<>();
String isPartOf; List<String> isPartOf = new ArrayList<>();
String imageTitle; String imageTitle;
public long getCityId() { public long getCityId() {
@ -27,7 +27,7 @@ public class WikivoyageSearchResult {
return langs; return langs;
} }
public String getIsPartOf() { public List<String> getIsPartOf() {
return isPartOf; return isPartOf;
} }

View file

@ -82,7 +82,7 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
.placeholder(placeholder) .placeholder(placeholder)
.into(holder.icon); .into(holder.icon);
holder.title.setText(searchRes.getArticleTitles().get(0)); holder.title.setText(searchRes.getArticleTitles().get(0));
holder.leftDescr.setText(searchRes.getIsPartOf()); holder.leftDescr.setText(searchRes.getIsPartOf().get(0));
holder.rightDescr.setText(searchRes.getFirstLangsString()); holder.rightDescr.setText(searchRes.getFirstLangsString());
} else { } else {
WikivoyageSearchHistoryItem historyItem = (WikivoyageSearchHistoryItem) item; WikivoyageSearchHistoryItem historyItem = (WikivoyageSearchHistoryItem) item;