summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Yu <jackyu@google.com>2019-05-08 10:29:38 -0700
committerJack Yu <jackyu@google.com>2019-05-08 10:48:47 -0700
commit468b75b68ca0642cd3c4203760790f99072b373a (patch)
tree064bbff33493ad6d017f81ccc9d4bf5b0eb1eee7
parentfd8c6cc7002a5f93d58d9140a4313d916ec60de5 (diff)
downloadCellBroadcastReceiver-468b75b68ca0642cd3c4203760790f99072b373a.tar.gz
Fixed no alert text shown when there is alert
Fixed by hiding the text when there is alert, and then unhide it when there is no alerts at beginning or after history cleared. Test: Manual Bug: 131642555 Change-Id: Ieca1bc28a6aee52a699ee408888087e30edf1d54
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastListActivity.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastListActivity.java b/src/com/android/cellbroadcastreceiver/CellBroadcastListActivity.java
index 1c1bf217e..dde4042ad 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastListActivity.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastListActivity.java
@@ -44,6 +44,7 @@ import android.view.View.OnCreateContextMenuListener;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ListView;
+import android.widget.TextView;
import java.util.ArrayList;
@@ -166,6 +167,7 @@ public class CellBroadcastListActivity extends Activity {
// old cursor once we return.)
mAdapter.swapCursor(data);
getActivity().invalidateOptionsMenu();
+ updateNoAlertTextVisibility();
}
@Override
@@ -206,6 +208,21 @@ public class CellBroadcastListActivity extends Activity {
}
};
+ private void updateNoAlertTextVisibility() {
+ TextView noAlertsTextView = getActivity().findViewById(R.id.empty);
+ if (noAlertsTextView != null) {
+ noAlertsTextView.setVisibility(!hasAlertsInHistory()
+ ? View.VISIBLE : View.INVISIBLE);
+ }
+ }
+
+ /**
+ * @return {@code true} if the alert history database has any item
+ */
+ private boolean hasAlertsInHistory() {
+ return mAdapter.getCursor().getCount() > 0;
+ }
+
@Override
public boolean onContextItemSelected(MenuItem item) {
Cursor cursor = mAdapter.getCursor();