Android Open Source - android-mimic-ui U I Slider Item






From Project

Back to project page android-mimic-ui.

License

The source code is released under:

Apache License

If you think the Android project android-mimic-ui listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.mimic.ui.tableview.support;
/*from   w w  w .  j  av  a2 s  .  co  m*/
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

import com.mimic.ui.R;
import com.mimic.ui.tableview.UITableViewItem;

public class UISliderItem extends UITableViewItem {
  
  private TextView mLabel = null;
  private SeekBar mSliderView = null;
  private TextView mValue = null;
  
  public UISliderItem(Context context, String label) {
    super(context, label);
    setStyle(STYLE_NONE);
    setupSliderViews();
    setLabel(label);
  }
  
  void setupSliderViews() {
    LinearLayout sliderItemContentView = (LinearLayout) getInflater().inflate(
        R.layout.uislideritem, null);
    mLabel = (TextView) sliderItemContentView.findViewById(R.id.label);
    mSliderView = (SeekBar) sliderItemContentView.findViewById(R.id.slider);
    mValue = (TextView) sliderItemContentView.findViewById(R.id.value);
    mSliderView.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
      
      @Override
      public void onStopTrackingTouch(SeekBar seekBar) {
      }
      
      @Override
      public void onStartTrackingTouch(SeekBar seekBar) {
      }
      
      @Override
      public void onProgressChanged(SeekBar seekBar, int progress,
          boolean fromUser) {
        mValue.setText(String.valueOf(progress));
      }
    });
    getContentView().removeAllViews();
    getContentView().addView(sliderItemContentView);
  }
  
  public interface OnSliderChangeListener {
    public void onValueChanged(UISliderItem sliderItem, int value, boolean fromUser);
  }
  
  public void setOnSliderChangeListener(final OnSliderChangeListener listener) {
    mSliderView.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
      
      @Override
      public void onStopTrackingTouch(SeekBar seekBar) {
      }
      
      @Override
      public void onStartTrackingTouch(SeekBar seekBar) {
      }
      
      @Override
      public void onProgressChanged(SeekBar seekBar, int progress,
          boolean fromUser) {
        mValue.setText(String.valueOf(progress));
        listener.onValueChanged(UISliderItem.this, progress, fromUser);
      }
    });
  }
  
  public TextView getLabelView() {
    return mLabel;
  }
  
  public void setLabel(String label) {
    if (label != null) {
      mLabel.setText(label);
      mLabel.setVisibility(View.VISIBLE);
    } else {
      mLabel.setVisibility(View.GONE);
    }
  }

  public void setLabelColor(int color) {
    if (color > -1) {
      mLabel.setTextColor(color);
    }
  }
  
  public void showItemLabel() {
    mLabel.setVisibility(View.VISIBLE);
  }
  
  public void hideItemLabel() {
    mLabel.setVisibility(View.GONE);
  }

  public ProgressBar getSliderView() {
    return mSliderView;
  }
  
  public int getValue() {
    return mSliderView.getProgress();
  }
  
  public void setValue(int value) {
    mSliderView.setProgress(value);
  }
  
  public TextView getValueLabelView() {
    return mValue;
  }
  
  public void showValueLabel() {
    mValue.setVisibility(View.VISIBLE);
  }
  
  public void hideValueLabel() {
    mValue.setVisibility(View.GONE);
  }
  
  @Override
  public boolean isClickable() {
    return false;
  }

  @Override
  public void setClickable(boolean clickable) {
    // do nothing
  }
}




Java Source Code List

com.mimic.ui.tableview.IListItem.java
com.mimic.ui.tableview.UITableViewActivity.java
com.mimic.ui.tableview.UITableViewItem.java
com.mimic.ui.tableview.UITableViewSection.java
com.mimic.ui.tableview.UITableView.java
com.mimic.ui.tableview.support.UIButtonItem.java
com.mimic.ui.tableview.support.UIMultiChoiceListSection.java
com.mimic.ui.tableview.support.UIProgressItem.java
com.mimic.ui.tableview.support.UISingleChoiceListSection.java
com.mimic.ui.tableview.support.UISliderItem.java
com.mimic.ui.tableview.support.UISwitchItem.java
com.mimic.ui.tableview.support.UITextInputItem.java
com.mimic.ui.tableview.support.UIVolumeControlItem.java