Commit 542446c7 authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Optimization

Can not cancel pin dialog
Fix bug
parent 4f157c29
...@@ -283,12 +283,13 @@ public class MainActivity extends BaseActivity { ...@@ -283,12 +283,13 @@ public class MainActivity extends BaseActivity {
final View pinView = getLayoutInflater().inflate(R.layout.dialog_badge, null); final View pinView = getLayoutInflater().inflate(R.layout.dialog_badge, null);
final EditText pinInput = pinView.findViewById(R.id.input_pin); final EditText pinInput = pinView.findViewById(R.id.input_pin);
final Button noPinButton = pinView.findViewById(R.id.button_no_pin);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this); final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
alertDialogBuilder alertDialogBuilder
.setTitle(R.string.badge_dialog) .setTitle(R.string.badge_dialog)
.setView(pinView) .setView(pinView)
.setCancelable(true) .setCancelable(false)
.setPositiveButton(R.string.connexion, new DialogInterface.OnClickListener() { .setPositiveButton(R.string.connexion, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int id) { public void onClick(DialogInterface dialogInterface, int id) {
if (pinInput.getText().toString().equals("")) { if (pinInput.getText().toString().equals("")) {
...@@ -302,12 +303,15 @@ public class MainActivity extends BaseActivity { ...@@ -302,12 +303,15 @@ public class MainActivity extends BaseActivity {
} }
} }
}) })
.setNeutralButton(R.string.no_pin, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.cancel, null);
public void onClick(DialogInterface dialogInterface, int id) {
connectWithBadge(idBadge, "0000"); noPinButton.setOnClickListener(new View.OnClickListener() {
dialogInterface.cancel(); @Override
} public void onClick(View view) {
}); dialog.dismiss();
connectWithBadge(idBadge, "0000");
}
});
dialog.createDialog(alertDialogBuilder, pinInput); dialog.createDialog(alertDialogBuilder, pinInput);
} }
......
...@@ -93,7 +93,9 @@ public class Dialog { ...@@ -93,7 +93,9 @@ public class Dialog {
} }
public void stopLoading() { public void stopLoading() {
this.loading.dismiss(); if (this.loading != null)
this.loading.dismiss();
this.loading = null; this.loading = null;
} }
} }
...@@ -4,13 +4,30 @@ ...@@ -4,13 +4,30 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<EditText <LinearLayout
android:id="@+id/input_pin"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginLeft="25dp" android:orientation="horizontal">
android:layout_marginRight="25dp"
android:maxLength="4" <EditText
android:inputType="numberPassword" android:id="@+id/input_pin"
android:hint="@string/pin" /> android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:hint="@string/pin"
android:inputType="numberPassword"
android:maxLength="4" />
<Button
android:id="@+id/button_no_pin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="25dp"
android:layout_weight="1"
android:text="@string/no_pin" />
</LinearLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment