Add a method to retrieve an article by title and language

This commit is contained in:
Alex Sytnyk 2018-06-06 22:24:36 +03:00
parent 4be4bb5733
commit efaac44a27

View file

@ -3,6 +3,7 @@ package net.osmand.plus.wikivoyage.data;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import net.osmand.Collator; import net.osmand.Collator;
import net.osmand.CollatorStringMatcher; import net.osmand.CollatorStringMatcher;
import net.osmand.CollatorStringMatcher.StringMatcherMode; import net.osmand.CollatorStringMatcher.StringMatcherMode;
@ -31,7 +32,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
@ -529,6 +529,23 @@ public class TravelDbHelper {
return res; return res;
} }
@Nullable
public TravelArticle getArticle(String title, String lang) {
TravelArticle res = null;
SQLiteConnection conn = openConnection();
if (conn != null) {
SQLiteCursor cursor = conn.rawQuery(ARTICLES_TABLE_SELECT + " WHERE " + ARTICLES_COL_TITLE + " = ? AND "
+ ARTICLES_COL_LANG + " = ?", new String[]{title, lang});
if (cursor != null) {
if (cursor.moveToFirst()) {
res = readArticle(cursor);
}
cursor.close();
}
}
return res;
}
public long getArticleId(String title, String lang) { public long getArticleId(String title, String lang) {
long res = 0; long res = 0;
SQLiteConnection conn = openConnection(); SQLiteConnection conn = openConnection();