Refactor some code
This commit is contained in:
parent
57fd20ef9e
commit
2914d883bf
4 changed files with 25 additions and 25 deletions
|
@ -230,9 +230,9 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
private String createHtmlContent(@NonNull WikivoyageArticle article) {
|
||||
StringBuilder sb = new StringBuilder(HEADER_INNER);
|
||||
|
||||
String articleImageTitle = article.getImageTitle();
|
||||
if (!TextUtils.isEmpty(articleImageTitle)&&getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) {
|
||||
String url = WikivoyageArticle.getImageUrl(articleImageTitle, false);
|
||||
String imageTitle = article.getImageTitle();
|
||||
if (!TextUtils.isEmpty(imageTitle) && getSettings().WIKIVOYAGE_SHOW_IMAGES.get()) {
|
||||
String url = WikivoyageArticle.getImageUrl(imageTitle, false);
|
||||
sb.append("<div class=\"title-image\" style=\"background-image: url(").append(url).append(")\"></div>");
|
||||
}
|
||||
sb.append("<div class=\"main\">\n");
|
||||
|
|
|
@ -41,6 +41,15 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
|
||||
setupToolbar((Toolbar) mainView.findViewById(R.id.toolbar));
|
||||
|
||||
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
WikivoyageOptionsBottomSheetDialogFragment fragment = new WikivoyageOptionsBottomSheetDialogFragment();
|
||||
fragment.setUsedOnMap(false);
|
||||
fragment.show(getChildFragmentManager(), WikivoyageOptionsBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
});
|
||||
|
||||
int searchColorId = nightMode ? R.color.icon_color : R.color.ctx_menu_title_color_dark;
|
||||
((TextView) mainView.findViewById(R.id.search_hint)).setTextColor(getResolvedColor(searchColorId));
|
||||
((ImageView) mainView.findViewById(R.id.search_icon))
|
||||
|
@ -53,15 +62,6 @@ public class WikivoyageExploreDialogFragment extends WikivoyageBaseDialogFragmen
|
|||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OptionsImagesCacheHistoryBottomSheetDialogFragment fragment = new OptionsImagesCacheHistoryBottomSheetDialogFragment();
|
||||
fragment.setUsedOnMap(false);
|
||||
fragment.show(getChildFragmentManager(), OptionsImagesCacheHistoryBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
});
|
||||
|
||||
final LockableViewPager viewPager = (LockableViewPager) mainView.findViewById(R.id.view_pager);
|
||||
viewPager.setOffscreenPageLimit(2);
|
||||
viewPager.setSwipeLocked(true);
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.os.Bundle;
|
|||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
|
@ -15,32 +16,31 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
|||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
||||
|
||||
public class OptionsImagesCacheHistoryBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
public class WikivoyageOptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "OptionsImagesCasheBottomSheetDialogFragment";
|
||||
public final static String TAG = "WikivoyageOptionsBottomSheetDialogFragment";
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
final OsmandApplication app = getMyApplication();
|
||||
final OsmandSettings.CommonPreference<Boolean> showImagesPref = app.getSettings().WIKIVOYAGE_SHOW_IMAGES;
|
||||
|
||||
items.add(new TitleItem(getString(R.string.shared_string_options)));
|
||||
|
||||
boolean showImages = getMyApplication().getSettings().WIKIVOYAGE_SHOW_IMAGES.get();
|
||||
|
||||
BaseBottomSheetItem showWebviewImagesItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(showImages)
|
||||
BaseBottomSheetItem showImagesItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(showImagesPref.get())
|
||||
.setIcon(getContentIcon(R.drawable.ic_type_img))
|
||||
.setTitle(getString(R.string.show_images))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_switch)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandSettings settings = getMyApplication().getSettings();
|
||||
settings.WIKIVOYAGE_SHOW_IMAGES.set(!settings.WIKIVOYAGE_SHOW_IMAGES.get());
|
||||
showImagesPref.set(!showImagesPref.get());
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(showWebviewImagesItem);
|
||||
items.add(showImagesItem);
|
||||
|
||||
BaseBottomSheetItem clearCacheItem = new BottomSheetItemWithDescription.Builder()
|
||||
.setDescription(getString(R.string.shared_string_clear))
|
||||
|
@ -65,7 +65,7 @@ public class OptionsImagesCacheHistoryBottomSheetDialogFragment extends MenuBott
|
|||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
WikivoyageLocalDataHelper.getInstance(getMyApplication()).clearHistory();
|
||||
WikivoyageLocalDataHelper.getInstance(app).clearHistory();
|
||||
dismiss();
|
||||
}
|
||||
})
|
|
@ -74,8 +74,8 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
if (item instanceof WikivoyageSearchResult) {
|
||||
WikivoyageSearchResult searchRes = (WikivoyageSearchResult) item;
|
||||
Picasso.get()
|
||||
.load(app.getSettings().WIKIVOYAGE_SHOW_IMAGES.get() ?
|
||||
WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true) : null)
|
||||
.load(app.getSettings().WIKIVOYAGE_SHOW_IMAGES.get()
|
||||
? WikivoyageArticle.getImageUrl(searchRes.getImageTitle(), true) : null)
|
||||
.transform(new CropCircleTransformation())
|
||||
.placeholder(placeholder)
|
||||
.into(holder.icon);
|
||||
|
|
Loading…
Reference in a new issue