From 72c839bd12c37b95776f2a03f98c52036b9400fc Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 30 May 2021 23:04:42 -0600 Subject: added dialog between main and wiimmfi activities, updated todo list for release --- .../me/brysonsteck/wiimmfiwatcher/MainActivity.java | 5 ++++- .../brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java | 12 +++++++++++- .../wiimmfiwatcher/WatchCodeFragment.java | 20 +++++++++++++++----- 3 files changed, 30 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/me/brysonsteck') diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java index 7247e58..8084714 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java @@ -3,7 +3,6 @@ package me.brysonsteck.wiimmfiwatcher; import android.os.Build; import android.os.Bundle; import android.view.View; -import android.view.ViewGroup; import android.view.WindowManager; import androidx.annotation.RequiresApi; @@ -48,4 +47,8 @@ public class MainActivity extends AppCompatActivity { }); } + @Override + protected void onStop() { + super.onStop(); + } } \ No newline at end of file diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java index 53828f9..7034888 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java @@ -1,5 +1,6 @@ package me.brysonsteck.wiimmfiwatcher; +import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; @@ -24,12 +25,15 @@ public class WatchCodeAdapter extends RecyclerView.Adapter entries; Context context; MaterialTextView errorText; + ProgressDialog progressBar; ArrayList recentCodes; - public WatchCodeAdapter(Context context, ObservableArrayList entries, MaterialTextView errorText) { + public WatchCodeAdapter(Context context, ObservableArrayList entries, + MaterialTextView errorText, ProgressDialog progressBar) { this.context = context; this.entries = entries; this.errorText = errorText; + this.progressBar = progressBar; this.recentCodes = new ArrayList<>(); } @@ -53,6 +57,12 @@ public class WatchCodeAdapter extends RecyclerView.Adapter { + progressBar.setCancelable(true); + progressBar.setMessage(holder.itemView.getResources().getString(R.string.locating_text, currentFC)); + progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER); + progressBar.setProgress(0); + progressBar.setMax(100); + progressBar.show(); errorText.setText(""); Intent intent = new Intent(view.getContext(), WiimmfiActivity.class); intent.putExtra("friendCode", currentFC); diff --git a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java index e263bb6..01069b6 100644 --- a/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java +++ b/app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java @@ -1,5 +1,6 @@ package me.brysonsteck.wiimmfiwatcher; +import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; import android.transition.TransitionInflater; @@ -8,13 +9,9 @@ import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; -import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.core.view.OnApplyWindowInsetsListener; -import androidx.core.view.ViewCompat; -import androidx.core.view.WindowInsetsCompat; import androidx.databinding.ObservableList; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; @@ -28,6 +25,7 @@ import me.brysonsteck.wiimmfiwatcher.viewmodel.FriendCodeViewModel; import me.brysonsteck.wiimmfiwatcher.wiimmfi.WiimmfiActivity; public class WatchCodeFragment extends Fragment { + ProgressDialog progressBar; public WatchCodeFragment() { super(R.layout.watch_code_fragment); @@ -60,9 +58,10 @@ public class WatchCodeFragment extends Fragment { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); FriendCodeViewModel viewModel = new ViewModelProvider(getActivity()).get(FriendCodeViewModel.class); + progressBar = new ProgressDialog(getContext(), R.style.AppCompatAlertDialogStyle); MaterialTextView errorText = view.findViewById(R.id.error_text); - WatchCodeAdapter adapter = new WatchCodeAdapter(getContext(), viewModel.getEntries(), errorText); + WatchCodeAdapter adapter = new WatchCodeAdapter(getContext(), viewModel.getEntries(), errorText, progressBar); viewModel.getEntries().addOnListChangedCallback(new ObservableList.OnListChangedCallback>() { @Override public void onChanged(ObservableList sender) { @@ -145,11 +144,22 @@ public class WatchCodeFragment extends Fragment { }); } + @Override + public void onStop() { + super.onStop(); + if (progressBar.isShowing()) { progressBar.dismiss(); } + } + public void startWiimmfiActivity(View view, EditText friendCode, MaterialTextView errorText, Button watchButton, FriendCodeViewModel viewModel) { Intent intent = new Intent(view.getContext(), WiimmfiActivity.class); if (!isValidFriendCode(friendCode.getText().toString())) { errorText.setText(R.string.error_fc_syntax); } else { + progressBar.setCancelable(false); + progressBar.setMessage(getResources().getString(R.string.locating_text, friendCode.getText())); + progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER); + progressBar.show(); + errorText.setText(""); viewModel.saveFriendCode("", friendCode.getText().toString()); intent.putExtra("friendCode", friendCode.getText().toString()); -- cgit v1.2.3