aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi')
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/SetImageView.java103
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java18
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java14
3 files changed, 126 insertions, 9 deletions
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/SetImageView.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/SetImageView.java
new file mode 100644
index 0000000..d77da38
--- /dev/null
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/SetImageView.java
@@ -0,0 +1,103 @@
+package me.brysonsteck.wiimmfiwatcher.wiimmfi;
+
+import android.widget.ImageView;
+
+import me.brysonsteck.wiimmfiwatcher.R;
+
+public class SetImageView {
+
+ public SetImageView(ImageView image, String header, boolean failure) {
+ if (failure) {
+ image.setImageResource(R.drawable.globe);
+ } else {
+ header = header.toLowerCase();
+ if (header.contains("wii luigi circuit")) {
+ image.setImageResource(R.drawable.course_lc);
+ } else if (header.contains("wii moo moo meadows")) {
+ image.setImageResource(R.drawable.course_mmm);
+ } else if (header.contains("wii mushroom gorge")) {
+ image.setImageResource(R.drawable.course_mg);
+ } else if (header.contains("wii toad's factory")) {
+ image.setImageResource(R.drawable.course_tf);
+ } else if (header.contains("wii mario circuit")) {
+ image.setImageResource(R.drawable.course_mc);
+ } else if (header.contains("wii coconut mall")) {
+ image.setImageResource(R.drawable.course_cm);
+ } else if (header.contains("wii dk summit") || header.contains("wii dk's snowboard cross")) {
+ image.setImageResource(R.drawable.course_dks);
+ } else if (header.contains("wii wario's gold mine")) {
+ image.setImageResource(R.drawable.course_wgm);
+ } else if (header.contains("wii daisy circuit")) {
+ image.setImageResource(R.drawable.course_dc);
+ } else if (header.contains("wii koopa cape")) {
+ image.setImageResource(R.drawable.course_kc);
+ } else if (header.contains("wii maple treeway")) {
+ image.setImageResource(R.drawable.course_mt);
+ } else if (header.contains("wii grumble volcano")) {
+ image.setImageResource(R.drawable.course_gv);
+ } else if (header.contains("wii dry dry ruins")) {
+ image.setImageResource(R.drawable.course_ddr);
+ } else if (header.contains("wii moonview highway")) {
+ image.setImageResource(R.drawable.course_mh);
+ } else if (header.contains("wii bowser's castle")) {
+ image.setImageResource(R.drawable.course_bc);
+ } else if (header.contains("wii rainbow road")) {
+ image.setImageResource(R.drawable.course_rr);
+ } else if (header.contains("gcn peach beach")) {
+ image.setImageResource(R.drawable.course_rpb);
+ } else if (header.contains("ds yoshi falls")) {
+ image.setImageResource(R.drawable.course_ryf);
+ } else if (header.contains("snes ghost valley 2")) {
+ image.setImageResource(R.drawable.course_rgv2);
+ } else if (header.contains("n64 mario raceway")) {
+ image.setImageResource(R.drawable.course_rmr);
+ } else if (header.contains("n64 sherbet land")) {
+ image.setImageResource(R.drawable.course_rsl);
+ } else if (header.contains("gba shy guy beach")) {
+ image.setImageResource(R.drawable.course_rsgb);
+ } else if (header.contains("ds delfino square")) {
+ image.setImageResource(R.drawable.course_rds);
+ } else if (header.contains("gcn waluigi stadium")) {
+ image.setImageResource(R.drawable.course_rws);
+ } else if (header.contains("ds desert hills")) {
+ image.setImageResource(R.drawable.course_rdh);
+ } else if (header.contains("gba bowser's castle 3")) {
+ image.setImageResource(R.drawable.course_rbc3);
+ } else if (header.contains("n64 dk's jungle parkway")) {
+ image.setImageResource(R.drawable.course_rdkjp);
+ } else if (header.contains("gcn mario circuit")) {
+ image.setImageResource(R.drawable.course_rmc);
+ } else if (header.contains("snes mario circuit 3")) {
+ image.setImageResource(R.drawable.course_rmc3);
+ } else if (header.contains("ds peach gardens")) {
+ image.setImageResource(R.drawable.course_rpg);
+ } else if (header.contains("gcn dk mountain")) {
+ image.setImageResource(R.drawable.course_rdkm);
+ } else if (header.contains("n64 bowser's castle")) {
+ image.setImageResource(R.drawable.course_rbc);
+ } else if (header.contains("wii block plaza")) {
+ image.setImageResource(R.drawable.battle_bp);
+ } else if (header.contains("wii delfino pier")) {
+ image.setImageResource(R.drawable.battle_dp);
+ } else if (header.contains("wii funky stadium")) {
+ image.setImageResource(R.drawable.battle_fs);
+ } else if (header.contains("wii chain chomp")) {
+ image.setImageResource(R.drawable.battle_ccw);
+ } else if (header.contains("wii thwomp desert")) {
+ image.setImageResource(R.drawable.battle_td);
+ } else if (header.contains("snes battle course 4")) {
+ image.setImageResource(R.drawable.battle_rbc4);
+ } else if (header.contains("n64 skyscraper")) {
+ image.setImageResource(R.drawable.battle_rs);
+ } else if (header.contains("gba battle course 3")) {
+ image.setImageResource(R.drawable.battle_rbc3);
+ } else if (header.contains("gcn cookie land")) {
+ image.setImageResource(R.drawable.battle_rcl);
+ } else if (header.contains("ds twilight house")) {
+ image.setImageResource(R.drawable.battle_rth);
+ } else if (header.contains("last track:") && !header.contains("nintendo")) {
+ image.setImageResource(R.drawable.course_ctgp);
+ }
+ }
+ }
+}
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 6936275..de7c97c 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java
@@ -5,6 +5,7 @@ import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
import android.os.StrictMode;
+import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.drawerlayout.widget.DrawerLayout;
@@ -32,6 +33,7 @@ public class WiimmfiActivity extends AppCompatActivity {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
+ ImageView image = findViewById(R.id.image);
MaterialToolbar toolbar = findViewById(R.id.toolbar);
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
NavigationView drawer = findViewById(R.id.navigation_view);
@@ -48,7 +50,7 @@ public class WiimmfiActivity extends AppCompatActivity {
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
@@ -61,49 +63,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, players, playerLink[0], "fc", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.roles) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "roles", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "roles", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.login_regions) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "login_regions", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "login_regions", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.room_match) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "room_match", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "room_match", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.world) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "world", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "world", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.conn_fail) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "conn_fail", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "conn_fail", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
if (menuItem.getItemId() == R.id.vr_br) {
players.clear();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "vr_br", toolbar), null)
+ .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "vr_br", toolbar, image), null)
.setReorderingAllowed(true)
.commit();
}
diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java
index d6326f7..90c97da 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/fragments/RoomFragment.java
@@ -2,7 +2,9 @@ package me.brysonsteck.wiimmfiwatcher.wiimmfi.fragments;
import android.os.Bundle;
import android.view.View;
+import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -18,6 +20,7 @@ import java.util.ArrayList;
import me.brysonsteck.wiimmfiwatcher.R;
import me.brysonsteck.wiimmfiwatcher.wiimmfi.Player;
import me.brysonsteck.wiimmfiwatcher.wiimmfi.RoomData;
+import me.brysonsteck.wiimmfiwatcher.wiimmfi.SetImageView;
public class RoomFragment extends Fragment {
String display;
@@ -26,8 +29,9 @@ public class RoomFragment extends Fragment {
ArrayList<Player> players;
RoomData roomData;
MaterialToolbar toolbar;
+ ImageView image;
- public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display, MaterialToolbar toolbar) {
+ public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display, MaterialToolbar toolbar, ImageView image) {
super(R.layout.room_fragment);
this.roomData = new RoomData(players, friendCode);
new Thread(() -> {
@@ -37,6 +41,7 @@ public class RoomFragment extends Fragment {
this.players = players;
this.playerLink = playerLink;
this.toolbar = toolbar;
+ this.image = image;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
@@ -46,20 +51,24 @@ public class RoomFragment extends Fragment {
if (header == null) {
headerTextView.setText(R.string.header_null_error);
toolbar.setNavigationIcon(null);
+ SetImageView setImageView = new SetImageView(image, header, true);
}
if (roomData.error != null) {
headerTextView.setText(getResources().getString(R.string.jsoup_error, roomData.error));
toolbar.setNavigationIcon(null);
+ SetImageView setImageView = new SetImageView(image, header, true);
}
if (roomData.error == null && header != null) {
headerTextView.setText(header);
toolbar.setNavigationIcon(R.drawable.ic_baseline_menu_24);
+ SetImageView setImageView = new SetImageView(image, header, false);
}
RecyclerView recyclerView = view.findViewById(R.id.player_data_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext()));
refreshButton.setOnClickListener((buttonView) -> {
+ Toast.makeText(getContext(), "Refreshing!", Toast.LENGTH_LONG).show();
this.players.clear();
this.header = "";
this.roomData = roomData.refresh();
@@ -69,14 +78,17 @@ public class RoomFragment extends Fragment {
if (header == null) {
headerTextView.setText(R.string.header_null_error);
toolbar.setNavigationIcon(null);
+ SetImageView setImageView = new SetImageView(image, header, true);
}
if (newRoomData.error instanceof java.net.SocketTimeoutException || newRoomData.error instanceof java.net.UnknownHostException) {
headerTextView.setText(getResources().getString(R.string.jsoup_error, roomData.error));
toolbar.setNavigationIcon(null);
+ SetImageView setImageView = new SetImageView(image, header, true);
}
if (roomData.error == null && header != null) {
headerTextView.setText(header);
toolbar.setNavigationIcon(R.drawable.ic_baseline_menu_24);
+ SetImageView setImageView = new SetImageView(image, header, false);
}
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext()));