Search in sources :

Example 1 with MainThread

use of android.annotation.MainThread in project android_frameworks_base by DirtyUnicorns.

the class Activity method onCreate.

/**
     * Called when the activity is starting.  This is where most initialization
     * should go: calling {@link #setContentView(int)} to inflate the
     * activity's UI, using {@link #findViewById} to programmatically interact
     * with widgets in the UI, calling
     * {@link #managedQuery(android.net.Uri , String[], String, String[], String)} to retrieve
     * cursors for data being displayed, etc.
     *
     * <p>You can call {@link #finish} from within this function, in
     * which case onDestroy() will be immediately called without any of the rest
     * of the activity lifecycle ({@link #onStart}, {@link #onResume},
     * {@link #onPause}, etc) executing.
     *
     * <p><em>Derived classes must call through to the super class's
     * implementation of this method.  If they do not, an exception will be
     * thrown.</em></p>
     *
     * @param savedInstanceState If the activity is being re-initialized after
     *     previously being shut down then this Bundle contains the data it most
     *     recently supplied in {@link #onSaveInstanceState}.  <b><i>Note: Otherwise it is null.</i></b>
     *
     * @see #onStart
     * @see #onSaveInstanceState
     * @see #onRestoreInstanceState
     * @see #onPostCreate
     */
@MainThread
@CallSuper
protected void onCreate(@Nullable Bundle savedInstanceState) {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState);
    if (mLastNonConfigurationInstances != null) {
        mFragments.restoreLoaderNonConfig(mLastNonConfigurationInstances.loaders);
    }
    if (mActivityInfo.parentActivityName != null) {
        if (mActionBar == null) {
            mEnableDefaultActionBarUp = true;
        } else {
            mActionBar.setDefaultDisplayHomeAsUpEnabled(true);
        }
    }
    if (savedInstanceState != null) {
        Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
        mFragments.restoreAllState(p, mLastNonConfigurationInstances != null ? mLastNonConfigurationInstances.fragments : null);
    }
    mFragments.dispatchCreate();
    getApplication().dispatchActivityCreated(this, savedInstanceState);
    if (mVoiceInteractor != null) {
        mVoiceInteractor.attachActivity(this);
    }
    mCalled = true;
}
Also used : Parcelable(android.os.Parcelable) MainThread(android.annotation.MainThread) CallSuper(android.annotation.CallSuper)

Example 2 with MainThread

use of android.annotation.MainThread in project android_frameworks_base by crdroidandroid.

the class PrintJob method getInfo.

/**
     * Gets the {@link PrintJobInfo} that describes this job.
     * <p>
     * <strong>Node:</strong>The returned info object is a snapshot of the
     * current print job state. Every call to this method returns a fresh
     * info object that reflects the current print job state.
     * </p>
     *
     * @return The print job info.
     */
@MainThread
@NonNull
public PrintJobInfo getInfo() {
    PrintService.throwIfNotCalledOnMainThread();
    if (isInImmutableState()) {
        return mCachedInfo;
    }
    PrintJobInfo info = null;
    try {
        info = mPrintServiceClient.getPrintJobInfo(mCachedInfo.getId());
    } catch (RemoteException re) {
        Log.e(LOG_TAG, "Couldn't get info for job: " + mCachedInfo.getId(), re);
    }
    if (info != null) {
        mCachedInfo = info;
    }
    return mCachedInfo;
}
Also used : PrintJobInfo(android.print.PrintJobInfo) RemoteException(android.os.RemoteException) MainThread(android.annotation.MainThread) NonNull(android.annotation.NonNull)

Example 3 with MainThread

use of android.annotation.MainThread in project android_frameworks_base by AOSPA.

the class Activity method onCreate.

