This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Job myJob = firebaseJobDispatcher.newJobBuilder() | |
.setService(SmartService.class) | |
.setTag(SmartService.LOCATION_SMART_JOB) | |
.setReplaceCurrent(false) | |
.setConstraints(ON_ANY_NETWORK) | |
.build(); | |
firebaseJobDispatcher.mustSchedule(myJob); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ComponentName service = new ComponentName(this, MyJobService.class); | |
JobScheduler mJobScheduler = (JobScheduler)getSystemService(Context.JOB_SCHEDULER_SERVICE); | |
JobInfo.Builder builder = new JobInfo.Builder(jobId, serviceComponent) | |
.setRequiredNetworkType(jobInfoNetworkType) | |
.setRequiresCharging(false) | |
.setRequiresDeviceIdle(false) | |
.setExtras(extras).build(); | |
mJobScheduler.schedule(jobInfo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int threads = Runtime.getRuntime().availableProcessors(); | |
ExecutorService executor = Executors.newFixedThreadPool(threads); | |
executor.submit(myWork); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<receiver | |
android:name=".login.NetworkHttpUnauthorizedReceiver"> | |
<intent-filter> | |
<action android:name="com.startup.network.http_unauthorized"/> | |
</intent-filter> | |
</receiver> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyIntentService extends IntentService { | |
private static final String TAG = MyIntentService.class.getSimpleName(); | |
private ArrayList<Object> objects; | |
private long timeMillisInBackground; | |
public MyIntentService() { | |
super("MyIntentService"); | |
} | |
@Override protected void onHandleIntent(Intent intent) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyService extends Service { | |
private static final String TAG = MyService.class.getSimpleName(); | |
private ArrayList<Object> objects; | |
public MyService() { | |
} | |
@Override public IBinder onBind(Intent intent) { | |
// TODO: Return the communication channel to the service. | |
throw new UnsupportedOperationException("Not yet implemented"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StarWarsService extends IntentService { | |
public StarWarsService() { | |
super("StarWarsService"); | |
} | |
@Override protected void onHandleIntent(Intent intent) { | |
if (intent != null) { | |
String json = ResourcesUtil.loadJson(this); | |
Gson gson = new GsonBuilder().setDateFormat("MMM d, yyyy").create(); | |
ArrayList<StarWarsMovie> moviesList = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainPresenter extends BasePresenter<MainActivityView> { | |
public static final String LOAD_COMPLETE_ACTION = | |
"com.academy.android.starwarsmovies.load_complete"; | |
public static final String DATA_KEY = "data_key"; | |
private StarWarsMovieDataReceiver movieDataReceiver; | |
private ArrayList<StarWarsMovie> movieList; | |
@Override public void attachView(MainActivityView mainActivityView) { | |
super.attachView(mainActivityView); | |
registerLoadDataReceiver(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class BasePresenter<T extends MvpView> { | |
HandlerThread thread; | |
Looper looper; | |
Handler handler; | |
private T mView; | |
public BasePresenter() { | |
} |