[Android] Sleep Advance Option : simplify code
Alexandre Perraud
git at videolan.org
Thu Sep 3 17:45:38 CEST 2015
vlc-ports/android | branch: data-binding | Alexandre Perraud <4leyx4ndre at gmail.com> | Wed Sep 2 17:52:48 2015 +0200| [61d39280da1daa7756f5dda9ca1988827213a23d] | committer: Geoffrey Métais
Sleep Advance Option : simplify code
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=61d39280da1daa7756f5dda9ca1988827213a23d
---
.../res/layout/fragment_advanced_options.xml | 26 +++++--------------
.../videolan/vlc/gui/dialogs/AdvOptionsDialog.java | 27 ++++++++++----------
2 files changed, 20 insertions(+), 33 deletions(-)
diff --git a/vlc-android/res/layout/fragment_advanced_options.xml b/vlc-android/res/layout/fragment_advanced_options.xml
index 34cce06..d01e258 100644
--- a/vlc-android/res/layout/fragment_advanced_options.xml
+++ b/vlc-android/res/layout/fragment_advanced_options.xml
@@ -16,27 +16,15 @@
<!-- Sleep Timer -->
- <LinearLayout
- android:id="@+id/sleep_timer_container"
+ <TextView
+ android:id="@+id/sleep"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <ImageView
- android:id="@+id/sleep_icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:clickable="true"
- android:focusable="true"
- android:src="?attr/ic_sleep_normal_style" />
-
- <TextView
- android:id="@+id/sleep_value"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center" />
-
- </LinearLayout>
+ android:layout_centerInParent="true"
+ android:clickable="true"
+ android:drawableTop="?attr/ic_sleep_normal_style"
+ android:focusable="true"
+ android:gravity="center_horizontal" />
<!-- Playback speed -->
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
index eccc136..079883c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
@@ -78,9 +78,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
private TextView mEqualizer;
private TextView mPlaybackSpeed;
-
- private ImageView mSleepIcon;
- private TextView mSleepValue;
+ private TextView mSleep;
private TextView mJumpTitle;
@@ -139,10 +137,9 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
mPlaybackSpeed.setOnClickListener(this);
mPlaybackSpeed.setOnLongClickListener(this);
- mSleepValue = (TextView) root.findViewById(R.id.sleep_value);
- mSleepIcon = (ImageView) root.findViewById(R.id.sleep_icon);
- mSleepIcon.setOnClickListener(this);
- mSleepValue.setOnFocusChangeListener(mFocusListener);
+ mSleep = (TextView) root.findViewById(R.id.sleep);
+ mSleep.setOnClickListener(this);
+ mSleep.setOnFocusChangeListener(mFocusListener);
mJumpTitle = (TextView) root.findViewById(R.id.jump_title);
mJumpTitle.setOnClickListener(this);
@@ -175,7 +172,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
} else
root.findViewById(R.id.opt_equalizer).setVisibility(View.GONE);
mHandler.sendEmptyMessage(TOGGLE_CANCEL);
- mTextColor = mSleepValue.getCurrentTextColor();
+ mTextColor = mSleep.getCurrentTextColor();
if (getDialog() != null) {
int dialogWidth = getResources().getDimensionPixelSize(mMode == MODE_VIDEO ?
@@ -292,13 +289,15 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
return;
switch (msg.what) {
case TOGGLE_CANCEL:
- owner.mSleepIcon.setImageResource(VLCApplication.sPlayerSleepTime == null ?
- Util.getResourceFromAttribute(owner.getActivity(), R.attr.ic_sleep_normal_style):
- R.drawable.ic_sleep_on);
+ owner.mSleep.setCompoundDrawablesWithIntrinsicBounds(0,
+ VLCApplication.sPlayerSleepTime == null ?
+ Util.getResourceFromAttribute(owner.getActivity(), R.attr.ic_sleep_normal_style):
+ R.drawable.ic_sleep_on,
+ 0 , 0);
case SLEEP_TEXT:
if (VLCApplication.sPlayerSleepTime != null)
- text = DateFormat.getTimeFormat(owner.mSleepValue.getContext()).format(VLCApplication.sPlayerSleepTime.getTime());
- owner.mSleepValue.setText(text);
+ text = DateFormat.getTimeFormat(owner.mSleep.getContext()).format(VLCApplication.sPlayerSleepTime.getTime());
+ owner.mSleep.setText(text);
break;
case DIALOG_LISTENER:
DialogFragment newFragment = (DialogFragment) msg.obj;
@@ -324,7 +323,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
@Override
public void onClick(View v) {
switch (v.getId()){
- case R.id.sleep_icon:
+ case R.id.sleep:
if (VLCApplication.sPlayerSleepTime == null)
showTimePickerFragment(ACTION_SLEEP_TIMER);
else {
More information about the Android
mailing list