Refactor DiscountHelper#showDiscountBanner
This commit is contained in:
parent
1093e22768
commit
b771618819
1 changed files with 10 additions and 14 deletions
|
@ -166,15 +166,18 @@ public class DiscountHelper {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void showDiscountBanner(final MapActivity mapActivity, final String title,
|
private static void showDiscountBanner(final MapActivity mapActivity,
|
||||||
final String description, final String icon, final String url) {
|
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();
|
final DiscountBarController toolbarController = new DiscountBarController();
|
||||||
toolbarController.setTitle(title);
|
toolbarController.setTitle(title);
|
||||||
toolbarController.setDescription(description);
|
toolbarController.setDescription(description);
|
||||||
int iconId = mapActivity.getResources().getIdentifier(icon, "drawable", mapActivity.getMyApplication().getPackageName());
|
|
||||||
toolbarController.setBackBtnIconIds(iconId, iconId);
|
toolbarController.setBackBtnIconIds(iconId, iconId);
|
||||||
if (!Algorithms.isEmpty(url)) {
|
if (!Algorithms.isEmpty(url)) {
|
||||||
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
|
View.OnClickListener clickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mapActivity.getMyApplication().logEvent(mapActivity, "motd_click");
|
mapActivity.getMyApplication().logEvent(mapActivity, "motd_click");
|
||||||
|
@ -182,16 +185,9 @@ public class DiscountHelper {
|
||||||
mapActivity.hideTopToolbar(toolbarController);
|
mapActivity.hideTopToolbar(toolbarController);
|
||||||
openUrl(mapActivity, url);
|
openUrl(mapActivity, url);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
toolbarController.setOnTitleClickListener(new View.OnClickListener() {
|
toolbarController.setOnBackButtonClickListener(clickListener);
|
||||||
@Override
|
toolbarController.setOnTitleClickListener(clickListener);
|
||||||
public void onClick(View v) {
|
|
||||||
mapActivity.getMyApplication().logEvent(mapActivity, "motd_click");
|
|
||||||
mBannerVisible = false;
|
|
||||||
mapActivity.hideTopToolbar(toolbarController);
|
|
||||||
openUrl(mapActivity, url);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() {
|
toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue