From 27b36802b876805ae30c322ecbadf7286d2239fb Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Mon, 10 May 2021 13:23:25 -0600 Subject: final cleanup before first release --- .../brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java | 3 +-- .../me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java | 12 ++++-------- .../brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java | 6 ++---- .../wiimmfiwatcher/wiimmfi/WiimmfiActivity.java | 16 ++++++++-------- 4 files changed, 15 insertions(+), 22 deletions(-) (limited to 'app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi') diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java index 0cf7a6e..c7a0f29 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java @@ -19,12 +19,11 @@ import java.util.ArrayList; import me.brysonsteck.wiimmfiwatcher.R; public class RoomAdapter extends RecyclerView.Adapter{ - String display; String playerLink; String header; ArrayList players; - boolean online = true; + public RoomAdapter (String display, String playerLink, String header, ArrayList players) { this.display = display; this.playerLink = playerLink; 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 f0d9db7..284b735 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomData.java @@ -14,7 +14,7 @@ public class RoomData { String friendCode; ArrayList players = new ArrayList<>(); - public RoomData (ArrayList players, String playerLink, String friendCode) { + public RoomData (ArrayList players, String friendCode) { this.friendCode = friendCode; getPlayerLink(); Document doc = null; @@ -91,10 +91,8 @@ public class RoomData { public void getPlayerLink() { try { - Document doc = null; - - doc = Jsoup.connect("https://wiimmfi.de/stats/mkw") - .userAgent("Wiimmfi Watcher for Android (https://github.com/brysonsteck/wiimmfi-watcher) (UNDER DEVELOPMENT)") + Document doc = Jsoup.connect("https://wiimmfi.de/stats/mkw") + .userAgent("Wiimmfi Watcher for Android (https://github.com/brysonsteck/wiimmfi-watcher) (Developer testing)") .get(); Element table = doc.select("table").get(0); Elements rows = table.select("tr"); @@ -102,13 +100,11 @@ public class RoomData { for (int i = 0; i < rows.size(); i++) { Element row = rows.get(i); Elements colPlayers = row.select("td"); - Elements colHeader = row.select("th"); if (colPlayers.size() > 0) { String data = colPlayers.get(0).select("a").toString(); -// System.out.println(data); if (data.contains(friendCode)) { System.out.println("Found friend code"); playerLink = data.split("\"")[3]; @@ -130,7 +126,7 @@ public class RoomData { public RoomData refresh() { players.clear(); roomHeader = ""; - return new RoomData(players, playerLink, friendCode); + return new RoomData(players, friendCode); } } 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 cbadf63..afb21d6 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java @@ -23,9 +23,9 @@ public class RoomFragment extends Fragment { ArrayList players; RoomData roomData; - public RoomFragment(String friendCode, String header, ArrayList players, String playerLink, String display) { + public RoomFragment(String friendCode, ArrayList players, String playerLink, String display) { super(R.layout.fragment_room); - this.roomData = new RoomData(players, playerLink, friendCode); + this.roomData = new RoomData(players, friendCode); this.header = roomData.getRoomHeader(); this.display = display; this.players = players; @@ -52,8 +52,6 @@ public class RoomFragment extends Fragment { roomData = roomData.refresh(); RoomData newRoomData = roomData.refresh(); players = roomData.getPlayers(); -// playerLink = roomData.getPlayerLink(); -// String otherPlayerLink = newRoomData.getPlayerLink(); header = newRoomData.getRoomHeader(); 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."; diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java index 24affee..f3029af 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java @@ -41,7 +41,7 @@ public class WiimmfiActivity extends AppCompatActivity { if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "fc"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc"), null) .setReorderingAllowed(true) .commit(); } @@ -54,49 +54,49 @@ public class WiimmfiActivity extends AppCompatActivity { if (menuItem.getItemId() == R.id.friend_code) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "fc"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.roles) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "roles"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "roles"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.login_regions) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "login_regions"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "login_regions"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.room_match) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "room_match"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "room_match"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.world) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "world"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "world"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.conn_fail) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "conn_fail"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "conn_fail"), null) .setReorderingAllowed(true) .commit(); } if (menuItem.getItemId() == R.id.vr_br) { players.clear(); getSupportFragmentManager().beginTransaction() - .replace(R.id.room_fragment, new RoomFragment(friendCode, roomHeader, players, playerLink[0], "vr_br"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "vr_br"), null) .setReorderingAllowed(true) .commit(); } -- cgit v1.2.3