Example usage for java.lang ClassCastException ClassCastException

List of usage examples for java.lang ClassCastException ClassCastException

Introduction

In this page you can find the example usage for java.lang ClassCastException ClassCastException.

Prototype

public ClassCastException(String s) 

Source Link

Document

Constructs a ClassCastException with the specified detail message.

Usage

From source file:com.firma.dev.letschat.MyFavoriteFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    try {/*from  w  w  w  .ja  v a2s  .co m*/
        signalCallback = (onUserTimerForcedToExpire) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement onUserTimerForcedToExpire");
    }
}

From source file:eu.codeplumbers.cosi.wizards.firstrun.ConnectFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    if (!(activity instanceof PageFragmentCallbacks)) {
        throw new ClassCastException("Activity must implement PageFragmentCallbacks");
    }/*  w w  w . j a v  a 2s .co  m*/

    mCallbacks = (PageFragmentCallbacks) activity;
}

From source file:org.openhab.habdroid.ui.OpenHABBindingFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    Log.d(TAG, "onAttach()");
    try {//from w ww  .  ja v a 2s.c  om
        mActivity = (OpenHABMainActivity) activity;
        mAsyncHttpClient = mActivity.getAsyncHttpClient();
        mActivity.setTitle(R.string.app_bindings);
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must be OpenHABMainActivity");
    }
}

From source file:org.openhab.habdroid.ui.OpenHABNotificationFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    Log.d(TAG, "onAttach()");
    try {/* ww w. j  a v a  2  s  .c om*/
        mActivity = (OpenHABMainActivity) activity;
        mAsyncHttpClient = mActivity.getAsyncHttpClient();
        mActivity.setTitle(R.string.app_notifications);
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must be OpenHABMainActivity");
    }
}

From source file:com.bq.robotic.robopad.fragments.RobotFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    // Check the listener is the correct one: the fragment activity container
    // implements that listener
    if (activity instanceof RobotListener) {
        this.listener = (RobotListener) activity;
    } else {//from w w w  .j av a 2 s .c om
        throw new ClassCastException(activity.toString() + " must implement robotListener");
    }
}

From source file:com.anstar.fieldwork.CaptureSignatureFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    // This makes sure that the container activity has implemented
    // the callback interface. If not, it throws an exception
    try {// w w w  .  j  a  va  2 s .  com
        mCaptureSignatureFragmentListener = (CaptureSignatureFragmentListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement CaptureSignatureFragmentListener");
    }
}

From source file:com.scooter1556.sms.android.fragment.MediaFolderFragment.java

@Override
public void onAttach(Context context) {
    super.onAttach(context);

    try {// w  w w  .  j av  a  2  s.c om
        mediaFolderListener = (MediaFolderListener) context;
    } catch (ClassCastException e) {
        throw new ClassCastException(context.toString() + " must implement MediaFolderListener");
    }
}

From source file:com.helpshift.kvstore.SharedPreferencesImpl.java

public boolean getBoolean(String key, boolean defValue) {
    String value = getValueByKey(key);
    if (value == null) {
        return defValue;
    } else {/*from   w w w .  j  av a 2  s  .c o  m*/
        try {
            return Boolean.parseBoolean(getValueByKey(key));
        } catch (NumberFormatException e) {
            throw new ClassCastException(value + "can not cast to Boolean");
        }
    }
}

From source file:com.bangz.smartmute.RulelistFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    ((BaseActivity) activity).onSectionAttached(getArguments().getInt(ARG_SECTION_NUMBER));

    try {//ww  w .  j  a v a 2s  . c om
        mRuleItemSelectedListerner = (OnRuleItemClickListerner) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement OnRuleItemClickListerner.");
    }

}

From source file:com.belatrixsf.allstars.ui.contacts.ContactFragment.java

private void castOrThrowException(Context context) {
    try {//from www  .  ja  va  2 s .  c  o m
        contactFragmentListener = (ContactFragmentListener) context;
    } catch (ClassCastException e) {
        throw new ClassCastException(context.toString() + " must implement ContactFragmentListener");
    }
}