From 567d8274ace9f23978273bbf7075574545e7fd6e Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 3 May 2018 14:18:03 +0300 Subject: [PATCH] made methods abstract and moved writeOutHTML to ArticleBaseDialogFragment --- .../wikipedia/ArticleBaseDialogFragment.java | 25 +++++++++++++------ .../WikivoyageArticleDialogFragment.java | 12 --------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java index 32adc2842d..31ea93b628 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/ArticleBaseDialogFragment.java @@ -3,6 +3,7 @@ package net.osmand.plus.wikipedia; import android.graphics.drawable.Drawable; import android.os.Build; import android.support.annotation.NonNull; +import android.util.Log; import android.view.View; import android.webkit.WebSettings; import android.webkit.WebView; @@ -14,9 +15,12 @@ import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment; +import java.io.BufferedWriter; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; -public class ArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { +public abstract class ArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { protected static final String HEADER_INNER = "\n" + "\n" + @@ -128,18 +132,23 @@ public class ArticleBaseDialogFragment extends WikivoyageBaseDialogFragment { return nightMode ? R.color.status_bar_wikivoyage_article_dark : R.color.status_bar_wikivoyage_article_light; } - protected void showPopupLangMenu(View view, final String langSelected) { - } + protected abstract void showPopupLangMenu(View view, final String langSelected); - protected void populateArticle() { - } + protected abstract void populateArticle(); @NonNull - protected String createHtmlContent() { - return ""; - } + protected abstract String createHtmlContent(); protected void writeOutHTML(StringBuilder sb) { + File file = new File(getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), "page.html"); + BufferedWriter writer = null; + try { + writer = new BufferedWriter(new FileWriter(file)); + writer.write(sb.toString()); + writer.close(); + } catch (IOException e) { + Log.w("ArticleDialog", e.getMessage(), e); + } } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 9bfbaeb360..fdf0c96d5f 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -354,18 +354,6 @@ public class WikivoyageArticleDialogFragment extends ArticleBaseDialogFragment { return sb.toString(); } - protected void writeOutHTML(StringBuilder sb) { - File file = new File(getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), "page.html"); - BufferedWriter writer = null; - try { - writer = new BufferedWriter(new FileWriter(file)); - writer.write(sb.toString()); - writer.close(); - } catch (IOException e) { - Log.w("ArticleDialog", e.getMessage(), e); - } - } - public static boolean showInstance(@NonNull OsmandApplication app, @NonNull FragmentManager fm, long cityId,