diff options
Diffstat (limited to 'app/src/main/java/me/brysonsteck/wiimmfiwatcher')
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java | 13 | ||||
-rw-r--r-- | app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/WiimmfiActivity.java | 18 |
2 files changed, 19 insertions, 12 deletions
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 4f5b1bc..f22bf1c 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/wiimmfi/RoomFragment.java @@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.floatingactionbutton.FloatingActionButton; import java.net.UnknownHostException; @@ -26,8 +27,9 @@ public class RoomFragment extends Fragment { String playerLink; ArrayList<Player> players; RoomData roomData; + MaterialToolbar toolbar; - public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display) { + public RoomFragment(String friendCode, ArrayList<Player> players, String playerLink, String display, MaterialToolbar toolbar) { super(R.layout.room_fragment); this.roomData = new RoomData(players, friendCode); new Thread(() -> { @@ -36,7 +38,7 @@ public class RoomFragment extends Fragment { this.display = display; this.players = players; this.playerLink = playerLink; - + this.toolbar = toolbar; } @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { @@ -45,13 +47,15 @@ public class RoomFragment extends Fragment { TextView headerTextView = view.findViewById(R.id.room_header_text); if (header == null) { headerTextView.setText(R.string.header_null_error); + toolbar.setNavigationIcon(null); } if (roomData.error != null) { headerTextView.setText(getResources().getString(R.string.jsoup_error, roomData.error)); - + toolbar.setNavigationIcon(null); } if (roomData.error == null && header != null) { headerTextView.setText(header); + toolbar.setNavigationIcon(R.drawable.ic_baseline_menu_24); } RecyclerView recyclerView = view.findViewById(R.id.player_data_recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); @@ -66,12 +70,15 @@ public class RoomFragment extends Fragment { header = newRoomData.getRoomHeader(); if (header == null) { headerTextView.setText(R.string.header_null_error); + toolbar.setNavigationIcon(null); } if (newRoomData.error instanceof java.net.SocketTimeoutException || newRoomData.error instanceof java.net.UnknownHostException) { headerTextView.setText(R.string.jsoup_error); + toolbar.setNavigationIcon(null); } if (roomData.error == null && header != null) { headerTextView.setText(header); + toolbar.setNavigationIcon(R.drawable.ic_baseline_menu_24); } recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(new RoomAdapter(display, playerLink, header, players, getContext())); 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 bb20969..c0d4c9f 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.view.View; import androidx.appcompat.app.AppCompatActivity; import androidx.drawerlayout.widget.DrawerLayout; @@ -33,7 +34,6 @@ public class WiimmfiActivity extends AppCompatActivity { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); - MaterialToolbar toolbar = findViewById(R.id.toolbar); DrawerLayout drawerLayout = findViewById(R.id.drawer_layout); NavigationView drawer = findViewById(R.id.navigation_view); @@ -50,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"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc", toolbar), null) .setReorderingAllowed(true) .commit(); } @@ -63,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"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "fc", toolbar), 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"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "roles", toolbar), 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"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "login_regions", toolbar), 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"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "room_match", toolbar), 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"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "world", toolbar), 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"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "conn_fail", toolbar), 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"), null) + .replace(R.id.room_fragment, new RoomFragment(friendCode, players, playerLink[0], "vr_br", toolbar), null) .setReorderingAllowed(true) .commit(); } |