Back to project page BleSensorTag.
The source code is released under:
MIT License
If you think the Android project BleSensorTag listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package sample.ble.sensortag.dialogs; /*from w ww . j av a 2s .c o m*/ import android.app.Activity; import android.app.Dialog; import android.app.DialogFragment; import android.os.Bundle; public class AppDialog<Listener> extends DialogFragment { private Listener listener; public Listener getListener() { return listener; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); } public boolean isShowing() { final Dialog dialog = getDialog(); return dialog != null && dialog.isShowing(); } protected boolean isListenerOptional() { return true; } @SuppressWarnings("unchecked") @Override public void onAttach(Activity activity) { super.onAttach(activity); try { listener = (Listener) activity; } catch (ClassCastException e) { if ( !isListenerOptional() ) throw new ClassCastException(activity.getClass().getName() + " must implement listener"); } } // Hack for android issue 17423 in the compatibility library @Override public void onDestroyView() { if ( getDialog() != null && getRetainInstance() ) getDialog().setDismissMessage(null); super.onDestroyView(); } }