From 377487c04e1e1dc0636f923e0405911f853f1521 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Fri, 21 May 2021 08:23:26 -0600 Subject: added a new error if jsoup throws exception --- .../java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java | 11 +++-------- .../me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java | 11 +++++++---- .../brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java | 15 +++++++++++++++ app/src/main/res/values/strings.xml | 3 +++ 4 files changed, 28 insertions(+), 12 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java index a0229ff..4624864 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/AboutFragment.java @@ -59,14 +59,9 @@ public class AboutFragment extends Fragment { TextView bugs = view.findViewById(R.id.bugs_text); TextView license = view.findViewById(R.id.license_text); - aboutWatcher.setText("Wiimmfi Watcher is an UNOFFICIAL application created for a school project that I have decided to turn into a full application. " + - "This application was made to provide an easy shortcut to the Wiimmfi website and display data in a mobile friendly way, since the official website doesn't have a mobile friendly version. " + - "Free and open source, you can watch your Wiimmfi matches on your phone in a quick and easy way. " + - ""); - - aboutMe.setText("Hi there! My name is Bryson Steck. I am a student studying Computer Science. This is my first official application that I'm maintaining. " + - "This whole \"application on the Google Play Store\" thing is new to me, so please be patient as I am learning how to maintain something like this. " + - "I hope you enjoy!"); + aboutWatcher.setText(R.string.about_watcher); + + aboutMe.setText(R.string.about_me); github.setClickable(true); github.setMovementMethod(LinkMovementMethod.getInstance()); diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java index 47faf4b..60ad7df 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java @@ -14,20 +14,21 @@ public class RoomData { String roomHeader; String playerLink; String friendCode; + Exception error; ArrayList players = new ArrayList<>(); String userAgent = "Wiimmfi Watcher for Android (https://github.com/brysonsteck/wiimmfi-watcher) Version " + BuildConfig.VERSION_NAME; public RoomData (ArrayList players, String friendCode) { this.friendCode = friendCode; - getPlayerLink(); + error = getPlayerLink(); Document doc = null; if (this.playerLink == null) { - System.out.println("The player link is null for some reason"); + System.out.println("The player link is null for some reason:"); + System.out.println(error); } else { try { - System.out.println(userAgent); doc = Jsoup.connect("https://wiimmfi.de/" + this.playerLink) .userAgent(userAgent) .get(); @@ -93,7 +94,7 @@ public class RoomData { } } - public void getPlayerLink() { + public Exception getPlayerLink() { try { Document doc = Jsoup.connect("https://wiimmfi.de/stats/mkw") .userAgent(userAgent) @@ -117,10 +118,12 @@ public class RoomData { } } } + return null; } catch (Exception e) { e.printStackTrace(); + return e; } } public ArrayList getPlayers() { return players; } diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java index 2c17476..8de81f9 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java @@ -14,7 +14,9 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.floatingactionbutton.FloatingActionButton; +import java.net.UnknownHostException; import java.util.ArrayList; +import java.util.Arrays; import me.brysonsteck.wiimmfiwatcher.R; @@ -44,6 +46,13 @@ public class RoomFragment extends Fragment { if (header == null) { header = "This player is not online, not inside a room or does not exist. Click the refresh button to try again, or click on the back button to enter a different friend code."; } + if (roomData.error != null) { + header = "Wiimmfi Watcher was unable to connect to the Wiimmfi servers. This could be that you are not connected to the internet, but it could be something else. Here was the error:\n\n" + + roomData.error.getMessage() + "\n\n" + + "If the error is along the lines of \"Unable to resolve host\" or \"Timeout\", you are probably having internet issues. Make sure you are connected to the internet then click the refresh button or press back to watch a new friend code.\n\n" + + "If the error is something other than that or if the error persists, make sure that Wiimmfi's website is currently running. Otherwise, please screenshot this screen and submit a bug report by clicking the About icon on the main page."; + + } headerTextView.setText(header); RecyclerView recyclerView = view.findViewById(R.id.player_data_recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); @@ -59,6 +68,12 @@ public class RoomFragment extends Fragment { if (header == null) { header = "This player is not online, not inside a room or does not exist. Click the refresh button to try again, or click on the back button to enter a different friend code."; } + if (newRoomData.error instanceof java.net.SocketTimeoutException || newRoomData.error instanceof java.net.UnknownHostException) { + header = "Wiimmfi Watcher was unable to connect to the Wiimmfi servers. This could be that you are not connected to the internet, but it could be something else. Here was the error:\n\n" + + roomData.error.getMessage() + "\n\n" + + "If the error is along the lines of \"Unable to resolve host\" or \"Timeout\", you are probably having internet issues. Make sure you are connected to the internet then click the refresh button or press back to watch a new friend code.\n\n" + + "If the error is something other than that or if the error persists, make sure that Wiimmfi's website is currently running. Otherwise, please screenshot this screen and submit a bug report by clicking the About icon on the main page."; + } recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext())); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3c7c9b2..ec1de5a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,8 @@ Wiimmfi + + Hi there! My name is Bryson Steck. I am a student studying Computer Science. This is my first official application that I\'m maintaining. This whole \"application on the Google Play Store\" thing is new to me, so please be patient as I am learning how to maintain something like this. I hope you enjoy! + Wiimmfi Watcher is an UNOFFICIAL application created for a school project that I have decided to turn into a full application. This application was made to provide an easy shortcut to the Wiimmfi website and display data in a mobile friendly way, since the official website doesn\'t have a mobile friendly version. Free and open source, you can watch your Wiimmfi matches on your phone in a quick and easy way. All of the code in this project is open source on my GitHub repository here. You are free to use this code and expand upon it under the GNU General Public License (Version 3). Speaking of bugs, did you find a bug? Do you want to provide feedback on the app? I\'d love to hear it! First, make sure that the issue you found is not listed on my todo list. It\'s possible I\'m already aware of it or working on it. If your issue is not addressed on the todo list, then you can create an issue on my GitHub repository here. If you don\'t know how to use GitHub, you can fill out this Google Form instead. © Copyright 2021 Bryson Steck\n\nWiimmfi Watcher is available under the GNU General Public License Version 3. You can view the license here.\n\nWiimmfi Watcher is free software: you can redistribute it and/or modify -- cgit v1.2.3