From e771101c6c390d13d8657a449ddf164db3c1aa30 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 30 May 2021 16:58:39 -0600 Subject: recent friend codes now clears errortext if any --- .../main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java | 6 +++++- .../main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java | 4 ++-- app/src/main/res/drawable/ic_baseline_dark_mode_24.xml | 5 +++++ app/src/main/res/drawable/ic_baseline_light_mode_24.xml | 5 +++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/ic_baseline_dark_mode_24.xml create mode 100644 app/src/main/res/drawable/ic_baseline_light_mode_24.xml (limited to 'app/src') diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java index ded5e65..53828f9 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java @@ -13,6 +13,7 @@ import androidx.databinding.ObservableArrayList; import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.button.MaterialButton; +import com.google.android.material.textview.MaterialTextView; import java.util.ArrayList; @@ -22,11 +23,13 @@ import me.brysonsteck.wiimmfiwatcher.wiimmfi.WiimmfiActivity; public class WatchCodeAdapter extends RecyclerView.Adapter{ ObservableArrayList entries; Context context; + MaterialTextView errorText; ArrayList recentCodes; - public WatchCodeAdapter(Context context, ObservableArrayList entries) { + public WatchCodeAdapter(Context context, ObservableArrayList entries, MaterialTextView errorText) { this.context = context; this.entries = entries; + this.errorText = errorText; this.recentCodes = new ArrayList<>(); } @@ -50,6 +53,7 @@ public class WatchCodeAdapter extends RecyclerView.Adapter { + errorText.setText(""); Intent intent = new Intent(view.getContext(), WiimmfiActivity.class); intent.putExtra("friendCode", currentFC); context.startActivity(intent); diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java index a14e6f7..e263bb6 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java @@ -61,7 +61,8 @@ public class WatchCodeFragment extends Fragment { super.onViewCreated(view, savedInstanceState); FriendCodeViewModel viewModel = new ViewModelProvider(getActivity()).get(FriendCodeViewModel.class); - WatchCodeAdapter adapter = new WatchCodeAdapter(getContext(), viewModel.getEntries()); + MaterialTextView errorText = view.findViewById(R.id.error_text); + WatchCodeAdapter adapter = new WatchCodeAdapter(getContext(), viewModel.getEntries(), errorText); viewModel.getEntries().addOnListChangedCallback(new ObservableList.OnListChangedCallback>() { @Override public void onChanged(ObservableList sender) { @@ -106,7 +107,6 @@ public class WatchCodeFragment extends Fragment { recyclerView.setAdapter(adapter); EditText friendCode = view.findViewById(R.id.friend_code_edit_text); - MaterialTextView errorText = view.findViewById(R.id.error_text); Button watchButton = view.findViewById(R.id.watch_button); watchButton.setOnClickListener(buttonClick -> { startWiimmfiActivity( diff --git a/app/src/main/res/drawable/ic_baseline_dark_mode_24.xml b/app/src/main/res/drawable/ic_baseline_dark_mode_24.xml new file mode 100644 index 0000000..e7b3592 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_dark_mode_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_light_mode_24.xml b/app/src/main/res/drawable/ic_baseline_light_mode_24.xml new file mode 100644 index 0000000..fea04c9 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_light_mode_24.xml @@ -0,0 +1,5 @@ + + + -- cgit v1.2.3