Java Code Examples for android.support.wearable.view.WearableListView#setAdapter()

The following examples show how to use android.support.wearable.view.WearableListView#setAdapter() . 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
Source File: MenuListActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    elements = getElements();
    setContentView(R.layout.actions_list_activity);

    // Get the list component from the layout of the activity
    WearableListView listView =
            (WearableListView) findViewById(R.id.wearable_list);

    // Assign an adapter to the list
    listView.setAdapter(new Adapter(this, elements));

    // Set a click listener
    listView.setClickListener(this);
}
 
Example 2
Source File: SelectionListActivity.java    From android-wear-gopro-remote with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_selection_list);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    Intent i = getIntent();
    if(i != null) {
        String[] items = i.getStringArrayExtra(EXTRA_ITEMS);
        String selected = i.getStringExtra(EXTRA_SELECTED_ITEM);
        WearableListView listView = (WearableListView) findViewById(R.id.list);
        Adapter adapter = new Adapter(this, items);
        listView.setAdapter(adapter);
        listView.setClickListener(this);
        listView.scrollToPosition(adapter.getPositionByValue(selected));
    }
}
 
Example 3
Source File: WearMenu.java    From WearMenu with Apache License 2.0 6 votes vote down vote up
public void setMenuElements(List<String> titles, List<Drawable> drawables){
    setContentView(R.layout.wearmenu_list);

    if(mListBackgroundId > 0)
        findViewById(R.id.wearmenu_listview_container).setBackgroundResource(mListBackgroundId);

    WearableListView listView = (WearableListView) findViewById(R.id.wearmenu_listview);
    listView.setAdapter(new WearMenuListListViewAdapter(getContext(), titles, drawables, mListTextColor, mListSelectedColor));
    listView.setClickListener(new WearableListView.ClickListener() {
        @Override
        public void onClick(WearableListView.ViewHolder viewHolder) {
            if(mWearMenuListener != null)
                mWearMenuListener.onWearMenuListClicked(viewHolder.getPosition());
            toggle();
        }

        @Override
        public void onTopEmptyRegionClick() {
            toggle();
        }
    });
}
 
Example 4
Source File: ScannerActivity.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_list_with_header);

	// Get the list component from the layout of the activity
	final WearableListView listView = findViewById(R.id.devices_list);
	listView.setAdapter(deviceAdapter = new DevicesAdapter(listView));
	listView.setClickListener(onRowClickListener);
	listView.addOnScrollListener(onScrollListener);

	// The header will be moved as the list is scrolled
	header = findViewById(R.id.header);

	// Register a broadcast receiver that will listen for events from the service.
	LocalBroadcastManager.getInstance(this).registerReceiver(serviceBroadcastReceiver, BleProfileService.makeIntentFilter());
}
 
Example 5
Source File: WatchSettingsActivity.java    From android-wear-gopro-remote with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_watch_settings);
    mListView = (WearableListView) findViewById(R.id.list);
    mLoadingPanel = (RelativeLayout)findViewById(R.id.loadingPanel);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);


    mListView.setAdapter(new SettingsAdapter(this));
    mListView.setClickListener(this);
 }
 
Example 6
Source File: WatchFaceConfigActivity.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_background_selector);

    mImageResourceList = getResources().obtainTypedArray( R.array.background_resource_ids );
    mHeader = (TextView) findViewById( R.id.header );

    WearableListView listView = (WearableListView) findViewById( R.id.background_picker );
    BoxInsetLayout content = (BoxInsetLayout) findViewById( R.id.content );

    content.setOnApplyWindowInsetsListener( new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            if( !insets.isRound() ) {
                v.setPaddingRelative( (getResources().getDimensionPixelSize( R.dimen.content_padding_start ) ),
                        v.getPaddingTop(),
                        v.getPaddingEnd(),
                        v.getPaddingBottom() );
            }

            return v.onApplyWindowInsets( insets );
        }
    });

    listView.setHasFixedSize( true );
    listView.setClickListener( this );
    listView.addOnScrollListener( this );

    String[] backgrounds = getResources().getStringArray( R.array.background_array );
    listView.setAdapter( new BackgroundListAdapter( backgrounds ) );


}
 
