Commit 78bdbe01 authored by djamel's avatar djamel

remove useless java class

parent 1df8752d
package djamelfel.gala;
import android.os.Parcel;
import android.os.Parcelable;
import java.io.Serializable;
/**
* Created by djamel on 08/11/15.
*/
public class Billet implements Serializable, Parcelable{
private String id_billet;
private int quantity;
private int prod_validate;
public Billet(String id_billet, int quantity) {
this.id_billet = id_billet;
this.quantity = quantity;
this.prod_validate = 1;
}
public Billet(String save) {
String[] str = save.split(" ");
this.id_billet = str[0];
this.quantity = Integer.parseInt(str[1]);
this.prod_validate = Integer.parseInt(str[2]);
}
protected Billet(Parcel in) {
this.id_billet = in.readString();
this.quantity = in.readInt();
this.prod_validate = in.readInt();
}
public String getId_billet() {
return this.id_billet;
}
public void validatePlace() {
this.prod_validate++;
}
public boolean isClickable() {
if(this.quantity < this.prod_validate)
return true;
return false;
}
@Override
public int describeContents() {
return 0;
}
public String writeToFile() {
return id_billet + " " + String.valueOf(quantity) + " " + String.valueOf(prod_validate);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.id_billet);
dest.writeInt(this.quantity);
dest.writeInt(this.prod_validate);
}
public static final Creator<Billet> CREATOR = new Creator<Billet>() {
@Override
public Billet createFromParcel(Parcel in) {
return new Billet(in);
}
@Override
public Billet[] newArray(int size) {
return new Billet[size];
}
};
}
package djamelfel.gala;
import android.app.ActionBar;
import android.content.Intent;
import android.database.MatrixCursor;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Iterator;
public class Settings extends ActionBarActivity implements View.OnClickListener {
private ArrayList<Key_List> key_list;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
Intent intent = getIntent();
if (intent != null) {
Log.i("intent", "variable");
key_list = intent.getParcelableArrayListExtra("key_list");
}
if (key_list != null) {
updateView();
} else {
key_list = new ArrayList<Key_List>();
}
findViewById(R.id.new_key).setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.new_key:
EditText id = (EditText)findViewById(R.id.id);
EditText key = (EditText)findViewById(R.id.key);
String idS = id.getText().toString();
String keyS = key.getText().toString();
if (idS.isEmpty() || keyS.isEmpty()) {
Toast.makeText(getApplicationContext(), R.string.empty_text_area, Toast
.LENGTH_LONG).show();
}
else {
key_list.add(new Key_List(Integer.parseInt(idS), keyS));
id.setText("");
key.setText("");
updateView();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent intent = new Intent(Settings.this, Read_QR_Code.class);
intent.putParcelableArrayListExtra("key_list", key_list);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void updateView() {
String[] columns = new String[]{"_id", "id", "key"};
MatrixCursor matrixCursor = new MatrixCursor(columns);
startManagingCursor(matrixCursor);
Iterator<Key_List> itr = key_list.iterator();
while(itr.hasNext()) {
Key_List kl = itr.next();
matrixCursor.addRow(new Object[]{
0, kl.getId(), kl.getKey()
});
}
String[] from = new String[]{"id", "key"};
int[] to = new int[]{R.id.textViewCol1, R.id.textViewCol2};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.row_item,
matrixCursor, from, to, 0);
ListView lv = (ListView) findViewById(R.id.listView);
lv.setAdapter(adapter);
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/listView"
android:weightSum="5">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="number"
android:id="@+id/id"
android:layout_weight="1"
android:numeric="integer"
android:hint="@string/id" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/key"
android:layout_weight="3"
android:autoText="false"
android:hint="@string/key" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/new_key"
android:layout_weight="1"
android:id="@+id/new_key" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2">
<TextView
android:id="@+id/textViewCol1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:layout_weight="1"
android:gravity="center"
android:padding="4dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/textViewCol2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Read_QR_Code">
<item android:id="@+id/action_settings"
android:icon="@drawable/ic_settings_black_48dp"
app:showAsAction="ifRoom"
android:title="@string/settings"/>
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/stepBack"
android:title="@string/stepBack" />
</menu>
\ No newline at end of file
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