aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/me')
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/MainActivity.java5
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeAdapter.java12
-rw-r--r--app/src/main/java/me/brysonsteck/wiimmfiwatcher/WatchCodeFragment.java20
3 files changed, 30 insertions, 7 deletions
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<WatchCodeAdapter.View
ObservableArrayList<FriendCode> entries;
Context context;
MaterialTextView errorText;
+ ProgressDialog progressBar;
ArrayList<String> recentCodes;
- public WatchCodeAdapter(Context context, ObservableArrayList<FriendCode> entries, MaterialTextView errorText) {
+ public WatchCodeAdapter(Context context, ObservableArrayList<FriendCode> 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<WatchCodeAdapter.View
}
fcButton.setText(currentFC);
fcButton.setOnClickListener(view -> {
+ 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<ObservableList<FriendCode>>() {
@Override
public void onChanged(ObservableList<FriendCode> 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());