Android Open Source - ArduinoRGB-Controller Slider Fragment






From Project

Back to project page ArduinoRGB-Controller.

License

The source code is released under:

MIT License

If you think the Android project ArduinoRGB-Controller 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 dk.cmol.arduinorgb_controller;
/* w  w w. j  ava 2s . c o m*/
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class SliderFragment extends Fragment implements OnSeekBarChangeListener {

  ToolbarListener activityCallback;
  
  public interface ToolbarListener {
    public void seekChange(String colors);
  }

  @Override
  public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {
      activityCallback = (ToolbarListener) activity;
    } catch (ClassCastException e) {
      throw new ClassCastException(activity.toString()
          + " must implement ToolbarListener");
    }
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_slider, container,
        false);
    
    SeekBar seekBarR = (SeekBar) rootView.findViewById(R.id.seekBarR);
    SeekBar seekBarG = (SeekBar) rootView.findViewById(R.id.seekBarG);
    SeekBar seekBarB = (SeekBar) rootView.findViewById(R.id.seekBarB);
    
    seekBarR.setOnSeekBarChangeListener(this);
    seekBarG.setOnSeekBarChangeListener(this);
    seekBarB.setOnSeekBarChangeListener(this);

    return rootView;
  }

  @Override
  public void onProgressChanged(SeekBar seekBar, int progress,
      boolean fromUser) {
    String cols = Integer.toString(((SeekBar)getActivity().findViewById(R.id.seekBarR)).getProgress())+"-";
    cols += Integer.toString(((SeekBar)getActivity().findViewById(R.id.seekBarG)).getProgress())+"-";
    cols += Integer.toString(((SeekBar)getActivity().findViewById(R.id.seekBarB)).getProgress());
    activityCallback.seekChange(cols);
  }

  @Override
  public void onStartTrackingTouch(SeekBar seekBar) {
  }

  @Override
  public void onStopTrackingTouch(SeekBar seekBar) {
  }

}




Java Source Code List

dk.cmol.arduinorgb_controller.ArduinoRGBActivity.java
dk.cmol.arduinorgb_controller.ArduinoSocket.java
dk.cmol.arduinorgb_controller.ColorDotsFragment.java
dk.cmol.arduinorgb_controller.FaderFragment.java
dk.cmol.arduinorgb_controller.GyroFragment.java
dk.cmol.arduinorgb_controller.LampParser.java
dk.cmol.arduinorgb_controller.MenuPagerAdapter.java
dk.cmol.arduinorgb_controller.SettingsActivity.java
dk.cmol.arduinorgb_controller.SettingsFragment.java
dk.cmol.arduinorgb_controller.SliderFragment.java