[android] Fixed review notes

This commit is contained in:
Dmitry Donskoy 2018-09-03 23:17:08 +03:00 committed by Aleksandr Zatsepin
parent 2ff60a4f14
commit 1ae7eafd57
5 changed files with 38 additions and 12 deletions

View file

@ -46,7 +46,7 @@ public class ConnectivityJobScheduler implements ConnectivityListener
}
@NonNull
private NativeConnectivityListener createNativeJobScheduler(@NonNull MwmApplication context)
private ConnectivityListener createNativeJobScheduler(@NonNull MwmApplication context)
{
return new NativeConnectivityListener(context);
}
@ -57,6 +57,7 @@ public class ConnectivityJobScheduler implements ConnectivityListener
mMasterConnectivityListener.listen();
}
@NonNull
public static ConnectivityJobScheduler from(@NonNull Context context)
{
MwmApplication application = (MwmApplication) context.getApplicationContext();

View file

@ -1,5 +1,7 @@
package com.mapswithme.maps.scheduling;
import android.support.annotation.NonNull;
import com.firebase.jobdispatcher.JobParameters;
import com.firebase.jobdispatcher.JobService;
import com.mapswithme.util.log.Logger;
@ -9,19 +11,27 @@ public class FirebaseJobService extends JobService
{
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
private static final String TAG = NativeJobService.class.getSimpleName();
@SuppressWarnings("NullableProblems")
@NonNull
private JobServiceDelegate mDelegate;
@Override
public void onCreate()
{
super.onCreate();
mDelegate = new JobServiceDelegate(getApplication());
}
@Override
public boolean onStartJob(JobParameters job)
{
LOGGER.d(TAG, "onStartJob FirebaseJobService");
JobServiceDelegate delegate = new JobServiceDelegate(getApplication());
delegate.onStartJob();
return true;
return mDelegate.onStartJob();
}
@Override
public boolean onStopJob(JobParameters job)
{
return false;
return mDelegate.onStopJob();
}
}

View file

@ -16,18 +16,23 @@ class JobServiceDelegate
mApp = app;
}
public void onStartJob()
public boolean onStartJob()
{
ConnectionState.Type type = ConnectionState.requestCurrentType();
if (type == ConnectionState.Type.WIFI)
NotificationService.startOnConnectivityChanged(mApp);
retryJob();
return true;
}
private void retryJob()
{
ConnectivityJobScheduler.from(mApp).listen();
}
public boolean onStopJob()
{
return false;
}
}

View file

@ -4,6 +4,7 @@ import android.annotation.TargetApi;
import android.app.job.JobParameters;
import android.app.job.JobService;
import android.os.Build;
import android.support.annotation.NonNull;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
@ -14,18 +15,27 @@ public class NativeJobService extends JobService
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
private static final String TAG = NativeJobService.class.getSimpleName();
@SuppressWarnings("NullableProblems")
@NonNull
private JobServiceDelegate mDelegate;
@Override
public void onCreate()
{
super.onCreate();
mDelegate = new JobServiceDelegate(getApplication());
}
@Override
public boolean onStartJob(JobParameters params)
{
LOGGER.d(TAG, "onStartJob");
JobServiceDelegate delegate = new JobServiceDelegate(getApplication());
delegate.onStartJob();
return true;
return mDelegate.onStartJob();
}
@Override
public boolean onStopJob(JobParameters params)
{
return false;
return mDelegate.onStopJob();
}
}

View file

@ -118,7 +118,7 @@ public class ConnectionState
return info != null && info.isRoaming();
}
/*jni call*/
// Called from JNI.
@SuppressWarnings("unused")
public static byte getConnectionState()
{