List of usage examples for java.lang ClassCastException ClassCastException
public ClassCastException(String s)
ClassCastException
with the specified detail message. From source file:ca.mudar.mtlaucasou.BaseListFragment.java
/** * Attach a listener// ww w . j a v a 2 s.c o m */ @Override public void onAttach(SupportActivity activity) { super.onAttach(activity); try { mListener = (OnPlacemarkSelectedListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnPlacemarkSelectedListener"); } }
From source file:com.deliciousdroid.fragment.MainFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*w w w . ja v a2 s.c om*/ mainActionListener = (OnMainActionListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnMainActionListener"); } }
From source file:com.conferenceengineer.android.iosched.ui.SandboxDetailFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (!(activity instanceof Callbacks)) { throw new ClassCastException("Activity must implement fragment's callbacks."); }// w w w. ja v a 2s . co m mCallbacks = (Callbacks) activity; }
From source file:com.dabay6.android.apps.carlog.ui.base.fragments.BaseDeleteListFragment.java
/** * {@inheritDoc}// w w w. j av a 2 s . c om */ @Override public void onAttach(final Activity activity) { super.onAttach(activity); try { onEntityListListener = (OnEntityListListener) activity; } catch (final ClassCastException ex) { throw new ClassCastException(activity.toString() + " must implement OnEntityListListener"); } }
From source file:edu.utah.further.core.api.message.ValidationUtil.java
/** * A useful check for {@link Comparable#compareTo(Object)} methods. * //from w w w .j a va 2 s . c o m * @param object1 * @param object2 */ public static void validateEqualClass(final Object object1, final Object object2) { try { if ((object1 != object2) && (object1.getClass() != object2.getClass())) { throw new ClassCastException(cannotCompareMessage(object1.getClass(), object2.getClass())); } } catch (final IllegalArgumentException e) { throw new BusinessRuleException(e.getMessage()); } }
From source file:com.androzic.route.RouteList.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 . j a v a 2s . c o m routeActionsCallback = (OnRouteActionListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnRouteActionListener"); } }
From source file:com.royclarkson.springagram.PhotoAddToGalleryFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from w ww.ja v a 2s .co m*/ this.photoAddToGalleryFragmentListener = (PhotoAddToGalleryFragmentListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement PhotoAddToGalleryFragmentListener"); } }
From source file:cat.wuyingren.rorhelper.fragments.dialogs.ManageSenatorDialogFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); // Verify that the host activity implements the callback interface try {/*from w w w . j av a 2s. c om*/ // Instantiate the NoticeDialogListener so we can send events to the host mListener = (ManageSenatorDialogListener) activity; } catch (ClassCastException e) { // The activity doesn't implement the interface, throw exception throw new ClassCastException(activity.toString() + " must implement ManageSenatorDialogListener"); } }
From source file:br.liveo.searchliveo.SearchLiveo.java
/** * Start context and the listener Search Live library. * Use this method when you are using an Activity * * @param context - Context Activity/*from w ww .j a v a2 s .c o m*/ */ public SearchLiveo with(Context context) { if (this.mContext == null) { try { this.mContext = (Activity) context; this.mSearchListener = (OnSearchListener) context; } catch (ClassCastException e) { throw new ClassCastException(mContext.getString(R.string.warning_listener)); } } else { build(); } return this; }
From source file:br.liveo.searchliveo.SearchCardLiveo.java
/** * Start context and the listener Search Live library. * Use this method when you are using an Activity * * @param context - Context Activity/* w w w . ja v a 2 s .c o m*/ */ public SearchCardLiveo with(Context context) { if (this.mContext == null) { try { this.mContext = (Activity) context; this.mSearchListener = (OnSearchListener) context; } catch (ClassCastException e) { throw new ClassCastException(mContext.getString(R.string.warning_listener)); } } else { build(); } return this; }