Skip to content

Commit

Permalink
[WIP] Added RV skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
Psykotik committed Jun 7, 2017
1 parent d7b42df commit 73ac8cb
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Radion/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 35 additions & 18 deletions Radion/app/src/main/java/fr/jordanlambert/radion/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import android.widget.ProgressBar;
import android.widget.TextView;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
Expand All @@ -38,7 +42,7 @@ public class MainActivity extends AppCompatActivity
static final String API_URL = "https://api.fullcontact.com/v2/person.json?";
*/
private static final String API_KEY = "lwUWLTDhm1mshKNpTegeITNu8qlVp1puJaGjsnlsx0Jnlkb1X3";
private static final String API_URL = "https://igdbcom-internet-game-database-v1.p.mashape.com/games/?fields=name%2Csummary%2Cslug%2Curl&limit=10&offset=0&order=release_dates.date%3Adesc";
private static final String API_URL = "https://igdbcom-internet-game-database-v1.p.mashape.com/games/?fields=name%2Csummary%2Cslug%2Curl&limit=10&offset=0&order=release_dates.date%3Adesc&search=zelda";

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -187,24 +191,37 @@ protected void onPostExecute(String response) {
if (response == null) {
response = "THERE WAS AN ERROR";
}
// Hide the progressbar
progressBar.setVisibility(View.GONE);
Log.i("INFO", response);
responseView.setText(response);
// TODO: check this.exception
// TODO: do something with the feed

// try {
// JSONObject object = (JSONObject) new JSONTokener(response).nextValue();
// String requestID = object.getString("requestId");
// int likelihood = object.getInt("likelihood");
// JSONArray photos = object.getJSONArray("photos");
// .
// .
// .
// .
// } catch (JSONException e) {
// e.printStackTrace();
// }

// Parse JSON response
try {
JSONArray jResponse = new JSONArray(response);
for (int i=0; i < jResponse.length(); i++)
{
try {
JSONObject oneObject = jResponse.getJSONObject(i);
// Pulling items from the array
String name = oneObject.getString("name");
String id = oneObject.getString("id");
String url = oneObject.getString("url");
String summary = oneObject.getString("summary");

Log.i("name of " + id + " ", name);

responseView.setText(name);

} catch (JSONException e) {
Log.e(TAG, "Something went wrong during JSON parsing :/");
}
}

} catch (JSONException e) {
e.printStackTrace();
}

//responseView.setText(repsonse);

}
}
}
10 changes: 9 additions & 1 deletion Radion/app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,13 @@
android:text="@string/buttonSearch"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
android:layout_centerHorizontal="true" />

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="42dp"
/>
</RelativeLayout>
19 changes: 19 additions & 0 deletions Radion/app/src/main/res/layout/recyclerviewgame.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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:orientation="vertical">

<TextView
android:id="@+id/subject_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_marginBottom="7dp"
android:layout_gravity="left"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="@color/colorPrimary"
/>

</LinearLayout>
2 changes: 1 addition & 1 deletion Radion/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions Radion/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 10:00:20 PST 2015
#Wed May 17 14:45:19 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

0 comments on commit 73ac8cb

Please sign in to comment.