Java Code Examples for android.support.wearable.view.WearableListView#ViewHolder

The following examples show how to use android.support.wearable.view.WearableListView#ViewHolder . 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: DigitalWatchFaceWearableConfigActivity.java    From wear-os-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
    ColorItemViewHolder colorItemViewHolder = (ColorItemViewHolder) holder;
    String colorName = mColors[position];
    colorItemViewHolder.mColorItem.setColor(colorName);

    RecyclerView.LayoutParams layoutParams =
            new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
    int colorPickerItemMargin = (int) getResources()
            .getDimension(R.dimen.digital_config_color_picker_item_margin);
    // Add margins to first and last item to make it possible for user to tap on them.
    if (position == 0) {
        layoutParams.setMargins(0, colorPickerItemMargin, 0, 0);
    } else if (position == mColors.length - 1) {
        layoutParams.setMargins(0, 0, 0, colorPickerItemMargin);
    } else {
        layoutParams.setMargins(0, 0, 0, 0);
    }
    colorItemViewHolder.itemView.setLayoutParams(layoutParams);
}
 
Example 2
Source File: WatchFaceConfigActivity.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(WearableListView.ViewHolder viewHolder, int position ) {
    BackgroundItemViewHolder holder = (BackgroundItemViewHolder) viewHolder;
    String backgroundName = mBackgrounds[ position ];
    holder.mBackgroundItem.setBackground( backgroundName, position );

    RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT );

    int backgroundPickerItemMargin = (int) getResources().getDimension( R.dimen.background_picker_item_margin );

    if( position == 0 ) {
        layoutParams.setMargins( 0, backgroundPickerItemMargin, 0, 0 );
    } else if( position == mBackgrounds.length - 1 ) {
        layoutParams.setMargins( 0, 0, 0, backgroundPickerItemMargin );
    } else {
        layoutParams.setMargins( 0, 0, 0, 0 );
    }

    holder.itemView.setLayoutParams( layoutParams );
}
 
Example 3
Source File: ItemListViewAdapter.java    From sensordatacollector with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(WearableListView.ViewHolder viewHolder, int i)
{
    String currentValue = this.elements.get(i);
    ItemListView itemView = (ItemListView) viewHolder.itemView;

    TextView txtView = (TextView) itemView.findViewById(R.id.text);
    txtView.setText(this.elements.get(i));

    CircledImageView imgView = (CircledImageView) itemView.findViewById(R.id.image);

    if(this.selectedElements == null) {
        imgView.setImageResource(android.R.color.transparent);
        return;
    }

    for(String activ : selectedElements) {  // mark activity and subactivity if subactivity is activ
        if(activ.equals(currentValue) || activ.startsWith(currentValue + Settings.ACTIVITY_DELIMITER) || (this.parent != null && activ.equals(this.parent + Settings.ACTIVITY_DELIMITER + currentValue))) {
            imgView.setImageResource(R.drawable.yes);
            return;
        }
    }

    imgView.setImageResource(android.R.color.transparent);
}
 
Example 4
Source File: SunsetsBackgroundWearableConfigActivity.java    From american-sunsets-watch-face with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
    ColorItemViewHolder colorItemViewHolder = (ColorItemViewHolder) holder;
    String colorName = mColors[position];
    colorItemViewHolder.mColorItem.setColor(colorName);

    RecyclerView.LayoutParams layoutParams =
            new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
    int colorPickerItemMargin = (int) getResources()
            .getDimension(R.dimen.digital_config_color_picker_item_margin);
    // Add margins to first and last item to make it possible for user to tap on them.
    if (position == 0) {
        layoutParams.setMargins(0, colorPickerItemMargin, 0, 0);
    } else if (position == mColors.length - 1) {
        layoutParams.setMargins(0, 0, 0, colorPickerItemMargin);
    } else {
        layoutParams.setMargins(0, 0, 0, 0);
    }
    colorItemViewHolder.itemView.setLayoutParams(layoutParams);
}
 
Example 5
Source File: MenuListActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder,
                             int position) {
    // retrieve the text view
    ItemViewHolder itemHolder = (ItemViewHolder) holder;
    TextView view = itemHolder.textView;
    // replace text contents
    view.setText(mDataset[position]);
    // replace list item's metadata
    holder.itemView.setTag(mDataset[position]);
}
 
