Skip to content

Commit

Permalink
set dialog title
Browse files Browse the repository at this point in the history
  • Loading branch information
r-cohen committed Mar 19, 2018
1 parent f8074fc commit 848fc86
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions btscanselector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 14
versionName "1.1.1"
versionCode 15
versionName "1.1.2"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@

public class BTScanSelectorBuilder {
public static void build(FragmentActivity activity, ABTScanSelectorEventsHandler handler) {
build(activity, handler, null);
}

public static void build(FragmentActivity activity, ABTScanSelectorEventsHandler handler, String title) {
BTScanSelectorDialog dialog = new BTScanSelectorDialog();
dialog.setTitle(title);
dialog.setEvents(handler);
dialog.show(activity.getSupportFragmentManager(), "selectbtdevice");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ public class BTScanSelectorDialog extends DialogFragment {
private static int REQUEST_ENABLE_BT = 1;
private static int REQUEST_LOCATION_PERMISSION = 2;
private IBTScanSelectorEvents mEvents;
private String dialogTitle;
BTScanSelectorAdapter mAdapter;
RecyclerView recyclerView;
ProgressBar progressBar;

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
dialogTitle = getString(R.string.nearbyDevices);
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.selector_dialog, null);

Expand Down Expand Up @@ -61,6 +63,7 @@ public void onClick(DialogInterface dialogInterface, int i) {
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
dialog.setTitle(dialogTitle);
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -78,6 +81,10 @@ public void setEvents(IBTScanSelectorEvents events) {
this.mEvents = events;
}

public void setTitle(String title) {
this.dialogTitle = title == null ? getString(R.string.nearbyDevices) : title;
}

@Override
public void onDestroy() {
if (mAdapter != null) {
Expand Down

0 comments on commit 848fc86

Please sign in to comment.