Example 7
Source File: CollectionActivity.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
/**
 * Handle a FeatureType response. The FeatureType response includes a list
 * FeatureTypes for the selected layer that can be shown to the user.
 *
 * @param item the DataItem received from the mobile device
 */
private void handleFeatureTypeResponse(DataItem item) {
  DataMap dm = DataMapItem.fromDataItem(item).getDataMap();
  // Get the list of feature types from the data map
  featureTypeNames = dm.getStringArrayList("featureTypes");
  // Set the content view to the selection scroll list
  setContentView(R.layout.selection_list);
  // Get the WearableListView and set its adapter and click listener
  WearableListView listView = (WearableListView) findViewById(R.id.wearable_list);
  listView.setAdapter(new Adapter(this, featureTypeNames));
  listView.setClickListener(this);
  // Note that our next response type should be a layer response (when the user selects
  // an item)
  mNextResponseType = RESPONSE_TYPE.FEATURE_TYPE;
}
 
Example 8
Source File: CollectionActivity.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
/**
 * Handles a layer response. The layer response includes a list of layers
 * that have recently been used on the mobile device that can be shown to
 * the user for selection.
 *
 * @param item the DataItem received from the mobile device
 */
private void handleLayerResponse(DataItem item) {
  DataMap dm = DataMapItem.fromDataItem(item).getDataMap();
  // Get the list of layer names from the data map
  layerNames = dm.getStringArrayList("layers");
  // Set the content view to the selection scroll list
  setContentView(R.layout.selection_list);
  // Get the WearableListView and set its adapter and click listener
  WearableListView listView = (WearableListView) findViewById(R.id.wearable_list);
  listView.setAdapter(new Adapter(this, layerNames));
  listView.setClickListener(this);
  // Note that our next response type should be a layer response (when the user selects
  // an item)
  mNextResponseType = RESPONSE_TYPE.LAYER;
}
 
Example 9
Source File: MainActivity.java    From AndroidWearable-Samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    WearableListView listView = (WearableListView) findViewById(R.id.list);
    listView.setAdapter(new Adapter(this));
    listView.setClickListener(this);
}
 
Example 10
Source File: SetTimerActivity.java    From android-Timer with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int paramLength = getIntent().getIntExtra(AlarmClock.EXTRA_LENGTH, 0);
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "SetTimerActivity:onCreate=" + paramLength);
    }
    if (paramLength > 0 && paramLength <= 86400) {
        long durationMillis = paramLength * 1000;
        setupTimer(durationMillis);
        finish();
        return;
    }

    Resources res = getResources();
    for (int i = 0; i < NUMBER_OF_TIMES; i++) {
        mTimeOptions[i] = new ListViewItem(
                res.getQuantityString(R.plurals.timer_minutes, i + 1, i + 1),
                (i + 1) * 60 * 1000);
    }

    setContentView(R.layout.timer_set_timer);

    // Initialize a simple list of countdown time options.
    mWearableListView = (WearableListView) findViewById(R.id.times_list_view);
    mWearableListView.setAdapter(new TimerWearableListViewAdapter(this));
    mWearableListView.setClickListener(this);
}
 
Example 11
Source File: UARTConfigurationsActivity.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_list);

	// Check if the WEAR device is connected to the UART device itself, or by the phone.
	// Binding will fail if we are using phone as proxy as the service has not been started before.
	final Intent service = new Intent(this, BleProfileService.class);
	bindService(service, serviceConnection, 0);

	final WearableListView listView = findViewById(R.id.list);
	listView.setClickListener(this);
	listView.setAdapter(adapter = new UARTConfigurationsAdapter(this));

	googleApiClient = new GoogleApiClient.Builder(this)
			.addApi(Wearable.API)
			.addConnectionCallbacks(this)
			.addOnConnectionFailedListener(this)
			.build();


	// Register the broadcast receiver that will listen for events from the device
	final IntentFilter filter = new IntentFilter();
	filter.addAction(BleProfileService.BROADCAST_CONNECTION_STATE);
	filter.addAction(BleProfileService.BROADCAST_ERROR);
	LocalBroadcastManager.getInstance(this).registerReceiver(serviceBroadcastReceiver, filter);
}
 
