From 8a2c211fa2e334b7646d0b9523e1b62743d9dd96 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Wed, 5 May 2021 00:01:19 -0600 Subject: finished final project --- .../java/com/example/wiimmterfaceandroid/WatchCodeAdapter.java | 9 +++++---- .../java/com/example/wiimmterfaceandroid/WatchCodeFragment.java | 2 +- .../com/example/wiimmterfaceandroid/wiimmfi/RoomFragment.java | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeAdapter.java b/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeAdapter.java index aacd9ef..6e7e69e 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeAdapter.java +++ b/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeAdapter.java @@ -1,5 +1,6 @@ package com.example.wiimmterfaceandroid; +import android.content.Context; import android.content.Intent; import android.view.LayoutInflater; import android.view.View; @@ -17,12 +18,13 @@ import com.google.android.material.button.MaterialButton; public class WatchCodeAdapter extends RecyclerView.Adapter{ ObservableArrayList entries; OnFriendCodeClicked listener; + Context context; public interface OnFriendCodeClicked { public void onClick(FriendCode entry); } - public WatchCodeAdapter(ObservableArrayList entries) { - + public WatchCodeAdapter(Context context, ObservableArrayList entries) { + this.context = context; this.entries = entries; } @@ -41,8 +43,7 @@ public class WatchCodeAdapter extends RecyclerView.Adapter { Intent intent = new Intent(view.getContext(), WiimmfiActivity.class); intent.putExtra("friendCode", currentFC.friendCode); - view.getContext(); - + context.startActivity(intent); }); } diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java b/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java index 67dfdcd..6de02dc 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java +++ b/app/src/main/java/com/example/wiimmterfaceandroid/WatchCodeFragment.java @@ -44,7 +44,7 @@ public class WatchCodeFragment extends Fragment { super.onViewCreated(view, savedInstanceState); FriendCodeViewModel viewModel = new ViewModelProvider(getActivity()).get(FriendCodeViewModel.class); - WatchCodeAdapter adapter = new WatchCodeAdapter(viewModel.getEntries()); + WatchCodeAdapter adapter = new WatchCodeAdapter(getContext(), viewModel.getEntries()); viewModel.getEntries().addOnListChangedCallback(new ObservableList.OnListChangedCallback>() { @Override public void onChanged(ObservableList sender) { diff --git a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomFragment.java b/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomFragment.java index e72e38a..463c635 100644 --- a/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomFragment.java +++ b/app/src/main/java/com/example/wiimmterfaceandroid/wiimmfi/RoomFragment.java @@ -36,7 +36,7 @@ public class RoomFragment extends Fragment { super.onViewCreated(view, savedInstanceState); FloatingActionButton refreshButton = view.findViewById(R.id.refresh_button); TextView headerTextView = view.findViewById(R.id.room_header_text); - if (players == null) { + 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); -- cgit v1.2.3