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:br.com.hojeti.wizardpager.ui.ReviewFragment.java

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

    if (!(activity instanceof Callbacks)) {
        throw new ClassCastException("Activity must implement fragment's callbacks");
    }/*from ww w . ja v  a  2  s . c o m*/

    mCallbacks = (Callbacks) activity;

    mWizardModel = mCallbacks.onGetModel();
    mWizardModel.registerListener(this);
    onPageTreeChanged();
}

From source file:dtu.ds.warnme.app.location.FollowMeLocationSource.java

public FollowMeLocationSource(Activity activity, Context context, GoogleMap map) {
    this.context = context;
    this.map = map;

    try {// w  w w  .  jav a2s .  c o m
        locationSourceListener = (FollowMeLocationSourceListener) activity;
    } catch (ClassCastException ex) {
        throw new ClassCastException(activity.toString() + " must implement FollowMeLocationSource");
    }

    init();
}

From source file:com.arcgis.android.samples.geometrysample.SampleListFragment.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 {/*from  w w w.  ja v a 2 s  .c o m*/
        mCallback = (OnSampleNameSelectedListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement OnSampleNameSelectedListener");
    }
}

From source file:br.com.bioscada.apps.biotracks.fragments.ChooseActivityTypeDialogFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {//ww w . j  a  v a  2s. co  m
        caller = (ChooseActivityTypeCaller) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(
                activity.toString() + " must implement " + ChooseActivityTypeCaller.class.getSimpleName());
    }
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.SignBrowserFragment.java

@SuppressWarnings("deprecation") // necessary for API 15!
@Override/*from  w w  w  .  j  a  v  a2 s  .c om*/
public void onAttach(Activity activity) {
    Log.d(TAG, "onAttach " + hashCode());
    super.onAttach(activity);
    try {
        this.onSignBrowserSignClickedListener = (OnSignBrowserSignClickedListener) activity;
    } catch (ClassCastException ex) {
        throw new ClassCastException(activity.toString() + " must implement OnSignBrowserSignClickedListener");
    }
}

From source file:com.battlelancer.seriesguide.ui.FirstRunFragment.java

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

    try {/*from   ww  w.java 2 s  . c  o m*/
        mListener = (OnFirstRunDismissedListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement OnFirstRunDismissedListener");
    }
}

From source file:com.dealbreaker.cloud.backend.core.CloudBackendFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {/*from w  ww .  j av a  2s. com*/
        callback = (OnListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement OnListener");
    }
}

From source file:com.sap.core.odata.core.debug.DebugInfoBody.java

private String getContentString() {
    String content;//from   ww w  .  ja  va  2s .  c om
    if (response.getEntity() instanceof String) {
        content = (String) response.getEntity();
    } else if (response.getEntity() instanceof InputStream) {
        content = getStringFromInputStream((InputStream) response.getEntity());
    } else {
        throw new ClassCastException(
                "Unsupported content entity class: " + response.getEntity().getClass().getName());
    }
    return content;
}

From source file:com.royclarkson.springagram.HomeFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {/* w  w w.  j a va 2  s .  c o m*/
        homeFragmentListener = (HomeFragmentListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement OnFragmentInteractionListener");
    }
}

From source file:com.dazone.crewchat.libGallery.fragment.VideoFragment.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  av  a 2 s  . c  o m*/
        mCallback = (OnVideoSelectedListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement OnVideoSelectedListener");
    }
}