Example 12
Source File: ListChooserActivity.java    From WearPreferenceActivity with Apache License 2.0 5 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.preference_list);

    loadIntentExtras();
    checkRequiredExtras();

    final WearableListView list = (WearableListView) findViewById(android.R.id.list);
    list.setAdapter(new PreferenceEntriesAdapter());
    list.scrollToPosition(getIntent().getIntExtra(EXTRA_CURRENT_VALUE, 0));
    list.setClickListener(this);
}
 
Example 13
Source File: Chooser.java    From sensordatacollector with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onClick(WearableListView.ViewHolder viewHolder)
{
    // parse data
    String posture = Chooser.this.adapterPosture.get(viewHolder.getPosition());

    // update mobile device
    BroadcastService.getInstance().sendMessage("/posture/update", posture);

    // update local device
    MainActivity mc = (MainActivity) ActivityController.getInstance().get("MainActivity");
    mc.updatePostureView(posture);

    // clean up
    ((TextView) findViewById(R.id.posture_posture_headline)).setText("");
    WearableListView view = (WearableListView) findViewById(R.id.posture_posture_list);
    view.setAdapter(null);
    view.setOnClickListener(null);

    // progressbar
    ProgressBar pb = (ProgressBar) findViewById(R.id.progressBar1);
    pb.setVisibility(View.VISIBLE);

    // send database request
    String query = "SELECT name FROM " + SQLTableName.POSITIONS;
    BroadcastService.getInstance().sendMessage("/database/request/position", query);
}
 
Example 14
Source File: Chooser.java    From sensordatacollector with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
    // init
    super.onCreate(savedInstanceState);
    setContentView(R.layout.round_chooser);
    detector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener()
    {
        public void onLongPress(MotionEvent e)
        {
            DismissOverlayView dismissOverlay = (DismissOverlayView) (Chooser.this).findViewById(R.id.dismiss_overlay);
            dismissOverlay.setIntroText(R.string.welcome_long_press_exit);
            dismissOverlay.showIntroIfNecessary();
            dismissOverlay.show();
        }
    });

    // register activity
    ActivityController.getInstance().add("Chooser", this);

    // adapter
    this.adapterPosture = new ItemListViewAdapter(Chooser.this, true);
    this.adapterPosition = new ItemListViewAdapter(Chooser.this, true);

    // view
    TextView tv = (TextView) findViewById(R.id.posture_posture_headline);
    tv.setText(R.string.posture_headline);

    WearableListView view = (WearableListView) findViewById(R.id.posture_posture_list);
    view.setAdapter(this.adapterPosture);
    view.setClickListener(new PostureClickListener());

    // send database request
    String query = "SELECT name FROM " + SQLTableName.POSTURES;
    BroadcastService.getInstance().sendMessage("/database/request/posture", query);
}
 
Example 15
Source File: ClimbTrackerWear.java    From climb-tracker with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    String gradeSystemTypePref = sharedPref.getString(Path.PREF_GRAD_SYSTEM_TYPE, GradeList.SYSTEM_DEFAULT);

    gradeList = new GradeList(this, gradeSystemTypePref);

    setContentView(R.layout.activity_climb_tracker_wear);

    WearableListView listView = (WearableListView) findViewById(R.id.list);
    listView.setAdapter(new Adapter(this, gradeList));
    listView.setClickListener(this);
}
 
