forked from organicmaps/organicmaps-tmp
[android] PR comments fixes.
This commit is contained in:
parent
442224bebd
commit
3bea44f852
8 changed files with 21 additions and 24 deletions
|
@ -48,6 +48,7 @@ public class MwmApplication extends android.app.Application implements ActiveCou
|
|||
|
||||
private static MwmApplication mSelf;
|
||||
private final Gson mGson = new Gson();
|
||||
private static SharedPreferences mPrefs;
|
||||
|
||||
private boolean mAreStatsInitialised;
|
||||
|
||||
|
@ -67,9 +68,9 @@ public class MwmApplication extends android.app.Application implements ActiveCou
|
|||
return mSelf.mGson;
|
||||
}
|
||||
|
||||
public static SharedPreferences getMwmSharedPreferences()
|
||||
public static SharedPreferences prefs()
|
||||
{
|
||||
return mSelf.getSharedPreferences(mSelf.getString(R.string.pref_file_name), MODE_PRIVATE);
|
||||
return mPrefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -147,8 +148,8 @@ public class MwmApplication extends android.app.Application implements ActiveCou
|
|||
|
||||
// init BookmarkManager (automatically loads bookmarks)
|
||||
BookmarkManager.getIcons();
|
||||
|
||||
initParse();
|
||||
mPrefs = getSharedPreferences(getString(R.string.pref_file_name), MODE_PRIVATE);
|
||||
}
|
||||
|
||||
private void initMyTracker()
|
||||
|
@ -254,7 +255,7 @@ public class MwmApplication extends android.app.Application implements ActiveCou
|
|||
@Override
|
||||
public void done(ParseException e)
|
||||
{
|
||||
SharedPreferences prefs = getMwmSharedPreferences();
|
||||
SharedPreferences prefs = prefs();
|
||||
String previousId = prefs.getString(PREF_PARSE_INSTALLATION_ID, "");
|
||||
String previousToken = prefs.getString(PREF_PARSE_DEVICE_TOKEN, "");
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public abstract class FacebookBasePedestrianDialogFragment extends BaseMwmDialog
|
|||
final LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
|
||||
@SuppressLint("InflateParams") final View root = buildView(inflater);
|
||||
builder.
|
||||
return builder.
|
||||
setView(root).
|
||||
setNegativeButton(R.string.dialog_routing_not_now, new DialogInterface.OnClickListener()
|
||||
{
|
||||
|
@ -43,9 +43,7 @@ public abstract class FacebookBasePedestrianDialogFragment extends BaseMwmDialog
|
|||
// TODO share
|
||||
Statistics.INSTANCE.trackSimpleNamedEvent(Statistics.EventName.FACEBOOK_PEDESTRIAN_SHARE);
|
||||
}
|
||||
});
|
||||
|
||||
return builder.create();
|
||||
}).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.mapswithme.maps.ads;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.text.format.DateUtils;
|
||||
|
@ -10,6 +8,7 @@ import android.util.SparseArray;
|
|||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.concurrency.UiThread;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
|
@ -84,7 +83,6 @@ public enum LikesManager
|
|||
}
|
||||
|
||||
private final boolean mIsNewUser = MwmApplication.get().getFirstInstallVersion() == BuildConfig.VERSION_CODE;
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
private Runnable mLikeRunnable;
|
||||
private WeakReference<FragmentActivity> mActivityRef;
|
||||
|
||||
|
@ -103,7 +101,7 @@ public enum LikesManager
|
|||
|
||||
public void cancelDialogs()
|
||||
{
|
||||
mHandler.removeCallbacks(mLikeRunnable);
|
||||
UiThread.cancelDelayedTasks(mLikeRunnable);
|
||||
}
|
||||
|
||||
public void onPedestrianBuilt()
|
||||
|
@ -123,7 +121,7 @@ public enum LikesManager
|
|||
return;
|
||||
setSessionRated(SESSION_NUM);
|
||||
|
||||
mHandler.removeCallbacks(mLikeRunnable);
|
||||
UiThread.cancelDelayedTasks(mLikeRunnable);
|
||||
mLikeRunnable = new Runnable()
|
||||
{
|
||||
@SuppressWarnings("TryWithIdenticalCatches")
|
||||
|
@ -148,7 +146,7 @@ public enum LikesManager
|
|||
}
|
||||
}
|
||||
};
|
||||
mHandler.postDelayed(mLikeRunnable, delayMillis);
|
||||
UiThread.runLater(mLikeRunnable, delayMillis);
|
||||
}
|
||||
|
||||
public static boolean isSessionRated(int sessionNum)
|
||||
|
|
|
@ -22,7 +22,7 @@ public class ConnectivityChangedReceiver extends BroadcastReceiver
|
|||
|
||||
public void onWiFiConnected(Context context)
|
||||
{
|
||||
final SharedPreferences prefs = MwmApplication.getMwmSharedPreferences();
|
||||
final SharedPreferences prefs = MwmApplication.prefs();
|
||||
final long lastEventTimestamp = prefs.getLong(DOWNLOAD_UPDATE_TIMESTAMP, 0);
|
||||
|
||||
if (System.currentTimeMillis() - lastEventTimestamp > MIN_EVENT_DELTA_MILLIS)
|
||||
|
|
|
@ -15,10 +15,10 @@ import com.mapswithme.util.statistics.Statistics;
|
|||
|
||||
public final class Notifier
|
||||
{
|
||||
private final static int ID_UPDATE_AVAIL = 0x1;
|
||||
private final static int ID_DOWNLOAD_FAILED = 0x3;
|
||||
private final static int ID_DOWNLOAD_NEW_COUNTRY = 0x4;
|
||||
private final static int ID_PEDESTRIAN = 0x5;
|
||||
private final static int ID_UPDATE_AVAILABLE = 1;
|
||||
private final static int ID_DOWNLOAD_FAILED = 2;
|
||||
private final static int ID_DOWNLOAD_NEW_COUNTRY = 3;
|
||||
private final static int ID_PEDESTRIAN = 4;
|
||||
|
||||
private static final MwmApplication APP = MwmApplication.get();
|
||||
|
||||
|
@ -43,7 +43,7 @@ public final class Notifier
|
|||
final PendingIntent pi = PendingIntent.getActivity(APP, 0, MwmActivity.createUpdateMapsIntent(),
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
placeNotification(title, countryName, pi, ID_UPDATE_AVAIL);
|
||||
placeNotification(title, countryName, pi, ID_UPDATE_AVAILABLE);
|
||||
}
|
||||
|
||||
public static void notifyDownloadFailed(Index idx, String countryName)
|
||||
|
|
|
@ -28,7 +28,7 @@ public class WorkerService extends IntentService
|
|||
private static final String PREF_NOTIFICATION_SHOWN = "PedestrianNotificationShown";
|
||||
|
||||
private static final MwmApplication APP = MwmApplication.get();
|
||||
private static final SharedPreferences PREFS = MwmApplication.getMwmSharedPreferences();
|
||||
private static final SharedPreferences PREFS = MwmApplication.prefs();
|
||||
|
||||
/**
|
||||
* Starts this service to check map updates available with the given parameters. If the
|
||||
|
|
|
@ -139,7 +139,7 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
|
|||
{
|
||||
super(context, attrs);
|
||||
|
||||
mIsLatLonDms = MwmApplication.getMwmSharedPreferences().getBoolean(PREF_USE_DMS, false);
|
||||
mIsLatLonDms = MwmApplication.prefs().getBoolean(PREF_USE_DMS, false);
|
||||
initViews();
|
||||
|
||||
initAnimationController(attrs, defStyleAttr);
|
||||
|
@ -643,7 +643,7 @@ public class PlacePageView extends RelativeLayout implements View.OnClickListene
|
|||
break;
|
||||
case R.id.ll__place_latlon:
|
||||
mIsLatLonDms = !mIsLatLonDms;
|
||||
MwmApplication.getMwmSharedPreferences().edit().putBoolean(PREF_USE_DMS, mIsLatLonDms).commit();
|
||||
MwmApplication.prefs().edit().putBoolean(PREF_USE_DMS, mIsLatLonDms).commit();
|
||||
refreshLatLon();
|
||||
break;
|
||||
case R.id.ll__place_phone:
|
||||
|
|
|
@ -117,7 +117,7 @@ public class UiThread
|
|||
*
|
||||
* @param task the code that must be cancelled.
|
||||
*/
|
||||
public static void cancelDelayedTask(Runnable task)
|
||||
public static void cancelDelayedTasks(Runnable task)
|
||||
{
|
||||
sUiHandler.removeCallbacks(task);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue