[android] Notifications. Review fixes

This commit is contained in:
Arsentiy Milchakov 2018-04-03 14:32:14 +03:00 committed by Aleksandr Zatsepin
parent 9fab79459c
commit 9a5573859b
6 changed files with 15 additions and 27 deletions

View file

@ -708,7 +708,7 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity
{
String countryId = intent.getStringExtra(EXTRA_COUNTRY);
mMapTaskToForward = new MwmActivity.ShowCountryTask(countryId, false);
mMapTaskToForward = new MwmActivity.ShowCountryTask(countryId);
org.alohalytics.Statistics.logEvent("OpenCountryTaskProcessor::process",
new String[] { "autoDownload", "false" },
LocationHelper.INSTANCE.getSavedLocation());

View file

@ -322,7 +322,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
private VisibleRectMeasurer mVisibleRectMeasurer;
public static Intent createShowMapIntent(Context context, String countryId)
public static Intent createShowMapIntent(@NonNull Context context, @Nullable String countryId)
{
return new Intent(context, DownloadResourcesLegacyActivity.class)
.putExtra(DownloadResourcesLegacyActivity.EXTRA_COUNTRY, countryId);
@ -1724,21 +1724,16 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
private static final long serialVersionUID = 1L;
private final String mCountryId;
private final boolean mDoAutoDownload;
public ShowCountryTask(String countryId, boolean doAutoDownload)
public ShowCountryTask(String countryId)
{
mCountryId = countryId;
mDoAutoDownload = doAutoDownload;
}
@Override
public boolean run(MwmActivity target)
{
if (mDoAutoDownload)
MapManager.warn3gAndDownload(target, mCountryId, null);
Framework.nativeShowCountry(mCountryId, mDoAutoDownload);
Framework.nativeShowCountry(mCountryId, false);
return true;
}
}

View file

@ -5,16 +5,12 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.PermissionsUtils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
import static com.mapswithme.maps.MwmApplication.backgroundTracker;
import static com.mapswithme.maps.MwmApplication.prefs;
public class ConnectivityChangedReceiver extends BroadcastReceiver
{
@ -24,6 +20,13 @@ public class ConnectivityChangedReceiver extends BroadcastReceiver
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent != null ? intent.getAction() : null;
if (!CONNECTIVITY_ACTION.equals(action))
{
LOGGER.w(TAG, "An intent with wrong action detected: " + action);
return;
}
String msg = "onReceive: " + intent + " app in background = "
+ !backgroundTracker().isForeground();
LOGGER.i(TAG, msg);

View file

@ -39,7 +39,7 @@ public final class Notifier
{
}
public static void notifyDownloadFailed(String id, String name)
public static void notifyDownloadFailed(@Nullable String id, @Nullable String name)
{
String title = APP.getString(R.string.app_name);
String content = APP.getString(R.string.download_country_failed, name);

View file

@ -1,28 +1,18 @@
package com.mapswithme.maps.background;
import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.text.TextUtils;
import android.util.Log;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.downloader.CountryItem;
import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.maps.editor.Editor;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.ugc.UGC;
import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.PermissionsUtils;
import com.mapswithme.util.concurrency.UiThread;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
import java.util.concurrent.CountDownLatch;
public class WorkerService extends IntentService
{
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
@ -69,7 +59,7 @@ public class WorkerService extends IntentService
CrashlyticsUtils.log(Log.INFO, TAG, msg);
final String action = intent.getAction();
if (action == null)
if (TextUtils.isEmpty(action))
return;
switch (action)

View file

@ -180,7 +180,7 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
{
Intent intent = new Intent(adapter.mActivity, MwmActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.putExtra(MwmActivity.EXTRA_TASK, new MwmActivity.ShowCountryTask(item.id, false));
intent.putExtra(MwmActivity.EXTRA_TASK, new MwmActivity.ShowCountryTask(item.id));
adapter.mActivity.startActivity(intent);
if (!(adapter.mActivity instanceof MwmActivity))