Finished connecting with the robot via Bluetooth
This commit is contained in:
@@ -11,9 +11,10 @@ import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class WifiOnDialog extends DialogFragment {
|
||||
private final String TAG = "NXTCAM_MAIN";
|
||||
private final String TAG = "NXTCAM_WIFI_DIALOG";
|
||||
private final String CLASS_NAME = WifiOnDialog.class.getSimpleName();
|
||||
|
||||
private WifiOnDialogListener listener;
|
||||
private WifiManager wifiManager;
|
||||
|
||||
public interface WifiOnDialogListener{
|
||||
@@ -26,23 +27,32 @@ public class WifiOnDialog extends DialogFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState){
|
||||
// Use the Builder class for convenient dialog construction
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
|
||||
builder.setMessage(R.string.wifi_on_msg).setPositiveButton(R.string.wifi_on_button, new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
public void onClick(DialogInterface dialog, int id){
|
||||
if(wifiManager != null){
|
||||
wifiManager.setWifiEnabled(true);
|
||||
Logger.log_d(TAG, CLASS_NAME + " :: setting wifi to on.");
|
||||
}else
|
||||
Logger.log_wtf(TAG, CLASS_NAME + " :: wifiManager is null! Doing nothing.");
|
||||
Logger.log_d(TAG, CLASS_NAME + ".setPositiveButton().onClick() :: setting wifi to on.");
|
||||
if(listener != null)
|
||||
listener.onWifiOnDialogPositiveClick(WifiOnDialog.this);
|
||||
}else{
|
||||
Logger.log_wtf(TAG, CLASS_NAME + ".setPositiveButton().onClick( :: wifiManager is null! Doing nothing.");
|
||||
if(listener != null)
|
||||
listener.onWifiOnDialogNegativeClick(WifiOnDialog.this);
|
||||
}
|
||||
}
|
||||
|
||||
}).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int id) { }
|
||||
public void onClick(DialogInterface dialog, int id){
|
||||
Logger.log_d(TAG, CLASS_NAME + ".setPositiveButton().onClick( :: User canceled.");
|
||||
if(listener != null)
|
||||
listener.onWifiOnDialogNegativeClick(WifiOnDialog.this);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -52,11 +62,13 @@ public class WifiOnDialog extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity){
|
||||
super.onAttach(activity);
|
||||
|
||||
try{
|
||||
@SuppressWarnings("unused")
|
||||
WifiOnDialogListener listener = (WifiOnDialogListener)activity;
|
||||
listener = (WifiOnDialogListener)activity;
|
||||
}catch(ClassCastException cce){
|
||||
throw new ClassCastException(activity.toString() + "Must implement WifiOnDialogListener.");
|
||||
listener = null;
|
||||
throw new ClassCastException(CLASS_NAME + ".onAttach() :: " + activity.toString() + "Must implement WifiOnDialogListener.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user