Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Donskoy <donskdmitry@mail.ru>2018-08-28 19:37:04 +0300
committerAleksandr Zatsepin <alexzatsepin@users.noreply.github.com>2018-08-29 14:01:26 +0300
commitd74618ddcb6ed9ef086e6877dbee26b210c00209 (patch)
tree63f642bfa96420ea0573e953753449b7f68d49ca /android
parent192c29caa3a56a85309273ab5e56c96757c00e3e (diff)
[android] Fixed review notes
Diffstat (limited to 'android')
-rw-r--r--android/src/com/mapswithme/maps/MwmActivity.java2
-rw-r--r--android/src/com/mapswithme/maps/MwmApplication.java7
-rw-r--r--android/src/com/mapswithme/maps/auth/PassportAuthDialogFragment.java19
-rw-r--r--android/src/com/mapswithme/maps/background/NotificationChannelFactory.java16
-rw-r--r--android/src/com/mapswithme/maps/background/NotificationChannelProvider.java113
-rw-r--r--android/src/com/mapswithme/maps/background/NotificationService.java10
-rw-r--r--android/src/com/mapswithme/maps/background/Notifier.java16
-rw-r--r--android/src/com/mapswithme/maps/background/OreoCompatNotificationChannelProvider.java50
-rw-r--r--android/src/com/mapswithme/maps/background/StubNotificationChannelProvider.java64
-rw-r--r--android/src/com/mapswithme/maps/base/BaseMwmDialogFragment.java2
-rw-r--r--android/src/com/mapswithme/maps/bookmarks/BookmarkBackupController.java2
-rw-r--r--android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java13
-rw-r--r--android/src/com/mapswithme/maps/downloader/ExpandRetryConfirmationListener.java29
-rw-r--r--android/src/com/mapswithme/maps/downloader/MapManager.java18
-rw-r--r--android/src/com/mapswithme/maps/downloader/OnmapDownloader.java2
-rw-r--r--android/src/com/mapswithme/maps/downloader/RetryFailedDownloadConfirmationListener.java24
-rw-r--r--android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java2
17 files changed, 222 insertions, 167 deletions
diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java
index 8a334e1e5e..7ba5962c4e 100644
--- a/android/src/com/mapswithme/maps/MwmActivity.java
+++ b/android/src/com/mapswithme/maps/MwmActivity.java
@@ -1216,7 +1216,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (intent == null)
return false;
- final Notifier notifier = new Notifier(getApplication());
+ final Notifier notifier = Notifier.from(getApplication());
notifier.processNotificationExtras(intent);
if (intent.hasExtra(EXTRA_TASK))
diff --git a/android/src/com/mapswithme/maps/MwmApplication.java b/android/src/com/mapswithme/maps/MwmApplication.java
index dc317d1003..620f3df3d9 100644
--- a/android/src/com/mapswithme/maps/MwmApplication.java
+++ b/android/src/com/mapswithme/maps/MwmApplication.java
@@ -16,6 +16,7 @@ import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.core.CrashlyticsCore;
import com.crashlytics.android.ndk.CrashlyticsNdk;
import com.mapswithme.maps.background.AppBackgroundTracker;
+import com.mapswithme.maps.background.NotificationChannelFactory;
import com.mapswithme.maps.background.NotificationChannelProvider;
import com.mapswithme.maps.background.Notifier;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
@@ -169,18 +170,18 @@ public class MwmApplication extends Application
mPrefs = getSharedPreferences(getString(R.string.pref_file_name), MODE_PRIVATE);
initCoreIndependentSdks();
+ initNotificationChannels();
mBackgroundTracker = new AppBackgroundTracker();
mBackgroundTracker.addListener(mVisibleAppLaunchListener);
mSubwayManager = new SubwayManager(this);
mConnectivityListener = new ConnectivityJobScheduler(this);
mConnectivityListener.listen();
- initNotificationChannels();
}
private void initNotificationChannels()
{
- NotificationChannelProvider channelProvider = NotificationChannelProvider.from(this);
+ NotificationChannelProvider channelProvider = NotificationChannelFactory.createProvider(this);
channelProvider.setAuthChannel();
channelProvider.setDownloadingChannel();
}
@@ -485,7 +486,7 @@ public class MwmApplication extends Application
@Override
public void onStatusChanged(List<MapManager.StorageCallbackData> data)
{
- Notifier notifier = new Notifier(MwmApplication.this);
+ Notifier notifier = Notifier.from(MwmApplication.this);
for (MapManager.StorageCallbackData item : data)
if (item.isLeafNode && item.newStatus == CountryItem.STATUS_FAILED)
{
diff --git a/android/src/com/mapswithme/maps/auth/PassportAuthDialogFragment.java b/android/src/com/mapswithme/maps/auth/PassportAuthDialogFragment.java
index 4f8da3ecb0..1500d87494 100644
--- a/android/src/com/mapswithme/maps/auth/PassportAuthDialogFragment.java
+++ b/android/src/com/mapswithme/maps/auth/PassportAuthDialogFragment.java
@@ -17,9 +17,8 @@ public class PassportAuthDialogFragment extends BaseMwmDialogFragment
@NonNull
private final Authorizer mAuthorizer = new Authorizer(this);
- @SuppressWarnings("NullableProblems")
@NonNull
- private AuthCallback mAuthCallback;
+ private final AuthCallback mAuthCallback = new AuthCallback();
@Nullable
private Bundle mSavedInstanceState;
@@ -28,8 +27,6 @@ public class PassportAuthDialogFragment extends BaseMwmDialogFragment
public void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
- Notifier notifier = new Notifier(getAppContextOrThrow());
- mAuthCallback = new AuthCallback(notifier);
mSavedInstanceState = savedInstanceState;
}
@@ -66,21 +63,15 @@ public class PassportAuthDialogFragment extends BaseMwmDialogFragment
private class AuthCallback implements Authorizer.Callback
{
- @NonNull
- private final Notifier mNotifier;
-
- AuthCallback(@NonNull Notifier notifier)
- {
- mNotifier = notifier;
- }
-
@Override
public void onAuthorizationFinish(boolean success)
{
dismiss();
-
if (success)
- mNotifier.cancelNotification(Notifier.ID_IS_NOT_AUTHENTICATED);
+ {
+ Notifier notifier = Notifier.from(getActivity().getApplication());
+ notifier.cancelNotification(Notifier.ID_IS_NOT_AUTHENTICATED);
+ }
}
@Override
diff --git a/android/src/com/mapswithme/maps/background/NotificationChannelFactory.java b/android/src/com/mapswithme/maps/background/NotificationChannelFactory.java
new file mode 100644
index 0000000000..57a6acd396
--- /dev/null
+++ b/android/src/com/mapswithme/maps/background/NotificationChannelFactory.java
@@ -0,0 +1,16 @@
+package com.mapswithme.maps.background;
+
+import android.app.Application;
+import android.support.annotation.NonNull;
+
+import com.mapswithme.util.Utils;
+
+public class NotificationChannelFactory
+{
+ @NonNull
+ public static NotificationChannelProvider createProvider(@NonNull Application app)
+ {
+ return Utils.isOreoOrLater() ? new OreoCompatNotificationChannelProvider(app)
+ : new StubNotificationChannelProvider(app);
+ }
+}
diff --git a/android/src/com/mapswithme/maps/background/NotificationChannelProvider.java b/android/src/com/mapswithme/maps/background/NotificationChannelProvider.java
index 7745faf387..0305bf8c97 100644
--- a/android/src/com/mapswithme/maps/background/NotificationChannelProvider.java
+++ b/android/src/com/mapswithme/maps/background/NotificationChannelProvider.java
@@ -1,15 +1,7 @@
package com.mapswithme.maps.background;
-import android.annotation.TargetApi;
-import android.app.Application;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.os.Build;
import android.support.annotation.NonNull;
-import com.mapswithme.maps.R;
-import com.mapswithme.util.Utils;
-
public interface NotificationChannelProvider
{
@NonNull
@@ -21,109 +13,4 @@ public interface NotificationChannelProvider
String getDownloadingChannel();
void setDownloadingChannel();
-
- class DefaultNotificationChannelProvider implements NotificationChannelProvider
- {
- private static final String DEFAULT_NOTIFICATION_CHANNEL = "default_notification_channel";
-
- @NonNull
- private final Application mApplication;
-
- @NonNull
- private final String mAuthChannel;
-
- @NonNull
- private final String mDownloadingChannel;
-
-
- DefaultNotificationChannelProvider(@NonNull Application context, @NonNull String authChannel,
- @NonNull String downloadingChannel)
- {
- mApplication = context;
- mAuthChannel = authChannel;
- mDownloadingChannel = downloadingChannel;
- }
-
- DefaultNotificationChannelProvider(@NonNull Application context)
- {
- this(context, DEFAULT_NOTIFICATION_CHANNEL, DEFAULT_NOTIFICATION_CHANNEL);
- }
-
- @Override
- @NonNull
- public String getAuthChannel()
- {
- return mAuthChannel;
- }
-
- @Override
- public void setAuthChannel()
- {
- /*Do nothing */
- }
-
- @NonNull
- @Override
- public String getDownloadingChannel()
- {
- return mDownloadingChannel;
- }
-
- @Override
- public void setDownloadingChannel()
- {
- /*Do nothing */
- }
-
- @NonNull
- protected Application getApplication()
- {
- return mApplication;
- }
- }
-
- @NonNull
- static NotificationChannelProvider from(@NonNull Application app)
- {
- return Utils.isOreoOrLater() ? new OreoCompatProvider(app)
- : new DefaultNotificationChannelProvider(app);
- }
-
- @TargetApi(Build.VERSION_CODES.O)
- class OreoCompatProvider extends DefaultNotificationChannelProvider
- {
- private static final String AUTH_NOTIFICATION_CHANNEL = "auth_notification_channel";
- private static final String DOWNLOADING_NOTIFICATION_CHANNEL = "downloading_notification_channel";
-
- OreoCompatProvider(@NonNull Application app)
- {
- super(app, AUTH_NOTIFICATION_CHANNEL, DOWNLOADING_NOTIFICATION_CHANNEL);
- }
-
- @Override
- public void setAuthChannel()
- {
- String name = getApplication().getString(R.string.notification_unsent_reviews_title);
- setChannelInternal(getAuthChannel(), name);
- }
-
- private void setChannelInternal(@NonNull String id, @NonNull String name)
- {
- NotificationManager notificationManager = getApplication().getSystemService(NotificationManager.class);
- NotificationChannel channel = notificationManager.getNotificationChannel(id);
- if (channel == null)
- channel = new NotificationChannel(id, name, NotificationManager.IMPORTANCE_DEFAULT);
- else
- channel.setName(name);
- notificationManager.createNotificationChannel(channel);
- }
-
-
- @Override
- public void setDownloadingChannel()
- {
- String name = "NEED STRING ID FOR CHANNEL";
- setChannelInternal(getDownloadingChannel(), name);
- }
- }
}
diff --git a/android/src/com/mapswithme/maps/background/NotificationService.java b/android/src/com/mapswithme/maps/background/NotificationService.java
index 83759fbd31..a27a93f4c6 100644
--- a/android/src/com/mapswithme/maps/background/NotificationService.java
+++ b/android/src/com/mapswithme/maps/background/NotificationService.java
@@ -1,6 +1,5 @@
package com.mapswithme.maps.background;
-import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
@@ -26,8 +25,7 @@ public class NotificationService extends JobIntentService
private static final String TAG = NotificationService.class.getSimpleName();
private static final String LAST_AUTH_NOTIFICATION_TIMESTAMP = "DownloadOrUpdateTimestamp";
private static final int MIN_COUNT_UNSENT_UGC = 2;
- private static final int DAYS_COUNT = 5;
- private static final long MIN_AUTH_EVENT_DELTA_MILLIS = TimeUnit.DAYS.toMillis(DAYS_COUNT);
+ private static final long MIN_AUTH_EVENT_DELTA_MILLIS = TimeUnit.DAYS.toMillis(5);
private interface NotificationExecutor
{
@@ -43,7 +41,7 @@ public class NotificationService extends JobIntentService
JobIntentService.enqueueWork(context, NotificationService.class, jobId, intent);
}
- private static boolean notifyIsNotAuthenticated(@NonNull Application application)
+ private boolean notifyIsNotAuthenticated()
{
if (!PermissionsUtils.isExternalStorageGranted() ||
!NetworkPolicy.getCurrentNetworkUsageStatus() ||
@@ -76,7 +74,7 @@ public class NotificationService extends JobIntentService
.putLong(LAST_AUTH_NOTIFICATION_TIMESTAMP, System.currentTimeMillis())
.apply();
- Notifier notifier = new Notifier(application);
+ Notifier notifier = Notifier.from(getApplication());
notifier.notifyAuthentication();
return true;
@@ -99,7 +97,7 @@ public class NotificationService extends JobIntentService
{
final NotificationExecutor notifyOrder[] =
{
- () -> notifyIsNotAuthenticated(getApplication())
+ this::notifyIsNotAuthenticated
};
// Only one notification should be shown at a time.
diff --git a/android/src/com/mapswithme/maps/background/Notifier.java b/android/src/com/mapswithme/maps/background/Notifier.java
index cd771e01da..6bf3e2d2e8 100644
--- a/android/src/com/mapswithme/maps/background/Notifier.java
+++ b/android/src/com/mapswithme/maps/background/Notifier.java
@@ -36,7 +36,7 @@ public final class Notifier
{
}
- public Notifier(@NonNull Application context)
+ private Notifier(@NonNull Application context)
{
mContext = context;
}
@@ -51,7 +51,7 @@ public final class Notifier
PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
- String channel = NotificationChannelProvider.from(mContext).getDownloadingChannel();
+ String channel = NotificationChannelFactory.createProvider(mContext).getDownloadingChannel();
placeNotification(title, content, pi, ID_DOWNLOAD_FAILED, channel);
Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOAD_COUNTRY_NOTIFICATION_SHOWN);
}
@@ -66,7 +66,7 @@ public final class Notifier
PendingIntent pi = PendingIntent.getActivity(mContext, 0, authIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
- String channel = NotificationChannelProvider.from(mContext).getAuthChannel();
+ String channel = NotificationChannelFactory.createProvider(mContext).getAuthChannel();
NotificationCompat.Builder builder =
getBuilder(mContext.getString(R.string.notification_unsent_reviews_title),
mContext.getString(R.string.notification_unsent_reviews_message),
@@ -114,6 +114,7 @@ public final class Notifier
getNotificationManager().notify(notificationId, notification);
}
+ @NonNull
private NotificationCompat.Builder getBuilder(String title, String content,
PendingIntent pendingIntent, @NonNull String channel)
{
@@ -128,6 +129,7 @@ public final class Notifier
.setContentIntent(pendingIntent);
}
+ @NonNull
private CharSequence getTicker(String title, String content)
{
int templateResId = StringUtils.isRtl() ? R.string.notification_ticker_rtl
@@ -135,8 +137,16 @@ public final class Notifier
return mContext.getString(templateResId, title, content);
}
+ @SuppressWarnings("ConstantConditions")
+ @NonNull
private NotificationManager getNotificationManager()
{
return (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
}
+
+ @NonNull
+ public static Notifier from(Application application)
+ {
+ return new Notifier(application);
+ }
}
diff --git a/android/src/com/mapswithme/maps/background/OreoCompatNotificationChannelProvider.java b/android/src/com/mapswithme/maps/background/OreoCompatNotificationChannelProvider.java
new file mode 100644
index 0000000000..64c34a96e1
--- /dev/null
+++ b/android/src/com/mapswithme/maps/background/OreoCompatNotificationChannelProvider.java
@@ -0,0 +1,50 @@
+package com.mapswithme.maps.background;
+
+import android.annotation.TargetApi;
+import android.app.Application;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.os.Build;
+import android.support.annotation.NonNull;
+
+import com.mapswithme.maps.R;
+
+import java.util.Objects;
+
+@TargetApi(Build.VERSION_CODES.O)
+public class OreoCompatNotificationChannelProvider extends StubNotificationChannelProvider
+{
+ private static final String AUTH_NOTIFICATION_CHANNEL = "auth_notification_channel";
+ private static final String DOWNLOADING_NOTIFICATION_CHANNEL = "downloading_notification_channel";
+
+ OreoCompatNotificationChannelProvider(@NonNull Application app)
+ {
+ super(app, AUTH_NOTIFICATION_CHANNEL, DOWNLOADING_NOTIFICATION_CHANNEL);
+ }
+
+ @Override
+ public void setAuthChannel()
+ {
+ String name = getApplication().getString(R.string.notification_unsent_reviews_title);
+ setChannelInternal(getAuthChannel(), name);
+ }
+
+ private void setChannelInternal(@NonNull String id, @NonNull String name)
+ {
+ NotificationManager notificationManager = getApplication().getSystemService(NotificationManager.class);
+ NotificationChannel channel = Objects.requireNonNull(notificationManager)
+ .getNotificationChannel(id);
+ if (channel == null)
+ channel = new NotificationChannel(id, name, NotificationManager.IMPORTANCE_DEFAULT);
+ else
+ channel.setName(name);
+ notificationManager.createNotificationChannel(channel);
+ }
+
+ @Override
+ public void setDownloadingChannel()
+ {
+ String name = "NEED STRING ID FOR CHANNEL";
+ setChannelInternal(getDownloadingChannel(), name);
+ }
+}
diff --git a/android/src/com/mapswithme/maps/background/StubNotificationChannelProvider.java b/android/src/com/mapswithme/maps/background/StubNotificationChannelProvider.java
new file mode 100644
index 0000000000..1847834d5e
--- /dev/null
+++ b/android/src/com/mapswithme/maps/background/StubNotificationChannelProvider.java
@@ -0,0 +1,64 @@
+package com.mapswithme.maps.background;
+
+import android.app.Application;
+import android.support.annotation.NonNull;
+
+public class StubNotificationChannelProvider implements NotificationChannelProvider
+{
+ private static final String DEFAULT_NOTIFICATION_CHANNEL = "default_notification_channel";
+
+ @NonNull
+ private final Application mApplication;
+
+ @NonNull
+ private final String mAuthChannel;
+
+ @NonNull
+ private final String mDownloadingChannel;
+
+
+ StubNotificationChannelProvider(@NonNull Application context, @NonNull String authChannel,
+ @NonNull String downloadingChannel)
+ {
+ mApplication = context;
+ mAuthChannel = authChannel;
+ mDownloadingChannel = downloadingChannel;
+ }
+
+ StubNotificationChannelProvider(@NonNull Application context)
+ {
+ this(context, DEFAULT_NOTIFICATION_CHANNEL, DEFAULT_NOTIFICATION_CHANNEL);
+ }
+
+ @Override
+ @NonNull
+ public String getAuthChannel()
+ {
+ return mAuthChannel;
+ }
+
+ @Override
+ public void setAuthChannel()
+ {
+ /*Do nothing */
+ }
+
+ @NonNull
+ @Override
+ public String getDownloadingChannel()
+ {
+ return mDownloadingChannel;
+ }
+
+ @Override
+ public void setDownloadingChannel()
+ {
+ /*Do nothing */
+ }
+
+ @NonNull
+ protected Application getApplication()
+ {
+ return mApplication;
+ }
+}
diff --git a/android/src/com/mapswithme/maps/base/BaseMwmDialogFragment.java b/android/src/com/mapswithme/maps/base/BaseMwmDialogFragment.java
index ceb44c53dc..9d738826b4 100644
--- a/android/src/com/mapswithme/maps/base/BaseMwmDialogFragment.java
+++ b/android/src/com/mapswithme/maps/base/BaseMwmDialogFragment.java
@@ -73,7 +73,7 @@ public class BaseMwmDialogFragment extends DialogFragment
{
Context context = getContext();
if (context == null)
- throw new IllegalStateException("Before call this method make sure that getContext() object exist");
+ throw new IllegalStateException("Before call this method make sure that the context exist");
return (Application) context.getApplicationContext();
}
}
diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkBackupController.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkBackupController.java
index e9968462d5..2ae8874f46 100644
--- a/android/src/com/mapswithme/maps/bookmarks/BookmarkBackupController.java
+++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkBackupController.java
@@ -225,7 +225,7 @@ public class BookmarkBackupController implements Authorizer.Callback,
LOGGER.d(TAG, "onAuthorizationFinish, success: " + success);
if (success)
{
- final Notifier notifier = new Notifier(mContext.getApplication());
+ final Notifier notifier = Notifier.from(mContext.getApplication());
notifier.cancelNotification(Notifier.ID_IS_NOT_AUTHENTICATED);
BookmarkManager.INSTANCE.setCloudEnabled(true);
Statistics.INSTANCE.trackEvent(Statistics.EventName.BM_SYNC_PROPOSAL_ENABLED);
diff --git a/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java b/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java
index 1f2e212ddb..908547c0e3 100644
--- a/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java
+++ b/android/src/com/mapswithme/maps/downloader/DownloaderAdapter.java
@@ -26,7 +26,6 @@ import android.widget.TextView;
import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
-import com.mapswithme.maps.background.Notifier;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.routing.RoutingController;
import com.mapswithme.util.BottomSheetHelper;
@@ -392,15 +391,9 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
break;
case CountryItem.STATUS_FAILED:
- final Notifier notifier = new Notifier(mActivity.getApplication());
- MapManager.warn3gAndRetry(mActivity, mItem.id, new Runnable()
- {
- @Override
- public void run()
- {
- notifier.cancelNotification(Notifier.ID_DOWNLOAD_FAILED);
- }
- });
+ RetryFailedDownloadConfirmationListener listener =
+ new RetryFailedDownloadConfirmationListener(mActivity.getApplication());
+ MapManager.warn3gAndRetry(mActivity, mItem.id, listener);
break;
case CountryItem.STATUS_UPDATABLE:
diff --git a/android/src/com/mapswithme/maps/downloader/ExpandRetryConfirmationListener.java b/android/src/com/mapswithme/maps/downloader/ExpandRetryConfirmationListener.java
new file mode 100644
index 0000000000..98e7eb11b2
--- /dev/null
+++ b/android/src/com/mapswithme/maps/downloader/ExpandRetryConfirmationListener.java
@@ -0,0 +1,29 @@
+package com.mapswithme.maps.downloader;
+
+import android.app.Application;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import com.mapswithme.util.Utils;
+
+class ExpandRetryConfirmationListener extends RetryFailedDownloadConfirmationListener
+{
+ @Nullable
+ private final Utils.Proc<Boolean> mDialogClickListener;
+
+ ExpandRetryConfirmationListener(@NonNull Application app,
+ @Nullable Utils.Proc<Boolean> dialogClickListener)
+ {
+ super(app);
+ mDialogClickListener = dialogClickListener;
+ }
+
+ @Override
+ public void run()
+ {
+ super.run();
+ if (mDialogClickListener == null)
+ return;
+ mDialogClickListener.invoke(true);
+ }
+}
diff --git a/android/src/com/mapswithme/maps/downloader/MapManager.java b/android/src/com/mapswithme/maps/downloader/MapManager.java
index c77fdd885a..c84ceb1352 100644
--- a/android/src/com/mapswithme/maps/downloader/MapManager.java
+++ b/android/src/com/mapswithme/maps/downloader/MapManager.java
@@ -1,6 +1,7 @@
package com.mapswithme.maps.downloader;
import android.app.Activity;
+import android.app.Application;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -10,7 +11,6 @@ import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
import com.mapswithme.maps.R;
-import com.mapswithme.maps.background.Notifier;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.Utils;
import com.mapswithme.util.statistics.Statistics;
@@ -117,7 +117,6 @@ public final class MapManager
throw new IllegalArgumentException("Given error can not be displayed: " + errorData.errorCode);
}
- final Notifier notifier = new Notifier(activity.getApplication());
AlertDialog dlg = new AlertDialog.Builder(activity)
.setTitle(R.string.country_status_download_failed)
.setMessage(text)
@@ -136,17 +135,10 @@ public final class MapManager
@Override
public void onClick(DialogInterface dialog, int which)
{
- warn3gAndRetry(activity, errorData.countryId, new Runnable()
- {
- @Override
- public void run()
- {
- notifier.cancelNotification(Notifier.ID_DOWNLOAD_FAILED);
-
- if (dialogClickListener != null)
- dialogClickListener.invoke(true);
- }
- });
+ Application app = activity.getApplication();
+ RetryFailedDownloadConfirmationListener listener
+ = new ExpandRetryConfirmationListener(app, dialogClickListener);
+ warn3gAndRetry(activity, errorData.countryId, listener);
}
}).create();
dlg.setCanceledOnTouchOutside(false);
diff --git a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java
index ed6aafaa99..1b8e2e32a5 100644
--- a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java
+++ b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java
@@ -197,7 +197,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
setAutodownloadLocked(true);
}
});
- final Notifier notifier = new Notifier(activity.getApplication());
+ final Notifier notifier = Notifier.from(activity.getApplication());
mButton.setOnClickListener(new View.OnClickListener()
{
@Override
diff --git a/android/src/com/mapswithme/maps/downloader/RetryFailedDownloadConfirmationListener.java b/android/src/com/mapswithme/maps/downloader/RetryFailedDownloadConfirmationListener.java
new file mode 100644
index 0000000000..1a01a1540b
--- /dev/null
+++ b/android/src/com/mapswithme/maps/downloader/RetryFailedDownloadConfirmationListener.java
@@ -0,0 +1,24 @@
+package com.mapswithme.maps.downloader;
+
+import android.app.Application;
+import android.support.annotation.NonNull;
+
+import com.mapswithme.maps.background.Notifier;
+
+public class RetryFailedDownloadConfirmationListener implements Runnable
+{
+ @NonNull
+ private final Application mApplication;
+
+ RetryFailedDownloadConfirmationListener(@NonNull Application application)
+ {
+ mApplication = application;
+ }
+
+ @Override
+ public void run()
+ {
+ final Notifier notifier = Notifier.from(mApplication);
+ notifier.cancelNotification(Notifier.ID_DOWNLOAD_FAILED);
+ }
+}
diff --git a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java
index 8ebe78eb0f..d2f0597886 100644
--- a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java
+++ b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java
@@ -109,7 +109,7 @@ public class UGCEditorFragment extends BaseMwmAuthorizationFragment
{
if (success)
{
- final Notifier notifier = new Notifier(getActivity().getApplication());
+ final Notifier notifier = Notifier.from(getActivity().getApplication());
notifier.cancelNotification(Notifier.ID_IS_NOT_AUTHENTICATED);
}