Spaces:
Sleeping
Sleeping
Fadhili Sumaye commited on
Commit ·
a112c25
1
Parent(s): ac6357c
UX: Implement dynamic resultCard visibility to declutter dashboard on launch
Browse files
app/src/main/java/com/example/pestdetection/MainActivity.java
CHANGED
|
@@ -37,6 +37,7 @@ public class MainActivity extends AppCompatActivity {
|
|
| 37 |
View loadingOverlay;
|
| 38 |
ProgressBar progressBar;
|
| 39 |
Button btnSelect, btnCamera, btnUpload;
|
|
|
|
| 40 |
|
| 41 |
private ConnectivityManager connectivityManager;
|
| 42 |
private ConnectivityManager.NetworkCallback networkCallback;
|
|
@@ -83,6 +84,7 @@ public class MainActivity extends AppCompatActivity {
|
|
| 83 |
btnSelect = findViewById(R.id.btnSelect);
|
| 84 |
btnCamera = findViewById(R.id.btnCamera);
|
| 85 |
btnUpload = findViewById(R.id.btnUpload);
|
|
|
|
| 86 |
resultText = findViewById(R.id.resultText);
|
| 87 |
treatmentText = findViewById(R.id.treatmentText);
|
| 88 |
tvConnectionStatus = findViewById(R.id.tvConnectionStatus);
|
|
@@ -147,6 +149,9 @@ public class MainActivity extends AppCompatActivity {
|
|
| 147 |
if (loadingOverlay != null) {
|
| 148 |
loadingOverlay.setVisibility(View.GONE);
|
| 149 |
}
|
|
|
|
|
|
|
|
|
|
| 150 |
if (resultText != null) {
|
| 151 |
resultText.setText("Waiting for scan...");
|
| 152 |
}
|
|
@@ -310,6 +315,7 @@ public class MainActivity extends AppCompatActivity {
|
|
| 310 |
// Show loaders and disable action controls to avoid duplicate clicks
|
| 311 |
if (progressBar != null) progressBar.setVisibility(View.VISIBLE);
|
| 312 |
if (loadingOverlay != null) loadingOverlay.setVisibility(View.VISIBLE);
|
|
|
|
| 313 |
if (btnUpload != null) btnUpload.setEnabled(false);
|
| 314 |
if (btnSelect != null) btnSelect.setEnabled(false);
|
| 315 |
if (btnCamera != null) btnCamera.setEnabled(false);
|
|
@@ -327,6 +333,7 @@ public class MainActivity extends AppCompatActivity {
|
|
| 327 |
// Hide loaders and re-enable buttons
|
| 328 |
if (progressBar != null) progressBar.setVisibility(View.GONE);
|
| 329 |
if (loadingOverlay != null) loadingOverlay.setVisibility(View.GONE);
|
|
|
|
| 330 |
if (btnUpload != null) btnUpload.setEnabled(true);
|
| 331 |
if (btnSelect != null) btnSelect.setEnabled(true);
|
| 332 |
if (btnCamera != null) btnCamera.setEnabled(true);
|
|
@@ -346,6 +353,7 @@ public class MainActivity extends AppCompatActivity {
|
|
| 346 |
// Hide loaders and re-enable buttons
|
| 347 |
if (progressBar != null) progressBar.setVisibility(View.GONE);
|
| 348 |
if (loadingOverlay != null) loadingOverlay.setVisibility(View.GONE);
|
|
|
|
| 349 |
if (btnUpload != null) btnUpload.setEnabled(true);
|
| 350 |
if (btnSelect != null) btnSelect.setEnabled(true);
|
| 351 |
if (btnCamera != null) btnCamera.setEnabled(true);
|
|
@@ -361,6 +369,7 @@ public class MainActivity extends AppCompatActivity {
|
|
| 361 |
// Reset loaders and re-enable buttons on error
|
| 362 |
if (progressBar != null) progressBar.setVisibility(View.GONE);
|
| 363 |
if (loadingOverlay != null) loadingOverlay.setVisibility(View.GONE);
|
|
|
|
| 364 |
if (btnUpload != null) btnUpload.setEnabled(true);
|
| 365 |
if (btnSelect != null) btnSelect.setEnabled(true);
|
| 366 |
if (btnCamera != null) btnCamera.setEnabled(true);
|
|
|
|
| 37 |
View loadingOverlay;
|
| 38 |
ProgressBar progressBar;
|
| 39 |
Button btnSelect, btnCamera, btnUpload;
|
| 40 |
+
View resultCard;
|
| 41 |
|
| 42 |
private ConnectivityManager connectivityManager;
|
| 43 |
private ConnectivityManager.NetworkCallback networkCallback;
|
|
|
|
| 84 |
btnSelect = findViewById(R.id.btnSelect);
|
| 85 |
btnCamera = findViewById(R.id.btnCamera);
|
| 86 |
btnUpload = findViewById(R.id.btnUpload);
|
| 87 |
+
resultCard = findViewById(R.id.resultCard);
|
| 88 |
resultText = findViewById(R.id.resultText);
|
| 89 |
treatmentText = findViewById(R.id.treatmentText);
|
| 90 |
tvConnectionStatus = findViewById(R.id.tvConnectionStatus);
|
|
|
|
| 149 |
if (loadingOverlay != null) {
|
| 150 |
loadingOverlay.setVisibility(View.GONE);
|
| 151 |
}
|
| 152 |
+
if (resultCard != null) {
|
| 153 |
+
resultCard.setVisibility(View.GONE);
|
| 154 |
+
}
|
| 155 |
if (resultText != null) {
|
| 156 |
resultText.setText("Waiting for scan...");
|
| 157 |
}
|
|
|
|
| 315 |
// Show loaders and disable action controls to avoid duplicate clicks
|
| 316 |
if (progressBar != null) progressBar.setVisibility(View.VISIBLE);
|
| 317 |
if (loadingOverlay != null) loadingOverlay.setVisibility(View.VISIBLE);
|
| 318 |
+
if (resultCard != null) resultCard.setVisibility(View.GONE);
|
| 319 |
if (btnUpload != null) btnUpload.setEnabled(false);
|
| 320 |
if (btnSelect != null) btnSelect.setEnabled(false);
|
| 321 |
if (btnCamera != null) btnCamera.setEnabled(false);
|
|
|
|
| 333 |
// Hide loaders and re-enable buttons
|
| 334 |
if (progressBar != null) progressBar.setVisibility(View.GONE);
|
| 335 |
if (loadingOverlay != null) loadingOverlay.setVisibility(View.GONE);
|
| 336 |
+
if (resultCard != null) resultCard.setVisibility(View.VISIBLE);
|
| 337 |
if (btnUpload != null) btnUpload.setEnabled(true);
|
| 338 |
if (btnSelect != null) btnSelect.setEnabled(true);
|
| 339 |
if (btnCamera != null) btnCamera.setEnabled(true);
|
|
|
|
| 353 |
// Hide loaders and re-enable buttons
|
| 354 |
if (progressBar != null) progressBar.setVisibility(View.GONE);
|
| 355 |
if (loadingOverlay != null) loadingOverlay.setVisibility(View.GONE);
|
| 356 |
+
if (resultCard != null) resultCard.setVisibility(View.VISIBLE);
|
| 357 |
if (btnUpload != null) btnUpload.setEnabled(true);
|
| 358 |
if (btnSelect != null) btnSelect.setEnabled(true);
|
| 359 |
if (btnCamera != null) btnCamera.setEnabled(true);
|
|
|
|
| 369 |
// Reset loaders and re-enable buttons on error
|
| 370 |
if (progressBar != null) progressBar.setVisibility(View.GONE);
|
| 371 |
if (loadingOverlay != null) loadingOverlay.setVisibility(View.GONE);
|
| 372 |
+
if (resultCard != null) resultCard.setVisibility(View.VISIBLE);
|
| 373 |
if (btnUpload != null) btnUpload.setEnabled(true);
|
| 374 |
if (btnSelect != null) btnSelect.setEnabled(true);
|
| 375 |
if (btnCamera != null) btnCamera.setEnabled(true);
|
app/src/main/res/layout/activity_main.xml
CHANGED
|
@@ -277,6 +277,7 @@
|
|
| 277 |
android:layout_width="0dp"
|
| 278 |
android:layout_height="wrap_content"
|
| 279 |
android:layout_marginTop="24dp"
|
|
|
|
| 280 |
app:cardCornerRadius="20dp"
|
| 281 |
app:cardElevation="4dp"
|
| 282 |
app:cardBackgroundColor="@color/surface_card"
|
|
|
|
| 277 |
android:layout_width="0dp"
|
| 278 |
android:layout_height="wrap_content"
|
| 279 |
android:layout_marginTop="24dp"
|
| 280 |
+
android:visibility="gone"
|
| 281 |
app:cardCornerRadius="20dp"
|
| 282 |
app:cardElevation="4dp"
|
| 283 |
app:cardBackgroundColor="@color/surface_card"
|