下面列出了android.content.Context#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (null == mComponentCallback) {
mComponentCallback = new OdysseyComponentCallback();
}
// Register the memory trim callback with the system.
context.registerComponentCallbacks(mComponentCallback);
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
try {
mToolbarAndFABCallback = (ToolbarAndFABCallback) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString() + " must implement ToolbarAndFABCallback");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
if(day == null){
day = Calendar.getInstance();
}
if(!day.getTimeZone().equals(TimeZone.getDefault())) {
day = Calendar.getInstance();
generateReports(true);
}
// Bind to stepDetector if today is shown
if (isTodayShown() && StepDetectionServiceHelper.isStepDetectionEnabled(getContext())) {
bindService();
}
registerReceivers();
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof Listener) {
this.listenerCallback = (Listener) context;
} else {
throw new ClassCastException(context.toString()
+ " must implement Listener");
}
if (context instanceof GenerateReviewFragment.ProgressListener) {
this.progressCallback = (GenerateReviewFragment.ProgressListener) context;
}
}
public TouchableWrapper(Context context) {
super(context);
// Force the host activity to implement the UpdateMapAfterUserInterection Interface
try {
updateMapAfterUserInterection = (SearchPlaceOnMapActivity) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString() + " must implement UpdateMapAfterUserInterection");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
interfaceWithConfigurationWizard = (DownloadFailedDialogInterface) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement NoticeDialogListener");
}
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
try {
mListener = (BookDeleteDialogListener) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement BookDeleteDialogListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnBehaviorChangedListener) {
mListener = (OnBehaviorChangedListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnBehaviorChangedListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnRecyclerFragmentInteractionListener) {
mListener = (OnRecyclerFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnRecyclerFragmentInteractionListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnTableOfContentTitleClickListener) {
mListener = (OnTableOfContentTitleClickListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnTableOfContentTitleClickListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
mCallback = (OnScanDataListener) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement OnScanDataListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
mListener = (OptionFragmentOnclickListener) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString() + "must implement OptionFragmentOnclickListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof MainActivity) {
mListener = (MainActivityInterface) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement MainAFInterface");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof ResultListener) {
resultListener = (ResultListener) context;
} else {
throw new RuntimeException(context.toString() + " must implement ResultListener");
}
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof Listener) {
mListener = (Listener) context;
} /*else if (getTargetFragment() instanceof Listener) {
mListener = (Listener) getTargetFragment();
} else if (getTargetFragment() != null && getTargetFragment().getActivity() instanceof Listener) {
mListener = (Listener) getTargetFragment().getActivity();
} */ else {
throw new RuntimeException(context.toString() + " must implement Listener");
}
}
@Override
public void onAttach (Context context)
{
super.onAttach(context);
if (context instanceof OnForgotFragmentInteractionListener)
{
mListener = (OnForgotFragmentInteractionListener) context;
}
else
{
throw new RuntimeException(context.toString() + " must implement OnFragmentInteractionListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (!(context instanceof Callbacks)) {
throw new ClassCastException(context.toString() + " must implement " + ConnectFragment.class.getSimpleName());
}
mCallbacks = (Callbacks) context;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(
context.toString() + " must implement OnFragmentInteractionListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
mBeaconSelectedListener = (OnTrackedBeaconSelectedListener) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement OnTrackedBeaconSelectedListener");
}
}