Refactoring

This commit is contained in:
Dima-1 2020-12-17 18:14:54 +02:00
parent 398724c9ff
commit b62c09b1d6
2 changed files with 12 additions and 25 deletions

View file

@ -1,7 +1,6 @@
package net.osmand.plus.wikivoyage.article;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
@ -44,7 +43,6 @@ import net.osmand.plus.wikivoyage.WikivoyageWebViewClient;
import net.osmand.plus.wikivoyage.data.TravelArticle;
import net.osmand.plus.wikivoyage.data.TravelHelper;
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
import net.osmand.plus.wikivoyage.explore.WikivoyageExploreActivity;
import net.osmand.util.Algorithms;
import java.io.File;
@ -55,7 +53,7 @@ import java.util.Map;
import static net.osmand.plus.wikipedia.WikiArticleShowImages.OFF;
public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragment implements TravelLocalDataHelper.Listener {
public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragment {
public static final String TAG = "WikivoyageArticleDialogFragment";
@ -212,7 +210,6 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
@Override
public void onPause() {
super.onPause();
getMyApplication().getTravelHelper().getBookmarksHelper().removeListener(this);
if (webViewClient != null) {
webViewClient.stopRunningAsyncTasks();
}
@ -221,7 +218,6 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
@Override
public void onResume() {
super.onResume();
getMyApplication().getTravelHelper().getBookmarksHelper().addListener(this);
OsmandSettings settings = getMyApplication().getSettings();
if (!settings.WIKI_ARTICLE_SHOW_IMAGES_ASKED.get()) {
FragmentActivity activity = getActivity();
@ -411,24 +407,6 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
}
}
@Override
public void savedArticlesUpdated() {
WikivoyageExploreActivity activity = getExploreActivity();
if (activity != null) {
activity.updateFragments();
}
}
@Nullable
private WikivoyageExploreActivity getExploreActivity() {
Activity activity = getActivity();
if (activity instanceof WikivoyageExploreActivity) {
return (WikivoyageExploreActivity) activity;
} else {
return null;
}
}
private class WikivoyageArticleWebAppInterface {
@JavascriptInterface

View file

@ -38,6 +38,7 @@ import net.osmand.plus.wikipedia.WikiArticleHelper;
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
import net.osmand.plus.wikivoyage.data.TravelArticle;
import net.osmand.plus.wikivoyage.data.TravelHelper;
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
import net.osmand.plus.wikivoyage.search.WikivoyageSearchDialogFragment;
import net.osmand.util.Algorithms;
@ -45,7 +46,8 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
public class WikivoyageExploreActivity extends TabActivity implements DownloadEvents, OnDialogFragmentResultListener {
public class WikivoyageExploreActivity extends TabActivity implements DownloadEvents, OnDialogFragmentResultListener,
TravelLocalDataHelper.Listener {
private static final String TAB_SELECTED = "tab_selected";
private static final String ROUTE_ID_KEY = "route_id_key";
@ -189,6 +191,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
setIntent(null);
}
getMyApplication().getDownloadThread().setUiActivity(this);
app.getTravelHelper().getBookmarksHelper().addListener(this);
}
protected void parseLaunchIntentLink(Uri data) {
@ -210,6 +213,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
protected void onPause() {
super.onPause();
getMyApplication().getDownloadThread().resetUiActivity(this);
app.getTravelHelper().getBookmarksHelper().removeListener(this);
}
@Nullable
@ -349,7 +353,12 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
}
public void onTabFragmentResume(Fragment fragment) {
updateFragments();
updateFragments();
}
@Override
public void savedArticlesUpdated() {
updateFragments();
}
private static class LoadWikivoyageData extends AsyncTask<Void, Void, Void> {