Commit b1052491 authored by djamel's avatar djamel

gestion des places pour mineur

parent 3d8e3ed7
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -9,17 +9,20 @@ import java.io.Serializable;
* Created by djamel on 17/10/15.
*/
public class Key_List implements Parcelable, Serializable {
int id;
String key;
private int id;
private String key;
private boolean is_child;
public Key_List(int id, String key) {
public Key_List(int id, String key, boolean is_child) {
this.id = id;
this.key = key;
this.is_child = is_child;
}
protected Key_List(Parcel in) {
this.id = in.readInt();
this.key = in.readString();
this.is_child = in.readByte() != 0;
}
public int getId() {
......@@ -30,6 +33,10 @@ public class Key_List implements Parcelable, Serializable {
return this.key;
}
public boolean getIs_child() {
return this.is_child;
}
@Override
public int describeContents() {
return 0;
......@@ -39,6 +46,7 @@ public class Key_List implements Parcelable, Serializable {
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.id);
dest.writeString(this.key);
dest.writeByte((byte) (this.is_child ? 1 : 0));
}
......
......@@ -76,7 +76,7 @@ public class Login extends ActionBarActivity implements View.OnClickListener {
for (int index = 0; index < response.length(); index++) {
element = response.getJSONObject(index);
Key_List key = new Key_List(element.getInt("id"), element.getString
("key"));
("key"), element.getBoolean("is_child"));
key_list.add(key);
}
} catch (JSONException e) {
......
......@@ -38,7 +38,7 @@ import cz.msebera.android.httpclient.entity.StringEntity;
public class Read_QR_Code extends ActionBarActivity implements View.OnClickListener {
static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";
private static final String ACTION_SCAN = "com.google.zxing.client.android.SCAN";
private ArrayList<Key_List> key_list = null;
private String server;
private EditText _nbrPlace;
......@@ -153,12 +153,44 @@ public class Read_QR_Code extends ActionBarActivity implements View.OnClickListe
// Ticket is valid
idFound = true;
if (key.getIs_child()) {
showChildDialog(Read_QR_Code.this, str[3], nbrPlaceTot, nbrPlaceSelect);
}
else {
sendRequest(str[3], nbrPlaceTot, nbrPlaceSelect);
}
}
}
}
if (!idFound) {
display(getString(R.string.ebillet_false), false);
}
}
private AlertDialog showChildDialog(final Activity act, final String hash, final int nbrPlaceTot,
final int nbrPlaceSelect) {
AlertDialog.Builder childDialog = new AlertDialog.Builder(act);
childDialog.setMessage(R.string.ebillet_mineur);
childDialog.setPositiveButton(R.string.check, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
sendRequest(hash, nbrPlaceTot, nbrPlaceSelect);
}
});
childDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
display(getString(R.string.cancelled), true);
}
});
return childDialog.show();
}
private void sendRequest(String hash, int nbrPlaceTot, int nbrPlaceSelect) {
JSONObject jsonParams = new JSONObject();
StringEntity entity = null;
try {
// Set parameters in JSON structure
jsonParams.put("verif", str[3]);
jsonParams.put("verif", hash);
jsonParams.put("nb", nbrPlaceTot);
jsonParams.put("qt", nbrPlaceSelect);
......@@ -211,12 +243,6 @@ public class Read_QR_Code extends ActionBarActivity implements View.OnClickListe
}
});
}
}
}
if (!idFound) {
display(getString(R.string.ebillet_false), false);
}
}
/**
*
......
......@@ -13,7 +13,7 @@
<string name="label_ipAddress">Adresse IP</string>
<string name="label_port">Numéro de Port</string>
<string name="connect">Se connecter</string>
<string name="connecting">Connection en cours ...</string>
<string name="connecting">Connection en cours </string>
<string name="nbPlace">Nombre de place</string>
<string name="nbPlaceOversize">Le nombre de place selectionné excéde le nombre de place
disponible pour ce billet</string>
......@@ -24,4 +24,7 @@
\'192.168.0.1\'</string>
<string name="errorPORT">Erreur: Vérifiez le numéro de port</string>
<string name="ex_3">ex: 3</string>
<string name="ebillet_mineur">Cette place est une place pour mineur !</string>
<string name="cancel">Annuler</string>
<string name="cancelled">L\'opération a été annulé</string>
</resources>
......@@ -57,11 +57,13 @@ data/keys.json.example
[
{
"id": 1120,
"key": "VDLV7897IEetisuare"
"key": "VDLV7897IEetisuare",
"is_child": true
},
{
"id": 7988,
"key": "TISEdodp7897tesiuaV8V"
"key": "TISEdodp7897tesiuaV8V",
"is_child": false
}
]
```
......
[
{
"id": 1120,
"key": "VDLV7897IEetisuare"
"key": "VDLV7897IEetisuare",
"is_child": true
},
{
"id": 7988,
"key": "TISEdodp7897tesiuaV8V"
"key": "TISEdodp7897tesiuaV8V",
"is_child", false
}
]
Markdown is supported
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