Skip to content

Commit f1d418e

Browse files
committed
feat:playback control using bottom fragment button
1 parent 0c4ff89 commit f1d418e

File tree

5 files changed

+43
-34
lines changed

5 files changed

+43
-34
lines changed

app/src/main/java/io/compactd/player/ui/activities/AlbumActivity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@
3232
import io.compactd.player.ui.fragments.ModelFragment;
3333
import io.compactd.player.ui.fragments.TracksFragment;
3434

35-
public class AlbumActivity extends AppCompatActivity {
35+
public class AlbumActivity extends SlidingMusicActivity {
3636

3737
public static final String BUNDLE_ALBUM_KEY = "album";
38-
@BindView(R.id.frame)
39-
FrameLayout frame;
4038

4139
@BindView(R.id.album_cover_view)
4240
ImageView albumCoverView;

app/src/main/java/io/compactd/player/ui/activities/SlidingMusicActivity.java

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.os.Handler;
88
import android.support.annotation.Nullable;
99
import android.support.v7.app.AppCompatActivity;
10+
import android.util.Log;
1011
import android.view.View;
1112
import android.widget.FrameLayout;
1213
import android.widget.ImageView;
@@ -32,38 +33,36 @@ public abstract class SlidingMusicActivity extends AppCompatActivity implements
3233
MediaPlayerService.MediaListener {
3334

3435
public static final int DELAY_MILLIS = 1000;
35-
@BindView(R.id.playback_image)
36-
ImageView playbackImage;
37-
38-
@BindView(R.id.caret_image)
39-
ImageView caretView;
40-
41-
@BindView(R.id.sliding_layout)
42-
SlidingUpPanelLayout panelLayout;
43-
44-
@BindView(R.id.sliding_content)
45-
FrameLayout mSlidingContent;
46-
47-
@BindView(R.id.mini_progress)
48-
ProgressBar miniProgress;
49-
50-
@BindView(R.id.track_title)
51-
TextView trackTitle;
36+
public static final String TAG = SlidingMusicActivity.class.getSimpleName();
5237

5338
private Unbinder unbinder;
5439
private MusicPlayerRemote remote;
5540
private Runnable progressRunnable;
5641
private Handler handler;
5742
private boolean monitorPlayback;
43+
private ImageView playbackImage;
44+
private ImageView caretView;
45+
private SlidingUpPanelLayout panelLayout;
46+
private FrameLayout mSlidingContent;
47+
private ProgressBar miniProgress;
48+
private TextView trackTitle;
5849

5950

6051
@Override
6152
protected void onCreate(@Nullable Bundle savedInstanceState) {
6253
super.onCreate(savedInstanceState);
54+
getWindow().getDecorView().setSystemUiVisibility(
55+
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
56+
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
6357

6458
setContentView(R.layout.sliding_music_layout);
6559

66-
unbinder = ButterKnife.bind(this);
60+
playbackImage = findViewById(R.id.playback_image);
61+
caretView = findViewById(R.id.caret_image);
62+
panelLayout = findViewById(R.id.sliding_layout);
63+
mSlidingContent = findViewById(R.id.sliding_content);
64+
miniProgress = findViewById(R.id.mini_progress);
65+
trackTitle = findViewById(R.id.track_title);
6766

6867
panelLayout.addPanelSlideListener(this);
6968

@@ -86,14 +85,26 @@ public void run() {
8685
}
8786
};
8887
handler.postDelayed(progressRunnable, DELAY_MILLIS);
88+
89+
playbackImage.setOnClickListener(new View.OnClickListener() {
90+
@Override
91+
public void onClick(View view) {
92+
if (remote.mediaPlayer.isPlaying()) {
93+
remote.mediaPlayer.pauseMedia();
94+
} else {
95+
remote.mediaPlayer.playMedia();
96+
}
97+
}
98+
});
8999
}
90100

91101
@Override
92102
public void setContentView(int layoutResID) {
93103
if (layoutResID == R.layout.sliding_music_layout) {
94-
super.setContentView(layoutResID);
104+
getWindow().setContentView(layoutResID);
95105
} else {
96-
getLayoutInflater().inflate(layoutResID, mSlidingContent, true);
106+
Log.d(TAG, "setContentView: " + mSlidingContent);
107+
getLayoutInflater().inflate(layoutResID, mSlidingContent);
97108
}
98109
}
99110

app/src/main/res/layout/activity_library.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
android:layout_width="match_parent"
1414
android:layout_height="wrap_content"
1515
android:paddingTop="@dimen/appbar_padding_top"
16-
android:theme="@style/AppTheme.AppBarOverlay">
16+
android:theme="@style/AppTheme.CustomAppBarOverlay">
1717

1818
<android.support.v7.widget.Toolbar
1919
android:id="@+id/toolbar"

app/src/main/res/layout/sliding_music_layout.xml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
1-
<com.sothree.slidinguppanel.SlidingUpPanelLayout
2-
xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
1+
<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:android="http://schemas.android.com/apk/res/android"
42
xmlns:sothree="http://schemas.android.com/apk/res-auto"
3+
xmlns:tools="http://schemas.android.com/tools"
54
android:id="@+id/sliding_layout"
65
android:layout_width="match_parent"
76
android:layout_height="match_parent"
87
android:gravity="bottom"
8+
sothree:umanoOverlay="true"
99
sothree:umanoPanelHeight="68dp"
10-
sothree:umanoShadowHeight="4dp"
1110
sothree:umanoParallaxOffset="100dp"
12-
sothree:umanoDragView="@+id/drag_view"
13-
sothree:umanoOverlay="true"
14-
sothree:umanoScrollableView="@+id/list">
11+
sothree:umanoShadowHeight="4dp">
1512

1613
<!-- MAIN CONTENT -->
1714
<FrameLayout
1815
android:id="@+id/sliding_content"
1916
android:layout_width="match_parent"
2017
android:layout_height="match_parent"
21-
android:orientation="vertical"></FrameLayout>
18+
android:orientation="vertical" />
2219

2320
<!-- SLIDING LAYOUT -->
2421
<LinearLayout
22+
android:id="@+id/dragView"
2523
android:layout_width="match_parent"
2624
android:layout_height="match_parent"
2725
android:background="#ffffff"
28-
android:orientation="vertical"
2926
android:clickable="true"
3027
android:focusable="false"
31-
android:id="@+id/dragView">
28+
android:orientation="vertical">
3229

3330
<!--<ScrollView-->
3431
<!--android:id="@+id/sv"-->

app/src/main/res/values/styles.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<item name="colorAccent">@color/colorAccent</item>
99
<item name="android:windowActionBarOverlay">true</item>
1010
</style>
11+
<style name="AppTheme.CustomAppBarOverlay" parent="AppTheme.AppBarOverlay">
12+
<item name="android:windowActionBarOverlay">true</item>
13+
</style>
1114

1215
<style name="AppTheme.TranslucentStatusBar" parent="Theme.AppCompat.Light.DarkActionBar">
1316
<!-- Customize your theme here. -->

0 commit comments

Comments
 (0)