Rename travel db helper and introduce settings for markers
This commit is contained in:
parent
263d3e764e
commit
899941c2fc
11 changed files with 64 additions and 64 deletions
|
@ -445,7 +445,7 @@ public class AppInitializer implements IProgress {
|
||||||
app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class);
|
app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class);
|
||||||
app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
|
app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
|
||||||
app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
|
app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
|
||||||
app.wikivoyageDbHelper = startupInit(new TravelDbHelper(app), TravelDbHelper.class);
|
app.travelDbHelper = startupInit(new TravelDbHelper(app), TravelDbHelper.class);
|
||||||
|
|
||||||
initOpeningHoursParser();
|
initOpeningHoursParser();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||||
import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
|
import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
|
||||||
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
@ -504,8 +504,8 @@ public class MapMarkersHelper {
|
||||||
List<MapMarkersGroup> res = new ArrayList<>();
|
List<MapMarkersGroup> res = new ArrayList<>();
|
||||||
TravelDbHelper travelDbHelper = ctx.getTravelDbHelper();
|
TravelDbHelper travelDbHelper = ctx.getTravelDbHelper();
|
||||||
if(travelDbHelper.getSelectedTravelBook() != null) {
|
if(travelDbHelper.getSelectedTravelBook() != null) {
|
||||||
List<WikivoyageArticle> savedArticles = travelDbHelper.getLocalDataHelper().getSavedArticles();
|
List<TravelArticle> savedArticles = travelDbHelper.getLocalDataHelper().getSavedArticles();
|
||||||
for (WikivoyageArticle art : savedArticles) {
|
for (TravelArticle art : savedArticles) {
|
||||||
String gpxName = travelDbHelper.getGPXName(art);
|
String gpxName = travelDbHelper.getGPXName(art);
|
||||||
File path = ctx.getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName);
|
File path = ctx.getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName);
|
||||||
MapMarkersGroup group = getOrCreateGroup(new File(path.getAbsolutePath()));
|
MapMarkersGroup group = getOrCreateGroup(new File(path.getAbsolutePath()));
|
||||||
|
|
|
@ -34,9 +34,9 @@ import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment;
|
import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageWebViewClient;
|
import net.osmand.plus.wikivoyage.WikivoyageWebViewClient;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||||
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -98,7 +98,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
private long cityId = NO_VALUE;
|
private long cityId = NO_VALUE;
|
||||||
private ArrayList<String> langs;
|
private ArrayList<String> langs;
|
||||||
private String selectedLang;
|
private String selectedLang;
|
||||||
private WikivoyageArticle article;
|
private TravelArticle article;
|
||||||
|
|
||||||
private TextView trackButton;
|
private TextView trackButton;
|
||||||
private TextView selectedLangTv;
|
private TextView selectedLangTv;
|
||||||
|
@ -267,7 +267,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
|
|
||||||
private void updateSaveButton() {
|
private void updateSaveButton() {
|
||||||
if (article != null) {
|
if (article != null) {
|
||||||
final WikivoyageLocalDataHelper helper = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
final TravelLocalDataHelper helper = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
||||||
final boolean saved = helper.isArticleSaved(article);
|
final boolean saved = helper.isArticleSaved(article);
|
||||||
Drawable icon = getActiveIcon(saved ? R.drawable.ic_action_read_later_fill : R.drawable.ic_action_read_later);
|
Drawable icon = getActiveIcon(saved ? R.drawable.ic_action_read_later_fill : R.drawable.ic_action_read_later);
|
||||||
saveBtn.setText(getString(saved ? R.string.shared_string_delete : R.string.shared_string_save));
|
saveBtn.setText(getString(saved ? R.string.shared_string_delete : R.string.shared_string_save));
|
||||||
|
@ -335,7 +335,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
trackButton.setText(getString(R.string.points) + " (" + article.getGpxFile().getPointsSize() +")");
|
trackButton.setText(getString(R.string.points) + " (" + article.getGpxFile().getPointsSize() +")");
|
||||||
}
|
}
|
||||||
|
|
||||||
WikivoyageLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
||||||
ldh.addToHistory(article);
|
ldh.addToHistory(article);
|
||||||
|
|
||||||
updateSaveButton();
|
updateSaveButton();
|
||||||
|
@ -348,12 +348,12 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private String createHtmlContent(@NonNull WikivoyageArticle article) {
|
private String createHtmlContent(@NonNull TravelArticle article) {
|
||||||
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
||||||
|
|
||||||
String imageTitle = article.getImageTitle();
|
String imageTitle = article.getImageTitle();
|
||||||
if (!TextUtils.isEmpty(imageTitle)) {
|
if (!TextUtils.isEmpty(imageTitle)) {
|
||||||
String url = WikivoyageArticle.getImageUrl(imageTitle, false);
|
String url = TravelArticle.getImageUrl(imageTitle, false);
|
||||||
sb.append("<div class=\"title-image\" style=\"background-image: url(").append(url).append(")\"></div>");
|
sb.append("<div class=\"title-image\" style=\"background-image: url(").append(url).append(")\"></div>");
|
||||||
}
|
}
|
||||||
sb.append("<div class=\"main\">\n");
|
sb.append("<div class=\"main\">\n");
|
||||||
|
|
|
@ -11,7 +11,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import org.apache.commons.codec.binary.Hex;
|
import org.apache.commons.codec.binary.Hex;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
|
||||||
public class WikivoyageArticle {
|
public class TravelArticle {
|
||||||
|
|
||||||
private static final String IMAGE_ROOT_URL = "https://upload.wikimedia.org/wikipedia/commons/";
|
private static final String IMAGE_ROOT_URL = "https://upload.wikimedia.org/wikipedia/commons/";
|
||||||
private static final String THUMB_PREFIX = "320px-";
|
private static final String THUMB_PREFIX = "320px-";
|
|
@ -75,7 +75,7 @@ public class TravelDbHelper {
|
||||||
private File selectedTravelBook = null;
|
private File selectedTravelBook = null;
|
||||||
private List<File> existingTravelBooks = new ArrayList<>();
|
private List<File> existingTravelBooks = new ArrayList<>();
|
||||||
private Collator collator;
|
private Collator collator;
|
||||||
private WikivoyageLocalDataHelper localDataHelper;
|
private TravelLocalDataHelper localDataHelper;
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class TravelDbHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WikivoyageLocalDataHelper getLocalDataHelper() {
|
public TravelLocalDataHelper getLocalDataHelper() {
|
||||||
initTravelBooks();
|
initTravelBooks();
|
||||||
return localDataHelper;
|
return localDataHelper;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class TravelDbHelper {
|
||||||
File[] possibleFiles = application.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles();
|
File[] possibleFiles = application.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles();
|
||||||
String travelBook = application.getSettings().SELECTED_TRAVEL_BOOK.get();
|
String travelBook = application.getSettings().SELECTED_TRAVEL_BOOK.get();
|
||||||
existingTravelBooks.clear();
|
existingTravelBooks.clear();
|
||||||
localDataHelper = new WikivoyageLocalDataHelper(application);
|
localDataHelper = new TravelLocalDataHelper(application);
|
||||||
if (possibleFiles != null) {
|
if (possibleFiles != null) {
|
||||||
for (File f : possibleFiles) {
|
for (File f : possibleFiles) {
|
||||||
if (f.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) {
|
if (f.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) {
|
||||||
|
@ -243,8 +243,8 @@ public class TravelDbHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public WikivoyageArticle getArticle(long cityId, String lang) {
|
public TravelArticle getArticle(long cityId, String lang) {
|
||||||
WikivoyageArticle res = null;
|
TravelArticle res = null;
|
||||||
SQLiteConnection conn = openConnection();
|
SQLiteConnection conn = openConnection();
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
SQLiteCursor cursor = conn.rawQuery(ARTICLES_TABLE_SELECT + " WHERE " + ARTICLES_COL_CITY_ID + " = ? AND "
|
SQLiteCursor cursor = conn.rawQuery(ARTICLES_TABLE_SELECT + " WHERE " + ARTICLES_COL_CITY_ID + " = ? AND "
|
||||||
|
@ -302,8 +302,8 @@ public class TravelDbHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private WikivoyageArticle readArticle(SQLiteCursor cursor) {
|
private TravelArticle readArticle(SQLiteCursor cursor) {
|
||||||
WikivoyageArticle res = new WikivoyageArticle();
|
TravelArticle res = new TravelArticle();
|
||||||
|
|
||||||
res.id = cursor.getString(0);
|
res.id = cursor.getString(0);
|
||||||
res.title = cursor.getString(1);
|
res.title = cursor.getString(1);
|
||||||
|
@ -339,7 +339,7 @@ public class TravelDbHelper {
|
||||||
return nm.substring(0, nm.indexOf('.')).replace('_', ' ');
|
return nm.substring(0, nm.indexOf('.')).replace('_', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGPXName(WikivoyageArticle article) {
|
public String getGPXName(TravelArticle article) {
|
||||||
return article.getTitle().replace('/', '_').replace('\'', '_').replace('\"', '_') + ".gpx";
|
return article.getTitle().replace('/', '_').replace('\'', '_').replace('\"', '_') + ".gpx";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,14 @@ import java.util.List;
|
||||||
|
|
||||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||||
|
|
||||||
public class WikivoyageLocalDataHelper {
|
public class TravelLocalDataHelper {
|
||||||
|
|
||||||
private static final int HISTORY_ITEMS_LIMIT = 300;
|
private static final int HISTORY_ITEMS_LIMIT = 300;
|
||||||
|
|
||||||
private WikivoyageLocalDataDbHelper dbHelper;
|
private WikivoyageLocalDataDbHelper dbHelper;
|
||||||
|
|
||||||
private TLongObjectHashMap<WikivoyageSearchHistoryItem> historyMap;
|
private TLongObjectHashMap<WikivoyageSearchHistoryItem> historyMap;
|
||||||
private List<WikivoyageArticle> savedArticles;
|
private List<TravelArticle> savedArticles;
|
||||||
|
|
||||||
private Listener listener;
|
private Listener listener;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class WikivoyageLocalDataHelper {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
WikivoyageLocalDataHelper(OsmandApplication app) {
|
TravelLocalDataHelper(OsmandApplication app) {
|
||||||
dbHelper = new WikivoyageLocalDataDbHelper(app);
|
dbHelper = new WikivoyageLocalDataDbHelper(app);
|
||||||
refreshCachedData();
|
refreshCachedData();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class WikivoyageLocalDataHelper {
|
||||||
dbHelper.clearAllHistory();
|
dbHelper.clearAllHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToHistory(@NonNull WikivoyageArticle article) {
|
public void addToHistory(@NonNull TravelArticle article) {
|
||||||
addToHistory(article.getCityId(), article.getTitle(), article.getLang(), article.getIsPartOf());
|
addToHistory(article.getCityId(), article.getTitle(), article.getLang(), article.getIsPartOf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,13 +90,13 @@ public class WikivoyageLocalDataHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public List<WikivoyageArticle> getSavedArticles() {
|
public List<TravelArticle> getSavedArticles() {
|
||||||
return new ArrayList<>(savedArticles);
|
return new ArrayList<>(savedArticles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addArticleToSaved(@NonNull WikivoyageArticle article) {
|
public void addArticleToSaved(@NonNull TravelArticle article) {
|
||||||
if (!isArticleSaved(article)) {
|
if (!isArticleSaved(article)) {
|
||||||
WikivoyageArticle saved = new WikivoyageArticle();
|
TravelArticle saved = new TravelArticle();
|
||||||
saved.cityId = article.cityId;
|
saved.cityId = article.cityId;
|
||||||
saved.title = article.title;
|
saved.title = article.title;
|
||||||
saved.lang = article.lang;
|
saved.lang = article.lang;
|
||||||
|
@ -109,7 +109,7 @@ public class WikivoyageLocalDataHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreSavedArticle(@NonNull WikivoyageArticle article) {
|
public void restoreSavedArticle(@NonNull TravelArticle article) {
|
||||||
if (!isArticleSaved(article)) {
|
if (!isArticleSaved(article)) {
|
||||||
savedArticles.add(article);
|
savedArticles.add(article);
|
||||||
dbHelper.addSavedArticle(article);
|
dbHelper.addSavedArticle(article);
|
||||||
|
@ -117,8 +117,8 @@ public class WikivoyageLocalDataHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeArticleFromSaved(@NonNull WikivoyageArticle article) {
|
public void removeArticleFromSaved(@NonNull TravelArticle article) {
|
||||||
WikivoyageArticle savedArticle = getArticle(article.cityId, article.lang);
|
TravelArticle savedArticle = getArticle(article.cityId, article.lang);
|
||||||
if (savedArticle != null) {
|
if (savedArticle != null) {
|
||||||
savedArticles.remove(savedArticle);
|
savedArticles.remove(savedArticle);
|
||||||
dbHelper.removeSavedArticle(savedArticle);
|
dbHelper.removeSavedArticle(savedArticle);
|
||||||
|
@ -126,7 +126,7 @@ public class WikivoyageLocalDataHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isArticleSaved(@NonNull WikivoyageArticle article) {
|
public boolean isArticleSaved(@NonNull TravelArticle article) {
|
||||||
return getArticle(article.cityId, article.lang) != null;
|
return getArticle(article.cityId, article.lang) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,8 +137,8 @@ public class WikivoyageLocalDataHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private WikivoyageArticle getArticle(long cityId, String lang) {
|
private TravelArticle getArticle(long cityId, String lang) {
|
||||||
for (WikivoyageArticle article : savedArticles) {
|
for (TravelArticle article : savedArticles) {
|
||||||
if (article.cityId == cityId && article.lang != null && article.lang.equals(lang)) {
|
if (article.cityId == cityId && article.lang != null && article.lang.equals(lang)) {
|
||||||
return article;
|
return article;
|
||||||
}
|
}
|
||||||
|
@ -340,8 +340,8 @@ public class WikivoyageLocalDataHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
List<WikivoyageArticle> getSavedArticles() {
|
List<TravelArticle> getSavedArticles() {
|
||||||
List<WikivoyageArticle> res = new ArrayList<>();
|
List<TravelArticle> res = new ArrayList<>();
|
||||||
SQLiteConnection conn = openConnection(true);
|
SQLiteConnection conn = openConnection(true);
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -361,7 +361,7 @@ public class WikivoyageLocalDataHelper {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSavedArticle(WikivoyageArticle article) {
|
void addSavedArticle(TravelArticle article) {
|
||||||
SQLiteConnection conn = openConnection(false);
|
SQLiteConnection conn = openConnection(false);
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -375,7 +375,7 @@ public class WikivoyageLocalDataHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeSavedArticle(WikivoyageArticle article) {
|
void removeSavedArticle(TravelArticle article) {
|
||||||
SQLiteConnection conn = openConnection(false);
|
SQLiteConnection conn = openConnection(false);
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -403,8 +403,8 @@ public class WikivoyageLocalDataHelper {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private WikivoyageArticle readSavedArticle(SQLiteCursor cursor) {
|
private TravelArticle readSavedArticle(SQLiteCursor cursor) {
|
||||||
WikivoyageArticle res = new WikivoyageArticle();
|
TravelArticle res = new TravelArticle();
|
||||||
|
|
||||||
res.cityId = cursor.getLong(0);
|
res.cityId = cursor.getLong(0);
|
||||||
res.title = cursor.getString(1);
|
res.title = cursor.getString(1);
|
|
@ -23,8 +23,8 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
||||||
import net.osmand.plus.widgets.tools.CropRectTransformation;
|
import net.osmand.plus.widgets.tools.CropRectTransformation;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -80,10 +80,10 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||||
holder.description.setText(String.valueOf(items.size() - 1));
|
holder.description.setText(String.valueOf(items.size() - 1));
|
||||||
} else {
|
} else {
|
||||||
final ItemVH holder = (ItemVH) viewHolder;
|
final ItemVH holder = (ItemVH) viewHolder;
|
||||||
WikivoyageArticle article = (WikivoyageArticle) getItem(position);
|
TravelArticle article = (TravelArticle) getItem(position);
|
||||||
boolean lastItem = position == getItemCount() - 1;
|
boolean lastItem = position == getItemCount() - 1;
|
||||||
RequestCreator rc = Picasso.get()
|
RequestCreator rc = Picasso.get()
|
||||||
.load(WikivoyageArticle.getImageUrl(article.getImageTitle(), false));
|
.load(TravelArticle.getImageUrl(article.getImageTitle(), false));
|
||||||
WikivoyageUtils.setupNetworkPolicy(settings, rc);
|
WikivoyageUtils.setupNetworkPolicy(settings, rc);
|
||||||
rc.transform(USE_ALTERNATIVE_CARD ? new CropRectTransformation() : new CropCircleTransformation())
|
rc.transform(USE_ALTERNATIVE_CARD ? new CropRectTransformation() : new CropCircleTransformation())
|
||||||
.into(holder.icon, new Callback() {
|
.into(holder.icon, new Callback() {
|
||||||
|
@ -174,9 +174,9 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Object item = getItemByPosition();
|
Object item = getItemByPosition();
|
||||||
if (item != null && item instanceof WikivoyageArticle) {
|
if (item != null && item instanceof TravelArticle) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.openArticle((WikivoyageArticle) item);
|
listener.openArticle((TravelArticle) item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,9 +189,9 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Object item = getItemByPosition();
|
Object item = getItemByPosition();
|
||||||
if (item != null && item instanceof WikivoyageArticle) {
|
if (item != null && item instanceof TravelArticle) {
|
||||||
final WikivoyageArticle article = (WikivoyageArticle) item;
|
final TravelArticle article = (TravelArticle) item;
|
||||||
final WikivoyageLocalDataHelper ldh = app.getTravelDbHelper().getLocalDataHelper();;
|
final TravelLocalDataHelper ldh = app.getTravelDbHelper().getLocalDataHelper();;
|
||||||
ldh.removeArticleFromSaved(article);
|
ldh.removeArticleFromSaved(article);
|
||||||
Snackbar snackbar = Snackbar.make(itemView, R.string.article_removed, Snackbar.LENGTH_LONG)
|
Snackbar snackbar = Snackbar.make(itemView, R.string.article_removed, Snackbar.LENGTH_LONG)
|
||||||
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
||||||
|
@ -218,6 +218,6 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
void openArticle(WikivoyageArticle article);
|
void openArticle(TravelArticle article);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||||
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SavedArticlesTabFragment extends BaseOsmAndFragment implements WikivoyageLocalDataHelper.Listener {
|
public class SavedArticlesTabFragment extends BaseOsmAndFragment implements TravelLocalDataHelper.Listener {
|
||||||
|
|
||||||
protected static final Log LOG = PlatformUtil.getLog(SavedArticlesTabFragment.class);
|
protected static final Log LOG = PlatformUtil.getLog(SavedArticlesTabFragment.class);
|
||||||
|
|
||||||
private WikivoyageLocalDataHelper dataHelper;
|
private TravelLocalDataHelper dataHelper;
|
||||||
|
|
||||||
private SavedArticlesRvAdapter adapter;
|
private SavedArticlesRvAdapter adapter;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Wiki
|
||||||
adapter = new SavedArticlesRvAdapter(app);
|
adapter = new SavedArticlesRvAdapter(app);
|
||||||
adapter.setListener(new SavedArticlesRvAdapter.Listener() {
|
adapter.setListener(new SavedArticlesRvAdapter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void openArticle(WikivoyageArticle article) {
|
public void openArticle(TravelArticle article) {
|
||||||
FragmentManager fm = getFragmentManager();
|
FragmentManager fm = getFragmentManager();
|
||||||
if (fm != null) {
|
if (fm != null) {
|
||||||
WikivoyageArticleDialogFragment.showInstance(app, fm, article.getCityId(), article.getLang());
|
WikivoyageArticleDialogFragment.showInstance(app, fm, article.getCityId(), article.getLang());
|
||||||
|
@ -84,7 +84,7 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Wiki
|
||||||
|
|
||||||
private List<Object> getItems() {
|
private List<Object> getItems() {
|
||||||
List<Object> items = new ArrayList<>();
|
List<Object> items = new ArrayList<>();
|
||||||
List<WikivoyageArticle> savedArticles = dataHelper.getSavedArticles();
|
List<TravelArticle> savedArticles = dataHelper.getSavedArticles();
|
||||||
if (!savedArticles.isEmpty()) {
|
if (!savedArticles.isEmpty()) {
|
||||||
Collections.reverse(savedArticles);
|
Collections.reverse(savedArticles);
|
||||||
items.add(getString(R.string.saved_articles));
|
items.add(getString(R.string.saved_articles));
|
||||||
|
@ -126,12 +126,12 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Wiki
|
||||||
Object newItem = newItems.get(newItemPosition);
|
Object newItem = newItems.get(newItemPosition);
|
||||||
if (oldItem instanceof String && newItem instanceof String) {
|
if (oldItem instanceof String && newItem instanceof String) {
|
||||||
return false;
|
return false;
|
||||||
} else if (oldItem instanceof WikivoyageArticle && newItem instanceof WikivoyageArticle) {
|
} else if (oldItem instanceof TravelArticle && newItem instanceof TravelArticle) {
|
||||||
if (newItemPosition == newItems.size() - 1 && lastItemChanged()) {
|
if (newItemPosition == newItems.size() - 1 && lastItemChanged()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
WikivoyageArticle oldArticle = (WikivoyageArticle) oldItem;
|
TravelArticle oldArticle = (TravelArticle) oldItem;
|
||||||
WikivoyageArticle newArticle = (WikivoyageArticle) newItem;
|
TravelArticle newArticle = (TravelArticle) newItem;
|
||||||
return oldArticle.getCityId() == newArticle.getCityId()
|
return oldArticle.getCityId() == newArticle.getCityId()
|
||||||
&& oldArticle.getLang().equals(newArticle.getLang());
|
&& oldArticle.getLang().equals(newArticle.getLang());
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -110,7 +110,7 @@ public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetD
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
WikivoyageLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
||||||
ldh.clearHistory();
|
ldh.clearHistory();
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageSearchHistoryItem;
|
import net.osmand.plus.wikivoyage.data.WikivoyageSearchHistoryItem;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult;
|
import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -77,7 +77,7 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
|
||||||
if (item instanceof WikivoyageSearchResult) {
|
if (item instanceof WikivoyageSearchResult) {
|
||||||
WikivoyageSearchResult searchRes = (WikivoyageSearchResult) item;
|
WikivoyageSearchResult searchRes = (WikivoyageSearchResult) item;
|
||||||
RequestCreator rc = Picasso.get()
|
RequestCreator rc = Picasso.get()
|
||||||
.load(WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true));
|
.load(TravelArticle.getImageUrl(searchRes.getImageTitle(), true));
|
||||||
WikivoyageUtils.setupNetworkPolicy(app.getSettings(), rc);
|
WikivoyageUtils.setupNetworkPolicy(app.getSettings(), rc);
|
||||||
rc.transform(new CropCircleTransformation())
|
rc.transform(new CropCircleTransformation())
|
||||||
.placeholder(placeholder)
|
.placeholder(placeholder)
|
||||||
|
|
|
@ -22,7 +22,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageSearchHistoryItem;
|
import net.osmand.plus.wikivoyage.data.WikivoyageSearchHistoryItem;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult;
|
import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ public class WikivoyageSearchDialogFragment extends WikivoyageBaseDialogFragment
|
||||||
|
|
||||||
private void setAdapterItems(@Nullable List<WikivoyageSearchResult> items) {
|
private void setAdapterItems(@Nullable List<WikivoyageSearchResult> items) {
|
||||||
if (items == null || items.isEmpty()) {
|
if (items == null || items.isEmpty()) {
|
||||||
WikivoyageLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
||||||
adapter.setHistoryItems(ldh.getAllHistory());
|
adapter.setHistoryItems(ldh.getAllHistory());
|
||||||
} else {
|
} else {
|
||||||
adapter.setItems(items);
|
adapter.setItems(items);
|
||||||
|
|
Loading…
Reference in a new issue