forked from organicmaps/organicmaps
[android] remove MwmApplication.get method
This commit is contained in:
parent
5e6803f039
commit
1af3297b66
32 changed files with 82 additions and 112 deletions
|
@ -227,7 +227,7 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity
|
|||
|
||||
setAction(DOWNLOAD);
|
||||
|
||||
if (ConnectionState.isWifiConnected())
|
||||
if (ConnectionState.INSTANCE.isWifiConnected())
|
||||
onDownloadClicked();
|
||||
|
||||
return;
|
||||
|
@ -421,7 +421,7 @@ public class DownloadResourcesLegacyActivity extends BaseMwmFragmentActivity
|
|||
return R.string.disconnect_usb_cable;
|
||||
|
||||
case ERR_DOWNLOAD_ERROR:
|
||||
return (ConnectionState.isConnected() ? R.string.download_has_failed
|
||||
return (ConnectionState.INSTANCE.isConnected() ? R.string.download_has_failed
|
||||
: R.string.common_check_internet_connection_dialog);
|
||||
default:
|
||||
return R.string.not_enough_memory;
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.mapswithme.maps.search.SearchEngine;
|
|||
import com.mapswithme.maps.sound.TtsPlayer;
|
||||
import com.mapswithme.maps.ugc.UGC;
|
||||
import com.mapswithme.util.Config;
|
||||
import com.mapswithme.util.ConnectionState;
|
||||
import com.mapswithme.util.Counters;
|
||||
import com.mapswithme.util.KeyValue;
|
||||
import com.mapswithme.util.SharedPropertiesUtils;
|
||||
|
@ -164,6 +165,7 @@ public class MwmApplication extends Application implements AppBackgroundTracker.
|
|||
mMediator.initSensitiveDataToleranceLibraries();
|
||||
mMediator.initSensitiveDataStrictLibrariesAsync();
|
||||
Statistics.INSTANCE.initialize(this);
|
||||
ConnectionState.INSTANCE.initialize(this);
|
||||
Statistics.INSTANCE.setMediator(mMediator);
|
||||
|
||||
initNotificationChannels();
|
||||
|
|
|
@ -85,7 +85,7 @@ public enum LikesManager
|
|||
{
|
||||
mActivityRef = new WeakReference<>(activity);
|
||||
|
||||
if (!ConnectionState.isConnected())
|
||||
if (!ConnectionState.INSTANCE.isConnected())
|
||||
return;
|
||||
|
||||
Context context = activity.getApplicationContext();
|
||||
|
|
|
@ -101,7 +101,7 @@ public class BookmarkBackupController implements Authorizer.Callback,
|
|||
|
||||
private void requestRestoring()
|
||||
{
|
||||
if (!ConnectionState.isConnected())
|
||||
if (!ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
DialogInterface.OnClickListener clickListener
|
||||
= (dialog, which) -> Utils.showSystemConnectionSettings(mContext);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class BookmarkHeaderView extends LinearLayout
|
|||
{
|
||||
final Context context = getContext();
|
||||
final String imageUrl = category.getImageUrl();
|
||||
if (TextUtils.isEmpty(imageUrl) || !ConnectionState.isConnected())
|
||||
if (TextUtils.isEmpty(imageUrl) || !ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
UiUtils.hide(mImageView);
|
||||
}
|
||||
|
|
|
@ -493,7 +493,7 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
|
||||
UiUtils.show(frag.mRetryBtn);
|
||||
UiUtils.hide(frag.mWebView, frag.mProgressView);
|
||||
if (ConnectionState.isConnected())
|
||||
if (ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
LOGGER.e(TAG, "Failed to load catalog: " + mError + ", description: " + description);
|
||||
Statistics.INSTANCE.trackDownloadCatalogError(Statistics.ParamValue.UNKNOWN);
|
||||
|
|
|
@ -76,7 +76,7 @@ public class DiscoveryFragment extends BaseMwmToolbarFragment implements Discove
|
|||
if (mOnlineMode)
|
||||
return;
|
||||
|
||||
if (ConnectionState.isConnected())
|
||||
if (ConnectionState.INSTANCE.isConnected())
|
||||
NetworkPolicy.checkNetworkPolicy(getFragmentManager(), DiscoveryFragment.this::onNetworkPolicyResult);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -185,7 +185,7 @@ public final class MapManager
|
|||
|
||||
private static boolean warnOn3gInternal(Activity activity, @NonNull final Runnable onAcceptListener)
|
||||
{
|
||||
if (nativeIsDownloadOn3gEnabled() || !ConnectionState.isMobileConnected())
|
||||
if (nativeIsDownloadOn3gEnabled() || !ConnectionState.INSTANCE.isMobileConnected())
|
||||
{
|
||||
onAcceptListener.run();
|
||||
return false;
|
||||
|
|
|
@ -172,7 +172,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener
|
|||
Config.isAutodownloadEnabled() &&
|
||||
!sAutodownloadLocked &&
|
||||
!failed &&
|
||||
ConnectionState.isWifiConnected())
|
||||
ConnectionState.INSTANCE.isWifiConnected())
|
||||
{
|
||||
Location loc = LocationHelper.INSTANCE.getSavedLocation();
|
||||
if (loc != null)
|
||||
|
|
|
@ -326,7 +326,7 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
|
|||
Context context = requireContext();
|
||||
Statistics.INSTANCE.trackEditorSuccess(mIsNewObject,
|
||||
String.valueOf(OsmOAuth.isAuthorized(context)));
|
||||
if (OsmOAuth.isAuthorized(context) || !ConnectionState.isConnected())
|
||||
if (OsmOAuth.isAuthorized(context) || !ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
Utils.navigateToParent(getActivity());
|
||||
return;
|
||||
|
|
|
@ -37,7 +37,7 @@ public class ViralFragment extends BaseMwmDialogFragment
|
|||
{
|
||||
return !MwmApplication.prefs(context).contains(EXTRA_CONGRATS_SHOWN) &&
|
||||
Editor.nativeGetStats()[0] == 2 &&
|
||||
ConnectionState.isConnected();
|
||||
ConnectionState.INSTANCE.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -542,7 +542,7 @@ public class Holders
|
|||
{
|
||||
super.bind(item);
|
||||
getButton().setText(R.string.gallery_pp_download_guides_offline_cta);
|
||||
boolean isBtnInvisible = ConnectionState.isConnected() &&
|
||||
boolean isBtnInvisible = ConnectionState.INSTANCE.isConnected() &&
|
||||
NetworkPolicy.newInstance(NetworkPolicy.getCurrentNetworkUsageStatus()).canUseNetwork();
|
||||
|
||||
if (isBtnInvisible)
|
||||
|
|
|
@ -27,7 +27,7 @@ public abstract class AbstractGuidesClickListener extends DefaultClickListener
|
|||
public void onItemClick(@NonNull View v, @NonNull BottomSheetItem item)
|
||||
{
|
||||
Mode mode = item.getMode();
|
||||
if (!mode.isEnabled(v.getContext()) && !ConnectionState.isConnected())
|
||||
if (!mode.isEnabled(v.getContext()) && !ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
mNoConnectionListener.onNoConnectionError();
|
||||
return;
|
||||
|
|
|
@ -243,7 +243,7 @@ abstract class AbstractBookmarkSubscriptionFragment extends BaseAuthFragment
|
|||
@Override
|
||||
public void onCheckNetworkConnection()
|
||||
{
|
||||
if (ConnectionState.isConnected())
|
||||
if (ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
onNetworkCheckPassed();
|
||||
return;
|
||||
|
|
|
@ -98,7 +98,7 @@ class BookmarkPurchaseController extends AbstractPurchaseController<ValidationCa
|
|||
@Override
|
||||
public void onPurchasesLoaded(@NonNull List<Purchase> purchases)
|
||||
{
|
||||
if (!ConnectionState.isWifiConnected())
|
||||
if (!ConnectionState.INSTANCE.isWifiConnected())
|
||||
{
|
||||
LOGGER.i(TAG, "Validation postponed, connection not WI-FI.");
|
||||
return;
|
||||
|
|
|
@ -113,7 +113,7 @@ class SubscriptionPurchaseController extends AbstractPurchaseController<Validati
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ConnectionState.isWifiConnected())
|
||||
if (!ConnectionState.INSTANCE.isWifiConnected())
|
||||
{
|
||||
LOGGER.i(TAG, "Validation postponed, connection not WI-FI.");
|
||||
return;
|
||||
|
|
|
@ -335,7 +335,7 @@ public class RoutingController implements TaxiManager.TaxiListener, Initializabl
|
|||
mLogger.d(TAG, "build");
|
||||
mTaxiRequestHandled = false;
|
||||
mLastBuildProgress = 0;
|
||||
mInternetConnected = ConnectionState.isConnected();
|
||||
mInternetConnected = ConnectionState.INSTANCE.isConnected();
|
||||
|
||||
if (isTaxiRouterType())
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ class JobServiceDelegate
|
|||
|
||||
boolean onStartJob()
|
||||
{
|
||||
ConnectionState.Type type = ConnectionState.requestCurrentType(mApp);
|
||||
ConnectionState.Type type = ConnectionState.INSTANCE.requestCurrentType();
|
||||
if (type == ConnectionState.Type.WIFI)
|
||||
NotificationService.startOnConnectivityChanged(mApp);
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ public class BookingFilterParams implements Parcelable
|
|||
public static BookingFilterParams createParams(
|
||||
long checkIn, long checkOut, @Nullable FilterUtils.RoomGuestCounts roomGuestCounts)
|
||||
{
|
||||
if (!ConnectionState.isConnected())
|
||||
if (!ConnectionState.INSTANCE.isConnected())
|
||||
return null;
|
||||
|
||||
return new BookingFilterParams(checkIn, checkOut, FilterUtils.toRooms(roomGuestCounts));
|
||||
|
|
|
@ -103,7 +103,7 @@ public enum PromoCategory
|
|||
@Override
|
||||
boolean isSupported()
|
||||
{
|
||||
return ConnectionState.isConnected() && Framework.nativeHasCitymobilCategoryBanner();
|
||||
return ConnectionState.INSTANCE.isConnected() && Framework.nativeHasCitymobilCategoryBanner();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -117,7 +117,7 @@ public class UGCEditorFragment extends BaseToolbarAuthFragment
|
|||
UserActionsLogger.logUgcSaved();
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.UGC_REVIEW_SUCCESS);
|
||||
|
||||
if (!ConnectionState.isConnected())
|
||||
if (!ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
if (isAuthorized())
|
||||
Utils.toastShortcut(getContext(), R.string.ugc_thanks_message_auth);
|
||||
|
|
|
@ -296,7 +296,7 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
|
|||
|
||||
private boolean isNetworkConnectionAbsent()
|
||||
{
|
||||
return !ConnectionState.isConnected();
|
||||
return !ConnectionState.INSTANCE.isConnected();
|
||||
}
|
||||
|
||||
private void openTagsScreen()
|
||||
|
|
|
@ -78,7 +78,7 @@ public class SearchToolbarController extends ToolbarController
|
|||
private FilterUtils.RoomGuestCounts mRoomGuestCounts;
|
||||
@NonNull
|
||||
private final View.OnClickListener mChooseDatesClickListener = v -> {
|
||||
if (!ConnectionState.isConnected())
|
||||
if (!ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
Statistics.INSTANCE.trackQuickFilterClickError(Statistics.EventParam.HOTEL,
|
||||
Statistics.ParamValue.DATE,
|
||||
|
@ -103,7 +103,7 @@ public class SearchToolbarController extends ToolbarController
|
|||
private MenuController mGuestsRoomsMenuController;
|
||||
@NonNull
|
||||
private final View.OnClickListener mRoomsClickListener = v -> {
|
||||
if (!ConnectionState.isConnected())
|
||||
if (!ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
Statistics.INSTANCE.trackQuickFilterClickError(Statistics.EventParam.HOTEL,
|
||||
Statistics.ParamValue.ROOMS,
|
||||
|
|
|
@ -35,7 +35,7 @@ public class ErrorCatalogPromoListener<T extends Items.Item> implements com.maps
|
|||
@Override
|
||||
public void onItemSelected(@NonNull T item, int position)
|
||||
{
|
||||
if (ConnectionState.isConnected())
|
||||
if (ConnectionState.INSTANCE.isConnected())
|
||||
NetworkPolicy.checkNetworkPolicy(mActivity.getSupportFragmentManager(), mListener, true);
|
||||
else
|
||||
Utils.showSystemConnectionSettings(getActivity());
|
||||
|
|
|
@ -1451,7 +1451,7 @@ public class PlacePageView extends NestedScrollViewClickFixed
|
|||
return;
|
||||
}
|
||||
|
||||
boolean isConnected = ConnectionState.isConnected();
|
||||
boolean isConnected = ConnectionState.INSTANCE.isConnected();
|
||||
if (isConnected && policy.canUseNetwork())
|
||||
showHotelDetailViews();
|
||||
else
|
||||
|
@ -1473,7 +1473,7 @@ public class PlacePageView extends NestedScrollViewClickFixed
|
|||
|
||||
boolean showTaxiOffer = taxiTypes != null && !taxiTypes.isEmpty() &&
|
||||
LocationHelper.INSTANCE.getMyPosition() != null &&
|
||||
ConnectionState.isConnected()
|
||||
ConnectionState.INSTANCE.isConnected()
|
||||
&& mapObject.getRoadWarningMarkType() == RoadWarningMarkType.UNKNOWN;
|
||||
UiUtils.showIf(showTaxiOffer, mTaxi, mTaxiShadow, mTaxiDivider);
|
||||
|
||||
|
|
|
@ -144,10 +144,4 @@ public final class BottomSheetHelper
|
|||
{
|
||||
return create(context, title).grid();
|
||||
}
|
||||
|
||||
public static Builder sheet(Builder builder, int id, @DrawableRes int iconRes, CharSequence text)
|
||||
{
|
||||
Drawable icon = ContextCompat.getDrawable(MwmApplication.get(), iconRes);
|
||||
return builder.sheet(id, icon, text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ public final class Config
|
|||
public static void setUseMobileDataSettings(@NonNull NetworkPolicy.Type value)
|
||||
{
|
||||
setInt(KEY_MISC_USE_MOBILE_DATA, value.ordinal());
|
||||
setBool(KEY_MISC_USE_MOBILE_DATA_ROAMING, ConnectionState.isInRoaming());
|
||||
setBool(KEY_MISC_USE_MOBILE_DATA_ROAMING, ConnectionState.INSTANCE.isInRoaming());
|
||||
}
|
||||
|
||||
public static void setMobileDataTimeStamp(long timestamp)
|
||||
|
|
|
@ -1,23 +1,28 @@
|
|||
package com.mapswithme.util;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.base.Initializable;
|
||||
|
||||
import static com.mapswithme.util.ConnectionState.Type.NONE;
|
||||
|
||||
public class ConnectionState
|
||||
public enum ConnectionState implements Initializable<Context>
|
||||
{
|
||||
INSTANCE;
|
||||
|
||||
// values should correspond to ones from enum class EConnectionType (in platform/platform.hpp)
|
||||
private static final byte CONNECTION_NONE = 0;
|
||||
private static final byte CONNECTION_WIFI = 1;
|
||||
private static final byte CONNECTION_WWAN = 2;
|
||||
@SuppressWarnings("NotNullFieldNotInitialized")
|
||||
@NonNull
|
||||
private Context mContext;
|
||||
|
||||
public enum Type
|
||||
{
|
||||
|
@ -45,68 +50,51 @@ public class ConnectionState
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the {@link #isNetworkConnected(Context, int)} method instead.
|
||||
*/
|
||||
@Deprecated
|
||||
private static boolean isNetworkConnected(int networkType)
|
||||
@Override
|
||||
public void initialize(@Nullable Context context)
|
||||
{
|
||||
mContext = MwmApplication.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
// No op
|
||||
}
|
||||
|
||||
private boolean isNetworkConnected(int networkType)
|
||||
{
|
||||
final NetworkInfo info = getActiveNetwork();
|
||||
return info != null && info.getType() == networkType && info.isConnected();
|
||||
}
|
||||
|
||||
private static boolean isNetworkConnected(@NonNull Context context, int networkType)
|
||||
{
|
||||
final NetworkInfo info = getActiveNetwork(context);
|
||||
return info != null && info.getType() == networkType && info.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the {@link #getActiveNetwork(Context)} method instead.
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public static NetworkInfo getActiveNetwork()
|
||||
public NetworkInfo getActiveNetwork()
|
||||
{
|
||||
Application context = MwmApplication.get();
|
||||
if (context == null)
|
||||
return null;
|
||||
|
||||
ConnectivityManager manager =
|
||||
((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
|
||||
((ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE));
|
||||
if (manager == null)
|
||||
return null;
|
||||
|
||||
return manager.getActiveNetworkInfo();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NetworkInfo getActiveNetwork(@NonNull Context context)
|
||||
{
|
||||
ConnectivityManager manager =
|
||||
((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
|
||||
if (manager == null)
|
||||
return null;
|
||||
|
||||
return manager.getActiveNetworkInfo();
|
||||
}
|
||||
|
||||
public static boolean isMobileConnected()
|
||||
public boolean isMobileConnected()
|
||||
{
|
||||
return isNetworkConnected(ConnectivityManager.TYPE_MOBILE);
|
||||
}
|
||||
|
||||
public static boolean isWifiConnected()
|
||||
public boolean isWifiConnected()
|
||||
{
|
||||
return isNetworkConnected(ConnectivityManager.TYPE_WIFI);
|
||||
}
|
||||
|
||||
public static boolean isConnected()
|
||||
public boolean isConnected()
|
||||
{
|
||||
return isNetworkConnected(ConnectivityManager.TYPE_WIFI) || isNetworkConnected(ConnectivityManager.TYPE_MOBILE);
|
||||
}
|
||||
|
||||
public static boolean isConnectionFast(NetworkInfo info)
|
||||
public boolean isConnectionFast(NetworkInfo info)
|
||||
{
|
||||
if (info == null || !info.isConnected())
|
||||
return false;
|
||||
|
@ -146,7 +134,7 @@ public class ConnectionState
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean isInRoaming()
|
||||
public boolean isInRoaming()
|
||||
{
|
||||
NetworkInfo info = getActiveNetwork();
|
||||
return info != null && info.isRoaming();
|
||||
|
@ -156,15 +144,11 @@ public class ConnectionState
|
|||
@SuppressWarnings("unused")
|
||||
public static byte getConnectionState()
|
||||
{
|
||||
return requestCurrentType().getNativeRepresentation();
|
||||
return INSTANCE.requestCurrentType().getNativeRepresentation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the {@link #requestCurrentType(Context)} method instead.
|
||||
*/
|
||||
@NonNull
|
||||
@Deprecated
|
||||
public static Type requestCurrentType()
|
||||
public Type requestCurrentType()
|
||||
{
|
||||
for (ConnectionState.Type each : ConnectionState.Type.values())
|
||||
{
|
||||
|
@ -173,15 +157,4 @@ public class ConnectionState
|
|||
}
|
||||
return NONE;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static Type requestCurrentType(@NonNull Context context)
|
||||
{
|
||||
for (ConnectionState.Type each : ConnectionState.Type.values())
|
||||
{
|
||||
if (isNetworkConnected(context, each.getPlatformRepresentation()))
|
||||
return each;
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public final class NetworkPolicy
|
|||
public void check(@NonNull FragmentManager fragmentManager,
|
||||
@NonNull NetworkPolicyListener listener, boolean isDialogAllowed)
|
||||
{
|
||||
boolean nowInRoaming = ConnectionState.isInRoaming();
|
||||
boolean nowInRoaming = ConnectionState.INSTANCE.isInRoaming();
|
||||
boolean acceptedInRoaming = Config.getMobileDataRoaming();
|
||||
|
||||
if (nowInRoaming && !acceptedInRoaming)
|
||||
|
@ -100,7 +100,7 @@ public final class NetworkPolicy
|
|||
public void check(@NonNull FragmentManager fragmentManager,
|
||||
@NonNull NetworkPolicyListener listener, boolean isDialogAllowed)
|
||||
{
|
||||
boolean nowInRoaming = ConnectionState.isInRoaming();
|
||||
boolean nowInRoaming = ConnectionState.INSTANCE.isInRoaming();
|
||||
boolean acceptedInRoaming = Config.getMobileDataRoaming();
|
||||
|
||||
if (nowInRoaming && !acceptedInRoaming)
|
||||
|
@ -137,13 +137,13 @@ public final class NetworkPolicy
|
|||
@NonNull final NetworkPolicyListener listener,
|
||||
boolean isDialogAllowed)
|
||||
{
|
||||
if (ConnectionState.isWifiConnected())
|
||||
if (ConnectionState.INSTANCE.isWifiConnected())
|
||||
{
|
||||
listener.onResult(new NetworkPolicy(true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ConnectionState.isMobileConnected())
|
||||
if (!ConnectionState.INSTANCE.isMobileConnected())
|
||||
{
|
||||
listener.onResult(new NetworkPolicy(false));
|
||||
return;
|
||||
|
@ -161,13 +161,13 @@ public final class NetworkPolicy
|
|||
|
||||
public static boolean getCurrentNetworkUsageStatus()
|
||||
{
|
||||
if (ConnectionState.isWifiConnected())
|
||||
if (ConnectionState.INSTANCE.isWifiConnected())
|
||||
return true;
|
||||
|
||||
if (!ConnectionState.isMobileConnected())
|
||||
if (!ConnectionState.INSTANCE.isMobileConnected())
|
||||
return false;
|
||||
|
||||
boolean nowInRoaming = ConnectionState.isInRoaming();
|
||||
boolean nowInRoaming = ConnectionState.INSTANCE.isInRoaming();
|
||||
boolean acceptedInRoaming = Config.getMobileDataRoaming();
|
||||
if (nowInRoaming && !acceptedInRoaming)
|
||||
return false;
|
||||
|
|
|
@ -343,9 +343,10 @@ public class Utils
|
|||
return res;
|
||||
}
|
||||
|
||||
public static void checkConnection(final Context context, final @StringRes int message, final Proc<Boolean> onCheckPassedCallback)
|
||||
public static void checkConnection(final Context context, final @StringRes int message,
|
||||
final Proc<Boolean> onCheckPassedCallback)
|
||||
{
|
||||
if (ConnectionState.isConnected())
|
||||
if (ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
onCheckPassedCallback.invoke(true);
|
||||
return;
|
||||
|
|
|
@ -43,7 +43,7 @@ public final class MytargetHelper
|
|||
|
||||
public MytargetHelper(final @NonNull Listener<Void> listener, @NonNull Context context)
|
||||
{
|
||||
if (!ConnectionState.isConnected())
|
||||
if (!ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
listener.onNoAds();
|
||||
return;
|
||||
|
|
|
@ -1060,14 +1060,14 @@ public enum Statistics implements Initializable<Context>
|
|||
|
||||
public void trackConnectionState()
|
||||
{
|
||||
if (ConnectionState.isConnected())
|
||||
if (ConnectionState.INSTANCE.isConnected())
|
||||
{
|
||||
final NetworkInfo info = ConnectionState.getActiveNetwork();
|
||||
final NetworkInfo info = ConnectionState.INSTANCE.getActiveNetwork();
|
||||
boolean isConnectionMetered = false;
|
||||
//noinspection ConstantConditions
|
||||
trackEvent(EventName.ACTIVE_CONNECTION,
|
||||
params().add(EventParam.CONNECTION_TYPE, info.getTypeName() + ":" + info.getSubtypeName())
|
||||
.add(EventParam.CONNECTION_FAST, String.valueOf(ConnectionState.isConnectionFast(info)))
|
||||
.add(EventParam.CONNECTION_FAST, String.valueOf(ConnectionState.INSTANCE.isConnectionFast(info)))
|
||||
.add(EventParam.CONNECTION_METERED, String.valueOf(isConnectionMetered)));
|
||||
}
|
||||
else
|
||||
|
@ -1094,7 +1094,7 @@ public enum Statistics implements Initializable<Context>
|
|||
{
|
||||
trackEvent(newObject ? EventName.EDITOR_START_CREATE : EventName.EDITOR_START_EDIT,
|
||||
editorMwmParams().add(EventParam.IS_AUTHENTICATED, valueOfIsAuthorized)
|
||||
.add(EventParam.IS_ONLINE, String.valueOf(ConnectionState.isConnected())));
|
||||
.add(EventParam.IS_ONLINE, String.valueOf(ConnectionState.INSTANCE.isConnected())));
|
||||
|
||||
if (newObject)
|
||||
PushwooshHelper.nativeSendEditorAddObjectTag();
|
||||
|
@ -1113,14 +1113,14 @@ public enum Statistics implements Initializable<Context>
|
|||
{
|
||||
trackEvent(newObject ? EventName.EDITOR_SUCCESS_CREATE : EventName.EDITOR_SUCCESS_EDIT,
|
||||
editorMwmParams().add(EventParam.IS_AUTHENTICATED, valueOfIsAuthorized)
|
||||
.add(EventParam.IS_ONLINE, String.valueOf(ConnectionState.isConnected())));
|
||||
.add(EventParam.IS_ONLINE, String.valueOf(ConnectionState.INSTANCE.isConnected())));
|
||||
}
|
||||
|
||||
public void trackEditorError(boolean newObject, String valueOfIsAuthorized)
|
||||
{
|
||||
trackEvent(newObject ? EventName.EDITOR_ERROR_CREATE : EventName.EDITOR_ERROR_EDIT,
|
||||
editorMwmParams().add(EventParam.IS_AUTHENTICATED, valueOfIsAuthorized)
|
||||
.add(EventParam.IS_ONLINE, String.valueOf(ConnectionState.isConnected())));
|
||||
.add(EventParam.IS_ONLINE, String.valueOf(ConnectionState.INSTANCE.isConnected())));
|
||||
}
|
||||
|
||||
public void trackNetworkUsageAlert(@NonNull String event, @NonNull String param)
|
||||
|
@ -1302,13 +1302,13 @@ public enum Statistics implements Initializable<Context>
|
|||
private String getConnectionState()
|
||||
{
|
||||
final String network;
|
||||
if (ConnectionState.isWifiConnected())
|
||||
if (ConnectionState.INSTANCE.isWifiConnected())
|
||||
{
|
||||
network = "wifi";
|
||||
}
|
||||
else if (ConnectionState.isMobileConnected())
|
||||
else if (ConnectionState.INSTANCE.isMobileConnected())
|
||||
{
|
||||
if (ConnectionState.isInRoaming())
|
||||
if (ConnectionState.INSTANCE.isInRoaming())
|
||||
network = "roaming";
|
||||
else
|
||||
network = "mobile";
|
||||
|
@ -1552,7 +1552,7 @@ public enum Statistics implements Initializable<Context>
|
|||
trackEvent(UGC_REVIEW_START,
|
||||
params()
|
||||
.add(EventParam.IS_AUTHENTICATED, Framework.nativeIsUserAuthenticated())
|
||||
.add(EventParam.IS_ONLINE, ConnectionState.isConnected())
|
||||
.add(EventParam.IS_ONLINE, ConnectionState.INSTANCE.isConnected())
|
||||
.add(EventParam.MODE, isEdit ? ParamValue.EDIT : ParamValue.ADD)
|
||||
.add(EventParam.FROM, isPPPreview ? ParamValue.PLACEPAGE_PREVIEW :
|
||||
isFromNotification ? ParamValue.NOTIFICATION : ParamValue.PLACEPAGE)
|
||||
|
|
Loading…
Add table
Reference in a new issue