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/RoomAdapter.java25
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java24
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java10
3 files changed, 48 insertions, 11 deletions
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 c7a0f29..5538869 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java
@@ -1,10 +1,13 @@
package me.brysonsteck.wiimmfiwatcher.wiimmfi;
import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -23,12 +26,14 @@ public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{
String playerLink;
String header;
ArrayList<Player> players;
+ Context context;
- public RoomAdapter (String display, String playerLink, String header, ArrayList<Player> players) {
+ public RoomAdapter (String display, String playerLink, String header, ArrayList<Player> players, Context context) {
this.display = display;
this.playerLink = playerLink;
this.header = header;
this.players = players;
+ this.context = context;
}
@NonNull
@@ -46,6 +51,20 @@ public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{
TextView miiName = holder.itemView.findViewById(R.id.mii_names);
TextView variableDisplay = holder.itemView.findViewById(R.id.variable_side_data);
Player currentPlayer = players.get(position);
+ LinearLayout.LayoutParams cardViewParams = new LinearLayout.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
+ cardView.setLayoutParams(cardViewParams);
+ ViewGroup.MarginLayoutParams cardViewMarginParams = (ViewGroup.MarginLayoutParams) cardView.getLayoutParams();
+ cardViewMarginParams.setMargins(40,40,40,40);
+ cardView.requestLayout();
+ int nightModeFlags =
+ context.getResources().getConfiguration().uiMode &
+ Configuration.UI_MODE_NIGHT_MASK;
+ if (nightModeFlags == Configuration.UI_MODE_NIGHT_YES) {
+ // Night mode is active, we're using dark theme
+ cardView.setCardBackgroundColor(Color.parseColor("#313131"));
+ }
if (currentPlayer.watching) {
cardView.setCardBackgroundColor(Color.parseColor("#0D47A1"));
rosterNumber.setTextColor(Color.WHITE);
@@ -78,6 +97,10 @@ public class RoomAdapter extends RecyclerView.Adapter<RoomAdapter.ViewHolder>{
variableDisplay.setText("VR: " + currentPlayer.vr + " / BR: " + currentPlayer.br);
break;
}
+ if (position + 1 == getItemCount()) {
+ cardViewMarginParams.setMargins(40,40,40,250);
+ cardView.requestLayout();
+ }
}
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 afb21d6..2c17476 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java
@@ -1,8 +1,10 @@
package me.brysonsteck.wiimmfiwatcher.wiimmfi;
import android.os.Bundle;
+import android.os.Looper;
import android.view.View;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -24,9 +26,11 @@ public class RoomFragment extends Fragment {
RoomData roomData;
public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display) {
- super(R.layout.fragment_room);
+ super(R.layout.room_fragment);
this.roomData = new RoomData(players, friendCode);
- this.header = roomData.getRoomHeader();
+ new Thread(() -> {
+ this.header = roomData.getRoomHeader();
+ }).start();
this.display = display;
this.players = players;
this.playerLink = playerLink;
@@ -43,23 +47,23 @@ public class RoomFragment extends Fragment {
headerTextView.setText(header);
RecyclerView recyclerView = view.findViewById(R.id.player_data_recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
- recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players));
+ recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext()));
refreshButton.setOnClickListener((buttonView) -> {
- refreshButton.setEnabled(false);
- players.clear();
+ this.players.clear();
this.header = "";
- roomData = roomData.refresh();
+ this.roomData = roomData.refresh();
RoomData newRoomData = roomData.refresh();
- players = roomData.getPlayers();
+ this.players = roomData.getPlayers();
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.";
}
- headerTextView.setText(header);
+
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
- recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players));
- refreshButton.setEnabled(true);
+ recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext()));
+ headerTextView.setText(header);
+
});
}
}
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 f3029af..1a9576a 100644
--- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java
+++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java
@@ -1,6 +1,8 @@
package me.brysonsteck.wiimmfiwatcher.wiimmfi;
import android.content.Intent;
+import android.content.res.Configuration;
+import android.graphics.Color;
import android.os.Bundle;
import android.os.StrictMode;
@@ -37,6 +39,14 @@ public class WiimmfiActivity extends AppCompatActivity {
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
NavigationView drawer = findViewById(R.id.navigation_view);
+ int nightModeFlags =
+ this.getResources().getConfiguration().uiMode &
+ Configuration.UI_MODE_NIGHT_MASK;
+ if (nightModeFlags == Configuration.UI_MODE_NIGHT_YES) {
+ // Night mode is active, we're using dark theme
+ drawer.setBackgroundColor(Color.parseColor("#313131"));
+ }
+
toolbar.setTitle("Watching " + friendCode);
if (savedInstanceState == null) {