Source code for enamlnative.android.android_seek_bar
"""
Copyright (c) 2017-2022, CodeLV.
Distributed under the terms of the MIT License.
The full license is in the file LICENSE, distributed with this software.
Created on June 7, 2017
"""
from atom.api import Typed, set_default
from enamlnative.widgets.seek_bar import ProxySeekBar
from .android_progress_bar import AndroidProgressBar, ProgressBar
from .bridge import JavaCallback, JavaMethod
class SeekBar(ProgressBar):
__nativeclass__ = "android.widget.SeekBar"
__signature__ = [
"android.content.Context",
"android.util.AttributeSet",
"android.R",
]
setSplitTrack = JavaMethod(bool)
setOnSeekBarChangeListener = JavaMethod(
"android.widget.SeekBar$OnSeekBarChangeListener"
)
setKeyProgressIncrement = JavaMethod(int)
onProgressChanged = JavaCallback("android.widget.SeekBar", int, bool)
onStartTrackingTouch = JavaCallback("android.widget.SeekBar")
onStopTrackingTouch = JavaCallback("android.widget.SeekBar")
[docs]class AndroidSeekBar(AndroidProgressBar, ProxySeekBar):
"""An Android implementation of an Enaml ProxySeekBar."""
#: A reference to the widget created by the proxy.
widget = Typed(SeekBar)
default_layout = set_default({"width": "wrap_content", "height": "wrap_content"}) # type: ignore
# -------------------------------------------------------------------------
# Initialization API
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# OnSeekBarChangeListener API
# -------------------------------------------------------------------------
def on_progress_changed(self, bar, progress, user):
d = self.declaration
with self.widget.setProgress.suppressed():
d.progress = progress
# -------------------------------------------------------------------------
# ProxySeekBar API
# -------------------------------------------------------------------------
def set_key_progress_increment(self, value):
self.widget.setKeyProgressIncrement(value)
def set_split_track(self, split):
self.widget.setSplitTrack(split)