forked from organicmaps/organicmaps
[android] Fixed review notes
This commit is contained in:
parent
34a8b5fe72
commit
3e18e027eb
11 changed files with 112 additions and 147 deletions
|
@ -291,6 +291,7 @@ public class MwmApplication extends Application implements AppBackgroundTracker.
|
|||
RoutingController.get().initialize();
|
||||
TrafficManager.INSTANCE.initialize();
|
||||
SubwayManager.from(this).initialize();
|
||||
IsolinesManager.from(this).initialize();
|
||||
mPurchaseOperationObservable.initialize();
|
||||
mBackgroundTracker.addListener(this);
|
||||
mFrameworkInitialized = true;
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package com.mapswithme.maps.content;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class AbstractContextualListener
|
||||
{
|
||||
@NonNull
|
||||
private final Application mApp;
|
||||
|
||||
public AbstractContextualListener(@NonNull Application app)
|
||||
{
|
||||
mApp = app;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Context getContext()
|
||||
{
|
||||
return mApp;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package com.mapswithme.maps.maplayer;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public abstract class AbstractMapLayerListener
|
||||
{
|
||||
@NonNull
|
||||
private final OnTransitSchemeChangedListener mSchemeChangedListener;
|
||||
|
||||
public AbstractMapLayerListener(@NonNull OnTransitSchemeChangedListener listener)
|
||||
{
|
||||
mSchemeChangedListener = listener;
|
||||
}
|
||||
|
||||
public final void setEnabled(boolean isEnabled)
|
||||
{
|
||||
if (isEnabled == isEnabled())
|
||||
return;
|
||||
|
||||
setEnabledInternal(isEnabled);
|
||||
}
|
||||
|
||||
public final void toggle()
|
||||
{
|
||||
setEnabled(!isEnabled());
|
||||
}
|
||||
|
||||
public final void initialize()
|
||||
{
|
||||
registerListener();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
protected OnTransitSchemeChangedListener getSchemeChangedListener()
|
||||
{
|
||||
return mSchemeChangedListener;
|
||||
}
|
||||
|
||||
public abstract boolean isEnabled();
|
||||
|
||||
protected abstract void setEnabledInternal(boolean isEnabled);
|
||||
|
||||
protected abstract void registerListener();
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package com.mapswithme.maps.maplayer;
|
||||
|
||||
import androidx.annotation.MainThread;
|
||||
|
||||
public interface OnTransitSchemeChangedListener
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
@MainThread
|
||||
void onTransitStateChanged(int type);
|
||||
}
|
|
@ -6,32 +6,44 @@ import android.content.Context;
|
|||
import androidx.annotation.NonNull;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.maplayer.AbstractMapLayerListener;
|
||||
import com.mapswithme.maps.maplayer.OnTransitSchemeChangedListener;
|
||||
import com.mapswithme.maps.maplayer.subway.OnIsolinesChangedListener;
|
||||
|
||||
public class IsolinesManager extends AbstractMapLayerListener
|
||||
public class IsolinesManager
|
||||
{
|
||||
@NonNull
|
||||
private final OnIsolinesChangedListener mListener;
|
||||
|
||||
public IsolinesManager(@NonNull Application application)
|
||||
{
|
||||
super(new IsolinesStateChangedListener(application));
|
||||
mListener = new OnIsolinesChangedListenerImpl(application);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return Framework.nativeIsIsolinesLayerEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setEnabledInternal(boolean isEnabled)
|
||||
private void registerListener()
|
||||
{
|
||||
nativeAddListener(mListener);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean isEnabled)
|
||||
{
|
||||
if (isEnabled == isEnabled())
|
||||
return;
|
||||
|
||||
Framework.nativeSetIsolinesLayerEnabled(isEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerListener()
|
||||
public void toggle()
|
||||
{
|
||||
nativeAddListener(getSchemeChangedListener());
|
||||
setEnabled(!isEnabled());
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
registerListener();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -41,6 +53,6 @@ public class IsolinesManager extends AbstractMapLayerListener
|
|||
return app.getIsolinesManager();
|
||||
}
|
||||
|
||||
private static native void nativeAddListener(@NonNull OnTransitSchemeChangedListener listener);
|
||||
private static native void nativeRemoveListener(@NonNull OnTransitSchemeChangedListener listener);
|
||||
private static native void nativeAddListener(@NonNull OnIsolinesChangedListener listener);
|
||||
private static native void nativeRemoveListener(@NonNull OnIsolinesChangedListener listener);
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package com.mapswithme.maps.maplayer.isolines;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.mapswithme.maps.content.AbstractContextualListener;
|
||||
import com.mapswithme.maps.maplayer.OnTransitSchemeChangedListener;
|
||||
|
||||
class IsolinesStateChangedListener extends AbstractContextualListener implements OnTransitSchemeChangedListener
|
||||
{
|
||||
IsolinesStateChangedListener(@NonNull Application app)
|
||||
{
|
||||
super(app);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitStateChanged(int type)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.mapswithme.maps.maplayer.isolines;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.mapswithme.maps.maplayer.subway.OnIsolinesChangedListener;
|
||||
|
||||
class OnIsolinesChangedListenerImpl implements OnIsolinesChangedListener
|
||||
{
|
||||
@NonNull
|
||||
private final Application mApp;
|
||||
|
||||
OnIsolinesChangedListenerImpl(@NonNull Application app)
|
||||
{
|
||||
mApp = app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(int type)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.mapswithme.maps.maplayer.subway;
|
||||
|
||||
public interface OnIsolinesChangedListener
|
||||
{
|
||||
void onStateChanged(int index);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.mapswithme.maps.maplayer.subway;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
interface OnTransitSchemeChangedListener
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
@MainThread
|
||||
void onTransitStateChanged(int type);
|
||||
|
||||
class Default implements OnTransitSchemeChangedListener
|
||||
{
|
||||
@NonNull
|
||||
private final Application mContext;
|
||||
|
||||
Default(@NonNull Application context)
|
||||
{
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitStateChanged(int index)
|
||||
{
|
||||
TransitSchemeState state = TransitSchemeState.values()[index];
|
||||
state.activate(mContext);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,29 +6,43 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.maplayer.AbstractMapLayerListener;
|
||||
import com.mapswithme.maps.maplayer.OnTransitSchemeChangedListener;
|
||||
|
||||
public class SubwayManager extends AbstractMapLayerListener
|
||||
public class SubwayManager
|
||||
{
|
||||
@NonNull
|
||||
private final OnTransitSchemeChangedListener mSchemeChangedListener;
|
||||
|
||||
public SubwayManager(@NonNull Application application) {
|
||||
super(new SubwayStateChangedListener(application));
|
||||
mSchemeChangedListener = new OnTransitSchemeChangedListener.Default(application);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return Framework.nativeIsTransitSchemeEnabled();
|
||||
}
|
||||
public void setEnabled(boolean isEnabled)
|
||||
{
|
||||
if (isEnabled == isEnabled())
|
||||
return;
|
||||
|
||||
@Override
|
||||
protected void setEnabledInternal(boolean isEnabled) {
|
||||
Framework.nativeSetTransitSchemeEnabled(isEnabled);
|
||||
Framework.nativeSaveSettingSchemeEnabled(isEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerListener() {
|
||||
nativeAddListener(getSchemeChangedListener());
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return Framework.nativeIsTransitSchemeEnabled();
|
||||
}
|
||||
|
||||
public void toggle()
|
||||
{
|
||||
setEnabled(!isEnabled());
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
registerListener();
|
||||
}
|
||||
|
||||
private void registerListener()
|
||||
{
|
||||
nativeAddListener(mSchemeChangedListener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -37,7 +51,7 @@ public class SubwayManager extends AbstractMapLayerListener
|
|||
MwmApplication app = (MwmApplication) context.getApplicationContext();
|
||||
return app.getSubwayManager();
|
||||
}
|
||||
|
||||
private static native void nativeAddListener(@NonNull OnTransitSchemeChangedListener listener);
|
||||
|
||||
private static native void nativeRemoveListener(@NonNull OnTransitSchemeChangedListener listener);
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package com.mapswithme.maps.maplayer.subway;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mapswithme.maps.content.AbstractContextualListener;
|
||||
import com.mapswithme.maps.maplayer.OnTransitSchemeChangedListener;
|
||||
|
||||
public class SubwayStateChangedListener extends AbstractContextualListener implements OnTransitSchemeChangedListener
|
||||
{
|
||||
SubwayStateChangedListener(@NonNull Application context)
|
||||
{
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitStateChanged(int index)
|
||||
{
|
||||
Context app = getContext();
|
||||
TransitSchemeState state = TransitSchemeState.values()[index];
|
||||
state.activate(app);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue