Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
计算机应用开发
高仿类项目
Remusic
提交
bdbbd902
R
Remusic
项目概览
计算机应用开发
/
高仿类项目
/
Remusic
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Remusic
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
bdbbd902
编写于
12月 20, 2016
作者:
W
wm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改一些问题
上级
a95f7c31
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
414 addition
and
285 deletion
+414
-285
app-release.apk
app-release.apk
+0
-0
app/app.iml
app/app.iml
+7
-7
app/src/main/java/com/wm/remusic/MainApplication.java
app/src/main/java/com/wm/remusic/MainApplication.java
+1
-1
app/src/main/java/com/wm/remusic/activity/AlbumsDetailActivity.java
...in/java/com/wm/remusic/activity/AlbumsDetailActivity.java
+43
-44
app/src/main/java/com/wm/remusic/activity/PlayingActivity.java
...rc/main/java/com/wm/remusic/activity/PlayingActivity.java
+0
-1
app/src/main/java/com/wm/remusic/activity/PlaylistActivity.java
...c/main/java/com/wm/remusic/activity/PlaylistActivity.java
+56
-20
app/src/main/java/com/wm/remusic/activity/RadioDetailActivity.java
...ain/java/com/wm/remusic/activity/RadioDetailActivity.java
+4
-4
app/src/main/java/com/wm/remusic/activity/RecentActivity.java
...src/main/java/com/wm/remusic/activity/RecentActivity.java
+2
-2
app/src/main/java/com/wm/remusic/fragment/AlbumDetailFragment.java
...ain/java/com/wm/remusic/fragment/AlbumDetailFragment.java
+2
-2
app/src/main/java/com/wm/remusic/fragment/ArtistDetailFragment.java
...in/java/com/wm/remusic/fragment/ArtistDetailFragment.java
+2
-2
app/src/main/java/com/wm/remusic/fragment/DownMusicFragment.java
.../main/java/com/wm/remusic/fragment/DownMusicFragment.java
+2
-2
app/src/main/java/com/wm/remusic/fragment/FolderDetailFragment.java
...in/java/com/wm/remusic/fragment/FolderDetailFragment.java
+2
-2
app/src/main/java/com/wm/remusic/fragment/MusicFragment.java
app/src/main/java/com/wm/remusic/fragment/MusicFragment.java
+73
-31
app/src/main/java/com/wm/remusic/fragment/QuickControlsFragment.java
...n/java/com/wm/remusic/fragment/QuickControlsFragment.java
+8
-3
app/src/main/java/com/wm/remusic/fragmentnet/ArtistInfoMusicFragment.java
...a/com/wm/remusic/fragmentnet/ArtistInfoMusicFragment.java
+2
-3
app/src/main/java/com/wm/remusic/fragmentnet/RankingFragment.java
...main/java/com/wm/remusic/fragmentnet/RankingFragment.java
+0
-2
app/src/main/java/com/wm/remusic/fragmentnet/SearchMusicFragment.java
.../java/com/wm/remusic/fragmentnet/SearchMusicFragment.java
+6
-3
app/src/main/java/com/wm/remusic/service/MediaService.java
app/src/main/java/com/wm/remusic/service/MediaService.java
+136
-116
app/src/main/java/com/wm/remusic/service/MusicPlayer.java
app/src/main/java/com/wm/remusic/service/MusicPlayer.java
+1
-1
app/src/main/res/drawable/press_selector.xml
app/src/main/res/drawable/press_selector.xml
+22
-0
app/src/main/res/layout/notification.xml
app/src/main/res/layout/notification.xml
+44
-38
app/src/main/res/values/colors.xml
app/src/main/res/values/colors.xml
+1
-1
未找到文件。
app-release.apk
浏览文件 @
bdbbd902
无法预览此类型文件
app/app.iml
浏览文件 @
bdbbd902
...
...
@@ -61,13 +61,6 @@
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/java"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/jni"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/rs"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/res"
type=
"java-test-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/resources"
type=
"java-test-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/assets"
type=
"java-test-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/aidl"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/java"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/jni"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/rs"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/res"
type=
"java-test-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/resources"
type=
"java-test-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/assets"
type=
"java-test-resource"
/>
...
...
@@ -75,6 +68,13 @@
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/java"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/jni"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/rs"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/res"
type=
"java-test-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/resources"
type=
"java-test-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/assets"
type=
"java-test-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/aidl"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/java"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/jni"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/androidTest/rs"
isTestSource=
"true"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/build/intermediates/assets"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/build/intermediates/blame"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/build/intermediates/bundles"
/>
...
...
app/src/main/java/com/wm/remusic/MainApplication.java
浏览文件 @
bdbbd902
...
...
@@ -151,7 +151,7 @@ public class MainApplication extends Application implements ThemeUtils.switchCol
// refWatcher = LeakCanary.install(this);
//
initCatchException();
initCatchException
();
if
(!
PreferencesUtility
.
getInstance
(
this
).
getFavriateMusicPlaylist
())
{
PlaylistInfo
.
getInstance
(
this
).
addPlaylist
(
favPlaylist
,
getResources
().
getString
(
R
.
string
.
my_fav_playlist
),
...
...
app/src/main/java/com/wm/remusic/activity/AlbumsDetailActivity.java
浏览文件 @
bdbbd902
...
...
@@ -61,6 +61,7 @@ import com.wm.remusic.service.MusicPlayer;
import
com.wm.remusic.uitl.CommonUtils
;
import
com.wm.remusic.uitl.IConstants
;
import
com.wm.remusic.uitl.ImageUtils
;
import
com.wm.remusic.uitl.L
;
import
com.wm.remusic.widget.DividerItemDecoration
;
import
java.util.ArrayList
;
...
...
@@ -96,6 +97,8 @@ public class AlbumsDetailActivity extends BaseActivity implements ObservableScro
private
int
mStatusSize
;
private
FrameLayout
headerViewContent
;
private
RelativeLayout
headerDetail
;
private
String
TAG
=
"AlbumsDetailActivity"
;
private
boolean
d
=
true
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -162,31 +165,6 @@ public class AlbumsDetailActivity extends BaseActivity implements ObservableScro
@Override
public
void
onClick
(
View
v
)
{
new
LoadAllDownInfos
((
Activity
)
AlbumsDetailActivity
.
this
,
mList
).
execute
();
// new AlertDialog.Builder(AlbumsDetailActivity.this).setTitle("要下载音乐吗").
// setPositiveButton(AlbumsDetailActivity.this.getString(R.string.sure), new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
//
// int len = mList.size();
// for(int i = 0; i < len ; i++){
// Down.downMusic(MainApplication.context, mList.get(i).getSong_id(),mList.get(i).getTitle());
// }
// mHandler.post(new Runnable() {
// @Override
// public void run() {
// Toast.makeText(AlbumsDetailActivity.this, "已加入到下载", Toast.LENGTH_SHORT).show();
// }
// });
// dialog.dismiss();
// }
// }).
// setNegativeButton(AlbumsDetailActivity.this.getString(R.string.cancel), new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
// }
// }).show();
}
});
headerDetail
.
setVisibility
(
View
.
GONE
);
...
...
@@ -517,22 +495,7 @@ public class AlbumsDetailActivity extends BaseActivity implements ObservableScro
IConstants
.
MUSICOVERFLOW
);
morefragment
.
show
(((
AppCompatActivity
)
mContext
).
getSupportFragmentManager
(),
"music"
);
}
// new AlertDialog.Builder(mContext).setTitle("要下载音乐吗").
// setPositiveButton(mContext.getString(R.string.sure), new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
//
// Down.downMusic(MainApplication.context, localItem.songId + "", localItem.musicName);
// dialog.dismiss();
// }
// }).
// setNegativeButton(mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
// }
// }).show();
}
});
...
...
@@ -576,7 +539,7 @@ public class AlbumsDetailActivity extends BaseActivity implements ObservableScro
public
void
onClick
(
View
v
)
{
//// TODO: 2016/1/20
new
Threa
d
(
new
Runnable
()
{
HandlerUtil
.
getInstance
(
mContext
).
postDelaye
d
(
new
Runnable
()
{
@Override
public
void
run
()
{
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
<
Long
,
MusicInfo
>();
...
...
@@ -587,9 +550,11 @@ public class AlbumsDetailActivity extends BaseActivity implements ObservableScro
list
[
i
]
=
info
.
songId
;
infos
.
put
(
list
[
i
],
info
);
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
if
(
getAdapterPosition
()
>
0
)
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}
).
start
(
);
}
,
70
);
}
...
...
@@ -630,4 +595,38 @@ public class AlbumsDetailActivity extends BaseActivity implements ObservableScro
}
}
PlayMusic
playMusic
;
public
class
PlayMusic
extends
Thread
{
private
volatile
boolean
isInterrupted
=
false
;
private
ArrayList
<
MusicInfo
>
arrayList
;
public
PlayMusic
(
ArrayList
<
MusicInfo
>
arrayList
){
this
.
arrayList
=
arrayList
;
}
public
void
interrupt
(){
isInterrupted
=
true
;
super
.
interrupt
();
}
public
void
run
(){
L
.
D
(
d
,
TAG
,
" start"
);
while
(!
isInterrupted
){
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
<
Long
,
MusicInfo
>();
int
len
=
arrayList
.
size
();
long
[]
list
=
new
long
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
MusicInfo
info
=
arrayList
.
get
(
i
);
list
[
i
]
=
info
.
songId
;
infos
.
put
(
list
[
i
],
info
);
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
// try{
//
// }catch(InterruptedException e){
// L.D(d,TAG, " 从阻塞中退出...");
// L.D(d,TAG, "this.isInterrupted()="+this.isInterrupted());
// }
}
L
.
D
(
d
,
TAG
,
"已经终止!"
);
}
}
}
app/src/main/java/com/wm/remusic/activity/PlayingActivity.java
浏览文件 @
bdbbd902
...
...
@@ -604,7 +604,6 @@ public class PlayingActivity extends BaseActivity implements IConstants {
}
}
isNextOrPreSetPage
=
false
;
if
(
MusicPlayer
.
getQueuePosition
()
+
1
!=
mViewPager
.
getCurrentItem
())
{
mViewPager
.
setCurrentItem
(
MusicPlayer
.
getQueuePosition
()
+
1
);
...
...
app/src/main/java/com/wm/remusic/activity/PlaylistActivity.java
浏览文件 @
bdbbd902
...
...
@@ -113,6 +113,9 @@ public class PlaylistActivity extends BaseActivity implements ObservableScrollVi
private
TextView
collectText
;
private
ImageView
collectView
;
private
LinearLayout
share
;
private
String
TAG
=
"PlaylistActivity"
;
private
boolean
d
=
true
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -219,9 +222,9 @@ public class PlaylistActivity extends BaseActivity implements ObservableScrollVi
// PlaylistsManager.getInstance(mContext).Insert(mContext,,adapterList);
if
(!
mCollected
)
{
collectText
.
setText
(
"已收藏"
);
new
Thread
(
new
Runnable
()
{
new
AsyncTask
<
Void
,
Void
,
Void
>()
{
@Override
p
ublic
void
run
(
)
{
p
rotected
Void
doInBackground
(
Void
...
params
)
{
String
albumart
=
null
;
boolean
isLocal
=
false
;
for
(
MusicInfo
info
:
adapterList
)
{
...
...
@@ -231,8 +234,6 @@ public class PlaylistActivity extends BaseActivity implements ObservableScrollVi
break
;
}
}
//String albumart = MusicUtils.getMusicInfo(getContext(), musicId[0]).albumData;
PlaylistInfo
.
getInstance
(
mContext
).
addPlaylist
(
Long
.
parseLong
(
playlsitId
),
playlistName
,
adapterList
.
size
(),
albumart
,
"net"
);
PlaylistsManager
.
getInstance
(
mContext
).
insertLists
(
mContext
,
Long
.
parseLong
(
playlsitId
),
adapterList
);
...
...
@@ -240,8 +241,9 @@ public class PlaylistActivity extends BaseActivity implements ObservableScrollVi
MainApplication
.
context
.
sendBroadcast
(
intent
);
mCollected
=
true
;
return
null
;
}
}
).
start
();
}
.
execute
();
}
else
{
collectText
.
setText
(
"收藏"
);
...
...
@@ -271,7 +273,7 @@ public class PlaylistActivity extends BaseActivity implements ObservableScrollVi
ObservableRecyclerView
recyclerView
=
(
ObservableRecyclerView
)
findViewById
(
R
.
id
.
recyclerview
);
recyclerView
.
setScrollViewCallbacks
(
PlaylistActivity
.
this
);
recyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
PlaylistActivity
.
this
));
recyclerView
.
setHasFixedSize
(
fals
e
);
recyclerView
.
setHasFixedSize
(
tru
e
);
mAdapter
=
new
PlaylistDetailAdapter
(
PlaylistActivity
.
this
,
adapterList
);
recyclerView
.
setAdapter
(
mAdapter
);
recyclerView
.
addItemDecoration
(
new
DividerItemDecoration
(
PlaylistActivity
.
this
,
DividerItemDecoration
.
VERTICAL_LIST
));
...
...
@@ -657,20 +659,21 @@ public class PlaylistActivity extends BaseActivity implements ObservableScrollVi
public
void
onClick
(
View
v
)
{
//// TODO: 2016/1/20
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
<
Long
,
MusicInfo
>();
int
len
=
arraylist
.
size
();
long
[]
list
=
new
long
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
MusicInfo
info
=
arraylist
.
get
(
i
);
list
[
i
]
=
info
.
songId
;
infos
.
put
(
list
[
i
],
info
);
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}).
start
();
HandlerUtil
.
getInstance
(
mContext
).
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
<
Long
,
MusicInfo
>();
int
len
=
arraylist
.
size
();
long
[]
list
=
new
long
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
MusicInfo
info
=
arraylist
.
get
(
i
);
list
[
i
]
=
info
.
songId
;
infos
.
put
(
list
[
i
],
info
);
}
if
(
getAdapterPosition
()
>
0
)
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
},
70
);
}
...
...
@@ -710,4 +713,37 @@ public class PlaylistActivity extends BaseActivity implements ObservableScrollVi
}
}
private
PlayMusic
mPlay
;
private
volatile
boolean
tryPlaying
=
false
;
public
class
PlayMusic
extends
Thread
{
private
volatile
boolean
isInterrupted
=
false
;
private
ArrayList
<
MusicInfo
>
arrayList
;
private
int
position
;
public
PlayMusic
(
ArrayList
<
MusicInfo
>
arrayList
,
int
position
){
this
.
arrayList
=
arrayList
;
this
.
position
=
position
;
}
public
void
interrupt
(){
isInterrupted
=
true
;
super
.
interrupt
();
}
public
void
run
(){
L
.
D
(
d
,
TAG
,
" start"
);
tryPlaying
=
true
;
while
(!
isInterrupted
){
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
<
Long
,
MusicInfo
>();
int
len
=
arrayList
.
size
();
long
[]
list
=
new
long
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
MusicInfo
info
=
arrayList
.
get
(
i
);
list
[
i
]
=
info
.
songId
;
infos
.
put
(
list
[
i
],
info
);
}
MusicPlayer
.
playAll
(
infos
,
list
,
position
,
false
);
}
tryPlaying
=
false
;
L
.
D
(
d
,
TAG
,
"已经终止!"
);
}
}
}
app/src/main/java/com/wm/remusic/activity/RadioDetailActivity.java
浏览文件 @
bdbbd902
...
...
@@ -595,7 +595,7 @@ public class RadioDetailActivity extends BaseActivity implements ObservableScrol
public
void
onClick
(
View
v
)
{
//// TODO: 2016/1/20
new
Threa
d
(
new
Runnable
()
{
HandlerUtil
.
getInstance
(
mContext
).
postDelaye
d
(
new
Runnable
()
{
@Override
public
void
run
()
{
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
<
Long
,
MusicInfo
>();
...
...
@@ -608,7 +608,7 @@ public class RadioDetailActivity extends BaseActivity implements ObservableScrol
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}
).
start
(
);
}
,
70
);
}
...
...
@@ -629,7 +629,7 @@ public class RadioDetailActivity extends BaseActivity implements ObservableScrol
@Override
public
void
onClick
(
View
v
)
{
new
Threa
d
(
new
Runnable
()
{
HandlerUtil
.
getInstance
(
mContext
).
postDelaye
d
(
new
Runnable
()
{
@Override
public
void
run
()
{
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
<
Long
,
MusicInfo
>();
...
...
@@ -660,7 +660,7 @@ public class RadioDetailActivity extends BaseActivity implements ObservableScrol
if
(
getAdapterPosition
()
>
0
)
MusicPlayer
.
playAll
(
infos
,
list
,
getAdapterPosition
()
-
1
,
false
);
}
}
).
start
(
);
}
,
70
);
}
...
...
app/src/main/java/com/wm/remusic/activity/RecentActivity.java
浏览文件 @
bdbbd902
...
...
@@ -225,7 +225,7 @@ public class RecentActivity extends BaseActivity {
public
void
onClick
(
View
v
)
{
//// TODO: 2016/1/20
new
Threa
d
(
new
Runnable
()
{
HandlerUtil
.
getInstance
(
RecentActivity
.
this
).
postDelaye
d
(
new
Runnable
()
{
@Override
public
void
run
()
{
long
[]
list
=
new
long
[
mList
.
size
()];
...
...
@@ -239,7 +239,7 @@ public class RecentActivity extends BaseActivity {
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}
).
start
(
);
}
,
70
);
}
...
...
app/src/main/java/com/wm/remusic/fragment/AlbumDetailFragment.java
浏览文件 @
bdbbd902
...
...
@@ -198,7 +198,7 @@ public class AlbumDetailFragment extends BaseFragment {
//播放专辑
@Override
public
void
onClick
(
View
v
)
{
new
Threa
d
(
new
Runnable
()
{
HandlerUtil
.
getInstance
(
getContext
()).
postDelaye
d
(
new
Runnable
()
{
@Override
public
void
run
()
{
long
[]
list
=
new
long
[
mList
.
size
()];
...
...
@@ -212,7 +212,7 @@ public class AlbumDetailFragment extends BaseFragment {
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}
).
start
(
);
}
,
70
);
}
...
...
app/src/main/java/com/wm/remusic/fragment/ArtistDetailFragment.java
浏览文件 @
bdbbd902
...
...
@@ -204,7 +204,7 @@ public class ArtistDetailFragment extends BaseFragment {
//播放歌手所有歌曲
@Override
public
void
onClick
(
View
v
)
{
new
Threa
d
(
new
Runnable
()
{
HandlerUtil
.
getInstance
(
getContext
()).
postDelaye
d
(
new
Runnable
()
{
@Override
public
void
run
()
{
long
[]
list
=
new
long
[
mList
.
size
()];
...
...
@@ -218,7 +218,7 @@ public class ArtistDetailFragment extends BaseFragment {
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}
).
start
(
);
}
,
70
);
}
...
...
app/src/main/java/com/wm/remusic/fragment/DownMusicFragment.java
浏览文件 @
bdbbd902
...
...
@@ -182,7 +182,7 @@ public class DownMusicFragment extends BaseFragment {
//播放文件夹
@Override
public
void
onClick
(
View
v
)
{
new
Threa
d
(
new
Runnable
()
{
HandlerUtil
.
getInstance
(
getContext
()).
postDelaye
d
(
new
Runnable
()
{
@Override
public
void
run
()
{
long
[]
list
=
new
long
[
mList
.
size
()];
...
...
@@ -196,7 +196,7 @@ public class DownMusicFragment extends BaseFragment {
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}
).
start
(
);
}
,
70
);
}
...
...
app/src/main/java/com/wm/remusic/fragment/FolderDetailFragment.java
浏览文件 @
bdbbd902
...
...
@@ -205,7 +205,7 @@ public class FolderDetailFragment extends BaseFragment {
//播放文件夹
@Override
public
void
onClick
(
View
v
)
{
new
Threa
d
(
new
Runnable
()
{
HandlerUtil
.
getInstance
(
getContext
()).
postDelaye
d
(
new
Runnable
()
{
@Override
public
void
run
()
{
long
[]
list
=
new
long
[
mList
.
size
()];
...
...
@@ -219,7 +219,7 @@ public class FolderDetailFragment extends BaseFragment {
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}
).
start
(
);
}
,
70
);
}
...
...
app/src/main/java/com/wm/remusic/fragment/MusicFragment.java
浏览文件 @
bdbbd902
...
...
@@ -4,6 +4,7 @@ package com.wm.remusic.fragment;
import
android.content.Intent
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
import
android.util.Log
;
...
...
@@ -20,6 +21,7 @@ import android.widget.TextView;
import
com.bilibili.magicasakura.widgets.TintImageView
;
import
com.github.promeg.pinyinhelper.Pinyin
;
import
com.wm.remusic.R
;
import
com.wm.remusic.activity.AlbumsDetailActivity
;
import
com.wm.remusic.activity.SelectActivity
;
import
com.wm.remusic.handler.HandlerUtil
;
import
com.wm.remusic.info.MusicInfo
;
...
...
@@ -243,11 +245,14 @@ public class MusicFragment extends BaseFragment {
final
static
int
FIRST_ITEM
=
0
;
final
static
int
ITEM
=
1
;
private
ArrayList
<
MusicInfo
>
mList
;
PlayMusic
playMusic
;
Handler
handler
;
public
Adapter
(
ArrayList
<
MusicInfo
>
list
)
{
// if (list == null) {
// throw new IllegalArgumentException("model Data must not be null");
// }
handler
=
HandlerUtil
.
getInstance
(
getContext
());
mList
=
list
;
}
...
...
@@ -331,21 +336,27 @@ public class MusicFragment extends BaseFragment {
public
void
onClick
(
View
v
)
{
//// TODO: 2016/1/20
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
long
[]
list
=
new
long
[
mList
.
size
()];
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
();
for
(
int
i
=
0
;
i
<
mList
.
size
();
i
++)
{
MusicInfo
info
=
mList
.
get
(
i
);
list
[
i
]
=
info
.
songId
;
info
.
islocal
=
true
;
info
.
albumData
=
MusicUtils
.
getAlbumArtUri
(
info
.
albumId
)
+
""
;
infos
.
put
(
list
[
i
],
mList
.
get
(
i
));
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}).
start
();
if
(
playMusic
!=
null
)
handler
.
removeCallbacks
(
playMusic
);
if
(
getAdapterPosition
()
>
0
){
playMusic
=
new
PlayMusic
(
0
);
handler
.
postDelayed
(
playMusic
,
70
);
}
// HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
// @Override
// public void run() {
// long[] list = new long[mList.size()];
// HashMap<Long, MusicInfo> infos = new HashMap();
// for (int i = 0; i < mList.size(); i++) {
// MusicInfo info = mList.get(i);
// list[i] = info.songId;
// info.islocal = true;
// info.albumData = MusicUtils.getAlbumArtUri(info.albumId) + "";
// infos.put(list[i], mList.get(i));
// }
// MusicPlayer.playAll(infos, list, 0, false);
// }
// },70);
}
...
...
@@ -358,6 +369,7 @@ public class MusicFragment extends BaseFragment {
TextView
mainTitle
,
title
;
TintImageView
playState
;
ListItemViewHolder
(
View
view
)
{
super
(
view
);
this
.
mainTitle
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
viewpager_list_toptext
);
...
...
@@ -365,6 +377,7 @@ public class MusicFragment extends BaseFragment {
this
.
playState
=
(
TintImageView
)
view
.
findViewById
(
R
.
id
.
play_state
);
this
.
moreOverflow
=
(
ImageView
)
view
.
findViewById
(
R
.
id
.
viewpager_list_button
);
moreOverflow
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
...
...
@@ -378,25 +391,54 @@ public class MusicFragment extends BaseFragment {
@Override
public
void
onClick
(
View
v
)
{
HandlerUtil
.
getInstance
(
getContext
()).
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
long
[]
list
=
new
long
[
mList
.
size
()];
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
();
for
(
int
i
=
0
;
i
<
mList
.
size
();
i
++)
{
MusicInfo
info
=
mList
.
get
(
i
);
list
[
i
]
=
info
.
songId
;
info
.
islocal
=
true
;
info
.
albumData
=
MusicUtils
.
getAlbumArtUri
(
info
.
albumId
)
+
""
;
infos
.
put
(
list
[
i
],
mList
.
get
(
i
));
}
if
(
getAdapterPosition
()
>
0
)
MusicPlayer
.
playAll
(
infos
,
list
,
getAdapterPosition
()
-
1
,
false
);
}
},
60
);
if
(
playMusic
!=
null
)
handler
.
removeCallbacks
(
playMusic
);
if
(
getAdapterPosition
()
>
0
){
playMusic
=
new
PlayMusic
(
getAdapterPosition
()
-
1
);
handler
.
postDelayed
(
playMusic
,
70
);
}
// HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
// @Override
// public void run() {
// long[] list = new long[mList.size()];
// HashMap<Long, MusicInfo> infos = new HashMap();
// for (int i = 0; i < mList.size(); i++) {
// MusicInfo info = mList.get(i);
// list[i] = info.songId;
// info.islocal = true;
// info.albumData = MusicUtils.getAlbumArtUri(info.albumId) + "";
// infos.put(list[i], mList.get(i));
// }
// if (getAdapterPosition() > 0)
// MusicPlayer.playAll(infos, list, getAdapterPosition() - 1, false);
// }
// }, 60);
}
}
class
PlayMusic
implements
Runnable
{
int
position
;
public
PlayMusic
(
int
position
){
this
.
position
=
position
;
}
@Override
public
void
run
()
{
long
[]
list
=
new
long
[
mList
.
size
()];
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
();
for
(
int
i
=
0
;
i
<
mList
.
size
();
i
++)
{
MusicInfo
info
=
mList
.
get
(
i
);
list
[
i
]
=
info
.
songId
;
info
.
islocal
=
true
;
info
.
albumData
=
MusicUtils
.
getAlbumArtUri
(
info
.
albumId
)
+
""
;
infos
.
put
(
list
[
i
],
mList
.
get
(
i
));
}
if
(
position
>
0
)
MusicPlayer
.
playAll
(
infos
,
list
,
position
,
false
);
}
}
}
}
\ No newline at end of file
app/src/main/java/com/wm/remusic/fragment/QuickControlsFragment.java
浏览文件 @
bdbbd902
...
...
@@ -186,9 +186,14 @@ public class QuickControlsFragment extends BaseFragment {
mAlbumArt
.
setImageURI
(
Uri
.
parse
(
"res:/"
+
R
.
drawable
.
placeholder_disk_210
));
}
};
if
(
MusicPlayer
.
getAlbumPath
()
!=
null
)
{
Log
.
e
(
"albumpath"
,
MusicPlayer
.
getAlbumPath
());
ImageRequest
request
=
ImageRequestBuilder
.
newBuilderWithSource
(
Uri
.
parse
(
MusicPlayer
.
getAlbumPath
())).
build
();
Uri
uri
=
null
;
try
{
uri
=
Uri
.
parse
(
MusicPlayer
.
getAlbumPath
());
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
if
(
uri
!=
null
)
{
ImageRequest
request
=
ImageRequestBuilder
.
newBuilderWithSource
(
uri
).
build
();
DraweeController
controller
=
Fresco
.
newDraweeControllerBuilder
()
.
setOldController
(
mAlbumArt
.
getController
())
...
...
app/src/main/java/com/wm/remusic/fragmentnet/ArtistInfoMusicFragment.java
浏览文件 @
bdbbd902
...
...
@@ -199,7 +199,7 @@ public class ArtistInfoMusicFragment extends BaseFragment {
public
void
onClick
(
View
v
)
{
//// TODO: 2016/1/20
new
Threa
d
(
new
Runnable
()
{
HandlerUtil
.
getInstance
(
mContext
).
postDelaye
d
(
new
Runnable
()
{
@Override
public
void
run
()
{
HashMap
<
Long
,
MusicInfo
>
infos
=
new
HashMap
<
Long
,
MusicInfo
>();
...
...
@@ -212,8 +212,7 @@ public class ArtistInfoMusicFragment extends BaseFragment {
}
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
}
}).
start
();
},
70
);
}
}
...
...
app/src/main/java/com/wm/remusic/fragmentnet/RankingFragment.java
浏览文件 @
bdbbd902
...
...
@@ -52,8 +52,6 @@ public class RankingFragment extends Fragment {
LinearLayoutManager
linearLayoutManager
;
RankingAdapter
rankingAdapter
;
ArrayList
<
BillboardInfo
>
items
=
new
ArrayList
<>();
private
static
ExecutorService
exec
=
Executors
.
newFixedThreadPool
(
6
);
@Override
public
void
setUserVisibleHint
(
boolean
isVisibleToUser
)
{
...
...
app/src/main/java/com/wm/remusic/fragmentnet/SearchMusicFragment.java
浏览文件 @
bdbbd902
package
com.wm.remusic.fragmentnet
;
import
android.content.DialogInterface
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
...
...
@@ -173,9 +174,10 @@ public class SearchMusicFragment extends Fragment {
@Override
public
void
onClick
(
View
v
)
{
final
SearchSongInfo
model
=
mList
.
get
(
getAdapterPosition
());
new
Thread
(
new
Runnable
()
{
new
AsyncTask
<
Void
,
Void
,
Void
>(){
@Override
p
ublic
void
run
(
)
{
p
rotected
Void
doInBackground
(
Void
...
params
)
{
MusicInfo
musicInfo
=
new
MusicInfo
();
try
{
MusicDetailInfo
info
=
null
;
...
...
@@ -202,8 +204,9 @@ public class SearchMusicFragment extends Fragment {
list
[
0
]
=
musicInfo
.
songId
;
infos
.
put
(
list
[
0
],
musicInfo
);
MusicPlayer
.
playAll
(
infos
,
list
,
0
,
false
);
return
null
;
}
}
).
start
();
}
.
execute
();
}
});
...
...
app/src/main/java/com/wm/remusic/service/MediaService.java
浏览文件 @
bdbbd902
...
...
@@ -578,38 +578,53 @@ public class MediaService extends Service {
}
private
void
updateNotification
()
{
// final int newNotifyMode;
// if (isPlaying()) {
// newNotifyMode = NOTIFY_MODE_FOREGROUND;
// } else if (recentlyPlayed()) {
// newNotifyMode = NOTIFY_MODE_BACKGROUND;
// } else {
// newNotifyMode = NOTIFY_MODE_NONE;
// }
//
// // int notificationId = hashCode();
//
// if (mNotifyMode != newNotifyMode) {
// if (mNotifyMode == NOTIFY_MODE_FOREGROUND) {
// if (CommonUtils.isLollipop())
// stopForeground(newNotifyMode == NOTIFY_MODE_NONE);
// else
// stopForeground(newNotifyMode == NOTIFY_MODE_NONE || newNotifyMode == NOTIFY_MODE_BACKGROUND);
// } else if (newNotifyMode == NOTIFY_MODE_NONE) {
// mNotificationManager.cancel(notificationId);
// mNotificationPostTime = 0;
// }
// }
//
// if (newNotifyMode == NOTIFY_MODE_FOREGROUND) {
// startForeground(notificationId, getNotification());
//
// } else if (newNotifyMode == NOTIFY_MODE_BACKGROUND) {
// mNotificationManager.notify(notificationId, getNotification());
final
int
newNotifyMode
;
if
(
isPlaying
())
{
newNotifyMode
=
NOTIFY_MODE_FOREGROUND
;
}
else
if
(
recentlyPlayed
())
{
newNotifyMode
=
NOTIFY_MODE_BACKGROUND
;
}
else
{
newNotifyMode
=
NOTIFY_MODE_NONE
;
}
// int notificationId = hashCode();
if
(
mNotifyMode
!=
newNotifyMode
)
{
if
(
mNotifyMode
==
NOTIFY_MODE_FOREGROUND
)
{
if
(
CommonUtils
.
isLollipop
())
stopForeground
(
newNotifyMode
==
NOTIFY_MODE_NONE
);
else
stopForeground
(
newNotifyMode
==
NOTIFY_MODE_NONE
||
newNotifyMode
==
NOTIFY_MODE_BACKGROUND
);
}
else
if
(
newNotifyMode
==
NOTIFY_MODE_NONE
)
{
mNotificationManager
.
cancel
(
notificationId
);
mNotificationPostTime
=
0
;
}
}
if
(
newNotifyMode
==
NOTIFY_MODE_FOREGROUND
)
{
startForeground
(
notificationId
,
getNotification
());
}
else
if
(
newNotifyMode
==
NOTIFY_MODE_BACKGROUND
)
{
mNotificationManager
.
notify
(
notificationId
,
getNotification
());
}
mNotifyMode
=
newNotifyMode
;
// Log.e("playing","updatenotification 0");
// if(mNotifyMode == NOTIFY_MODE_NONE){
// Log.e("playing","updatenotification 1");
// Notification notification = getNotification();
// Log.e("playing","updatenotification 2");
// startForeground(notificationId,notification);
// Log.e("playing","updatenotification 3.0");
// mNotifyMode = NOTIFY_MODE_FOREGROUND;
// }else {
// Log.e("playing","updatenotification 3");
// Notification notification = getNotification();
// Log.e("playing","updatenotification 3.1");
// mNotificationManager.notify(notificationId,notification);
// Log.e("playing","updatenotification 3.001");
// }
//
// mNotifyMode = newNotifyMode;
startForeground
(
notificationId
,
getNotification
());
}
...
...
@@ -702,13 +717,13 @@ public class MediaService extends Service {
}
mFileToPlay
=
null
;
closeCursor
();
if
(
goToIdle
)
{
setIsSupposedToBePlaying
(
false
,
false
);
}
else
{
if
(
CommonUtils
.
isLollipop
())
stopForeground
(
false
);
else
stopForeground
(
true
);
}
//
if (goToIdle) {
//
setIsSupposedToBePlaying(false, false);
//
} else {
//
if (CommonUtils.isLollipop())
//
stopForeground(false);
//
else stopForeground(true);
//
}
}
private
int
removeTracksInternal
(
int
first
,
int
last
)
{
...
...
@@ -914,7 +929,12 @@ public class MediaService extends Service {
PreferencesUtility
.
getInstance
(
MediaService
.
this
).
setPlayLink
(
id
,
url
);
}
}
L
.
E
(
D
,
TAG
,
"current url = "
+
url
);
if
(
url
!=
null
){
L
.
E
(
D
,
TAG
,
"current url = "
+
url
);
}
else
{
gotoNext
(
true
);
}
if
(!
stop
)
{
startProxy
();
// String urlEn = HttpUtil.urlEncode(url);
...
...
@@ -1439,6 +1459,7 @@ public class MediaService extends Service {
Notification
mNotification
;
private
Notification
getNotification
()
{
Log
.
e
(
"playing"
,
"get notification start"
);
final
int
PAUSE_FLAG
=
0x1
;
final
int
NEXT_FLAG
=
0x2
;
final
int
STOP_FLAG
=
0x3
;
...
...
@@ -1447,27 +1468,43 @@ public class MediaService extends Service {
final
boolean
isPlaying
=
isPlaying
();
remoteViews
=
new
RemoteViews
(
this
.
getPackageName
(),
R
.
layout
.
notification
);
Log
.
e
(
"playing"
,
"get notification start 3.1"
);
String
text
=
TextUtils
.
isEmpty
(
albumName
)
?
artistName
:
artistName
+
" - "
+
albumName
;
remoteViews
.
setTextViewText
(
R
.
id
.
title
,
getTrackName
());
remoteViews
.
setTextViewText
(
R
.
id
.
text
,
text
);
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
this
.
getApplicationContext
(),
0
,
new
Intent
(
this
.
getApplicationContext
(),
PlayingActivity
.
class
),
PendingIntent
.
FLAG_UPDATE_CURRENT
);
//此处action不能是一样的 如果一样的 接受的flag参数只是第一个设置的值
Intent
pauseIntent
=
new
Intent
(
TOGGLEPAUSE_ACTION
);
pauseIntent
.
putExtra
(
"FLAG"
,
PAUSE_FLAG
);
PendingIntent
pausePIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
pauseIntent
,
0
);
remoteViews
.
setImageViewResource
(
R
.
id
.
iv_pause
,
isPlaying
?
R
.
drawable
.
note_btn_pause
:
R
.
drawable
.
note_btn_play
);
remoteViews
.
setOnClickPendingIntent
(
R
.
id
.
iv_pause
,
pausePIntent
);
//remoteView.setInt(R.id.iv_pause, "setBackgroundResource", R.color.your_color);
Intent
nextIntent
=
new
Intent
(
NEXT_ACTION
);
nextIntent
.
putExtra
(
"FLAG"
,
NEXT_FLAG
);
PendingIntent
nextPIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
nextIntent
,
0
);
remoteViews
.
setOnClickPendingIntent
(
R
.
id
.
iv_next
,
nextPIntent
);
Intent
preIntent
=
new
Intent
(
STOP_ACTION
);
preIntent
.
putExtra
(
"FLAG"
,
STOP_FLAG
);
PendingIntent
prePIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
preIntent
,
0
);
remoteViews
.
setOnClickPendingIntent
(
R
.
id
.
iv_stop
,
prePIntent
);
// PendingIntent pendingIntent = PendingIntent.getActivity(this.getApplicationContext(), 0,
// new Intent(this.getApplicationContext(), PlayingActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
final
Intent
nowPlayingIntent
=
new
Intent
();
nowPlayingIntent
.
setAction
(
"com.wm.remusic.LAUNCH_NOW_PLAYING_ACTION"
);
// nowPlayingIntent.setComponent(new ComponentName("com.wm.remusic","com.wm.remusic.activity.PlayingActivity"));
PendingIntent
clickIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
nowPlayingIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
Intent
intent
=
new
Intent
(
getApplicationContext
(),
PlayingActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
PendingIntent
pi
=
PendingIntent
.
getActivity
(
getApplicationContext
(),
0
,
intent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
//
//
Intent intent = new Intent(getApplicationContext(),
//
PlayingActivity.class);
//
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//
PendingIntent pi = PendingIntent.getActivity(getApplicationContext(),
//
0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
final
Bitmap
bitmap
=
ImageUtils
.
getArtworkQuick
(
this
,
getAlbumId
(),
160
,
160
);
if
(
bitmap
!=
null
)
{
remoteViews
.
setImageViewBitmap
(
R
.
id
.
image
,
bitmap
);
// remoteViews.setImageViewUri(R.id.image, MusicUtils.getAlbumUri(this, getAudioId()));
...
...
@@ -1479,83 +1516,70 @@ public class MediaService extends Service {
noBit
=
null
;
}
else
{
ImageRequest
imageRequest
=
ImageRequestBuilder
.
newBuilderWithSource
(
Uri
.
parse
(
getAlbumPath
()))
.
setProgressiveRenderingEnabled
(
true
)
.
build
();
ImagePipeline
imagePipeline
=
Fresco
.
getImagePipeline
();
DataSource
<
CloseableReference
<
CloseableImage
>>
dataSource
=
imagePipeline
.
fetchDecodedImage
(
imageRequest
,
MediaService
.
this
);
dataSource
.
subscribe
(
new
BaseBitmapDataSubscriber
()
{
@Override
public
void
onNewResultImpl
(
@Nullable
Bitmap
bitmap
)
{
// You can use the bitmap in only limited ways
// No need to do any cleanup.
if
(
bitmap
!=
null
)
{
noBit
=
bitmap
;
Uri
uri
=
null
;
if
(
getAlbumPath
()
!=
null
){
try
{
uri
=
Uri
.
parse
(
getAlbumPath
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
if
(
getAlbumPath
()
==
null
||
uri
==
null
){
noBit
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
placeholder_disk_210
);
updateNotification
();
}
else
{
ImageRequest
imageRequest
=
ImageRequestBuilder
.
newBuilderWithSource
(
uri
)
.
setProgressiveRenderingEnabled
(
true
)
.
build
();
ImagePipeline
imagePipeline
=
Fresco
.
getImagePipeline
();
DataSource
<
CloseableReference
<
CloseableImage
>>
dataSource
=
imagePipeline
.
fetchDecodedImage
(
imageRequest
,
MediaService
.
this
);
dataSource
.
subscribe
(
new
BaseBitmapDataSubscriber
()
{
@Override
public
void
onNewResultImpl
(
@Nullable
Bitmap
bitmap
)
{
// You can use the bitmap in only limited ways
// No need to do any cleanup.
if
(
bitmap
!=
null
)
{
noBit
=
bitmap
;
}
updateNotification
();
}
;
updateNotification
();
}
@Override
public
void
onFailureImpl
(
DataSource
dataSource
)
{
// No cleanup required here.
noBit
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
placeholder_disk_210
);
updateNotification
();
}
},
CallerThreadExecutor
.
getInstance
());
}
@Override
public
void
onFailureImpl
(
DataSource
dataSource
)
{
// No cleanup required here.
noBit
=
BitmapFactory
.
decodeResource
(
getResources
(),
R
.
drawable
.
placeholder_disk_210
);
updateNotification
();
}
},
CallerThreadExecutor
.
getInstance
());
}
}
}
else
{
remoteViews
.
setImageViewResource
(
R
.
id
.
image
,
R
.
drawable
.
placeholder_disk_210
);
}
remoteViews
.
setTextViewText
(
R
.
id
.
title
,
getTrackName
());
remoteViews
.
setTextViewText
(
R
.
id
.
text
,
text
);
//此处action不能是一样的 如果一样的 接受的flag参数只是第一个设置的值
Intent
pauseIntent
=
new
Intent
(
TOGGLEPAUSE_ACTION
);
pauseIntent
.
putExtra
(
"FLAG"
,
PAUSE_FLAG
);
PendingIntent
pausePIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
pauseIntent
,
0
);
remoteViews
.
setImageViewResource
(
R
.
id
.
iv_pause
,
isPlaying
?
R
.
drawable
.
note_btn_pause
:
R
.
drawable
.
note_btn_play
);
remoteViews
.
setOnClickPendingIntent
(
R
.
id
.
iv_pause
,
pausePIntent
);
Intent
nextIntent
=
new
Intent
(
NEXT_ACTION
);
nextIntent
.
putExtra
(
"FLAG"
,
NEXT_FLAG
);
PendingIntent
nextPIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
nextIntent
,
0
);
remoteViews
.
setOnClickPendingIntent
(
R
.
id
.
iv_next
,
nextPIntent
);
Intent
preIntent
=
new
Intent
(
STOP_ACTION
);
preIntent
.
putExtra
(
"FLAG"
,
STOP_FLAG
);
PendingIntent
prePIntent
=
PendingIntent
.
getBroadcast
(
this
,
0
,
preIntent
,
0
);
remoteViews
.
setOnClickPendingIntent
(
R
.
id
.
iv_stop
,
prePIntent
);
if
(
mNotificationPostTime
==
0
)
{
mNotificationPostTime
=
System
.
currentTimeMillis
();
}
Log
.
e
(
TAG
,
" notificationtime = "
+
mNotificationPostTime
);
if
(
mNotification
==
null
){
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
this
).
setContent
(
remoteViews
)
.
setSmallIcon
(
R
.
drawable
.
ic_notification
)
.
setContentIntent
(
clickIntent
)
.
setWhen
(
mNotificationPostTime
)
.
setOnlyAlertOnce
(
true
)
.
setOngoing
(
false
)
.
setPriority
(
Notification
.
PRIORITY_DEFAULT
);
.
setWhen
(
mNotificationPostTime
)
;
if
(
CommonUtils
.
isJellyBeanMR1
())
{
builder
.
setShowWhen
(
false
);
}
mNotification
=
builder
.
build
();
}
else
{
mNotification
.
contentView
=
remoteViews
;
}
// if (CommonUtils.isJellyBeanMR1()) {
// builder.setShowWhen(false);
// }
return
mNotification
;
}
...
...
@@ -1919,7 +1943,6 @@ public class MediaService extends Service {
openCurrentAndNext
();
play
();
notifyChange
(
META_CHANGED
);
notifyChange
(
MUSIC_CHANGED
);
if
(
mShuffleMode
==
SHUFFLE_AUTO
)
{
doAutoShuffleUpdate
();
}
...
...
@@ -2012,7 +2035,7 @@ public class MediaService extends Service {
Log
.
e
(
"Playing"
,
" no info"
);
return
true
;
}
Log
.
e
(
"Playing"
,
" music "
+
info
.
islocal
);
Log
.
e
(
"Playing"
,
" music
is local =
"
+
info
.
islocal
);
return
info
.
islocal
;
}
}
...
...
@@ -2298,27 +2321,22 @@ public class MediaService extends Service {
MediaButtonIntentReceiver
.
class
.
getName
()));
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
mSession
.
setActive
(
true
);
if
(
createNewNextTrack
)
{
setNextTrack
();
}
else
{
setNextTrack
(
mNextPlayPos
);
}
if
(
mPlayer
.
isTrackPrepared
())
{
final
long
duration
=
mPlayer
.
duration
();
if
(
mRepeatMode
!=
REPEAT_CURRENT
&&
duration
>
2000
&&
mPlayer
.
position
()
>=
duration
-
2000
)
{
gotoNext
(
true
);
Log
.
e
(
"play to go"
,
""
);
}
}
mPlayer
.
start
();
mPlayerHandler
.
removeMessages
(
FADEDOWN
);
mPlayerHandler
.
sendEmptyMessage
(
FADEUP
);
setIsSupposedToBePlaying
(
true
,
true
);
cancelShutdown
();
updateNotification
();
notifyChange
(
META_CHANGED
);
...
...
@@ -2343,6 +2361,7 @@ public class MediaService extends Service {
}
public
void
gotoNext
(
final
boolean
force
)
{
Log
.
e
(
"playing"
,
"gotonext"
);
if
(
D
)
Log
.
d
(
TAG
,
"Going to next track"
);
synchronized
(
this
)
{
if
(
mPlaylist
.
size
()
<=
0
)
{
...
...
@@ -2601,6 +2620,7 @@ public class MediaService extends Service {
service
.
updateCursor
(
service
.
mPlaylist
.
get
(
service
.
mPlayPos
).
mId
);
service
.
notifyChange
(
META_CHANGED
);
service
.
notifyChange
(
MUSIC_CHANGED
);
service
.
updateNotification
();
break
;
case
TRACK_ENDED:
...
...
app/src/main/java/com/wm/remusic/service/MusicPlayer.java
浏览文件 @
bdbbd902
...
...
@@ -498,7 +498,7 @@ public class MusicPlayer {
}
}
public
static
void
playAll
(
final
HashMap
<
Long
,
MusicInfo
>
infos
,
final
long
[]
list
,
int
position
,
final
boolean
forceShuffle
)
{
public
static
synchronized
void
playAll
(
final
HashMap
<
Long
,
MusicInfo
>
infos
,
final
long
[]
list
,
int
position
,
final
boolean
forceShuffle
)
{
if
(
list
==
null
||
list
.
length
==
0
||
mService
==
null
)
{
return
;
}
...
...
app/src/main/res/drawable/press_selector.xml
0 → 100644
浏览文件 @
bdbbd902
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2016 Bilibili
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"@color/notification_bak"
android:state_pressed=
"true"
/>
<item
android:drawable=
"@android:color/transparent"
/>
</selector>
\ No newline at end of file
app/src/main/res/layout/notification.xml
浏览文件 @
bdbbd902
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/layout"
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
...
...
@@ -11,44 +12,6 @@
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:scaleType=
"centerCrop"
/>
<LinearLayout
android:id=
"@+id/action"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
>
<ImageView
android:id=
"@+id/iv_pause"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"5dp"
android:src=
"@drawable/note_btn_play"
/>
<ImageView
android:id=
"@+id/iv_next"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"10dp"
android:src=
"@drawable/note_btn_next"
/>
<ImageView
android:id=
"@+id/iv_stop"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_margin=
"5dp"
android:src=
"@drawable/notification_close"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
@@ -83,5 +46,48 @@
android:textColor=
"@color/bottom_text"
android:textSize=
"12sp"
/>
</LinearLayout>
<LinearLayout
android:layout_marginRight=
"10dp"
android:id=
"@+id/action"
android:layout_width=
"wrap_content"
android:layout_height=
"41dp"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
>
<ImageButton
android:padding=
"7dp"
android:id=
"@+id/iv_pause"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_gravity=
"center_vertical"
android:scaleType=
"centerInside"
android:background=
"@drawable/press_selector"
android:layout_marginRight=
"10dp"
/>
<ImageButton
android:id=
"@+id/iv_next"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_gravity=
"center_vertical"
android:scaleType=
"centerInside"
android:padding=
"7dp"
android:layout_marginRight=
"10dp"
android:background=
"@drawable/press_selector"
android:src=
"@drawable/note_btn_next"
/>
<ImageButton
android:id=
"@+id/iv_stop"
android:padding=
"5dp"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:scaleType=
"centerInside"
android:layout_gravity=
"center_vertical"
android:layout_marginRight=
"5dp"
android:background=
"@drawable/press_selector"
android:src=
"@drawable/notification_close"
/>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/values/colors.xml
浏览文件 @
bdbbd902
...
...
@@ -5,7 +5,7 @@
<!-- notification text -->
<color
name=
"bottom_text"
>
#c1c0c0
</color>
<color
name=
"notification_bak"
>
#47fafafa
</color>
<color
name=
"theme_color_primary_dark"
>
#b85671
</color>
<color
name=
"primary_material_light_1"
>
#3f51b5
</color>
<color
name=
"background_material_light_1"
>
#fafafa
</color>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录