Merge pull request #623 from jwaghetti/playback_speed_gui
GUI for podcast playback speed.
This commit is contained in:
commit
b2e4132645
2 changed files with 58 additions and 1 deletions
|
@ -6,9 +6,11 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
@ -39,6 +41,7 @@ import de.luhmer.owncloudnewsreader.events.podcast.StartDownloadPodcast;
|
|||
import de.luhmer.owncloudnewsreader.events.podcast.TogglePlayerStateEvent;
|
||||
import de.luhmer.owncloudnewsreader.events.podcast.UpdatePodcastStatusEvent;
|
||||
import de.luhmer.owncloudnewsreader.events.podcast.WindPodcast;
|
||||
import de.luhmer.owncloudnewsreader.events.podcast.SpeedPodcast;
|
||||
import de.luhmer.owncloudnewsreader.model.MediaItem;
|
||||
import de.luhmer.owncloudnewsreader.model.PodcastFeedItem;
|
||||
import de.luhmer.owncloudnewsreader.model.PodcastItem;
|
||||
|
@ -178,6 +181,8 @@ public class PodcastFragment extends Fragment {
|
|||
tvTo.setText(String.format("%02d:%02d", minutes, seconds));
|
||||
tvToSlider.setText(String.format("%02d:%02d", minutes, seconds));
|
||||
|
||||
tvPlaybackSpeed.setText(String.format("%.02f", podcast.getSpeed()));
|
||||
|
||||
tvTitle.setText(podcast.getTitle());
|
||||
tvTitleSlider.setText(podcast.getTitle());
|
||||
|
||||
|
@ -236,6 +241,9 @@ public class PodcastFragment extends Fragment {
|
|||
@BindView(R.id.pb_progress) ProgressBar pb_progress;
|
||||
@BindView(R.id.pb_progress2) ProgressBar pb_progress2;
|
||||
|
||||
@Bind(R.id.tv_playbackSpeed) TextView tvPlaybackSpeed;
|
||||
@Bind(R.id.buttonSpeedMinus) TextView btnSpeedMinus;
|
||||
@Bind(R.id.buttonSpeedPlus) TextView btnSpeedPlus;
|
||||
|
||||
@BindView(R.id.podcastFeedList) ListView /* CardGridView CardListView*/ podcastFeedList;
|
||||
@BindView(R.id.rlPodcast) RelativeLayout rlPodcast;
|
||||
|
@ -273,6 +281,18 @@ public class PodcastFragment extends Fragment {
|
|||
}});
|
||||
}
|
||||
|
||||
@OnClick(R.id.buttonSpeedMinus) void speedMinus() {
|
||||
eventBus.post(new SpeedPodcast() {{
|
||||
playbackSpeed = podcast.getSpeed() - 0.1f;
|
||||
}});
|
||||
}
|
||||
|
||||
@OnClick(R.id.buttonSpeedPlus) void speedPlus() {
|
||||
eventBus.post(new SpeedPodcast() {{
|
||||
playbackSpeed = podcast.getSpeed() + 0.1f;
|
||||
}});
|
||||
}
|
||||
|
||||
PodcastSlidingUpPanelLayout sliding_layout;
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -312,7 +332,7 @@ public class PodcastFragment extends Fragment {
|
|||
podcastFeedList.setVisibility(View.VISIBLE);
|
||||
|
||||
sb_progress.setOnSeekBarChangeListener(onSeekBarChangeListener);
|
||||
|
||||
tvPlaybackSpeed.setOnEditorActionListener(onEditorActionListener);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -384,6 +404,21 @@ public class PodcastFragment extends Fragment {
|
|||
}
|
||||
};
|
||||
|
||||
private TextView.OnEditorActionListener onEditorActionListener = new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(final TextView textView, int i, KeyEvent keyEvent) {
|
||||
final float pbSpeed = Float.parseFloat(textView.getText().toString());
|
||||
if(hasTitleInCache) {
|
||||
eventBus.post(new SpeedPodcast() {{
|
||||
playbackSpeed = pbSpeed;
|
||||
}});
|
||||
}
|
||||
Log.v(TAG, "playback speed changed: "+pbSpeed);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
boolean blockSeekbarUpdate = false;
|
||||
private SeekBar.OnSeekBarChangeListener onSeekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
|
|
|
@ -339,6 +339,28 @@
|
|||
android:scaleType="fitXY"
|
||||
android:contentDescription="@string/content_desc_forward"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonSpeedMinus"
|
||||
android:layout_width="43dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="-" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/tv_playbackSpeed"
|
||||
android:layout_width="71dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:inputType="numberDecimal"
|
||||
android:selectAllOnFocus="true"
|
||||
android:visibility="visible"
|
||||
android:focusable="false"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonSpeedPlus"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="+" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue