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.TimePickerDialogTask.java

@Override
public void onCreate() {
    super.onCreate();
    mDialog = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
        public void onTimeSet(TimePicker view, int hour, int minute) {
            JSONObject result = new JSONObject();
            try {
                result.put("which", "positive");
                result.put("hour", hour);
                result.put("minute", minute);
                setResult(result);/*from  w  w  w. j  a v a  2s. co  m*/
            } catch (JSONException e) {
                throw new AndroidRuntimeException(e);
            }
        }
    }, mHour, mMinute, mIs24Hour);
    mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface view) {
            JSONObject result = new JSONObject();
            try {
                result.put("which", "neutral");
                result.put("hour", mHour);
                result.put("minute", mMinute);
                setResult(result);
            } catch (JSONException e) {
                throw new AndroidRuntimeException(e);
            }
        }
    });
    mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        public void onDismiss(DialogInterface dialog) {
            JSONObject result = new JSONObject();
            try {
                result.put("which", "negative");
                result.put("hour", mHour);
                result.put("minute", mMinute);
                setResult(result);
            } catch (JSONException e) {
                throw new AndroidRuntimeException(e);
            }
        }
    });
    mDialog.show();
    mShowLatch.countDown();
}

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

@Override
public void onCreate() {
    super.onCreate();
    mDialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
        public void onDateSet(DatePicker view, int year, int month, int day) {
            JSONObject result = new JSONObject();
            try {
                result.put("which", "positive");
                result.put("year", year);
                result.put("month", month + 1);
                result.put("day", day);
                setResult(result);/*from  ww w  .  j a v  a2  s  . c o m*/
            } catch (JSONException e) {
                throw new AndroidRuntimeException(e);
            }
        }
    }, mYear, mMonth, mDay);
    mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface view) {
            JSONObject result = new JSONObject();
            try {
                result.put("which", "neutral");
                result.put("year", mYear);
                result.put("month", mMonth + 1);
                result.put("day", mDay);
                setResult(result);
            } catch (JSONException e) {
                throw new AndroidRuntimeException(e);
            }
        }
    });
    mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        public void onDismiss(DialogInterface dialog) {
            JSONObject result = new JSONObject();
            try {
                result.put("which", "negative");
                result.put("year", mYear);
                result.put("month", mMonth + 1);
                result.put("day", mDay);
                setResult(result);
            } catch (JSONException e) {
                throw new AndroidRuntimeException(e);
            }
        }
    });
    mDialog.show();
    mShowLatch.countDown();
}

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

private void configureButtons(final AlertDialog.Builder builder, final Activity activity) {
    DialogInterface.OnClickListener buttonListener = new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            JSONObject result = new JSONObject();
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                try {
                    result.put("which", "positive");
                    result.put("progress", mSeekBar.getProgress());
                } catch (JSONException e) {
                    throw new AndroidRuntimeException(e);
                }//from w  ww.  ja v a 2  s.c o  m
                break;
            case DialogInterface.BUTTON_NEGATIVE:
                try {
                    result.put("which", "negative");
                    result.put("progress", mSeekBar.getProgress());
                } catch (JSONException e) {
                    throw new AndroidRuntimeException(e);
                }
                break;
            }
            dismissDialog();
            setResult(result);
        }
    };
    if (mNegativeButtonText != null) {
        builder.setNegativeButton(mNegativeButtonText, buttonListener);
    }
    if (mPositiveButtonText != null) {
        builder.setPositiveButton(mPositiveButtonText, buttonListener);
    }
}

From source file:android.support.transition.TransitionSet.java

/**
 * Sets the play order of this set's child transitions.
 *
 * @param ordering {@link #ORDERING_TOGETHER} to play this set's child
 *                 transitions together, {@link #ORDERING_SEQUENTIAL} to play the child
 *                 transitions in sequence.
 * @return This transitionSet object./*  w ww . j  a v  a 2 s  . c om*/
 */
@NonNull
public TransitionSet setOrdering(int ordering) {
    switch (ordering) {
    case ORDERING_SEQUENTIAL:
        mPlayTogether = false;
        break;
    case ORDERING_TOGETHER:
        mPlayTogether = true;
        break;
    default:
        throw new AndroidRuntimeException("Invalid parameter for TransitionSet " + "ordering: " + ordering);
    }
    return this;
}

From source file:io.github.yavski.fabspeeddial.FabSpeedDial.java

private void resolveCompulsoryAttributes(TypedArray typedArray) {
    if (typedArray.hasValue(R.styleable.FabSpeedDial_fabMenu)) {
        menuId = typedArray.getResourceId(R.styleable.FabSpeedDial_fabMenu, 0);
    } else {/* w  ww . java 2  s .  c o  m*/
        throw new AndroidRuntimeException("You must provide the id of the menu resource.");
    }

    if (typedArray.hasValue(R.styleable.FabSpeedDial_fabGravity)) {
        fabGravity = typedArray.getInt(R.styleable.FabSpeedDial_fabGravity, DEFAULT_MENU_POSITION);
    } else {
        throw new AndroidRuntimeException("You must specify the gravity of the Fab.");
    }
}

From source file:com.albedinsky.android.support.intent.BaseIntent.java

/**
 * Creates an instance of {@link AndroidRuntimeException} indicating that one of required parameters
 * for this intent builder has not been specified, but {@link #build()} has been invoked.
 * <p>//from   ww  w  .j a  v a2s  . c o  m
 * This can be invoked from {@link #build()} to handle such situation.
 *
 * @param message Message to be included into exception.
 */
protected final AndroidRuntimeException cannotBuildIntentException(@NonNull String message) {
    final String intentName = getClass().getSimpleName();
    return new AndroidRuntimeException("Cannot build " + intentName + ". " + message);
}

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

@Rpc(description = "Set alert dialog positive button text.")
public void dialogSetPositiveButtonText(@RpcParameter(name = "text") String text) {
    if (mDialogTask != null && mDialogTask instanceof AlertDialogTask) {
        ((AlertDialogTask) mDialogTask).setPositiveButtonText(text);
    } else if (mDialogTask != null && mDialogTask instanceof SeekBarDialogTask) {
        ((SeekBarDialogTask) mDialogTask).setPositiveButtonText(text);
    } else {//from  w  ww. j  a  v  a2 s  .c o m
        throw new AndroidRuntimeException("No dialog to add button to.");
    }
}

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

@Rpc(description = "Set alert dialog button text.")
public void dialogSetNegativeButtonText(@RpcParameter(name = "text") String text) {
    if (mDialogTask != null && mDialogTask instanceof AlertDialogTask) {
        ((AlertDialogTask) mDialogTask).setNegativeButtonText(text);
    } else if (mDialogTask != null && mDialogTask instanceof SeekBarDialogTask) {
        ((SeekBarDialogTask) mDialogTask).setNegativeButtonText(text);
    } else {//from w  ww. ja v  a2  s.c  o  m
        throw new AndroidRuntimeException("No dialog to add button to.");
    }
}

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

@Rpc(description = "Set alert dialog button text.")
public void dialogSetNeutralButtonText(@RpcParameter(name = "text") String text) {
    if (mDialogTask != null && mDialogTask instanceof AlertDialogTask) {
        ((AlertDialogTask) mDialogTask).setNeutralButtonText(text);
    } else {/*from  w  w w  . j  a va2  s  . c  o  m*/
        throw new AndroidRuntimeException("No dialog to add button to.");
    }
}

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

/**
 * This effectively creates list of options. Clicking on an item will immediately return an "item"
 * element, which is the index of the selected item.
 *///from w w w  . ja va  2 s . c  o  m
@Rpc(description = "Set alert dialog list items.")
public void dialogSetItems(@RpcParameter(name = "items") JSONArray items) {
    if (mDialogTask != null && mDialogTask instanceof AlertDialogTask) {
        ((AlertDialogTask) mDialogTask).setItems(items);
    } else {
        throw new AndroidRuntimeException("No dialog to add list to.");
    }
}