update
This commit is contained in:
parent
728d700e54
commit
249568aa11
@ -136,6 +136,11 @@ public class MusicData {
|
|||||||
if (StringUtil.isEmpty(track)) {
|
if (StringUtil.isEmpty(track)) {
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
|
try{
|
||||||
|
Integer.parseInt(track);
|
||||||
|
}catch (Exception e){
|
||||||
|
return track.substring(0,1);
|
||||||
|
}
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ public class MediaBrowserHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MediaBrowserSubscriptionCallback extends MediaBrowserCompat.SubscriptionCallback {
|
public static class MediaBrowserSubscriptionCallback extends MediaBrowserCompat.SubscriptionCallback {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,9 @@ public class MusicService extends MediaBrowserServiceCompat {
|
|||||||
IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);;
|
IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);;
|
||||||
|
|
||||||
public void updateNotification() {
|
public void updateNotification() {
|
||||||
|
|
||||||
MediaMetadataCompat metadataCompat = MusicContainer.getInstance().getNowPlayMetadataCompat();
|
MediaMetadataCompat metadataCompat = MusicContainer.getInstance().getNowPlayMetadataCompat();
|
||||||
|
System.out.println("更新通知栏:"+metadataCompat.getString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID));
|
||||||
mediaSession.setMetadata(metadataCompat);
|
mediaSession.setMetadata(metadataCompat);
|
||||||
mediaSession.setActive(true);
|
mediaSession.setActive(true);
|
||||||
Notification notification =
|
Notification notification =
|
||||||
|
@ -51,7 +51,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private TextView positionTime, durationTime, bitRate;
|
private TextView positionTime, durationTime, bitRate;
|
||||||
private SeekBar seekBar;
|
private SeekBar seekBar;
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private KProgressHUD hud;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -64,11 +63,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
play.setOnClickListener(new View.OnClickListener() {
|
play.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (hud != null) {
|
|
||||||
hud.dismiss();
|
|
||||||
hud = null;
|
|
||||||
}
|
|
||||||
hud = AppTools.showLoading(MainActivity.this);
|
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -78,10 +73,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
browserHelper.getTransportControls().play();
|
browserHelper.getTransportControls().play();
|
||||||
}
|
}
|
||||||
if (hud != null && hud.isShowing()) {
|
|
||||||
hud.dismiss();
|
|
||||||
hud = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,19 +81,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
next.setOnClickListener(new View.OnClickListener() {
|
next.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (hud != null) {
|
|
||||||
hud.dismiss();
|
|
||||||
hud = null;
|
|
||||||
}
|
|
||||||
hud = AppTools.showLoading(MainActivity.this);
|
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
browserHelper.getTransportControls().skipToNext();
|
browserHelper.getTransportControls().skipToNext();
|
||||||
if (hud != null && hud.isShowing()) {
|
|
||||||
hud.dismiss();
|
|
||||||
hud = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -111,19 +95,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
previous.setOnClickListener(new View.OnClickListener() {
|
previous.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (hud != null) {
|
|
||||||
hud.dismiss();
|
|
||||||
hud = null;
|
|
||||||
}
|
|
||||||
hud = AppTools.showLoading(MainActivity.this);
|
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
browserHelper.getTransportControls().skipToPrevious();
|
browserHelper.getTransportControls().skipToPrevious();
|
||||||
if (hud != null && hud.isShowing()) {
|
|
||||||
hud.dismiss();
|
|
||||||
hud = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -141,19 +116,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
if (hud != null) {
|
|
||||||
hud.dismiss();
|
|
||||||
hud = null;
|
|
||||||
}
|
|
||||||
hud = AppTools.showLoading(MainActivity.this);
|
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (browserHelper.getTransportControls() != null)
|
if (browserHelper.getTransportControls() != null) {
|
||||||
browserHelper.getTransportControls().seekTo(MainActivity.this.seekBar.getProgress());
|
browserHelper.getTransportControls().seekTo(MainActivity.this.seekBar.getProgress());
|
||||||
if (hud != null && hud.isShowing()) {
|
|
||||||
hud.dismiss();
|
|
||||||
hud = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -200,7 +167,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
Intent intent = new Intent(
|
Intent intent = new Intent(
|
||||||
MainActivity.this, PlayLibsActivity.class);
|
MainActivity.this, PlayLibsActivity.class);
|
||||||
intent.putExtra("bar_pos",seekBar.getProgress());
|
intent.putExtra("bar_pos", seekBar.getProgress());
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
startActivity(intent, bundle);
|
startActivity(intent, bundle);
|
||||||
} else {
|
} else {
|
||||||
@ -251,13 +218,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
+ String.format(Locale.CHINA, "%02d", seconds));
|
+ String.format(Locale.CHINA, "%02d", seconds));
|
||||||
int model = ConfigTools.getPreferences().getInt("playModel", MusicContainer.PLAY_MODEL_RANDOM);
|
int model = ConfigTools.getPreferences().getInt("playModel", MusicContainer.PLAY_MODEL_RANDOM);
|
||||||
setPlayModelButton(model);
|
setPlayModelButton(model);
|
||||||
if (data.getImg(-1,-1) != null) {
|
if (data.getImg(-1, -1) != null) {
|
||||||
setImage(data);
|
setImage(data);
|
||||||
} else {
|
} else {
|
||||||
new Timer().schedule(new TimerTask() {
|
new Timer().schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (data.getImg(-1,-1) != null) {
|
if (data.getImg(-1, -1) != null) {
|
||||||
AppData.handler.post(new Runnable() {
|
AppData.handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -294,10 +261,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void setImage(MusicData data) {
|
private void setImage(MusicData data) {
|
||||||
setBarColor(data.getImageColor());
|
setBarColor(data.getImageColor());
|
||||||
Glide.with(this).load(data.getImg(-1,-1))
|
Glide.with(this).load(data.getImg(-1, -1))
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
||||||
.into(album_image);
|
.into(album_image);
|
||||||
Glide.with(this).load(data.getImg(200,200))
|
Glide.with(this).load(data.getImg(200, 200))
|
||||||
.apply(RequestOptions.bitmapTransform(new BlurTransformation(25, 3)))
|
.apply(RequestOptions.bitmapTransform(new BlurTransformation(25, 3)))
|
||||||
.into(background_image);
|
.into(background_image);
|
||||||
}
|
}
|
||||||
@ -326,9 +293,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if(browserHelper!=null){
|
if (browserHelper != null) {
|
||||||
browserHelper.onStop();
|
browserHelper.onStop();
|
||||||
browserHelper=null;
|
browserHelper = null;
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user