/** * This method is called once the view is attached to this presenter for the very first time. * For instance, it will not be called again during screen orientation changes when the view will be * detached temporarily. * <p> * <p> * The counter part of this method is {@link #unbindIntents()}. * This {@link #bindIntents()} and {@link #unbindIntents()} are kind of representing the * lifecycle of this Presenter. * {@link #bindIntents()} is called the first time the view is attached * and {@link #unbindIntents()} is called once the view is detached permanently because it has * been destroyed and hence this presenter is not needed anymore and will also be destroyed * afterwards * </p> */ @MainThread abstract protected void bindIntents();
/** * Android API agnostic Bluetooth scan callback wrapper. * <p> * Since Android bluetooth scan callbacks occur on the main thread it is expected that these * callbacks will also occur on the main thread. * * Created by dyoung on 10/6/14. */ @MainThread public interface CycledLeScanCallback { void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord); void onCycleEnd(); }
@Override @MainThread public final void onStart(Intent intent, int startId) {}
/** * Called when the scheduling engine has decided to interrupt the execution of a running job, most * likely because the runtime constraints associated with the job are no longer satisfied. The job * must stop execution. * * @return true if the job should be retried * @see com.firebase.jobdispatcher.JobInvocation.Builder#setRetryStrategy(RetryStrategy) * @see RetryStrategy */ @MainThread public abstract boolean onStopJob(@NonNull JobParameters job);
@Nullable @Override @MainThread public final IBinder onBind(Intent intent) { return binder; }
@MainThread // Not thread-safe. static String formatDollars(double dollars) { return dollars % 1 == 0d ? DOLLARS_ONLY.format(dollars) : DOLLARS_AND_CENTS.format(dollars); }
@MainThread // Not thread-safe. static String formatCents(long cents) { return cents % 100 == 0 ? DOLLARS_ONLY.format(cents / 100) : DOLLARS_AND_CENTS.format(cents / 100d); }
/** * The entry point to your Job. Implementations should offload work to another thread of execution * as soon as possible because this runs on the main thread. If work was offloaded, call {@link * JobService#jobFinished(JobParameters, boolean)} to notify the scheduling service that the work * is completed. * * <p>If a job with the same service and tag was rescheduled during execution {@link * JobService#onStopJob(JobParameters)} will be called and the wakelock will be released. Please * make sure that all reschedule requests happen at the end of the job. * * @return {@code true} if there is more work remaining in the worker thread, {@code false} if the * job was completed. */ @MainThread public abstract boolean onStartJob(@NonNull JobParameters job);
@MainThread public static B with(@NonNull Context applicationContext) { return mBuilder = new B(applicationContext); }
/** * If the view is attached, the view action is run immediately. * If view is not attached, the action will be put in a queue. Once a view is attached, each * action will be polled from the queue and executed one after another. * <p> * You have to call this method from Android's main UI thread. * * @param action The action that should run to interact with the view */ @MainThread protected final void onceViewAttached(ViewAction<V> action) { viewActionQueue.add(action); runQueuedActions(); }
@MainThread public void setValue(@Nullable T t) { pending.set(true); super.setValue(t); }
@MainThread @Override public void run() { scanLeDevice(true); } }, millisecondsUntilStart > 1000 ? 1000 : millisecondsUntilStart);
@MainThread @Override public void run() { scheduleScanCycleStop(); } }, millisecondsUntilStop > 1000 ? 1000 : millisecondsUntilStop);
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override @MainThread public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) { processScanResult(device, rssi, scanRecord); }
@Override @MainThread public final int onStartCommand(Intent intent, int flags, int startId) { stopSelf(startId); return START_NOT_STICKY; }
@Override @MainThread public final void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }
@Override @MainThread public final void onTaskRemoved(Intent rootIntent) { super.onTaskRemoved(rootIntent); }
@Override @MainThread public final void onRebind(Intent intent) { super.onRebind(intent); }
/** * Actually subscribes the view as consumer to the internally view relay. * * @param view The mvp view */ @MainThread private void subscribeViewStateConsumerActually(@NonNull final V view) { if (view == null) { throw new NullPointerException("View is null"); } if (viewStateConsumer == null) { throw new NullPointerException(ViewStateConsumer.class.getSimpleName() + " is null. This is a Mosby internal bug. Please file an issue at https://github.com/sockeqwe/mosby/issues"); } viewRelayConsumerDisposable = viewStateBehaviorSubject.subscribe(new Consumer<VS>() { @Override public void accept(VS vs) throws Exception { viewStateConsumer.accept(view, vs); } }); }
@MainThread public static B with(@NonNull Context applicationContext) { return mBuilder = new B(applicationContext); }