Example usage for android.util AndroidRuntimeException AndroidRuntimeException

List of usage examples for android.util AndroidRuntimeException AndroidRuntimeException

Introduction

In this page you can find the example usage for android.util AndroidRuntimeException AndroidRuntimeException.

Prototype

public AndroidRuntimeException(Exception cause) 

Source Link

Usage

From source file:com.googlecode.android_scripting.facade.ui.UiFacade.java

/**
 * This creates a list of radio buttons. You can select one item out of the list. A response will
 * not be returned until the dialog is closed, either with the Cancel key or a button
 * (positive/negative/neutral). Use {@link #dialogGetSelectedItems()} to find out what was
 * selected./*from   ww w  . j  a v  a  2 s .  c o m*/
 */
@Rpc(description = "Set dialog single choice items and selected item.")
public void dialogSetSingleChoiceItems(@RpcParameter(name = "items") JSONArray items,
        @RpcParameter(name = "selected", description = "selected item index") @RpcDefault("0") Integer selected) {
    if (mDialogTask != null && mDialogTask instanceof AlertDialogTask) {
        ((AlertDialogTask) mDialogTask).setSingleChoiceItems(items, selected);
    } else {
        throw new AndroidRuntimeException("No dialog to add list to.");
    }
}

From source file:com.googlecode.android_scripting.facade.ui.UiFacade.java

/**
 * This creates a list of check boxes. You can select multiple items out of the list. A response
 * will not be returned until the dialog is closed, either with the Cancel key or a button
 * (positive/negative/neutral). Use {@link #dialogGetSelectedItems()} to find out what was
 * selected./* www .j  a  v  a  2s.c om*/
 */

@Rpc(description = "Set dialog multiple choice items and selection.")
public void dialogSetMultiChoiceItems(@RpcParameter(name = "items") JSONArray items,
        @RpcParameter(name = "selected", description = "list of selected items") @RpcOptional JSONArray selected)
        throws JSONException {
    if (mDialogTask != null && mDialogTask instanceof AlertDialogTask) {
        ((AlertDialogTask) mDialogTask).setMultiChoiceItems(items, selected);
    } else {
        throw new AndroidRuntimeException("No dialog to add list to.");
    }
}

From source file:com.googlecode.android_scripting.facade.ui.UiFacade.java

@Rpc(description = "Returns dialog response.")
public Object dialogGetResponse() {
    try {/*ww w. j a v  a 2 s .c  o m*/
        return mDialogTask.getResult();
    } catch (Exception e) {
        throw new AndroidRuntimeException(e);
    }
}

From source file:com.googlecode.android_scripting.facade.ui.UiFacade.java

@Rpc(description = "This method provides list of items user selected.", returns = "Selected items")
public Set<Integer> dialogGetSelectedItems() {
    if (mDialogTask != null && mDialogTask instanceof AlertDialogTask) {
        return ((AlertDialogTask) mDialogTask).getSelectedItems();
    } else {/*from ww w .j a va  2s  .c  om*/
        throw new AndroidRuntimeException("No dialog to add list to.");
    }
}

From source file:android.support.animation.DynamicAnimation.java

/**
 * Starts an animation. If the animation has already been started, no op. Note that calling
 * {@link #start()} will not immediately set the property value to start value of the animation.
 * The property values will be changed at each animation pulse, which happens before the draw
 * pass. As a result, the changes will be reflected in the next frame, the same as if the values
 * were set immediately. This method should only be called on main thread.
 *
 * @throws AndroidRuntimeException if this method is not called on the main thread
 *//*from  w  ww. jav  a 2 s  . c  o  m*/
public void start() {
    if (Looper.myLooper() != Looper.getMainLooper()) {
        throw new AndroidRuntimeException("Animations may only be started on the main thread");
    }
    if (!mRunning) {
        startAnimationInternal();
    }
}

From source file:android.support.animation.DynamicAnimation.java

/**
 * Cancels the on-going animation. If the animation hasn't started, no op. Note that this method
 * should only be called on main thread.
 *
 * @throws AndroidRuntimeException if this method is not called on the main thread
 *///  w  w  w  . j  a  v a  2 s . c o  m
public void cancel() {
    if (Looper.myLooper() != Looper.getMainLooper()) {
        throw new AndroidRuntimeException("Animations may only be canceled on the main thread");
    }
    if (mRunning) {
        endAnimationInternal(true);
    }
}

From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java

@Override
public boolean requestFeature(int featureId) {
    if (DEBUG)/*w w w .j a  v  a  2 s  .c  o  m*/
        Log.d(TAG, "[requestFeature] featureId: " + featureId);

    if (mContentParent != null) {
        throw new AndroidRuntimeException("requestFeature() must be called before adding content");
    }

    switch (featureId) {
    case Window.FEATURE_ACTION_BAR:
    case Window.FEATURE_ACTION_BAR_OVERLAY:
    case Window.FEATURE_ACTION_MODE_OVERLAY:
    case Window.FEATURE_INDETERMINATE_PROGRESS:
    case Window.FEATURE_NO_TITLE:
    case Window.FEATURE_PROGRESS:
        mFeatures |= (1 << featureId);
        return true;

    default:
        return false;
    }
}

From source file:com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.java

/**
 * Start the animation playing. This version of start() takes a boolean flag that indicates
 * whether the animation should play in reverse. The flag is usually false, but may be set
 * to true if called from the reverse() method.
 *
 * <p>The animation started by calling this method will be run on the thread that called
 * this method. This thread should have a Looper on it (a runtime exception will be thrown if
 * this is not the case). Also, if the animation will animate
 * properties of objects in the view hierarchy, then the calling thread should be the UI
 * thread for that view hierarchy.</p>
 *
 * @param playBackwards Whether the ValueAnimator should start playing in reverse.
 *///from w  w  w  .j  a v  a2s . c o m
private void start(boolean playBackwards) {
    if (Looper.myLooper() == null) {
        throw new AndroidRuntimeException("Animators may only be run on Looper threads");
    }
    mPlayingBackwards = playBackwards;
    mCurrentIteration = 0;
    mPlayingState = STOPPED;
    mStarted = true;
    mStartedDelay = false;
    sPendingAnimations.get().add(this);
    if (mStartDelay == 0) {
        // This sets the initial value of the animation, prior to actually starting it running
        setCurrentPlayTime(getCurrentPlayTime());
        mPlayingState = STOPPED;
        mRunning = true;

        if (mListeners != null) {
            ArrayList<AnimatorListener> tmpListeners = (ArrayList<AnimatorListener>) mListeners.clone();
            int numListeners = tmpListeners.size();
            for (int i = 0; i < numListeners; ++i) {
                tmpListeners.get(i).onAnimationStart(this);
            }
        }
    }
    AnimationHandler animationHandler = sAnimationHandler.get();
    if (animationHandler == null) {
        animationHandler = new AnimationHandler();
        sAnimationHandler.set(animationHandler);
    }
    animationHandler.sendEmptyMessage(ANIMATION_START);
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

private void throwFeatureRequestIfSubDecorInstalled() {
    if (mSubDecorInstalled) {
        throw new AndroidRuntimeException("Window feature must be requested before adding content");
    }// w  ww  .ja v a2s .co  m
}