From 11aa7c75e16d6819d0681f408c720cbc6a6754ba Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Tue, 18 May 2021 20:48:17 -0600 Subject: did a ton of stuff i dont remember like a dark mode and small enhancements --- .../wiimmfiwatcher/wiimmfi/RoomAdapter.java | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomAdapter.java') 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{ String playerLink; String header; ArrayList players; + Context context; - public RoomAdapter (String display, String playerLink, String header, ArrayList players) { + public RoomAdapter (String display, String playerLink, String header, ArrayList 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{ 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{ variableDisplay.setText("VR: " + currentPlayer.vr + " / BR: " + currentPlayer.br); break; } + if (position + 1 == getItemCount()) { + cardViewMarginParams.setMargins(40,40,40,250); + cardView.requestLayout(); + } } -- cgit v1.2.3