From 9361d64931f993512ff9786d428dfa2c479b2722 Mon Sep 17 00:00:00 2001 From: Jesper Handskemager Date: Mon, 3 Jan 2022 13:34:58 +0100 Subject: [PATCH] Add ratio to the stats page --- .../DisplayMessageActivity.java | 8 ++-- .../res/layout/activity_display_message.xml | 41 +++++++++++++++---- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/jesperh/showyoutubedislikes/DisplayMessageActivity.java b/app/src/main/java/com/jesperh/showyoutubedislikes/DisplayMessageActivity.java index 1832e04..0782c59 100644 --- a/app/src/main/java/com/jesperh/showyoutubedislikes/DisplayMessageActivity.java +++ b/app/src/main/java/com/jesperh/showyoutubedislikes/DisplayMessageActivity.java @@ -121,24 +121,22 @@ public class DisplayMessageActivity extends AppCompatActivity { { return ""; } - String Dislike_Count = ""; - String view_count = ""; - String like_count = ""; String FINAL_URL = API_BASE_URL + API_QUERY_URL + result; final TextView textViewDislikes = (TextView) findViewById(R.id.YTDislikes); final TextView textViewLikes = (TextView) findViewById(R.id.YTLikes); final TextView textViewViews = (TextView) findViewById(R.id.YTViews); final TextView textViewVideoLink = (TextView) findViewById(R.id.YTVideoLink); + final TextView textViewRatio = (TextView) findViewById(R.id.YTRatio); - String myUrl = FINAL_URL; - StringRequest myRequest = new StringRequest(Request.Method.GET, myUrl, + StringRequest myRequest = new StringRequest(Request.Method.GET, FINAL_URL, response -> { try{ //Create a JSON object containing information from the API. JSONObject myJsonObject = new JSONObject(response); textViewDislikes.setText(myJsonObject.getString("dislikes") + " \uD83D\uDC4E"); textViewLikes.setText(myJsonObject.getString("likes") + " \uD83D\uDC4D"); + textViewRatio.setText(myJsonObject.getString("rating").substring(0, 3) + " / 5 ⭐"); textViewViews.setText(myJsonObject.getString("viewCount") + " \uD83D\uDC41️"); textViewVideoLink.setText(YouTubeLink + " \uD83D\uDD17"); } catch (JSONException e) { diff --git a/app/src/main/res/layout/activity_display_message.xml b/app/src/main/res/layout/activity_display_message.xml index 76140b5..441a209 100644 --- a/app/src/main/res/layout/activity_display_message.xml +++ b/app/src/main/res/layout/activity_display_message.xml @@ -11,7 +11,7 @@ android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="417dp" + android:layout_marginTop="336dp" android:minHeight="48dp" android:onClick="ClickReturnYouTubeDislikeLink" android:text="Thanks to returnyoutubedislike.com" @@ -47,16 +47,29 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + @@ -65,7 +78,7 @@ android:layout_width="300dp" android:layout_height="61dp" android:layout_marginStart="172dp" - android:layout_marginTop="296dp" + android:layout_marginTop="356dp" android:layout_marginEnd="181dp" android:text="Downloading Data" app:layout_constraintEnd_toEndOf="parent" @@ -100,14 +113,28 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView3" /> + +