use of android.content.DialogInterface.OnCancelListener in project MWM-for-Android-Gen1 by MetaWatchOpenProjects.
the class DeviceSelection method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = this;
pdWait = ProgressDialog.show(this, "Please wait", "Searching Bluetooth devices...");
pdWait.setCancelable(true);
pdWait.setOnCancelListener(new OnCancelListener() {
public void onCancel(DialogInterface dialog) {
Log.d(MetaWatch.TAG, "canceled");
if (MetaWatchService.bluetoothAdapter.isDiscovering())
MetaWatchService.bluetoothAdapter.cancelDiscovery();
finish();
}
});
pdWait.show();
setContentView(R.layout.device_selection);
// constructMenuList();
listView = (ListView) findViewById(android.R.id.list);
// listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menuList));
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Log.d(MetaWatch.TAG, "device selected: " + arg2);
Map<String, String> map = list.get(arg2);
String mac = map.get("mac");
Log.d(MetaWatch.TAG, "mac selected: " + mac);
MetaWatchService.Preferences.watchMacAddress = mac;
MetaWatchService.saveMac(context, mac);
sendToast("Selected watch set");
finish();
}
});
if (MetaWatchService.bluetoothAdapter == null)
MetaWatchService.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Set<BluetoothDevice> pairedDevices = MetaWatchService.bluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
addToList(device.getAddress(), device.getName());
}
}
Receiver receiver = new Receiver();
IntentFilter intentFilter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
registerReceiver(receiver, intentFilter);
MetaWatchService.bluetoothAdapter.startDiscovery();
}
use of android.content.DialogInterface.OnCancelListener in project smartmodule by carozhu.
the class MyWebChromeHelper method onJsConfirm.
/**
* 覆盖默认的window.confirm展示界面,避免title里显示为“:来自file:////”
*/
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
final AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder.setTitle("lizongbo的Android webview测试confirm对话框").setMessage(message).setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
}
}).setNeutralButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.cancel();
}
});
builder.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
result.cancel();
}
});
// 屏蔽keycode等于84之类的按键,避免按键后导致对话框消息而页面无法再弹出对话框的问题
builder.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
Log.v("onJsConfirm", "keyCode==" + keyCode + "event=" + event);
return true;
}
});
// 禁止响应按back键的事件
// builder.setCancelable(false);
AlertDialog dialog = builder.create();
dialog.show();
return true;
// return super.onJsConfirm(view, url, message, result);
}
use of android.content.DialogInterface.OnCancelListener in project Android-DialogFragments by wada811.
the class AbstractDialogFragment method setOnCancelListener.
protected void setOnCancelListener(Dialog dialog) {
useOnCancelListener = true;
dialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
bindCancelListener();
}
});
}
use of android.content.DialogInterface.OnCancelListener in project physical-web by google.
the class BluetoothSite method connect.
/**
* Connects to the Gatt service of the device to download a web page and displays a progress bar
* for the title.
* @param deviceAddress The mac address of the bar
* @param title The title of the web page being downloaded
*/
public void connect(String deviceAddress, String title) {
running = true;
String progressTitle = activity.getString(R.string.page_loading_title) + " " + title;
progress = new ProgressDialog(activity);
progress.setCancelable(true);
progress.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
Log.i(TAG, "Dialog box canceled");
close();
}
});
progress.setTitle(progressTitle);
progress.setMessage(activity.getString(R.string.page_loading_message));
progress.show();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
mBluetoothGatt = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(deviceAddress).connectGatt(activity, false, BluetoothSite.this);
}
});
}
use of android.content.DialogInterface.OnCancelListener in project glimmr by brk3.
the class GetRequestToken method onPreExecute.
@Override
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog = ProgressDialog.show(mActivity, "", mActivity.getString(R.string.just_a_moment));
mProgressDialog.setCanceledOnTouchOutside(true);
mProgressDialog.setCancelable(true);
mProgressDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dlg) {
GetRequestToken.this.cancel(true);
}
});
}
Aggregations