Android Open Source - android_shaderize Prefs Seek Bar






From Project

Back to project page android_shaderize.

License

The source code is released under:

Apache License

If you think the Android project android_shaderize 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 fi.harism.shaderize;
/* w  ww .  j  a  v  a2 s . c  o  m*/
import android.content.Context;
import android.content.SharedPreferences;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;

public class PrefsSeekBar extends LinearLayout implements
    SeekBar.OnSeekBarChangeListener {

  private int mDefaultValue;
  private Observer mObserver;
  private SharedPreferences mPrefs;
  private int mPrefsKey;

  public PrefsSeekBar(Context context) {
    super(context);
  }

  public PrefsSeekBar(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  @Override
  public void onProgressChanged(SeekBar seekBar, int progress,
      boolean fromUser) {
    if (mObserver != null) {
      mPrefs.edit().putInt(getContext().getString(mPrefsKey), progress)
          .commit();
      mObserver.onSeekBarChanged(mPrefsKey,
          (float) progress / seekBar.getMax());
    }
  }

  @Override
  public void onStartTrackingTouch(SeekBar seekBar) {
  }

  @Override
  public void onStopTrackingTouch(SeekBar seekBar) {
  }

  public void setDefaultValue(int defaultValue) {
    mDefaultValue = defaultValue;
  }

  public void setPrefs(SharedPreferences prefs, int prefsKey,
      Observer observer) {
    mPrefs = prefs;
    mPrefsKey = prefsKey;
    mObserver = observer;

    int progress = mPrefs.getInt(getContext().getString(prefsKey),
        mDefaultValue);
    SeekBar seekBar = (SeekBar) findViewById(R.id.prefs_seekbar_seekbar);
    seekBar.setOnSeekBarChangeListener(this);
    seekBar.setProgress(progress);
  }

  public void setText(int resId) {
    TextView textView = (TextView) findViewById(R.id.prefs_seekbar_text);
    textView.setText(resId);
  }

  public interface Observer {
    public void onSeekBarChanged(int key, float value);
  }

}




Java Source Code List

fi.harism.shaderize.MainActivity.java
fi.harism.shaderize.MainMenus.java
fi.harism.shaderize.MainRenderer.java
fi.harism.shaderize.Matrix.java
fi.harism.shaderize.ObjCube.java
fi.harism.shaderize.ObjFbo.java
fi.harism.shaderize.ObjScene.java
fi.harism.shaderize.ObjShader.java
fi.harism.shaderize.PrefsSeekBar.java
fi.harism.shaderize.RendererBloom.java
fi.harism.shaderize.RendererDof.java
fi.harism.shaderize.RendererFlat.java
fi.harism.shaderize.RendererFxaa.java
fi.harism.shaderize.RendererHex.java
fi.harism.shaderize.RendererLightning.java
fi.harism.shaderize.RendererRounded.java
fi.harism.shaderize.Renderer.java
fi.harism.shaderize.Utils.java