Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The device picker should actually notify the listener of cancel #113

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/com/connectsdk/device/DevicePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
Expand Down Expand Up @@ -77,15 +78,15 @@ public void cancelPicker() {
* @param message The title for the AlertDialog
* @param listener The listener for the ListView to get the item that was clicked on
*/
public AlertDialog getPickerDialog(String message, final OnItemClickListener listener) {
public AlertDialog getPickerDialog(String message, final OnItemClickListener listener, DialogInterface.OnCancelListener cancelListener) {
final DevicePickerListView view = new DevicePickerListView(activity);

TextView title = (TextView) activity.getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null);
title.setText(message);

final AlertDialog pickerDialog = new AlertDialog.Builder(activity)
.setCustomTitle(title)
.setCancelable(true)
.setOnCancelListener(cancelListener)
.setView(view)
.create();

Expand Down
6 changes: 6 additions & 0 deletions src/com/connectsdk/device/SimpleDevicePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.util.Log;
import android.view.View;
Expand Down Expand Up @@ -138,6 +139,11 @@ public void onItemClick(AdapterView<?> adapter, View view, int pos,

selectDevice(device);
}
}, new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
listener.onPickDeviceFailed(true);
}
});

pickerDialog.show();
Expand Down