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

The following examples show how to use android.support.wearable.view.WearableListView#addOnScrollListener() . 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: 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 2
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 3
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();
}
 
Example 4
Source File: HeadingListView.java    From WearPreferenceActivity with Apache License 2.0 4 votes vote down vote up
@Override protected void onFinishInflate() {
    super.onFinishInflate();
    heading = (TextView) findViewById(R.id.heading);
    list = (WearableListView) findViewById(android.R.id.list);
    list.addOnScrollListener(this);
}
 
Example 5
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 6
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();
}