下面列出了android.widget.SeekBar#getTag ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Notification that the user has finished a touch gesture. Clients may want to use this
* to re-enable advancing the seekbar.
*/
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
final Object tag = seekBar.getTag();
if (tag instanceof StreamResources) {
StreamResources sr = (StreamResources) tag;
// because remote volume updates are asynchronous, AudioService might have received
// a new remote volume value since the finger adjusted the slider. So when the
// progress of the slider isn't being tracked anymore, adjust the slider to the last
// "published" remote volume value, so the UI reflects the actual volume.
if (sr.getStreamType() == STREAM_REMOTE_MUSIC) {
seekBar.setProgress(getStreamVolume(STREAM_REMOTE_MUSIC));
}
}
onUserInteraction();
}
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (!fromUser) return;
if (isVirtualizerSupported() && seekBar.getId() == R.id.virtualizer) {
virtualizer.setStrength((short) progress);
LOGI(virtualizer.getClass().getSimpleName(), "setStrength(" + progress + ')');
} else if (isBassBostSupported() && seekBar.getId() == R.id.bass_boost) {
bassBoost.setStrength((short) progress);
LOGI(bassBoost.getClass().getSimpleName(), "setStrength(" + progress + ')');
} else if (null != equalizer) {
Object tag = seekBar.getTag();
if (tag instanceof Short) {
short band = (Short) tag;
equalizer.setBandLevel(band, (short) (progress + range[0]));
LOGI(equalizer.getClass().getSimpleName(), "setBandLevel(" + (progress + range[0]) + ')');
}
}
onUserInteraction();
}
/**
* Notification that the user has finished a touch gesture. Clients may want to use this
* to re-enable advancing the seekbar.
*/
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
final Object tag = seekBar.getTag();
if (tag instanceof StreamResources) {
StreamResources sr = (StreamResources) tag;
// because remote volume updates are asynchronous, AudioService might have received
// a new remote volume value since the finger adjusted the slider. So when the
// progress of the slider isn't being tracked anymore, adjust the slider to the last
// "published" remote volume value, so the UI reflects the actual volume.
if (sr.getStreamType() == STREAM_REMOTE_MUSIC) {
seekBar.setProgress(getStreamVolume(STREAM_REMOTE_MUSIC));
}
}
onUserInteraction();
}
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (!fromUser) return;
if (isVirtualizerSupported() && seekBar.getId() == R.id.virtualizer) {
virtualizer.setStrength((short) progress);
LOGI(virtualizer.getClass().getSimpleName(), "setStrength(" + progress + ')');
} else if (isBassBostSupported() && seekBar.getId() == R.id.bass_boost) {
bassBoost.setStrength((short) progress);
LOGI(bassBoost.getClass().getSimpleName(), "setStrength(" + progress + ')');
} else if (null != equalizer) {
Object tag = seekBar.getTag();
if (tag instanceof Short) {
short band = (Short) tag;
equalizer.setBandLevel(band, (short) (progress + range[0]));
LOGI(equalizer.getClass().getSimpleName(), "setBandLevel(" + (progress + range[0]) + ')');
}
}
onUserInteraction();
}
@Override public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
final Object tag = seekBar.getTag();
if (fromUser && tag instanceof StreamControl) {
StreamControl sc = (StreamControl) tag;
if (getStreamVolume(sc.streamType) != progress) {
LOGI(TAG, "setStreamVolume(" + sc.streamType + ", " + progress + ')');
setStreamVolume(sc.streamType, progress);
}
}
onUserInteraction();
}
@Override public void onStopTrackingTouch(SeekBar seekBar) {
final Object tag = seekBar.getTag();
if (tag instanceof StreamControl) {
StreamControl sc = (StreamControl) tag;
// because remote volume updates are asynchronous, AudioService might have received
// a new remote volume value since the finger adjusted the slider. So when the
// progress of the slider isn't being tracked anymore, adjust the slider to the last
// "published" remote volume value, so the UI reflects the actual volume.
if (sc.streamType == STREAM_REMOTE_MUSIC) {
seekBar.setProgress(getStreamVolume(STREAM_REMOTE_MUSIC));
}
}
}
/**
* Notification that the progress level has changed. Clients can use the fromUser parameter
* to distinguish user-initiated changes from those that occurred programmatically.
*/
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
LOGD("VolumePanel", "onProgressChanged(" + progress + ")");
final Object tag = seekBar.getTag();
if (fromUser && tag instanceof StreamResources) {
StreamResources sr = (StreamResources) tag;
if (getStreamVolume(sr.getStreamType()) != progress) {
setStreamVolume(sr.getStreamType(), progress);
mVolumeDirty = true;
}
}
onUserInteraction();
}
@Override public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
final Object tag = seekBar.getTag();
if (fromUser && tag instanceof StreamControl) {
StreamControl sc = (StreamControl) tag;
if (getStreamVolume(sc.streamType) != progress) {
LOGI(TAG, "setStreamVolume(" + sc.streamType + ", " + progress + ')');
setStreamVolume(sc.streamType, progress);
}
}
onUserInteraction();
}
@Override public void onStopTrackingTouch(SeekBar seekBar) {
final Object tag = seekBar.getTag();
if (tag instanceof StreamControl) {
StreamControl sc = (StreamControl) tag;
// because remote volume updates are asynchronous, AudioService might have received
// a new remote volume value since the finger adjusted the slider. So when the
// progress of the slider isn't being tracked anymore, adjust the slider to the last
// "published" remote volume value, so the UI reflects the actual volume.
if (sc.streamType == STREAM_REMOTE_MUSIC) {
seekBar.setProgress(getStreamVolume(STREAM_REMOTE_MUSIC));
}
}
}
/**
* Notification that the progress level has changed. Clients can use the fromUser parameter
* to distinguish user-initiated changes from those that occurred programmatically.
*/
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
LOGD("VolumePanel", "onProgressChanged(" + progress + ")");
final Object tag = seekBar.getTag();
if (fromUser && tag instanceof StreamResources) {
StreamResources sr = (StreamResources) tag;
if (getStreamVolume(sr.getStreamType()) != progress) {
setStreamVolume(sr.getStreamType(), progress);
mVolumeDirty = true;
}
}
onUserInteraction();
}