Example 6
Source File: MenuListActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(WearableListView.ViewHolder v) {
    String tag = (String) v.itemView.getTag();
    doAction(tag);
    //ActionsDefinitions.doAction(v.getAdapterPosition(), this);
    finish();
}
 
Example 7
Source File: CitiesAdapter.java    From sms-ticket with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(WearableListView.ViewHolder viewHolder, int position) {
    City city = mCities.get(position);
    ListItem listItem = (ListItem)viewHolder.itemView;
    TextView text = (TextView)listItem.findViewById(R.id.text);
    text.setText(city.city);
    CircledImageView image = (CircledImageView)listItem.findViewById(R.id.image);
    image.setImageResource(R.drawable.list_ic_city);
    listItem.setTag(city.id);
}
 
Example 8
Source File: SelectionListActivity.java    From android-wear-gopro-remote with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
    TextView view = (TextView) holder.itemView.findViewById(R.id.name);
    view.setText(labels[position]);
    holder.itemView.setTag(values[position]);
    if(imageResources[position] > 0) {
        ImageView imageView = (ImageView) holder.itemView.findViewById(R.id.circle);
        imageView.setImageResource(imageResources[position]);
    }
}
 
Example 9
Source File: MenuListActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                      int viewType) {
    // Inflate our custom layout for list items
    return new ItemViewHolder(mInflater.inflate(R.layout.list_item, null));
}
 
Example 10
Source File: UARTConfigurationsAdapter.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull final WearableListView.ViewHolder holder, final int position) {
	final ConfigurationViewHolder viewHolder = (ConfigurationViewHolder) holder;
	viewHolder.setConfiguration(configurations.get(position));
}
 
Example 11
Source File: SetTimerActivity.java    From android-Timer with Apache License 2.0 4 votes vote down vote up
@Override
public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    return new WearableListView.ViewHolder(
            mInflater.inflate(R.layout.timer_list_item, null));
}
 
Example 12
Source File: SelectionListActivity.java    From android-wear-gopro-remote with Apache License 2.0 4 votes vote down vote up
@Override
public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    return new WearableListView.ViewHolder(
            mInflater.inflate(R.layout.selection_list_item, null));
}
 
Example 13
Source File: WatchSettingsActivity.java    From android-wear-gopro-remote with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(WearableListView.ViewHolder viewHolder) {

    mCurrentSettingIndex = (Integer)viewHolder.itemView.getTag();
    byte[] data = new byte[1];
    String message = "";

    switch (mCurrentSettingIndex) {
        case SETTING_SPOT_METER:
            data[0] = (byte)(mLastStatus.SpotMeter ? 0 : 1);
            message = WearMessages.MESSAGE_SET_SPOTMETTER;
            break;
        case SETTING_BEEP_VOLUME:
            data[0] = -1;
            switch (mLastStatus.CurrentBeepVolume) {
                case GoProStatus.VOLUME_100:
                    data[0] = GoProStatus.VOLUME_70;
                    break;
                case GoProStatus.VOLUME_70:
                    data[0] = GoProStatus.VOLUME_OFF;
                    break;
                case GoProStatus.VOLUME_OFF:
                    data[0] = GoProStatus.VOLUME_100;
                    break;
            }
            if(data[0] > -1) {
                message = WearMessages.MESSAGE_SET_BEEP_VOLUME;
            }
            break;
        case SETTING_UPSIDE_DOWN:
            data[0] = (byte)(mLastStatus.IsUpsideDown ? 0 : 1);
            message = WearMessages.MESSAGE_SET_UPSIDEDOWN;
            break;
        case SETTING_LEDS:
            data[0] = -1;
            switch (mLastStatus.Leds) {
                case GoProStatus.LEDS_4:
                    data[0] = GoProStatus.LEDS_2;
                    break;
                case GoProStatus.LEDS_2:
                    data[0] = GoProStatus.LEDS_OFF;
                    break;
                case GoProStatus.LEDS_OFF:
                    data[0] = GoProStatus.LEDS_4;
                    break;
            }
            if(data[0] > -1) {
                message = WearMessages.MESSAGE_SET_LEDS;
            }
            break;
        /*case SETTING_OSD:
            data[0] = (byte)(mLastStatus.IsOsdOn ? 0 : 1);
            message = WearMessages.MESSAGE_SET_OSD;
            break;*/
        case SETTING_LOCATE:
            data[0] = (byte)(mLastStatus.IsBeeping ? 0 : 1);
            message = WearMessages.MESSAGE_SET_BEEPING;
            break;
        case SETTING_TURN_OFF:
            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if(which == DialogInterface.BUTTON_POSITIVE) {
                        sendWearMessage(WearMessages.MESSAGE_POWEROFF, null);
                    }
                }
            };

            Drawable icon = getResources()
                    .getDrawable(R.drawable.icon_power).mutate();

            icon.setColorFilter(0xffff0000, PorterDuff.Mode.MULTIPLY );

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder
                    .setTitle(R.string.setting_poweroff)
                    .setMessage(R.string.prompt_are_you_sure)
                    .setIcon(icon)
                    .setInverseBackgroundForced(true)
                    .setPositiveButton(R.string.label_yes, dialogClickListener)
                    .setNegativeButton(R.string.label_no, dialogClickListener).show();
            break;
    }

    if(!TextUtils.isEmpty(message)) {
        sendWearMessage(message, data);
    }
}
 