Example 16
Source File: SunsetsGeneralWearableConfigActivity.java    From american-sunsets-watch-face with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_general_config);
    colors = new String[]{getResources().getString(R.string.image),getResources().getString(R.string.fluid_motion)};
    mHeader = (TextView) findViewById(R.id.header);
    listView = (WearableListView) findViewById(R.id.color_picker);
    BoxInsetLayout content = (BoxInsetLayout) findViewById(R.id.content);
    // BoxInsetLayout adds padding by default on round devices. Add some on square devices.
    content.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            if (!insets.isRound()) {
                v.setPaddingRelative(
                        (int) getResources().getDimensionPixelSize(R.dimen.content_padding_start),
                        v.getPaddingTop(),
                        v.getPaddingEnd(),
                        v.getPaddingBottom());
            }
            return v.onApplyWindowInsets(insets);
        }
    });

    listView.setHasFixedSize(true);
    listView.setClickListener(this);
    listView.addOnScrollListener(this);

    listView.setAdapter(new ColorListAdapter(colors));
    mPeerId = getIntent().getStringExtra(WatchFaceCompanion.EXTRA_PEER_ID);
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(Bundle connectionHint) {
                    Log.d(TAG, "onConnected: " + connectionHint);
                    //Uri.Builder builder = new Uri.Builder();
                    //Uri uri = builder.scheme("wear").path(PATH_WITH_FEATURE).build();
                    //Wearable.DataApi.getDataItem(mGoogleApiClient, uri).setResultCallback(SunsetsGeneralWearableConfigActivity.this);
                    new Thread() {
                        @Override
                        public void run() {
                            PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient,getUriForDataItem());
                            results.setResultCallback(new ResultCallback<DataItemBuffer>() {
                                @Override
                                public void onResult(DataItemBuffer dataItems) {
                                    if (dataItems.getCount() != 0) {
                                        for(int i=0; i<dataItems.getCount(); i++) {
                                            DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItems.get(i));
                                            DataMap config = dataMapItem.getDataMap();
                                            Log.d(TAG, "startup setup UI...");
                                            updateUiForConfigDataMap(config);
                                        }
                                    }

                                    dataItems.release();
                                }
                            });
                        }
                    }.start();

                    Wearable.DataApi.addListener(mGoogleApiClient, SunsetsGeneralWearableConfigActivity.this);
                }

                @Override
                public void onConnectionSuspended(int cause) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionSuspended: " + cause);
                    }
                }
            })
            .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(ConnectionResult result) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionFailed: " + result);
                    }
                }
            })
            .addApi(Wearable.API)
            .build();
}
 
Example 17
Source File: SunsetsBackgroundWearableConfigActivity.java    From american-sunsets-watch-face with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_background_config);

    mHeader = (TextView) findViewById(R.id.header);
    WearableListView listView = (WearableListView) findViewById(R.id.color_picker);
    BoxInsetLayout content = (BoxInsetLayout) findViewById(R.id.content);
    // BoxInsetLayout adds padding by default on round devices. Add some on square devices.
    content.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            if (!insets.isRound()) {
                v.setPaddingRelative(
                        (int) getResources().getDimensionPixelSize(R.dimen.content_padding_start),
                        v.getPaddingTop(),
                        v.getPaddingEnd(),
                        v.getPaddingBottom());
            }
            return v.onApplyWindowInsets(insets);
        }
    });

    listView.setHasFixedSize(true);
    listView.setClickListener(this);
    listView.addOnScrollListener(this);

    String[] colors = getResources().getStringArray(R.array.bitmap_face_array);
    listView.setAdapter(new ColorListAdapter(colors));

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(Bundle connectionHint) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnected: " + connectionHint);
                    }
                }

                @Override
                public void onConnectionSuspended(int cause) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionSuspended: " + cause);
                    }
                }
            })
            .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(ConnectionResult result) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionFailed: " + result);
                    }
                }
            })
            .addApi(Wearable.API)
            .build();
}
 
Example 18
Source File: DigitalWatchFaceWearableConfigActivity.java    From wear-os-samples with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_digital_config);

    mHeader = (TextView) findViewById(R.id.header);
    WearableListView listView = (WearableListView) findViewById(R.id.color_picker);
    BoxInsetLayout content = (BoxInsetLayout) findViewById(R.id.content);
    // BoxInsetLayout adds padding by default on round devices. Add some on square devices.
    content.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            if (!insets.isRound()) {
                v.setPaddingRelative(
                        (int) getResources().getDimensionPixelSize(R.dimen.content_padding_start),
                        v.getPaddingTop(),
                        v.getPaddingEnd(),
                        v.getPaddingBottom());
            }
            return v.onApplyWindowInsets(insets);
        }
    });

    listView.setHasFixedSize(true);
    listView.setClickListener(this);
    listView.addOnScrollListener(this);

    String[] colors = getResources().getStringArray(R.array.color_array);
    listView.setAdapter(new ColorListAdapter(colors));

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                @Override
                public void onConnected(Bundle connectionHint) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnected: " + connectionHint);
                    }
                }

                @Override
                public void onConnectionSuspended(int cause) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionSuspended: " + cause);
                    }
                }
            })
            .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(ConnectionResult result) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "onConnectionFailed: " + result);
                    }
                }
            })
            .addApi(Wearable.API)
            .build();
}