mirror of
https://github.com/Aviortheking/Hangman.git
synced 2024-12-19 18:20:54 +00:00
Update time !
This commit is contained in:
@ -4,7 +4,7 @@ android {
|
||||
buildToolsVersion "26.0.1"
|
||||
defaultConfig {
|
||||
applicationId "net.DeltaWings.Android.Hangman"
|
||||
minSdkVersion 15
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 26
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
@ -6,19 +6,26 @@ import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
import android.widget.TextView;
|
||||
|
||||
import static net.DeltaWings.Android.Hangman.MainActivity.instance;
|
||||
import net.DeltaWings.Android.Hangman.Util.ConnectionUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GameActivity extends AppCompatActivity {
|
||||
|
||||
ProgressBar progressBar;
|
||||
AlertDialog.Builder builder;
|
||||
private AlertDialog.Builder builder;
|
||||
private ConnectionUtil co;
|
||||
private List<String> letters = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
builder.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -29,47 +36,105 @@ public class GameActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.game_activity);
|
||||
|
||||
ProgressBar progressBar = findViewById(R.id.progressBar);
|
||||
EditText input = findViewById(R.id.input);
|
||||
|
||||
log("Logs");
|
||||
log("Connecting...");
|
||||
co = new ConnectionUtil();
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setDisplayShowHomeEnabled(true);
|
||||
} else {
|
||||
Toast.makeText(instance, " There is a problem here let's see what it is", Toast.LENGTH_LONG).show();
|
||||
log("A problem occurred Please restart the application");
|
||||
}
|
||||
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
|
||||
|
||||
|
||||
|
||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which){
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
Toast.makeText(instance, "Selected Yes", Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
//Close Connection
|
||||
log("Closing connection");
|
||||
co.closeConnection();
|
||||
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
Toast.makeText(instance, "Selected No", Toast.LENGTH_LONG).show();
|
||||
//send to main menu
|
||||
finish();
|
||||
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Input Management
|
||||
input.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
String text = ((EditText) v).getText().toString();
|
||||
if(text.length() == 1) {
|
||||
log("Letter : " + text);
|
||||
if(letters.contains(text)) {
|
||||
log("Letter : " + text + "Already in");
|
||||
} else {
|
||||
log("Sending letter " + text);
|
||||
//Send Letter
|
||||
}
|
||||
} else if(text.length() > 1) {
|
||||
log("Word : " + text);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
//Input Management
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Return Builder
|
||||
builder = new AlertDialog.Builder(this);
|
||||
|
||||
builder.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener)
|
||||
builder.setMessage("Do you really want to quit your game ?")
|
||||
.setPositiveButton("Yes", dialogClickListener)
|
||||
.setNegativeButton("No", dialogClickListener);
|
||||
//Return Builder
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
log("Connected !");
|
||||
setProgressAnimate(progressBar, 100);
|
||||
}
|
||||
|
||||
private void setProgressAnimate(ProgressBar pb, int progressTo)
|
||||
{
|
||||
|
||||
private void setProgressAnimate(ProgressBar pb, int progressTo) {
|
||||
ObjectAnimator animation = ObjectAnimator.ofInt(pb, "progress", pb.getProgress(), progressTo);
|
||||
animation.setDuration(250);
|
||||
animation.setInterpolator(new DecelerateInterpolator());
|
||||
animation.start();
|
||||
}
|
||||
|
||||
private void log(String message) {
|
||||
TextView logs = findViewById(R.id.logs);
|
||||
logs.setText(logs.getText().toString() + "\n" + message);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package net.DeltaWings.Android.Hangman.Util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConnectionUtil {
|
||||
|
||||
static public ConnectionUtil connection;
|
||||
|
||||
private String ip = null;
|
||||
private String userID = null;
|
||||
private String jsp = "jsp";
|
||||
public int percent = 0;
|
||||
|
||||
public ConnectionUtil ConnectionUtil() {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
|
||||
}
|
||||
|
||||
public boolean sendData(List<Object> query) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@
|
||||
style="@android:style/Widget.DeviceDefault.Light.ProgressBar.Horizontal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="false"
|
||||
android:max="100"
|
||||
android:paddingTop="-4dp"
|
||||
android:progress="50"
|
||||
@ -27,14 +28,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_begin="4dp"
|
||||
app:layout_constraintGuide_begin="3dp"
|
||||
tools:layout_editor_absoluteX="0dp"
|
||||
tools:layout_editor_absoluteY="4dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@ -76,7 +76,7 @@
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editText"
|
||||
android:id="@+id/input"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="0dp"
|
||||
@ -93,11 +93,17 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Logs"/>
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/logs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
Reference in New Issue
Block a user