Java Code Examples for android.widget.ListView#invalidate()

The following examples show how to use android.widget.ListView#invalidate() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Updates the existing dialog to show a list of available sensors
 * from the specified node. List items will be set when they are
 * available through an @AvailableSensorsUpdatedListener.
 */
private void showSensorSelectionForNode(String nodeId) {
    String nodeName = app.getGoogleApiMessenger().getNodeName(nodeId);
    Log.d(TAG, "Showing sensor selection for node: " + nodeName + " - " + nodeId);

    // prepare dialog for new sensor selection
    String title = getString(R.string.loading_sensors_on_device).replace("[DEVICENAME]", nodeName);
    getDialog().setTitle(title);

    // update icon
    if (nodeId != null && nodeId.equals(app.getGoogleApiMessenger().getLocalNodeId())) {
        setDialogIcon(R.drawable.ic_phone_android_black_48dp);
    } else {
        setDialogIcon(R.drawable.ic_watch_black_48dp);
    }

    // create & apply new list adapter
    multiChoiceAdapter = new SensorListAdapter(new ArrayList<DeviceSensor>(), getActivity());
    ListView listView = ((AlertDialog) getDialog()).getListView();
    listView.setAdapter(multiChoiceAdapter);

    // update layout params & invalidate list view
    ((ViewGroup.MarginLayoutParams) listView.getLayoutParams()).setMargins((int) UnitHelper.convertDpToPixel(16, getActivity()), 0, 0, 0);
    listView.invalidate();

    // update available sensors
    AvailableSensorsUpdatedListener availableSensorsUpdatedListener = createAvailableSensorsUpdatedListener();
    if (availableSensors.containsKey(nodeId)) {
        // set sensors
        availableSensorsUpdatedListener.onAvailableSensorsUpdated(nodeId, availableSensors.get(nodeId));
    } else {
        // request sensors
        requestAvailableSensors(nodeId, availableSensorsUpdatedListener);
    }

    // track analytics event
    Bundle bundle = new Bundle();
    bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "Device Sensors");
    bundle.putString(FirebaseAnalytics.Param.VALUE, nodeName);
    app.getAnalytics().logEvent(FirebaseAnalytics.Event.VIEW_ITEM_LIST, bundle);
}