From b7716188193b4f362875cfd3cb7042973c2ef989 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Thu, 18 Oct 2018 12:01:57 +0300 Subject: [PATCH] Refactor DiscountHelper#showDiscountBanner --- .../osmand/plus/helpers/DiscountHelper.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java index 8b289f1a1a..bc60a93eea 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java @@ -166,15 +166,18 @@ public class DiscountHelper { return result; } - private static void showDiscountBanner(final MapActivity mapActivity, final String title, - final String description, final String icon, final String url) { + private static void showDiscountBanner(final MapActivity mapActivity, + final String title, + final String description, + final String icon, + final String url) { + int iconId = mapActivity.getResources().getIdentifier(icon, "drawable", mapActivity.getMyApplication().getPackageName()); final DiscountBarController toolbarController = new DiscountBarController(); toolbarController.setTitle(title); toolbarController.setDescription(description); - int iconId = mapActivity.getResources().getIdentifier(icon, "drawable", mapActivity.getMyApplication().getPackageName()); toolbarController.setBackBtnIconIds(iconId, iconId); if (!Algorithms.isEmpty(url)) { - toolbarController.setOnBackButtonClickListener(new View.OnClickListener() { + View.OnClickListener clickListener = new View.OnClickListener() { @Override public void onClick(View v) { mapActivity.getMyApplication().logEvent(mapActivity, "motd_click"); @@ -182,16 +185,9 @@ public class DiscountHelper { mapActivity.hideTopToolbar(toolbarController); openUrl(mapActivity, url); } - }); - toolbarController.setOnTitleClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - mapActivity.getMyApplication().logEvent(mapActivity, "motd_click"); - mBannerVisible = false; - mapActivity.hideTopToolbar(toolbarController); - openUrl(mapActivity, url); - } - }); + }; + toolbarController.setOnBackButtonClickListener(clickListener); + toolbarController.setOnTitleClickListener(clickListener); } toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() { @Override