mirror of
https://github.com/Aviortheking/Hangman.git
synced 2024-12-19 18:20:54 +00:00
Continuing dev
This commit is contained in:
parent
2156de4939
commit
2fb83c57b0
@ -4,7 +4,7 @@ android {
|
|||||||
buildToolsVersion "27.0.3"
|
buildToolsVersion "27.0.3"
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "net.DeltaWings.Android.Hangman"
|
applicationId "net.DeltaWings.Android.Hangman"
|
||||||
minSdkVersion 21
|
minSdkVersion 26
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:fullBackupContent="@xml/backup_descriptor"
|
android:fullBackupContent="@xml/backup_descriptor"
|
||||||
@ -32,7 +33,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".settings.SettingActivity"
|
android:name=".settings.SettingActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/DeltaWings.Dark">
|
android:theme="@style/DeltaWings.Color">
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".AboutActivity"
|
<activity android:name=".AboutActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.StrictMode;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@ -50,6 +51,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||||
|
StrictMode.setThreadPolicy(policy);
|
||||||
|
|
||||||
setTheme(this);
|
setTheme(this);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
@ -1,24 +1,38 @@
|
|||||||
package net.DeltaWings.Android.Hangman.Util;
|
package net.DeltaWings.Android.Hangman.Util;
|
||||||
|
|
||||||
|
import android.os.Environment;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Xml;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.DeltaWings.Android.Hangman.MainActivity;
|
import net.DeltaWings.Android.Hangman.MainActivity;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
public class GameUtil {
|
public class GameUtil {
|
||||||
|
|
||||||
private String word = "example";
|
private String word = "example";
|
||||||
@ -36,25 +50,19 @@ public class GameUtil {
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL url = new URL(s);
|
|
||||||
|
|
||||||
// read from the URL
|
byte[] encoded = Files.readAllBytes(Paths.get("/sdcard/list.txt"));
|
||||||
Scanner scan = new Scanner(url.openStream());
|
String[] strings = new String(encoded, Charset.defaultCharset()).split("\r");
|
||||||
StringBuilder str = new StringBuilder();
|
Log.v(tag, strings[randInt(0, strings.length-1)]);
|
||||||
|
word = strings[randInt(0, strings.length-1)];
|
||||||
while (scan.hasNext()) str.append(scan.nextLine());
|
|
||||||
scan.close();
|
|
||||||
|
|
||||||
obj = new JSONObject(str.toString());
|
|
||||||
int pageName = obj.getJSONObject("pageInfo").length();
|
|
||||||
Log.v("NTM", pageName +"");
|
|
||||||
Toast.makeText(MainActivity.getInstance(), pageName, Toast.LENGTH_LONG).show();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
//ntm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
word = generateRandomWords();
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < word.length(); i++) {
|
for (int i = 0; i < word.length(); i++) {
|
||||||
res.add("_");
|
res.add("_");
|
||||||
}
|
}
|
||||||
@ -112,6 +120,12 @@ public class GameUtil {
|
|||||||
|
|
||||||
return randomStrings;
|
return randomStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int randInt(int min, int max) {
|
||||||
|
Random rand = new Random();
|
||||||
|
int randomNum = rand.nextInt((max - min) + 1) + min;
|
||||||
|
return randomNum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user