Permalink
Browse files

show match history in shit way

  • Loading branch information...
danolanater committed Nov 14, 2017
1 parent 5556393 commit 4611d981af6821827f264128753663ef911274a5
@@ -55,4 +55,4 @@ public Cursor getAllData() {
Cursor res = db.rawQuery("select * from " + TABLE_NAME, null);
return res;
}
}
}
@@ -3,8 +3,8 @@
import android.database.Cursor;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
/**
* Created by Danolanater on 10/9/2017.
@@ -18,19 +18,32 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.match_history);
myDb = new DatabaseHelper(this);
viewAll();
}
public void viewAll(View view) {
public void viewAll() {
Cursor res = myDb.getAllData();
if(res.getCount() == 0)
if(res.getCount() == 0) {
showMessage("Error", "No data found");
return;
}
StringBuffer buffer = new StringBuffer();
while (res.moveToNext()) {
buffer.append("Id :" + res.getString(0) + "\n");
buffer.append("Opponent :" + res.getString(1) + "\n");
buffer.append("Match Type :" + res.getString(2) + "\n");
buffer.append("Result :" + res.getString(3) + "\n\n");
}
showMessage("Data",buffer.toString());
}
public void showMessage(String title, String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle(title);
builder.setMessage(message);
builder.show();
}
}
@@ -18,7 +18,7 @@
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_margin="4dp"
android:text="Player 1"
android:textAlignment="center"
android:textSize="24sp" />
@@ -41,7 +41,7 @@
android:layout_centerHorizontal="true"
android:text="20"
android:textAlignment="center"
android:textSize="52sp" />
android:textSize="32sp" />
<Button
android:id="@+id/increase_button"
@@ -93,7 +93,7 @@
android:layout_height="wrap_content"
android:text="0"
android:textAlignment="center"
android:textSize="72sp" />
android:textSize="36sp" />
<Button
android:onClick="player1Victory"
@@ -122,7 +122,7 @@
android:layout_height="wrap_content"
android:text="-"
android:textAlignment="center"
android:textSize="56sp" />
android:textSize="24sp" />
<Button
android:onClick="draw"
@@ -155,7 +155,7 @@
android:layout_height="wrap_content"
android:text="0"
android:textAlignment="center"
android:textSize="72sp" />
android:textSize="36sp" />
<Button
android:onClick="player2Victory"
@@ -206,7 +206,7 @@
android:layout_centerHorizontal="true"
android:text="20"
android:textAlignment="center"
android:textSize="52sp" />
android:textSize="32sp" />
<Button
android:id="@+id/increase_button2"

0 comments on commit 4611d98

Please sign in to comment.