diff --git a/.idea/misc.xml b/.idea/misc.xml index 0c8166a..5d19981 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 54b7b3f..031c785 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,9 @@ - + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 14f19b7..8c35c86 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> + diff --git a/app/src/main/java/com/welchsoftwaredevelopers/myapplication/MainActivity.java b/app/src/main/java/com/welchsoftwaredevelopers/myapplication/MainActivity.java index cfbe0e8..b7e7840 100644 --- a/app/src/main/java/com/welchsoftwaredevelopers/myapplication/MainActivity.java +++ b/app/src/main/java/com/welchsoftwaredevelopers/myapplication/MainActivity.java @@ -19,6 +19,7 @@ import java.util.List; import org.json.JSONArray; import org.json.JSONException; +import org.json.JSONObject; public class MainActivity extends AppCompatActivity { public List> script = new ArrayList<>(); @@ -30,13 +31,21 @@ public class MainActivity extends AppCompatActivity { try { JSONArray test = new JSONArray(convertStreamToString(getResources().openRawResource(R.raw.script))); - + readJson(test); } catch (JSONException | IOException e) { e.printStackTrace(); } } - //http://www.java2s.com/Code/Java/File-Input-Output/ConvertInputStreamtoString.htm + public static void readJson(JSONArray ScriptObject) throws JSONException { + Integer length = ScriptObject.length(); + for (i = 0; i > length; i++) { + JSONObject question = ScriptObject.getJSONObject(i); + question + } + } + + //http://www.java2s.com/Code/Java/File-Input-Output/ConvertInputStreamtoString.htm public static String convertStreamToString(InputStream is) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); @@ -60,10 +69,13 @@ public class MainActivity extends AppCompatActivity { public void Click(View v) { if (true) { Toast.makeText(this, " Please Make A Selection ", Toast.LENGTH_SHORT).show(); - } else { + } + else { Intent intent = new Intent(this, ChoiceActivity.class); intent.putStringArrayListExtra("Text", (ArrayList) script.get(1).get("Text")); intent.putIntegerArrayListExtra("Destination", (ArrayList) script.get(1).get("Destination")); + intent.putExtra("Question", (ArrayList) script.get(1).get("Question")); + intent. startActivity(intent); } } diff --git a/app/src/main/res/raw/script.json b/app/src/main/res/raw/script.json index ac1030a..d904dd6 100644 --- a/app/src/main/res/raw/script.json +++ b/app/src/main/res/raw/script.json @@ -1,22 +1,28 @@ [ - [ - { - "Text": "opt1", - "DESTINATION": 1 - }, - { - "Text": "opt2", - "DESTINATION": 2 - } - ], - [ - { - "Text": "opt1", - "DESTINATION": 3 - }, - { - "Text": "opt2", - "DESTINATION": 0 - } - ] + { + "question": "question 1:", + "opts": [ + { + "Text": "opt1", + "DESTINATION": 1 + }, + { + "Text": "opt2", + "DESTINATION": 2 + } + ] + }, + { + "question": "question 2:", + "opts": [ + { + "Text": "opt1", + "DESTINATION": 3 + }, + { + "Text": "opt2", + "DESTINATION": 0 + } + ] + } ] \ No newline at end of file diff --git a/build.gradle b/build.gradle index 1ea4bd0..74b2ab0 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files