/**
     * Called when the activity is starting.  This is where most initialization
     * should go: calling {@link #setContentView(int)} to inflate the
     * activity's UI, using {@link #findViewById} to programmatically interact
     * with widgets in the UI, calling
     * {@link #managedQuery(android.net.Uri , String[], String, String[], String)} to retrieve
     * cursors for data being displayed, etc.
     *
     * <p>You can call {@link #finish} from within this function, in
     * which case onDestroy() will be immediately called without any of the rest
     * of the activity lifecycle ({@link #onStart}, {@link #onResume},
     * {@link #onPause}, etc) executing.
     *
     * <p><em>Derived classes must call through to the super class's
     * implementation of this method.  If they do not, an exception will be
     * thrown.</em></p>
     *
     * @param savedInstanceState If the activity is being re-initialized after
     *     previously being shut down then this Bundle contains the data it most
     *     recently supplied in {@link #onSaveInstanceState}.  <b><i>Note: Otherwise it is null.</i></b>
     *
     * @see #onStart
     * @see #onSaveInstanceState
     * @see #onRestoreInstanceState
     * @see #onPostCreate
     */
@MainThread
@CallSuper
protected void onCreate(@Nullable Bundle savedInstanceState) {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState);
    if (mLastNonConfigurationInstances != null) {
        mFragments.restoreLoaderNonConfig(mLastNonConfigurationInstances.loaders);
    }
    if (mActivityInfo.parentActivityName != null) {
        if (mActionBar == null) {
            mEnableDefaultActionBarUp = true;
        } else {
            mActionBar.setDefaultDisplayHomeAsUpEnabled(true);
        }
    }
    if (savedInstanceState != null) {
        Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
        mFragments.restoreAllState(p, mLastNonConfigurationInstances != null ? mLastNonConfigurationInstances.fragments : null);
    }
    mFragments.dispatchCreate();
    getApplication().dispatchActivityCreated(this, savedInstanceState);
    if (mVoiceInteractor != null) {
        mVoiceInteractor.attachActivity(this);
    }
    mCalled = true;
}
Also used : Parcelable(android.os.Parcelable) MainThread(android.annotation.MainThread) CallSuper(android.annotation.CallSuper)

Example 4 with MainThread

use of android.annotation.MainThread in project android_frameworks_base by DirtyUnicorns.

the class PrintJob method block.

/**
     * Blocks the print job. You should call this method if {@link #isStarted()} returns true and
     * you need to block the print job. For example, the user has to add some paper to continue
     * printing. To resume the print job call {@link #start()}. To change the reason call
     * {@link #setStatus(CharSequence)}.
     *
     * @param reason The human readable, short, and translated reason why the print job is blocked.
     * @return Whether the job was blocked.
     *
     * @see #isStarted()
     * @see #isBlocked()
     */
@MainThread
public boolean block(@Nullable String reason) {
    PrintService.throwIfNotCalledOnMainThread();
    PrintJobInfo info = getInfo();
    final int state = info.getState();
    if (state == PrintJobInfo.STATE_STARTED || state == PrintJobInfo.STATE_BLOCKED) {
        return setState(PrintJobInfo.STATE_BLOCKED, reason);
    }
    return false;
}
Also used : PrintJobInfo(android.print.PrintJobInfo) MainThread(android.annotation.MainThread)

Example 5 with MainThread

use of android.annotation.MainThread in project android_frameworks_base by DirtyUnicorns.

the class PrintJob method getInfo.

/**
     * Gets the {@link PrintJobInfo} that describes this job.
     * <p>
     * <strong>Node:</strong>The returned info object is a snapshot of the
     * current print job state. Every call to this method returns a fresh
     * info object that reflects the current print job state.
     * </p>
     *
     * @return The print job info.
     */
@MainThread
@NonNull
public PrintJobInfo getInfo() {
    PrintService.throwIfNotCalledOnMainThread();
    if (isInImmutableState()) {
        return mCachedInfo;
    }
    PrintJobInfo info = null;
    try {
        info = mPrintServiceClient.getPrintJobInfo(mCachedInfo.getId());
    } catch (RemoteException re) {
        Log.e(LOG_TAG, "Couldn't get info for job: " + mCachedInfo.getId(), re);
    }
    if (info != null) {
        mCachedInfo = info;
    }
    return mCachedInfo;
}
Also used : PrintJobInfo(android.print.PrintJobInfo) RemoteException(android.os.RemoteException) MainThread(android.annotation.MainThread) NonNull(android.annotation.NonNull)

Aggregations

MainThread (android.annotation.MainThread)15 PrintJobInfo (android.print.PrintJobInfo)10 CallSuper (android.annotation.CallSuper)5 NonNull (android.annotation.NonNull)5 Parcelable (android.os.Parcelable)5 RemoteException (android.os.RemoteException)5