Changed ProgressBar to SeekBar
This commit is contained in:
parent
e48bb036ac
commit
85d78e566b
@ -5,7 +5,7 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.philliphsu.clock2.AsyncTimersTableUpdateHandler;
|
||||
@ -17,6 +17,7 @@ import com.philliphsu.clock2.util.ProgressBarUtils;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.OnTouch;
|
||||
|
||||
/**
|
||||
* Created by Phillip Hsu on 7/25/2016.
|
||||
@ -31,7 +32,7 @@ public class TimerViewHolder extends BaseViewHolder<Timer> {
|
||||
|
||||
@Bind(R.id.label) TextView mLabel;
|
||||
@Bind(R.id.duration) CountdownChronometer mChronometer;
|
||||
@Bind(R.id.progress_bar) ProgressBar mProgressBar;
|
||||
@Bind(R.id.seek_bar) SeekBar mSeekBar;
|
||||
@Bind(R.id.add_one_minute) ImageButton mAddOneMinute;
|
||||
@Bind(R.id.start_pause) ImageButton mStartPause;
|
||||
@Bind(R.id.stop) ImageButton mStop;
|
||||
@ -70,6 +71,11 @@ public class TimerViewHolder extends BaseViewHolder<Timer> {
|
||||
mController.stop();
|
||||
}
|
||||
|
||||
@OnTouch(R.id.seek_bar)
|
||||
boolean captureTouchOnSeekBar() {
|
||||
return true; // Do nothing when the user touches the seek bar
|
||||
}
|
||||
|
||||
private void bindLabel(String label) {
|
||||
if (!label.isEmpty()) {
|
||||
mLabel.setText(label);
|
||||
@ -131,11 +137,15 @@ public class TimerViewHolder extends BaseViewHolder<Timer> {
|
||||
if (!timer.isRunning()) {
|
||||
// If our scale were 1, then casting ratio to an int will ALWAYS
|
||||
// truncate down to zero.
|
||||
mProgressBar.setMax(100);
|
||||
mProgressBar.setProgress((int) (100 * ratio));
|
||||
mSeekBar.setMax(100);
|
||||
final int progress = (int) (100 * ratio);
|
||||
mSeekBar.setProgress(progress);
|
||||
// mSeekBar.getThumb().mutate().setAlpha(progress == 0 ? 0 : 255);
|
||||
} else {
|
||||
// mSeekBar.getThumb().mutate().setAlpha(255);
|
||||
mProgressAnimator = ProgressBarUtils.startNewAnimator(
|
||||
mProgressBar, ratio, timeRemaining);
|
||||
}
|
||||
mSeekBar, ratio, timeRemaining);
|
||||
}
|
||||
mSeekBar.getThumb().mutate().setAlpha(timeRemaining <= 0 ? 0 : 255);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="8dp">
|
||||
@ -29,13 +30,19 @@
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textSize="45sp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
<!--TODO: Consider removing this bottom margin, because the seekbar
|
||||
is rendering with HUGE top and bottom padding already. -->
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
<!-- Cannot be touch controlled -->
|
||||
<!--The default style has padding start and end, so we remove both-->
|
||||
<SeekBar
|
||||
android:id="@+id/seek_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_below="@id/duration"/>
|
||||
android:layout_below="@id/duration"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:splitTrack="false"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/add_one_minute"
|
||||
@ -43,7 +50,7 @@
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_half_day_1_24dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:layout_below="@id/progress_bar"
|
||||
android:layout_below="@id/seek_bar"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="8dp"/>
|
||||
|
||||
@ -53,7 +60,7 @@
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_half_day_1_24dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:layout_below="@id/progress_bar"
|
||||
android:layout_below="@id/seek_bar"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
|
||||
<ImageButton
|
||||
@ -62,7 +69,7 @@
|
||||
android:layout_height="48dp"
|
||||
android:src="@drawable/ic_half_day_1_24dp"
|
||||
android:background="?selectableItemBackground"
|
||||
android:layout_below="@id/progress_bar"
|
||||
android:layout_below="@id/seek_bar"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="8dp"/>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user