recent friend codes now clears errortext if any

This commit is contained in:
Bryson Steck 2021-05-30 16:58:39 -06:00
parent 1ed362fdca
commit e771101c6c
4 changed files with 17 additions and 3 deletions

View file

@ -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<WatchCodeAdapter.ViewHolder>{
ObservableArrayList<FriendCode> entries;
Context context;
MaterialTextView errorText;
ArrayList<String> recentCodes;
public WatchCodeAdapter(Context context, ObservableArrayList<FriendCode> entries) {
public WatchCodeAdapter(Context context, ObservableArrayList<FriendCode> 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<WatchCodeAdapter.View
}
fcButton.setText(currentFC);
fcButton.setOnClickListener(view -> {
errorText.setText("");
Intent intent = new Intent(view.getContext(), WiimmfiActivity.class);
intent.putExtra("friendCode", currentFC);
context.startActivity(intent);

View file

@ -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<ObservableList<FriendCode>>() {
@Override
public void onChanged(ObservableList<FriendCode> 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(

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,3c-4.97,0 -9,4.03 -9,9s4.03,9 9,9s9,-4.03 9,-9c0,-0.46 -0.04,-0.92 -0.1,-1.36c-0.98,1.37 -2.58,2.26 -4.4,2.26c-2.98,0 -5.4,-2.42 -5.4,-5.4c0,-1.81 0.89,-3.42 2.26,-4.4C12.92,3.04 12.46,3 12,3L12,3z"/>
</vector>

View file

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5s5,-2.24 5,-5S14.76,7 12,7L12,7zM2,13l2,0c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1l-2,0c-0.55,0 -1,0.45 -1,1S1.45,13 2,13zM20,13l2,0c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1l-2,0c-0.55,0 -1,0.45 -1,1S19.45,13 20,13zM11,2v2c0,0.55 0.45,1 1,1s1,-0.45 1,-1V2c0,-0.55 -0.45,-1 -1,-1S11,1.45 11,2zM11,20v2c0,0.55 0.45,1 1,1s1,-0.45 1,-1v-2c0,-0.55 -0.45,-1 -1,-1C11.45,19 11,19.45 11,20zM5.99,4.58c-0.39,-0.39 -1.03,-0.39 -1.41,0c-0.39,0.39 -0.39,1.03 0,1.41l1.06,1.06c0.39,0.39 1.03,0.39 1.41,0s0.39,-1.03 0,-1.41L5.99,4.58zM18.36,16.95c-0.39,-0.39 -1.03,-0.39 -1.41,0c-0.39,0.39 -0.39,1.03 0,1.41l1.06,1.06c0.39,0.39 1.03,0.39 1.41,0c0.39,-0.39 0.39,-1.03 0,-1.41L18.36,16.95zM19.42,5.99c0.39,-0.39 0.39,-1.03 0,-1.41c-0.39,-0.39 -1.03,-0.39 -1.41,0l-1.06,1.06c-0.39,0.39 -0.39,1.03 0,1.41s1.03,0.39 1.41,0L19.42,5.99zM7.05,18.36c0.39,-0.39 0.39,-1.03 0,-1.41c-0.39,-0.39 -1.03,-0.39 -1.41,0l-1.06,1.06c-0.39,0.39 -0.39,1.03 0,1.41s1.03,0.39 1.41,0L7.05,18.36z"/>
</vector>