Example 14
Source File: WatchSettingsActivity.java    From android-wear-gopro-remote with Apache License 2.0 4 votes vote down vote up
@Override
public WearableListView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
    return new WearableListView.ViewHolder(
            mInflater.inflate(R.layout.selection_list_item, null));
}
 
Example 15
Source File: MainActivity.java    From AndroidWearable-Samples with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(WearableListView.ViewHolder v) {
    updateNotification((Integer) v.itemView.getTag());
}
 
Example 16
Source File: SunsetsBackgroundWearableConfigActivity.java    From american-sunsets-watch-face with Apache License 2.0 4 votes vote down vote up
@Override // WearableListView.ClickListener
public void onClick(WearableListView.ViewHolder viewHolder) {
    ColorItemViewHolder colorItemViewHolder = (ColorItemViewHolder) viewHolder;
    updateConfigDataItem(BitmapWatchFaceUtils.getColorID(colorItemViewHolder.mColorItem.getColorName()));
    finish();
}
 
Example 17
Source File: WearPreferenceActivity.java    From WearPreferenceActivity with Apache License 2.0 4 votes vote down vote up
@Override public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final ListItemLayout itemView = new ListItemLayout(WearPreferenceActivity.this);
    return new WearableListView.ViewHolder(itemView);
}
 
Example 18
Source File: WatchSettingsActivity.java    From android-wear-gopro-remote with Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder, int i) {
    /*
    Spot Meter -> on/off
    Beep volume -> 100/70/off
    Camera Upside Down - yes/no
    Leds -> 4/2/off
    OSD -> on/off
    Turn off -> Confirmation -> finish activity
    */

    TextView view = (TextView) holder.itemView.findViewById(R.id.name);
    ImageView imageView = (ImageView) holder.itemView.findViewById(R.id.circle);
    imageView.setImageResource(R.drawable.icon_setting_up);
    holder.itemView.setTag(i);
    String value = mActivity.getSettingValue(i);
    switch (i) {
        case SETTING_SPOT_METER:
            view.setText(mActivity.getString(R.string.setting_spot_metter, value));
            break;
        case SETTING_BEEP_VOLUME:
            view.setText(mActivity.getString(R.string.setting_beep, value));
            break;
        case SETTING_UPSIDE_DOWN:
            view.setText(mActivity.getString(R.string.setting_upside, value));
            break;
        case SETTING_LEDS:
            view.setText(mActivity.getString(R.string.setting_leds, value));
            break;
        /*case SETTING_OSD:
            view.setText(mActivity.getString(R.string.setting_osd, value));
            break;*/
        case SETTING_LOCATE:
            view.setText(mActivity.getString(R.string.setting_locate, value));
            break;
        case SETTING_TURN_OFF:
            view.setText(R.string.setting_poweroff);
            imageView.setImageResource(R.drawable.icon_power);
            break;
    }
}
 
Example 19
Source File: SetTimerActivity.java    From android-Timer with Apache License 2.0 4 votes vote down vote up
@Override
public void onClick(WearableListView.ViewHolder holder) {
    long duration = mTimeOptions[holder.getPosition()].duration;
    setupTimer(duration);
}
 
Example 20
Source File: ListChooserActivity.java    From WearPreferenceActivity with Apache License 2.0 4 votes vote down vote up
@Override public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
    final ListItemLayout itemView = (ListItemLayout)holder.itemView;
    itemView.bindView(icons != null ? icons[position] : icon, entries[position], null);
    itemView.onNonCenterPosition(false);
}