提交 09c8f87e 编写于 作者: W wm

加入桌面小部件

上级 ea4e25e9
......@@ -17,8 +17,9 @@
![](https://github.com/aa112901/remusic/blob/master/screenshot/play_change.png)
![](https://github.com/aa112901/remusic/blob/master/screenshot/device-2016-03-26-123242.png)
![](https://github.com/aa112901/remusic/blob/master/screenshot/device-2016-03-26-123513.png)
![](https://github.com/aa112901/remusic/blob/master/screenshot/device-2016-03-24-134009%20(%E5%A4%8D%E5%88%B6).png)
![](https://github.com/aa112901/remusic/blob/master/screenshot/device-2016-03-24-134324%20(%E5%A4%8D%E5%88%B6).png)
![](https://github.com/aa112901/remusic/blob/master/screenshot/locked.png)
![](https://github.com/aa112901/remusic/blob/master/screenshot/widget.png)
#Credits
......@@ -33,6 +34,9 @@
- [MagicaSakura](https://github.com/Bilibili/MagicaSakura "MagicaSakura")
# Change Log
## 1.6
- 加入桌面小部件
- 修正动画和一些问题
## 12.23
- 加入锁屏控制
......
无法预览此类型文件
......@@ -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/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" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<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" />
......@@ -75,6 +68,13 @@
<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" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<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" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......
......@@ -75,6 +75,7 @@
android:noHistory="true"
android:taskAffinity="com.package.name.lockscreen"
android:theme="@style/LockScreenTheme"/>
<activity android:name=".request.UiMonitorActivity"/>
<service android:name=".downmusic.DownService">
<intent-filter>
......@@ -91,9 +92,7 @@
</service>
<service
android:name=".service.MediaService"
android:process=":main"
/>
android:process=":main" />
<receiver android:name=".receiver.MediaButtonIntentReceiver">
<intent-filter>
......@@ -108,6 +107,17 @@
</intent-filter>
</receiver>
<receiver android:name=".widget.SimpleWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.wm.remusic.metachanged"/>
<action android:name="com.wm.remusi.change_music"/>
<action android:name="com.wm.remusic.progress"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/appwidget_info" />
</receiver>
</application>
</manifest>
......@@ -18,10 +18,12 @@ package com.bilibili.magicasakura.widgets;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
......@@ -106,8 +108,15 @@ public class AppCompatImageHelper extends AppCompatBaseHelper {
*/
private void setImageDrawable(Drawable drawable) {
if (skipNextApply()) return;
if(drawable instanceof AnimationDrawable){
Log.e("drawable","instanceof true");
AnimationDrawable drawable1 = ((AnimationDrawable) drawable);
((ImageView) mView).setImageDrawable(drawable1);
drawable1.start();
}else {
((ImageView) mView).setImageDrawable(drawable);
}
((ImageView) mView).setImageDrawable(drawable);
}
private boolean setSupportImageTint(int resId) {
......@@ -133,23 +142,56 @@ public class AppCompatImageHelper extends AppCompatBaseHelper {
private boolean applySupportImageTint() {
Drawable image = ((ImageView) mView).getDrawable();
AnimationDrawable animationDrawable = null;
if(image instanceof AnimationDrawable){
Log.e("drawable","is animationdrawable");
animationDrawable = ((AnimationDrawable) image);
//image = animationDrawable;
}
if (image != null && mImageTintInfo != null && mImageTintInfo.mHasTintList) {
Drawable tintDrawable = image.mutate();
tintDrawable = DrawableCompat.wrap(tintDrawable);
if (mImageTintInfo.mHasTintList) {
DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList);
}
if (mImageTintInfo.mHasTintMode) {
DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode);
}
if (tintDrawable.isStateful()) {
tintDrawable.setState(mView.getDrawableState());
}
setImageDrawable(tintDrawable);
if (image == tintDrawable) {
tintDrawable.invalidateSelf();
if(animationDrawable != null){
Log.e("drawable","is animationdrawable not null");
Drawable tintDrawable = animationDrawable;
Log.e("drawable","start0");
tintDrawable = DrawableCompat.wrap(tintDrawable);
Log.e("drawable","start1");
if (mImageTintInfo.mHasTintList) {
DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList);
}
if (mImageTintInfo.mHasTintMode) {
DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode);
}
if (tintDrawable.isStateful()) {
tintDrawable.setState(mView.getDrawableState());
}
tintDrawable = DrawableCompat.unwrap(tintDrawable);
setImageDrawable(tintDrawable);
if (image == tintDrawable) {
Log.e("drawable","invalidateself");
// tintDrawable.invalidateSelf();
}
return true;
}else {
Drawable tintDrawable = image.mutate();
tintDrawable = DrawableCompat.wrap(tintDrawable);
if (mImageTintInfo.mHasTintList) {
DrawableCompat.setTintList(tintDrawable, mImageTintInfo.mTintList);
}
if (mImageTintInfo.mHasTintMode) {
DrawableCompat.setTintMode(tintDrawable, mImageTintInfo.mTintMode);
}
if (tintDrawable.isStateful()) {
tintDrawable.setState(mView.getDrawableState());
}
setImageDrawable(tintDrawable);
if (image == tintDrawable) {
tintDrawable.invalidateSelf();
}
return true;
}
return true;
}
return false;
}
......
......@@ -6,7 +6,6 @@ import android.os.Build;
import android.os.Environment;
import android.support.annotation.ColorInt;
import android.support.annotation.ColorRes;
import android.util.Log;
import com.bilibili.magicasakura.utils.ThemeUtils;
import com.facebook.cache.disk.DiskCacheConfig;
......@@ -28,8 +27,8 @@ import com.wm.remusic.uitl.ThemeHelper;
*/
public class MainApplication extends Application implements ThemeUtils.switchColor {
public static Context context;
//private RefWatcher refWatcher;
private static int MAX_MEM = (int) Runtime.getRuntime().maxMemory() / 3;
// private RefWatcher refWatcher;
private static int MAX_MEM = (int) Runtime.getRuntime().maxMemory() / 4;
//private static int MAX_MEM = 60 * ByteConstants.MB;
private long favPlaylist = IConstants.FAV_PLAYLIST;
private static Gson gson;
......@@ -142,16 +141,22 @@ public class MainApplication extends Application implements ThemeUtils.switchCol
public void onCreate() {
frescoInit();
super.onCreate();
// if (LeakCanary.isInAnalyzerProcess(this)) {
// // This process is dedicated to LeakCanary for heap analysis.
// // You should not init your app in this process.
// return;
// }
context = this;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Nammu.init(this);
}
ThemeUtils.setSwitchColor(this);
// refWatcher = LeakCanary.install(this);
initCatchException();
// refWatcher = LeakCanary.install(this);
// LeakCanary.install(this);
// initCatchException();
if (!PreferencesUtility.getInstance(this).getFavriateMusicPlaylist()) {
PlaylistInfo.getInstance(this).addPlaylist(favPlaylist, getResources().getString(R.string.my_fav_playlist),
......@@ -169,7 +174,6 @@ public class MainApplication extends Application implements ThemeUtils.switchCol
if (theme != null) {
colorId = getThemeColorId(context, colorId, theme);
}
Log.e("theme", "color" + " " + colorId);
return context.getResources().getColor(colorId);
}
......@@ -180,7 +184,6 @@ public class MainApplication extends Application implements ThemeUtils.switchCol
}
String theme = getTheme(context);
int colorId = -1;
Log.e("theme", "replacecolor");
if (theme != null) {
colorId = getThemeColor(context, originColor, theme);
}
......
......@@ -313,6 +313,12 @@ public class AlbumsDetailActivity extends BaseActivity implements ObservableScro
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
RequestThreadPool.finish();
}
private void setAlbumart() {
albumTitle.setText(albumName);
......
......@@ -247,6 +247,12 @@ public class ArtistDetailActivity extends BaseActivity implements ObservableScro
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
RequestThreadPool.finish();
}
ArtistInfo artistInfo;
private void setAlbumart() {
......
......@@ -50,12 +50,16 @@ public class BaseActivity extends AppCompatActivity implements ServiceConnection
public void updateTrackInfo() {
for (final MusicStateListener listener : mMusicListener) {
if (listener != null) {
listener.reloadAdapter();
listener.updateTrackInfo();
}
}
}
public void refreshUI() {
/**
* fragment界面刷新
*/
private void refreshUI() {
for (final MusicStateListener listener : mMusicListener) {
if (listener != null) {
listener.reloadAdapter();
......@@ -72,14 +76,15 @@ public class BaseActivity extends AppCompatActivity implements ServiceConnection
}
}
/**
* 歌曲切换
*/
public void updateTrack() {
for (final MusicStateListener listener : mMusicListener) {
if (listener != null) {
listener.updateTrackInfo();
}
}
}
public void updateLrc() {
}
......@@ -99,6 +104,13 @@ public class BaseActivity extends AppCompatActivity implements ServiceConnection
}
}
/**
* @param l 歌曲是否加载中
*/
public void loading(boolean l){
}
/**
* @param outState 取消保存状态
......@@ -153,6 +165,7 @@ public class BaseActivity extends AppCompatActivity implements ServiceConnection
f.addAction(MediaService.MUSIC_CHANGED);
f.addAction(MediaService.LRC_UPDATED);
f.addAction(IConstants.PLAYLIST_COUNT_CHANGED);
f.addAction(MediaService.MUSIC_LODING);
registerReceiver(mPlaybackStatus, new IntentFilter(f));
showQuickControl(true);
}
......@@ -221,7 +234,6 @@ public class BaseActivity extends AppCompatActivity implements ServiceConnection
BaseActivity baseActivity = mReference.get();
if (baseActivity != null) {
if (action.equals(MediaService.META_CHANGED)) {
baseActivity.refreshUI();
baseActivity.updateTrackInfo();
} else if (action.equals(MediaService.PLAYSTATE_CHANGED)) {
......@@ -230,8 +242,8 @@ public class BaseActivity extends AppCompatActivity implements ServiceConnection
baseActivity.updateTime();
} else if (action.equals(MediaService.BUFFER_UP)) {
baseActivity.updateBuffer(intent.getIntExtra("progress", 0));
} else if (action.equals(IConstants.EMPTY_LIST)) {
} else if (action.equals(MediaService.MUSIC_LODING)) {
baseActivity.loading(intent.getBooleanExtra("isloading",false));
} else if (action.equals(MediaService.REFRESH)) {
} else if (action.equals(IConstants.MUSIC_COUNT_CHANGED)) {
......
package com.wm.remusic.activity;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.drawable.Animatable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.facebook.common.executors.CallerThreadExecutor;
import com.facebook.common.logging.FLog;
import com.facebook.common.references.CloseableReference;
import com.facebook.datasource.DataSource;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.BaseControllerListener;
import com.facebook.drawee.controller.ControllerListener;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.core.ImagePipeline;
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber;
import com.facebook.imagepipeline.image.CloseableImage;
import com.facebook.imagepipeline.image.ImageInfo;
import com.facebook.imagepipeline.image.QualityInfo;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.wm.remusic.R;
......@@ -44,9 +28,7 @@ import com.wm.remusic.lrc.LrcRow;
import com.wm.remusic.provider.PlaylistsManager;
import com.wm.remusic.service.MediaService;
import com.wm.remusic.service.MusicPlayer;
import com.wm.remusic.service.MusicTrack;
import com.wm.remusic.uitl.IConstants;
import com.wm.remusic.uitl.ImageUtils;
import com.wm.remusic.widget.SildingFinishLayout;
import java.io.BufferedReader;
......@@ -118,7 +100,7 @@ public class LockActivity extends LockBaseActivity implements View.OnClickListen
});
mView.setTouchView(getWindow().getDecorView());
mHandler = HandlerUtil.getInstance(this);
mHandler.post(runnable);
mHandler.post(updateRunnable);
pre.setOnClickListener(this);
play.setOnClickListener(this);
next.setOnClickListener(this);
......@@ -129,7 +111,7 @@ public class LockActivity extends LockBaseActivity implements View.OnClickListen
@Override
protected void onUserLeaveHint() {
Log.d("aeon","onUserLeaveHint");
Log.d("lock","onUserLeaveHint");
super.onUserLeaveHint();
Intent intent = new Intent();
......@@ -139,7 +121,7 @@ public class LockActivity extends LockBaseActivity implements View.OnClickListen
finish();
}
Runnable runnable = new Runnable() {
Runnable updateRunnable = new Runnable() {
@Override
public void run() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm-MM月dd日 E", Locale.CHINESE);
......@@ -157,7 +139,7 @@ public class LockActivity extends LockBaseActivity implements View.OnClickListen
}else {
mLrc.setText(null);
}
mHandler.postDelayed(runnable,300);
mHandler.postDelayed(updateRunnable,300);
}
};
......@@ -188,6 +170,7 @@ public class LockActivity extends LockBaseActivity implements View.OnClickListen
intent.setAction(MediaService.LOCK_SCREEN);
intent.putExtra("islock",false);
sendBroadcast(intent);
mHandler.removeCallbacks(updateRunnable);
super.onDestroy();
Log.e("lock"," on destroy");
......@@ -318,17 +301,5 @@ public class LockActivity extends LockBaseActivity implements View.OnClickListen
return rows;
}
@Override
public boolean onKeyDown( int keyCode, KeyEvent event) {
Log.e("keys"," " + keyCode);
if (keyCode == KeyEvent.KEYCODE_HOME) {
Intent intent = new Intent();
intent.setAction(MediaService.LOCK_SCREEN);
intent.putExtra("islock",false);
sendBroadcast(intent);
finish();
}
return super.onKeyDown(keyCode, event);
}
}
......@@ -72,10 +72,7 @@ public class LockBaseActivity extends AppCompatActivity implements ServiceConnec
@Override
protected void onPause() {
super.onPause();
try {
unregisterReceiver(mPlaybackStatus);
} catch (final Throwable e) {
}
}
@Override
......@@ -86,7 +83,10 @@ public class LockBaseActivity extends AppCompatActivity implements ServiceConnec
@Override
protected void onStop() {
super.onStop();
try {
unregisterReceiver(mPlaybackStatus);
} catch (final Throwable e) {
}
}
@Override
......
......@@ -7,8 +7,10 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.media.AudioManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
......@@ -26,8 +28,11 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.view.animation.Transformation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
......@@ -41,6 +46,7 @@ import com.facebook.common.executors.CallerThreadExecutor;
import com.facebook.common.references.CloseableReference;
import com.facebook.datasource.DataSource;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.drawable.DrawableUtils;
import com.facebook.imagepipeline.core.ImagePipeline;
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber;
import com.facebook.imagepipeline.image.CloseableImage;
......@@ -63,6 +69,7 @@ import com.wm.remusic.uitl.ImageUtils;
import com.wm.remusic.uitl.L;
import com.wm.remusic.uitl.MusicUtils;
import com.wm.remusic.widget.AlbumViewPager;
import com.wm.remusic.widget.PlayerSeekBar;
import java.io.BufferedReader;
import java.io.FileInputStream;
......@@ -82,7 +89,7 @@ import static com.wm.remusic.service.MusicPlayer.getAlbumPath;
public class PlayingActivity extends BaseActivity implements IConstants {
private ImageView backAlbum, playingmode, control, next, pre, playlist, cmt, fav, down, more, needle;
private TextView timePlayed, duration;
private SeekBar mProgress;
private PlayerSeekBar mProgress;
private ActionBar ab;
private ObjectAnimator needleAnim, animator;
......@@ -101,8 +108,9 @@ public class PlayingActivity extends BaseActivity implements IConstants {
private FrameLayout albumLayout;
private RelativeLayout lrcViewContainer;
private LrcView mLrcView;
TextView tryGetLrc;
LinearLayout musicTool;
private TextView tryGetLrc;
private LinearLayout musicTool;
private SeekBar mVolumeSeek;
private boolean print = true;
private String TAG = PlayingActivity.class.getSimpleName();
......@@ -149,11 +157,14 @@ public class PlayingActivity extends BaseActivity implements IConstants {
down = (ImageView) findViewById(R.id.playing_down);
timePlayed = (TextView) findViewById(R.id.music_duration_played);
duration = (TextView) findViewById(R.id.music_duration);
mProgress = (SeekBar) findViewById(R.id.play_seek);
mProgress = (PlayerSeekBar) findViewById(R.id.play_seek);
needle = (ImageView) findViewById(R.id.needle);
mViewPager = (AlbumViewPager) findViewById(R.id.view_pager);
mViewPager.setOffscreenPageLimit(2);
mVolumeSeek = (SeekBar) findViewById(R.id.volume_seek);
mProgress.setIndeterminate(false);
mProgress.setProgress(1);
if(MusicPlayer.isTrackLocal()){
mProgress.setSecondaryProgress(100);
}
......@@ -197,6 +208,27 @@ public class PlayingActivity extends BaseActivity implements IConstants {
}
});
final AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
int v = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
int mMaxVol = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
mVolumeSeek.setMax(mMaxVol);
mVolumeSeek.setProgress(v);
mVolumeSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress ,AudioManager.ADJUST_SAME);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
......@@ -243,7 +275,6 @@ public class PlayingActivity extends BaseActivity implements IConstants {
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
// System.out.println(sb.toString());
rows = DefaultLrcParser.getIstance().getLrcRows(sb.toString());
} catch (IOException e) {
e.printStackTrace();
......@@ -251,33 +282,14 @@ public class PlayingActivity extends BaseActivity implements IConstants {
return rows;
}
int progress;
Runnable runnable = new Runnable() {
@Override
public void run() {
if (progress != 100) {
mProgress.incrementSecondaryProgressBy(progress);
} else {
progress += 10;
HandlerUtil.getInstance(PlayingActivity.this).postDelayed(runnable, 1000);
}
}
};
private void loadOther() {
new Thread(new Runnable() {
@Override
public void run() {
needleAnim = ObjectAnimator.ofFloat(needle, "rotation", -30, 0);
needleAnim.setDuration(60);
needleAnim.setRepeatMode(0);
needleAnim.setInterpolator(new LinearInterpolator());
needleAnim = ObjectAnimator.ofFloat(needle, "rotation", -30, 0);
needleAnim.setDuration(60);
needleAnim.setRepeatMode(0);
needleAnim.setInterpolator(new LinearInterpolator());
setSeekBarListener();
setTools();
}
}).start();
setSeekBarListener();
setTools();
}
......@@ -536,97 +548,116 @@ public class PlayingActivity extends BaseActivity implements IConstants {
}
public void updateTrack() {
Log.e("playing", " updatetrack");
new setBlurredAlbumArt().execute();
}
public void updateTrackInfo() {
if (MusicPlayer.getQueueSize() == 0) {
return;
}
if (!duetoplaypause) {
isFav = false;
long[] favlists = playlistsManager.getPlaylistIds(IConstants.FAV_PLAYLIST);
long currentid = MusicPlayer.getCurrentAudioId();
for(long i : favlists){
if(currentid == i){
isFav = true;
break;
if (MusicPlayer.getQueueSize() == 0) {
return;
}
if (!duetoplaypause) {
isFav = false;
long[] favlists = playlistsManager.getPlaylistIds(IConstants.FAV_PLAYLIST);
long currentid = MusicPlayer.getCurrentAudioId();
for(long i : favlists){
if(currentid == i){
isFav = true;
break;
}
}
updateFav(isFav);
updateLrc();
}
updateFav(isFav);
updateLrc();
}
duetoplaypause = false;
Fragment fragment = (RoundFragment) mViewPager.getAdapter().instantiateItem(mViewPager, mViewPager.getCurrentItem());
viewWeakReference = new WeakReference<View>(fragment.getView());
activeView = viewWeakReference.get();
if (activeView != null) {
// animatorWeakReference = new WeakReference<>((ObjectAnimator) activeView.getTag(R.id.tag_animator));
// animator = animatorWeakReference.get();
animator = (ObjectAnimator) activeView.getTag(R.id.tag_animator);
}
duetoplaypause = false;
ab.setTitle(MusicPlayer.getTrackName());
ab.setSubtitle(MusicPlayer.getArtistName());
Fragment fragment = (RoundFragment) mViewPager.getAdapter().instantiateItem(mViewPager, mViewPager.getCurrentItem());
if(fragment != null){
View v = fragment.getView();
if(v != null){
((ViewGroup) v).setAnimationCacheEnabled(false);
}
if(viewWeakReference != null)
viewWeakReference.clear();
viewWeakReference = new WeakReference<View>(v);
activeView = viewWeakReference.get();
}
duration.setText(MusicUtils.makeShortTimeString(PlayingActivity.this.getApplication(), MusicPlayer.duration() / 1000));
//mProgress.setMax((int) MusicPlayer.duration());
if (activeView != null) {
// animatorWeakReference = new WeakReference<>((ObjectAnimator) activeView.getTag(R.id.tag_animator));
// animator = animatorWeakReference.get();
animator = (ObjectAnimator) activeView.getTag(R.id.tag_animator);
}
mProgress.postDelayed(mUpdateProgress, 10);
ab.setTitle(MusicPlayer.getTrackName());
ab.setSubtitle(MusicPlayer.getArtistName());
if (MusicPlayer.isPlaying()) {
control.setImageResource(R.drawable.play_rdi_btn_pause);
duration.setText(MusicUtils.makeShortTimeString(PlayingActivity.this.getApplication(), MusicPlayer.duration() / 1000));
//mProgress.setMax((int) MusicPlayer.duration());
} else {
control.setImageResource(R.drawable.play_rdi_btn_play);
}
mProgress.postDelayed(mUpdateProgress, 10);
animatorSet = new AnimatorSet();
if (MusicPlayer.isPlaying()) {
if (animator != null && !animator.isRunning()) {
animatorSet.play(needleAnim).before(animator);
animatorSet.start();
}
if (MusicPlayer.isPlaying()) {
control.setImageResource(R.drawable.play_rdi_btn_pause);
} else {
if (needleAnim != null) {
needleAnim.reverse();
needleAnim.end();
} else {
control.setImageResource(R.drawable.play_rdi_btn_play);
}
if (animator != null && animator.isRunning()) {
animator.cancel();
float valueAvatar = (float) animator.getAnimatedValue();
animator.setFloatValues(valueAvatar, 360f + valueAvatar);
}
}
isNextOrPreSetPage = false;
if (MusicPlayer.getQueuePosition() + 1 != mViewPager.getCurrentItem()) {
mViewPager.setCurrentItem(MusicPlayer.getQueuePosition() + 1);
isNextOrPreSetPage = true;
}
animatorSet = new AnimatorSet();
if (MusicPlayer.isPlaying()) {
if (animatorSet != null && animator != null && !animator.isRunning() ) {
//修复从playactivity回到Main界面null
if(needleAnim == null){
needleAnim = ObjectAnimator.ofFloat(needle, "rotation", -30, 0);
needleAnim.setDuration(60);
needleAnim.setRepeatMode(0);
needleAnim.setInterpolator(new LinearInterpolator());
}
animatorSet.play(needleAnim).before(animator);
animatorSet.start();
}
} else {
if (needleAnim != null) {
needleAnim.reverse();
needleAnim.end();
}
if (animator != null && animator.isRunning()) {
animator.cancel();
float valueAvatar = (float) animator.getAnimatedValue();
animator.setFloatValues(valueAvatar, 360f + valueAvatar);
}
}
isNextOrPreSetPage = false;
if (MusicPlayer.getQueuePosition() + 1 != mViewPager.getCurrentItem()) {
mViewPager.setCurrentItem(MusicPlayer.getQueuePosition() + 1);
isNextOrPreSetPage = true;
}
}
@Override
public void updateTime() {
duration.setText(MusicUtils.makeShortTimeString(PlayingActivity.this.getApplication(), MusicPlayer.duration() / 1000));
duration.setText(MusicUtils.makeTimeString(MusicPlayer.duration()));
//mProgress.setMax((int) MusicPlayer.duration());
}
@Override
public void updateBuffer(int p) {
super.updateBuffer(p);
mProgress.setSecondaryProgress(p);
}
@Override
public void loading(boolean l) {
mProgress.setLoading(l);
}
private Runnable mUpdateProgress = new Runnable() {
......@@ -640,10 +671,10 @@ public class PlayingActivity extends BaseActivity implements IConstants {
if (duration > 0)
mProgress.setProgress((int) (mProgress.getMax() * position / duration));
timePlayed.setText(MusicUtils.makeShortTimeString(PlayingActivity.this.getApplication(), position / 1000));
}
if (MusicPlayer.isPlaying()) {
mProgress.postDelayed(mUpdateProgress, 100);
if(MusicPlayer.isPlaying()){
mProgress.postDelayed(mUpdateProgress, 50);
}
}
}
};
......@@ -696,13 +727,6 @@ public class PlayingActivity extends BaseActivity implements IConstants {
super.onPause();
}
@Override
public void onSaveInstanceState(Bundle outState) {
onBackPressed();
//super.onSaveInstanceState(outState);
}
@Override
public void onStop() {
super.onStop();
......@@ -781,7 +805,6 @@ public class PlayingActivity extends BaseActivity implements IConstants {
newOpts.inSampleSize = 6;
newOpts.inPreferredConfig = Bitmap.Config.RGB_565;
}
Log.e("albumuri", "start");
if (!MusicPlayer.isTrackLocal()) {
L.D(print, TAG, "music is net");
if (getAlbumPath() == null) {
......@@ -879,7 +902,7 @@ public class PlayingActivity extends BaseActivity implements IConstants {
backAlbum.setImageDrawable(td);
//去除过度绘制
td.setCrossFadeEnabled(true);
td.startTransition(370);
td.startTransition(200);
} else {
backAlbum.setImageDrawable(result);
......
......@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.net.Uri;
......@@ -312,7 +313,7 @@ public class PlaylistActivity extends BaseActivity implements ObservableScrollVi
}
return headerTranslationY;
}
private void loadAllLists() {
......@@ -442,6 +443,11 @@ public class PlaylistActivity extends BaseActivity implements ObservableScrollVi
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
RequestThreadPool.finish();
}
private void setAlbumart() {
playlistTitleView.setText(playlistName);
......
......@@ -8,55 +8,49 @@ import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.PopupWindow;
import com.google.gson.JsonArray;
import com.wm.remusic.MainApplication;
import com.wm.remusic.R;
import com.wm.remusic.downmusic.DownService;
import com.wm.remusic.json.GeDanGeInfo;
import com.wm.remusic.json.MusicFileDownInfo;
import com.wm.remusic.net.BMA;
import com.wm.remusic.net.HttpUtil;
import com.wm.remusic.net.MusicFileDownInfoGet;
import com.wm.remusic.net.RequestThreadPool;
import com.wm.remusic.uitl.PreferencesUtility;
import java.util.ArrayList;
public class LoadAllDownInfos extends AsyncTask<Void, Void, Void> {
Activity mContext;
private Activity mContext;
private ArrayList<GeDanGeInfo> mList = new ArrayList<GeDanGeInfo>();
private PopupWindow popupWindow;
private int size;
private ArrayList<String> urlList = new ArrayList<>();
public LoadAllDownInfos(Activity context, ArrayList<GeDanGeInfo> list) {
mContext = context;
mList = list;
}
PopupWindow popupWindow;
@Override
protected void onPreExecute() {
super.onPreExecute();
View view;
RotateAnimation animation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
animation.setDuration(5000);
animation.setRepeatCount(Animation.INFINITE);
animation.setInterpolator(new LinearInterpolator());
// RotateAnimation animation = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f,
// Animation.RELATIVE_TO_SELF, 0.5f);
// animation.setDuration(5000);
// animation.setRepeatCount(Animation.INFINITE);
// animation.setInterpolator(new LinearInterpolator());
if (popupWindow == null) {
LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.loading_circle, null);
ImageView imageView = (ImageView) view.findViewById(R.id.rotate);
//ImageView imageView = (ImageView) view.findViewById(R.id.rotate);
popupWindow = new PopupWindow(view, 200, 220);
imageView.setAnimation(animation);
//imageView.setAnimation(animation);
}
popupWindow.setFocusable(true);
......@@ -68,46 +62,64 @@ public class LoadAllDownInfos extends AsyncTask<Void, Void, Void> {
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
RequestThreadPool.finish();
cancel(true);
}
});
animation.start();
//animation.start();
}
int size;
ArrayList<String> urlList = new ArrayList<>();
SparseArray<MusicFileDownInfo> sparseArray = new SparseArray<>();
@Override
protected Void doInBackground(Void... params) {
int le = mList.size();
for (int j = 0; j < le; j++) {
int downloadBit = PreferencesUtility.getInstance(mContext).getDownMusicBit();
for (int i = 0; i < le; i++) {
RequestThreadPool.post(new MusicFileDownInfoGet(mList.get(i).getSong_id(), i, sparseArray, downloadBit));
}
int tryCount = 0;
while (sparseArray.size() != le && tryCount < 6000) {
tryCount++;
try {
JsonArray jsonArray = HttpUtil.getResposeJsonObject(BMA.Song.songInfo(mList.get(j).getSong_id())).get("songurl")
.getAsJsonObject().get("url").getAsJsonArray();
int len = jsonArray.size();
int downloadBit = PreferencesUtility.getInstance(mContext).getDownMusicBit();
MusicFileDownInfo musicFileDownInfo = null;
for (int i = len - 1; i > -1; i--) {
int bit = Integer.parseInt(jsonArray.get(i).getAsJsonObject().get("file_bitrate").toString());
if (bit == downloadBit) {
musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
} else if (bit < downloadBit && bit >= 64) {
musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
}
}
if (musicFileDownInfo != null) {
urlList.add(musicFileDownInfo.getShow_link());
size += musicFileDownInfo.getFile_size();
}
} catch (Exception e) {
Thread.sleep(30);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
for (int i = 0; i < le; i++) {
size += sparseArray.get(i).getFile_size();
urlList.add(sparseArray.get(i).getFile_link());
}
// for (int j = 0; j < le; j++) {
// try {
// JsonArray jsonArray = HttpUtil.getResposeJsonObject(BMA.Song.songInfo(mList.get(j).getSong_id())).get("songurl")
// .getAsJsonObject().get("url").getAsJsonArray();
// int len = jsonArray.size();
//
// int downloadBit = PreferencesUtility.getInstance(mContext).getDownMusicBit();
// MusicFileDownInfo musicFileDownInfo = null;
// for (int i = len - 1; i > -1; i--) {
// int bit = Integer.parseInt(jsonArray.get(i).getAsJsonObject().get("file_bitrate").toString());
// if (bit == downloadBit) {
// musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
// } else if (bit < downloadBit && bit >= 64) {
// musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
// }
// }
// if (musicFileDownInfo != null) {
// urlList.add(musicFileDownInfo.getShow_link());
// size += musicFileDownInfo.getFile_size();
// }
//
//
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// }
return null;
}
......@@ -154,6 +166,7 @@ public class LoadAllDownInfos extends AsyncTask<Void, Void, Void> {
setNegativeButton(mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
RequestThreadPool.finish();
dialog.dismiss();
}
}).show();
......
......@@ -113,6 +113,7 @@ public class MusicFragment extends BaseFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.load_framelayout, container, false);
Log.e("musicfrag","oncreateview");
frameLayout = (FrameLayout) view.findViewById(R.id.loadframe);
View loadView = LayoutInflater.from(getActivity()).inflate(R.layout.loading, frameLayout, false);
frameLayout.addView(loadView);
......
......@@ -28,6 +28,7 @@ import com.wm.remusic.uitl.IConstants;
import com.wm.remusic.widget.DividerItemDecoration;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
......@@ -91,9 +92,12 @@ public class PlayQueueFragment extends DialogFragment {
public void onClick(View v) {
MusicPlayer.clearQueue();
MusicPlayer.stop();
Intent intent = new Intent(IConstants.EMPTY_LIST);
intent.putExtra("showorhide", "hide");
getActivity().sendBroadcast(intent);
File file = new File(getContext().getCacheDir().getAbsolutePath() + "playlist");
if(file.exists()){
file.delete();
}
MusicPlaybackState.getInstance(getContext()).clearQueue();
if(adapter != null)
adapter.notifyDataSetChanged();
dismiss();
}
......
......@@ -6,7 +6,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -72,7 +71,6 @@ public class QuickControlsFragment extends BaseFragment {
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.bottom_nav, container, false);
this.rootView = rootView;
mPlayPause = (TintImageView) rootView.findViewById(R.id.control);
mProgress = (TintProgressBar) rootView.findViewById(R.id.song_progress_normal);
mTitle = (TextView) rootView.findViewById(R.id.playbar_info);
......@@ -229,6 +227,13 @@ public class QuickControlsFragment extends BaseFragment {
}
@Override
public void onDestroy() {
super.onDestroy();
mProgress.removeCallbacks(mUpdateProgress);
}
public void updateState() {
if (MusicPlayer.isPlaying()) {
mPlayPause.setImageResource(R.drawable.playbar_btn_pause);
......
......@@ -8,6 +8,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -54,7 +55,7 @@ public class RoundFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_roundimage, container, false);
((ViewGroup) rootView).setAnimationCacheEnabled(false);
if (getArguments() != null) {
albumPath = getArguments().getString("album");
}
......@@ -200,9 +201,13 @@ public class RoundFragment extends Fragment {
@Override
public void onDestroy() {
super.onDestroy();
Log.e("roundfragment"," id = " + hashCode());
if (animator != null) {
animator = null;
Log.e("roundfragment"," id = " + hashCode() + " , animator destroy");
}
// RefWatcher refWatcher = MainApplication.getRefWatcher(getActivity());
// refWatcher.watch(this);
}
......
......@@ -94,7 +94,7 @@ public class TabPagerFragment extends Fragment {
viewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
if (viewPager != null) {
setupViewPager(viewPager);
viewPager.setOffscreenPageLimit(2);
viewPager.setOffscreenPageLimit(3);
}
final TabLayout tabLayout = (TabLayout) rootView.findViewById(R.id.tabs);
......
......@@ -110,19 +110,6 @@ public class RecommendFragment extends Fragment {
LinearLayout linearLayout;
public String getThisMonthDate() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cc2 = Calendar.getInstance();
int maxMonthDay = cc2.getActualMaximum(Calendar.DAY_OF_MONTH);
cc2.set(cc2.get(Calendar.YEAR), cc2.get(Calendar.MONTH), maxMonthDay, 23, 59, 59);
String end = sdf.format(cc2.getTime());
cc2.set(cc2.get(Calendar.YEAR), cc2.get(Calendar.MONTH), 1, 0, 0, 0);
String start = sdf.format(cc2.getTime());
return start + "|" + end;
}
private void reloadAdapter() {
new AsyncTask<Void, Void, Void>() {
......
package com.wm.remusic.net;
import android.util.SparseArray;
import com.google.gson.JsonArray;
import com.wm.remusic.MainApplication;
import com.wm.remusic.json.MusicFileDownInfo;
public class MusicFileDownInfoGet implements Runnable {
String id;
int p;
SparseArray<MusicFileDownInfo> arrayList;
int downloadBit;
public MusicFileDownInfoGet(String id, int position, SparseArray<MusicFileDownInfo> arrayList, int bit) {
this.id = id;
p = position;
this.arrayList = arrayList;
downloadBit = bit;
}
@Override
public void run() {
try {
JsonArray jsonArray = HttpUtil.getResposeJsonObject(BMA.Song.songInfo(id)).get("songurl")
.getAsJsonObject().get("url").getAsJsonArray();
int len = jsonArray.size();
MusicFileDownInfo musicFileDownInfo = null;
for (int i = len - 1; i > -1; i--) {
int bit = Integer.parseInt(jsonArray.get(i).getAsJsonObject().get("file_bitrate").toString());
if (bit == downloadBit) {
musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
} else if (bit < downloadBit && bit >= 64) {
musicFileDownInfo = MainApplication.gsonInstance().fromJson(jsonArray.get(i), MusicFileDownInfo.class);
}
}
synchronized (this) {
if (musicFileDownInfo != null) {
arrayList.put(p, musicFileDownInfo);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
package com.wm.remusic.net;
import com.wm.remusic.json.MusicDetailInfo;
import java.util.ArrayList;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
......@@ -39,12 +34,14 @@ public class RequestThreadPool {
workQueue);
}
public static boolean isTerminated(){
public static boolean isTerminated() {
return mInstance.mThreadPoolExec.isTerminated();
}
public static void finish() {
mInstance.mThreadPoolExec.shutdown();
mInstance = null;
if (mInstance != null) {
mInstance.mThreadPoolExec.shutdown();
mInstance = null;
}
}
}
......@@ -151,6 +151,8 @@ public class MediaService extends Service {
public static final String TRY_GET_TRACKINFO = "com.wm.remusic.gettrackinfo";
public static final String BUFFER_UP = "com.wm.remusic.bufferup";
public static final String LOCK_SCREEN = "com.wm.remusic.lock";
public static final String SEND_PROGRESS = "com.wm.remusic.progress";
public static final String MUSIC_LODING = "com.wm.remusic.loading";
private static final String SHUTDOWN = "com.wm.remusic.shutdown";
public static final int NEXT = 2;
public static final int LAST = 3;
......@@ -391,6 +393,7 @@ public class MediaService extends Service {
filter.addAction(TRY_GET_TRACKINFO);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(LOCK_SCREEN);
filter.addAction(SEND_PROGRESS);
// Attach the broadcast listener
registerReceiver(mIntentReceiver, filter);
......@@ -589,15 +592,33 @@ public class MediaService extends Service {
if(isPlaying() && !isLocked){
Intent lockscreen = new Intent(this, LockActivity.class);
lockscreen.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
lockscreen.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(lockscreen);
}
} else if (MediaService.LOCK_SCREEN.equals(action)){
} else if (LOCK_SCREEN.equals(action)){
isLocked = intent.getBooleanExtra("islock",true);
Log.e("lock","isloced = " + isLocked);
} else if(SEND_PROGRESS.equals(action)){
Log.e("widget","mediaservce sendprogress");
if(isPlaying() && !isSending){
mPlayerHandler.post(sendDuration);
isSending = true;
}else if(!isPlaying()) {
mPlayerHandler.removeCallbacks(sendDuration);
isSending = false;
}
}
}
boolean isLocked;
private boolean isSending = false;
private Runnable sendDuration = new Runnable() {
@Override
public void run() {
notifyChange(SEND_PROGRESS);
mPlayerHandler.postDelayed(sendDuration,1000);
}
};
private boolean isLocked;
private void updateNotification() {
final int newNotifyMode;
if (isPlaying()) {
......@@ -1284,7 +1305,13 @@ public class MediaService extends Service {
private void notifyChange(final String what) {
if (D) Log.d(TAG, "notifyChange: what = " + what);
if(SEND_PROGRESS.equals(what)){
final Intent intent = new Intent(what);
intent.putExtra("position", position());
intent.putExtra("duration", duration());
sendStickyBroadcast(intent);
return;
}
// Update the lockscreen controls
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
......@@ -1404,7 +1431,6 @@ 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);
......@@ -1600,7 +1626,7 @@ public class MediaService extends Service {
e.printStackTrace();
}
}
if (mPlaylist.size() > 0) {
if ((mPlaylist.size() == mPlaylistInfo.size()) && mPlaylist.size() > 0) {
final int pos = mPreferences.getInt("curpos", 0);
if (pos < 0 || pos >= mPlaylist.size()) {
mPlaylist.clear();
......@@ -1651,7 +1677,14 @@ public class MediaService extends Service {
}
}
mShuffleMode = shufmode;
}else {
File file = new File(getCacheDir().getAbsolutePath() + "playlist");
if(file.exists()){
file.delete();
}
MusicPlaybackState.getInstance(this).clearQueue();
}
notifyChange(MUSIC_CHANGED);
}
public boolean openFile(final String path) {
......@@ -2476,6 +2509,12 @@ public class MediaService extends Service {
notifyChange(PLAYLIST_CHANGED);
}
public void loading(boolean l){
Intent intent = new Intent(MUSIC_LODING);
intent.putExtra("isloading",l);
sendBroadcast(intent);
}
public void setLockscreenAlbumArt(boolean enabled) {
mShowAlbumArtOnLockscreen = enabled;
notifyChange(META_CHANGED);
......@@ -2820,6 +2859,7 @@ public class MediaService extends Service {
mService.get().sendUpdateBuffer(100);
mCurrentMediaPlayer.start();
} else {
mService.get().loading(true);
handler.postDelayed(startMediaPlayerIfPrepared, 50);
}
mService.get().notifyChange(MUSIC_CHANGED);
......@@ -2887,6 +2927,7 @@ public class MediaService extends Service {
mService.get().gotoNext(true);
Log.e("play to go", "");
}
mService.get().loading(false);
} else {
handler.postDelayed(startMediaPlayerIfPrepared, 700);
}
......
......@@ -692,7 +692,9 @@ public class MusicPlayer {
}
public static void clearQueue() {
try {
if(mService != null)
mService.removeTracks(0, Integer.MAX_VALUE);
} catch (final RemoteException ignored) {
}
......
......@@ -3,28 +3,27 @@ package com.wm.remusic.uitl;
import android.util.Log;
import com.wm.remusic.info.AlbumInfo;
import com.wm.remusic.info.MusicInfo;
import java.util.Comparator;
public class AlbumComparator implements Comparator<AlbumInfo> {
@Override
@Override
public int compare(AlbumInfo a1, AlbumInfo a2) {
String py1 = a1.album_sort;
String py2 = a2.album_sort;
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
// 判断是否为空""
if (isEmpty(py1) && isEmpty(py2))
return 0;
if (isEmpty(py1))
return -1;
if (isEmpty(py2))
if (isEmpty(py1) && isEmpty(py2))
return 0;
if (isEmpty(py1))
return -1;
if (isEmpty(py2))
return 1;
return py1.compareTo(py2);
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
\ No newline at end of file
......@@ -2,29 +2,28 @@ package com.wm.remusic.uitl;
import android.util.Log;
import com.wm.remusic.info.AlbumInfo;
import com.wm.remusic.info.ArtistInfo;
import java.util.Comparator;
public class ArtistComparator implements Comparator<ArtistInfo> {
@Override
@Override
public int compare(ArtistInfo a1, ArtistInfo a2) {
String py1 = a1.artist_sort;
String py2 = a2.artist_sort;
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
// 判断是否为空""
if (isEmpty(py1) && isEmpty(py2))
return 0;
if (isEmpty(py1))
return -1;
if (isEmpty(py2))
if (isEmpty(py1) && isEmpty(py2))
return 0;
if (isEmpty(py1))
return -1;
if (isEmpty(py2))
return 1;
return py1.compareTo(py2);
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
\ No newline at end of file
......@@ -2,29 +2,28 @@ package com.wm.remusic.uitl;
import android.util.Log;
import com.wm.remusic.info.ArtistInfo;
import com.wm.remusic.info.FolderInfo;
import java.util.Comparator;
public class FolderComparator implements Comparator<FolderInfo> {
@Override
@Override
public int compare(FolderInfo a1, FolderInfo a2) {
String py1 = a1.folder_sort;
String py2 = a2.folder_sort;
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
// 判断是否为空""
if (isEmpty(py1) && isEmpty(py2))
return 0;
if (isEmpty(py1))
return -1;
if (isEmpty(py2))
if (isEmpty(py1) && isEmpty(py2))
return 0;
if (isEmpty(py1))
return -1;
if (isEmpty(py2))
return 1;
return py1.compareTo(py2);
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
\ No newline at end of file
......@@ -7,16 +7,16 @@ import com.wm.remusic.info.FolderInfo;
import java.util.Comparator;
public class FolderCountComparator implements Comparator<FolderInfo> {
@Override
@Override
public int compare(FolderInfo a1, FolderInfo a2) {
Integer py1 = a1.folder_count;
Integer py2 = a2.folder_count;
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
return py2.compareTo(py1);
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@
package com.wm.remusic.uitl;
/**
* <p/>
* <p>
* 常量接口
*/
public interface IConstants {
......
......@@ -7,23 +7,23 @@ import com.wm.remusic.info.MusicInfo;
import java.util.Comparator;
public class MusicComparator implements Comparator<MusicInfo> {
@Override
@Override
public int compare(MusicInfo m1, MusicInfo m2) {
String py1 = m1.sort;
String py2 = m2.sort;
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
Log.e("compare", "py1 = " + py1 + " py2 = " + py2);
// 判断是否为空""
if (isEmpty(py1) && isEmpty(py2))
return 0;
if (isEmpty(py1))
return -1;
if (isEmpty(py2))
if (isEmpty(py1) && isEmpty(py2))
return 0;
if (isEmpty(py1))
return -1;
if (isEmpty(py2))
return 1;
return py1.compareTo(py2);
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
private boolean isEmpty(String str) {
return "".equals(str.trim());
}
}
\ No newline at end of file
......@@ -12,11 +12,11 @@ import android.util.Log;
import android.widget.TextView;
public class CustomTextView extends TextView {
private final static String TAG = CustomTextView.class.getSimpleName();
private Paint paint1;
private Paint paint2;
private int mWidth;
private LinearGradient gradient;
private Matrix matrix;
......@@ -38,20 +38,20 @@ public class CustomTextView extends TextView {
paint1.setStyle(Paint.Style.FILL);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if(mWidth == 0){
Log.e(TAG,"*********************");
if (mWidth == 0) {
Log.e(TAG, "*********************");
mWidth = getMeasuredWidth();
paint2 = getPaint();
//颜色渐变器
gradient = new LinearGradient(0, 0, mWidth, 0, new int[]{Color.GRAY,Color.WHITE,Color.GRAY}, new float[]{
0.3f,0.5f,1.0f
gradient = new LinearGradient(0, 0, mWidth, 0, new int[]{Color.GRAY, Color.WHITE, Color.GRAY}, new float[]{
0.3f, 0.5f, 1.0f
}, Shader.TileMode.CLAMP);
paint2.setShader(gradient);
matrix = new Matrix();
}
}
......@@ -59,9 +59,9 @@ public class CustomTextView extends TextView {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if(matrix !=null){
if (matrix != null) {
deltaX += mWidth / 5;
if(deltaX > 2 * mWidth){
if (deltaX > 2 * mWidth) {
deltaX = -mWidth;
}
}
......
/*
* Copyright (C) 2011 The Android Open Source Project
*
* 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.
*/
package com.wm.remusic.widget;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
/**
* Implementation of {@link android.support.v4.view.PagerAdapter} that
* uses a {@link Fragment} to manage each page. This class also handles
* saving and restoring of fragment's state.
*
* <p>This version of the pager is more useful when there are a large number
* of pages, working more like a list view. When pages are not visible to
* the user, their entire fragment may be destroyed, only keeping the saved
* state of that fragment. This allows the pager to hold on to much less
* memory associated with each visited page as compared to
* {@link FragmentPagerAdapter} at the cost of potentially more overhead when
* switching between pages.
*
* <p>When using FragmentPagerAdapter the host ViewPager must have a
* valid ID set.</p>
*
* <p>Subclasses only need to implement {@link #getItem(int)}
* and {@link #getCount()} to have a working adapter.
*
* <p>Here is an example implementation of a pager containing fragments of
* lists:
*
* {@sample development/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java
* complete}
*
* <p>The <code>R.layout.fragment_pager</code> resource of the top-level fragment is:
*
* {@sample development/samples/Support13Demos/res/layout/fragment_pager.xml
* complete}
*
* <p>The <code>R.layout.fragment_pager_list</code> resource containing each
* individual fragment's layout is:
*
* {@sample development/samples/Support13Demos/res/layout/fragment_pager_list.xml
* complete}
*/
public abstract class FragmentStatePagerAdapter extends PagerAdapter {
private static final String TAG = "FragmentStatePagerAdapter";
private static final boolean DEBUG = false;
private final FragmentManager mFragmentManager;
private FragmentTransaction mCurTransaction = null;
private ArrayList<Fragment.SavedState> mSavedState = new ArrayList<Fragment.SavedState>();
private ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
private Fragment mCurrentPrimaryItem = null;
public FragmentStatePagerAdapter(FragmentManager fm) {
mFragmentManager = fm;
}
/**
* Return the Fragment associated with a specified position.
*/
public abstract Fragment getItem(int position);
@Override
public void startUpdate(ViewGroup container) {
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
// If we already have this item instantiated, there is nothing
// to do. This can happen when we are restoring the entire pager
// from its saved state, where the fragment manager has already
// taken care of restoring the fragments we previously had instantiated.
if (mFragments.size() > position) {
Fragment f = mFragments.get(position);
if (f != null) {
return f;
}
}
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
}
Fragment fragment = getItem(position);
if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
if (mSavedState.size() > position) {
Fragment.SavedState fss = mSavedState.get(position);
if (fss != null) {
fragment.setInitialSavedState(fss);
}
}
while (mFragments.size() <= position) {
mFragments.add(null);
}
fragment.setMenuVisibility(false);
fragment.setUserVisibleHint(false);
mFragments.set(position, fragment);
mCurTransaction.add(container.getId(), fragment);
return fragment;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
Fragment fragment = (Fragment) object;
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction();
}
if (DEBUG) Log.v(TAG, "Removing item #" + position + ": f=" + object
+ " v=" + ((Fragment)object).getView());
while (mSavedState.size() <= position) {
mSavedState.add(null);
}
mSavedState.set(position, fragment.isAdded()
? mFragmentManager.saveFragmentInstanceState(fragment) : null);
mFragments.set(position, null);
mCurTransaction.remove(fragment);
}
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
Fragment fragment = (Fragment)object;
if (fragment != mCurrentPrimaryItem) {
if (mCurrentPrimaryItem != null) {
mCurrentPrimaryItem.setMenuVisibility(false);
mCurrentPrimaryItem.setUserVisibleHint(false);
}
if (fragment != null) {
fragment.setMenuVisibility(true);
fragment.setUserVisibleHint(true);
}
mCurrentPrimaryItem = fragment;
}
}
@Override
public void finishUpdate(ViewGroup container) {
if (mCurTransaction != null) {
mCurTransaction.commitAllowingStateLoss();
mCurTransaction = null;
mFragmentManager.executePendingTransactions();
}
}
@Override
public boolean isViewFromObject(View view, Object object) {
return ((Fragment)object).getView() == view;
}
@Override
public Parcelable saveState() {
Bundle state = null;
if (mSavedState.size() > 0) {
state = new Bundle();
Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
mSavedState.toArray(fss);
state.putParcelableArray("states", fss);
}
for (int i=0; i<mFragments.size(); i++) {
Fragment f = mFragments.get(i);
if (f != null && f.isAdded()) {
if (state == null) {
state = new Bundle();
}
String key = "f" + i;
mFragmentManager.putFragment(state, key, f);
}
}
return state;
}
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
if (state != null) {
Bundle bundle = (Bundle)state;
bundle.setClassLoader(loader);
Parcelable[] fss = bundle.getParcelableArray("states");
mSavedState.clear();
mFragments.clear();
if (fss != null) {
for (int i=0; i<fss.length; i++) {
mSavedState.add((Fragment.SavedState)fss[i]);
}
}
Iterable<String> keys = bundle.keySet();
for (String key: keys) {
if (key.startsWith("f")) {
int index = Integer.parseInt(key.substring(1));
Fragment f = mFragmentManager.getFragment(bundle, key);
if (f != null) {
while (mFragments.size() <= index) {
mFragments.add(null);
}
f.setMenuVisibility(false);
mFragments.set(index, f);
} else {
Log.w(TAG, "Bad fragment at key " + key);
}
}
}
}
}
}
package com.wm.remusic.widget;
import android.database.DataSetObservable;
import android.database.DataSetObserver;
import android.os.Parcelable;
import android.view.View;
import android.view.ViewGroup;
/**
* Base class providing the adapter to populate pages inside of
* a {@link ViewPager}. You will most likely want to use a more
* specific implementation of this, such as
* {@link android.support.v4.app.FragmentPagerAdapter} or
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
* <p>
* <p>When you implement a PagerAdapter, you must override the following methods
* at minimum:</p>
* <ul>
* <li>{@link #instantiateItem(ViewGroup, int)}</li>
* <li>{@link #destroyItem(ViewGroup, int, Object)}</li>
* <li>{@link #getCount()}</li>
* <li>{@link #isViewFromObject(View, Object)}</li>
* </ul>
* <p>
* <p>PagerAdapter is more general than the adapters used for
* {@link android.widget.AdapterView AdapterViews}. Instead of providing a
* View recycling mechanism directly ViewPager uses callbacks to indicate the
* steps taken during an update. A PagerAdapter may implement a form of View
* recycling if desired or use a more sophisticated method of managing page
* Views such as Fragment transactions where each page is represented by its
* own Fragment.</p>
* <p>
* <p>ViewPager associates each page with a key Object instead of working with
* Views directly. This key is used to track and uniquely identify a given page
* independent of its position in the adapter. A call to the PagerAdapter method
* {@link #startUpdate(ViewGroup)} indicates that the contents of the ViewPager
* are about to change. One or more calls to {@link #instantiateItem(ViewGroup, int)}
* and/or {@link #destroyItem(ViewGroup, int, Object)} will follow, and the end
* of an update will be signaled by a call to {@link #finishUpdate(ViewGroup)}.
* By the time {@link #finishUpdate(ViewGroup) finishUpdate} returns the views
* associated with the key objects returned by
* {@link #instantiateItem(ViewGroup, int) instantiateItem} should be added to
* the parent ViewGroup passed to these methods and the views associated with
* the keys passed to {@link #destroyItem(ViewGroup, int, Object) destroyItem}
* should be removed. The method {@link #isViewFromObject(View, Object)} identifies
* whether a page View is associated with a given key object.</p>
* <p>
* <p>A very simple PagerAdapter may choose to use the page Views themselves
* as key objects, returning them from {@link #instantiateItem(ViewGroup, int)}
* after creation and adding them to the parent ViewGroup. A matching
* {@link #destroyItem(ViewGroup, int, Object)} implementation would remove the
* View from the parent ViewGroup and {@link #isViewFromObject(View, Object)}
* could be implemented as <code>return view == object;</code>.</p>
* <p>
* <p>PagerAdapter supports data set changes. Data set changes must occur on the
* main thread and must end with a call to {@link #notifyDataSetChanged()} similar
* to AdapterView adapters derived from {@link android.widget.BaseAdapter}. A data
* set change may involve pages being added, removed, or changing position. The
* ViewPager will keep the current page active provided the adapter implements
* the method {@link #getItemPosition(Object)}.</p>
*/
public abstract class PagerAdapter {
private final DataSetObservable mObservable = new DataSetObservable();
private DataSetObserver mViewPagerObserver;
public static final int POSITION_UNCHANGED = -1;
public static final int POSITION_NONE = -2;
/**
* Return the number of views available.
*/
public abstract int getCount();
/**
* Called when a change in the shown pages is going to start being made.
*
* @param container The containing View which is displaying this adapter's
* page views.
*/
public void startUpdate(ViewGroup container) {
startUpdate((View) container);
}
/**
* Create the page for the given position. The adapter is responsible
* for adding the view to the container given here, although it only
* must ensure this is done by the time it returns from
* {@link #finishUpdate(ViewGroup)}.
*
* @param container The containing View in which the page will be shown.
* @param position The page position to be instantiated.
* @return Returns an Object representing the new page. This does not
* need to be a View, but can be some other container of the page.
*/
public Object instantiateItem(ViewGroup container, int position) {
return instantiateItem((View) container, position);
}
/**
* Remove a page for the given position. The adapter is responsible
* for removing the view from its container, although it only must ensure
* this is done by the time it returns from {@link #finishUpdate(ViewGroup)}.
*
* @param container The containing View from which the page will be removed.
* @param position The page position to be removed.
* @param object The same object that was returned by
* {@link #instantiateItem(View, int)}.
*/
public void destroyItem(ViewGroup container, int position, Object object) {
destroyItem((View) container, position, object);
}
/**
* Called to inform the adapter of which item is currently considered to
* be the "primary", that is the one show to the user as the current page.
*
* @param container The containing View from which the page will be removed.
* @param position The page position that is now the primary.
* @param object The same object that was returned by
* {@link #instantiateItem(View, int)}.
*/
public void setPrimaryItem(ViewGroup container, int position, Object object) {
setPrimaryItem((View) container, position, object);
}
/**
* Called when the a change in the shown pages has been completed. At this
* point you must ensure that all of the pages have actually been added or
* removed from the container as appropriate.
*
* @param container The containing View which is displaying this adapter's
* page views.
*/
public void finishUpdate(ViewGroup container) {
finishUpdate((View) container);
}
/**
* Called when a change in the shown pages is going to start being made.
*
* @param container The containing View which is displaying this adapter's
* page views.
* @deprecated Use {@link #startUpdate(ViewGroup)}
*/
public void startUpdate(View container) {
}
/**
* Create the page for the given position. The adapter is responsible
* for adding the view to the container given here, although it only
* must ensure this is done by the time it returns from
* {@link #finishUpdate(ViewGroup)}.
*
* @param container The containing View in which the page will be shown.
* @param position The page position to be instantiated.
* @return Returns an Object representing the new page. This does not
* need to be a View, but can be some other container of the page.
* @deprecated Use {@link #instantiateItem(ViewGroup, int)}
*/
public Object instantiateItem(View container, int position) {
throw new UnsupportedOperationException(
"Required method instantiateItem was not overridden");
}
/**
* Remove a page for the given position. The adapter is responsible
* for removing the view from its container, although it only must ensure
* this is done by the time it returns from {@link #finishUpdate(View)}.
*
* @param container The containing View from which the page will be removed.
* @param position The page position to be removed.
* @param object The same object that was returned by
* {@link #instantiateItem(View, int)}.
* @deprecated Use {@link #destroyItem(ViewGroup, int, Object)}
*/
public void destroyItem(View container, int position, Object object) {
throw new UnsupportedOperationException("Required method destroyItem was not overridden");
}
/**
* Called to inform the adapter of which item is currently considered to
* be the "primary", that is the one show to the user as the current page.
*
* @param container The containing View from which the page will be removed.
* @param position The page position that is now the primary.
* @param object The same object that was returned by
* {@link #instantiateItem(View, int)}.
* @deprecated Use {@link #setPrimaryItem(ViewGroup, int, Object)}
*/
public void setPrimaryItem(View container, int position, Object object) {
}
/**
* Called when the a change in the shown pages has been completed. At this
* point you must ensure that all of the pages have actually been added or
* removed from the container as appropriate.
*
* @param container The containing View which is displaying this adapter's
* page views.
* @deprecated Use {@link #finishUpdate(ViewGroup)}
*/
public void finishUpdate(View container) {
}
/**
* Determines whether a page View is associated with a specific key object
* as returned by {@link #instantiateItem(ViewGroup, int)}. This method is
* required for a PagerAdapter to function properly.
*
* @param view Page View to check for association with <code>object</code>
* @param object Object to check for association with <code>view</code>
* @return true if <code>view</code> is associated with the key object <code>object</code>
*/
public abstract boolean isViewFromObject(View view, Object object);
/**
* Save any instance state associated with this adapter and its pages that should be
* restored if the current UI state needs to be reconstructed.
*
* @return Saved state for this adapter
*/
public Parcelable saveState() {
return null;
}
/**
* Restore any instance state associated with this adapter and its pages
* that was previously saved by {@link #saveState()}.
*
* @param state State previously saved by a call to {@link #saveState()}
* @param loader A ClassLoader that should be used to instantiate any restored objects
*/
public void restoreState(Parcelable state, ClassLoader loader) {
}
/**
* Called when the host view is attempting to determine if an item's position
* has changed. Returns {@link #POSITION_UNCHANGED} if the position of the given
* item has not changed or {@link #POSITION_NONE} if the item is no longer present
* in the adapter.
* <p>
* <p>The default implementation assumes that items will never
* change position and always returns {@link #POSITION_UNCHANGED}.
*
* @param object Object representing an item, previously returned by a call to
* {@link #instantiateItem(View, int)}.
* @return object's new position index from [0, {@link #getCount()}),
* {@link #POSITION_UNCHANGED} if the object's position has not changed,
* or {@link #POSITION_NONE} if the item is no longer present.
*/
public int getItemPosition(Object object) {
return POSITION_UNCHANGED;
}
/**
* This method should be called by the application if the data backing this adapter has changed
* and associated views should update.
*/
public void notifyDataSetChanged() {
synchronized (this) {
if (mViewPagerObserver != null) {
mViewPagerObserver.onChanged();
}
}
mObservable.notifyChanged();
}
/**
* Register an observer to receive callbacks related to the adapter's data changing.
*
* @param observer The {@link DataSetObserver} which will receive callbacks.
*/
public void registerDataSetObserver(DataSetObserver observer) {
mObservable.registerObserver(observer);
}
/**
* Unregister an observer from callbacks related to the adapter's data changing.
*
* @param observer The {@link DataSetObserver} which will be unregistered.
*/
public void unregisterDataSetObserver(DataSetObserver observer) {
mObservable.unregisterObserver(observer);
}
void setViewPagerObserver(DataSetObserver observer) {
synchronized (this) {
mViewPagerObserver = observer;
}
}
/**
* This method may be called by the ViewPager to obtain a title string
* to describe the specified page. This method may return null
* indicating no title for this page. The default implementation returns
* null.
*
* @param position The position of the title requested
* @return A title for the requested page
*/
public CharSequence getPageTitle(int position) {
return null;
}
/**
* Returns the proportional width of a given page as a percentage of the
* ViewPager's measured width from (0.f-1.f]
*
* @param position The position of the page requested
* @return Proportional width for the given page position
*/
public float getPageWidth(int position) {
return 1.f;
}
}
\ No newline at end of file
package com.wm.remusic.widget;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.SeekBar;
import com.wm.remusic.R;
/**
* Created by wm on 2016/12/29.
*/
public class PlayerSeekBar extends SeekBar {
private boolean drawLoading = false;
private int degree = 0;
private Matrix matrix = new Matrix();
private Bitmap loading = BitmapFactory.decodeResource(getResources(), R.drawable.play_plybar_btn_loading);
private Drawable drawable;
public PlayerSeekBar(Context context) {
super(context);
}
public PlayerSeekBar(Context context, AttributeSet attrs) {
super(context, attrs);
setThumb(getContext().getResources().getDrawable(R.drawable.play_plybar_btn));
}
public void setLoading(boolean loading) {
if (loading) {
drawLoading = true;
invalidate();
} else {
drawLoading = false;
}
}
@Override
public void setThumb(Drawable thumb) {
Rect localRect = null;
if (drawable != null) {
localRect = drawable.getBounds();
}
super.setThumb(drawable);
drawable = thumb;
if ((localRect != null) && (drawable != null)) {
drawable.setBounds(localRect);
}
}
@Override
public Drawable getThumb() {
if (Build.VERSION.SDK_INT >= 16) {
return super.getThumb();
}
return drawable;
}
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (drawLoading) {
canvas.save();
degree = ((int) (degree + 3.0F));
degree %= 360;
matrix.reset();
matrix.postRotate(degree, loading.getWidth() / 2, loading.getHeight() / 2);
canvas.translate(getPaddingLeft() + getThumb().getBounds().left + drawable.getIntrinsicWidth() / 2 - loading.getWidth() / 2 - getThumbOffset(), getPaddingTop() + getThumb().getBounds().top + drawable.getIntrinsicHeight() / 2 - loading.getHeight() / 2);
canvas.drawBitmap(loading, matrix, null);
canvas.restore();
invalidate();
}
}
}
package com.wm.remusic.widget;
import android.util.Log;
import android.view.animation.Interpolator;
public class ReInterpolator implements Interpolator {
float current;
float lastValue;
boolean isrunning = true;
public void pause() {
isrunning = false;
}
public void start() {
isrunning = true;
}
public void reset() {
current = 0.0F;
lastValue = 0.0F;
isrunning = true;
}
public void clear() {
current = 0.0F;
lastValue = 0.0F;
isrunning = false;
}
public float getInterpolation(float paramFloat) {
Log.e("inter","float" + paramFloat);
if (isrunning) {
current = (paramFloat - lastValue);
Log.e("inter","current" + current);
return current;
}
lastValue = (paramFloat - current);
Log.e("inter","lastvalue = " + lastValue);
return current;
}
}
package com.wm.remusic.widget;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Animatable;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.BaseControllerListener;
import com.facebook.drawee.controller.ControllerListener;
import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
import com.facebook.drawee.generic.RoundingParams;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.image.ImageInfo;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.wm.remusic.R;
/**
* Created by wm on 2017/1/4.
*/
public class RoundView extends FrameLayout {
private View mView;
private SimpleDraweeView albumView;
public RoundView(Context context) {
super(context);
initView(context);
}
public RoundView(Context context, AttributeSet attrs) {
super(context, attrs);
initView(context);
}
public static RoundView getView(Context context, String str) {
RoundView view = new RoundView(context);
view.setAlbum(str);
return view;
}
private void initView(Context context) {
this.setAnimationCacheEnabled(false);
mView = LayoutInflater.from(context).inflate(R.layout.fragment_roundimage, null);
albumView = (SimpleDraweeView) mView.findViewById(R.id.sdv);
addView(mView);
//设置图像是否为圆形
rp.setRoundAsCircle(true);
//设置圆角半径
//rp.setCornersRadius(20);
//分别设置左上角、右上角、左下角、右下角的圆角半径
//rp.setCornersRadii(20,25,30,35);
//分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径
//rp.setCornersRadii(new float[]{20,25,30,35,40,45,50,55});
//设置边框颜色及其宽度
rp.setBorder(Color.BLACK, 6);
albumView.setHierarchy(hierarchy);
}
public void setAlbum(String albumPath) {
if (albumPath == null) {
albumView.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_play_song));
} else {
try {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(albumPath)).build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setOldController(albumView.getController())
.setImageRequest(request)
.setControllerListener(controllerListener)
.build();
albumView.setController(controller);
} catch (Exception e) {
e.printStackTrace();
}
}
Log.e("roundview", "setalbum = " + albumPath);
}
//初始化圆角圆形参数对象
RoundingParams rp = new RoundingParams();
//获取GenericDraweeHierarchy对象
GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
//设置圆形圆角参数
.setRoundingParams(rp)
//设置圆角半径
//.setRoundingParams(RoundingParams.fromCornersRadius(20))
//分别设置左上角、右上角、左下角、右下角的圆角半径
//.setRoundingParams(RoundingParams.fromCornersRadii(20,25,30,35))
//分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径
//.setRoundingParams(RoundingParams.fromCornersRadii(new float[]{20,25,30,35,40,45,50,55}))
//设置圆形圆角参数;RoundingParams.asCircle()是将图像设置成圆形
//.setRoundingParams(RoundingParams.asCircle())
//设置淡入淡出动画持续时间(单位:毫秒ms)
.setFadeDuration(300)
//构建
.build();
ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
}
@Override
public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
}
@Override
public void onFailure(String id, Throwable throwable) {
albumView.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_play_song));
}
};
}
package com.wm.remusic.widget;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.RemoteViews;
import com.facebook.common.executors.CallerThreadExecutor;
import com.facebook.common.references.CloseableReference;
import com.facebook.datasource.DataSource;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.core.ImagePipeline;
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber;
import com.facebook.imagepipeline.image.CloseableImage;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.wm.remusic.R;
import com.wm.remusic.info.MusicInfo;
import com.wm.remusic.provider.PlaylistsManager;
import com.wm.remusic.service.MediaService;
import com.wm.remusic.service.MusicPlayer;
import com.wm.remusic.uitl.IConstants;
import com.wm.remusic.uitl.ImageUtils;
import java.util.HashMap;
public class SimpleWidgetProvider extends AppWidgetProvider {
private SimpleWidgetProvider mProvider = null;
private boolean mStop = true;
private static String art,trackname ,albumuri;
private static boolean isTrackLocal = true;
private static Bitmap noBit;
private static boolean isFav ,isPlaying;
private static long currentId = -1;
private static long position,duration;
private static HashMap<String, Bitmap> albumMap = new HashMap<>(); //储存专辑封面的图片
private PendingIntent getPendingIntent(Context context, int buttonId) {
Intent intent = new Intent();
intent.setClass(context, SimpleWidgetProvider.class);
intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
intent.setData(Uri.parse("harvic:" + buttonId));
PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0);
return pi;
}
// 更新所有的 widget
private synchronized void pushUpdate(final Context context,AppWidgetManager appWidgetManager ,boolean updateProgress) {
Log.d("harvic", "pushupdate");
pushAction(context,MediaService.SEND_PROGRESS);
RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.simple_control_widget_layout);
//将按钮与点击事件绑定
remoteView.setOnClickPendingIntent(R.id.widget_play,getPendingIntent(context, R.id.widget_play));
remoteView.setOnClickPendingIntent(R.id.widget_pre, getPendingIntent(context, R.id.widget_pre));
remoteView.setOnClickPendingIntent(R.id.widget_next, getPendingIntent(context, R.id.widget_next));
remoteView.setOnClickPendingIntent(R.id.widget_love, getPendingIntent(context, R.id.widget_love));
remoteView.setTextViewText(R.id.widget_content,trackname == null && art == null ? "" : trackname + "-" + art);
remoteView.setProgressBar(R.id.widget_progress, (int) duration,(int) position,false);
isFav = false;
long[] favlists = PlaylistsManager.getInstance(context).getPlaylistIds(IConstants.FAV_PLAYLIST);
for(long i : favlists){
if(currentId == i){
isFav = true;
break;
}
}
Log.e("harvic", " isloved = " + isFav);
if (isFav) {
remoteView.setImageViewResource(R.id.widget_love,R.drawable.widget_unstar_selector);
} else {
remoteView.setImageViewResource(R.id.widget_love,R.drawable.widget_star_selector);
}
if(isPlaying){
remoteView.setImageViewResource(R.id.widget_play,R.drawable.widget_pause_selector);
}else {
remoteView.setImageViewResource(R.id.widget_play,R.drawable.widget_play_selector);
}
if(updateProgress){
if(albumuri == null){
remoteView.setImageViewResource(R.id.widget_image, R.drawable.placeholder_disk_210);
}else {
if(isTrackLocal){
Bitmap bitmap = ImageUtils.getArtworkQuick(context, Uri.parse(albumuri), 160, 160);
if (bitmap != null) {
remoteView.setImageViewBitmap(R.id.widget_image, bitmap);
}else {
remoteView.setImageViewResource(R.id.widget_image, R.drawable.placeholder_disk_210);
}
}else {
Bitmap bitmap = albumMap.get(albumuri);
if(bitmap != null)
remoteView.setImageViewBitmap(R.id.widget_image,bitmap);
}
}
}else {
if(albumuri == null){
remoteView.setImageViewResource(R.id.widget_image, R.drawable.placeholder_disk_210);
}else {
if(isTrackLocal){
final Bitmap bitmap = ImageUtils.getArtworkQuick(context, Uri.parse(albumuri), 160, 160);
if (bitmap != null) {
remoteView.setImageViewBitmap(R.id.widget_image, bitmap);
}else {
remoteView.setImageViewResource(R.id.widget_image, R.drawable.placeholder_disk_210);
}
albumMap.clear();
}else {
if (albumMap.get(albumuri) != null) {
remoteView.setImageViewBitmap(R.id.widget_image, albumMap.get(albumuri));
//noBit = null;
} else {
Uri uri = Uri.parse(albumuri);
if(uri == null){
noBit = BitmapFactory.decodeResource(context.getResources(), R.drawable.placeholder_disk_210);
albumMap.put(albumuri,noBit);
pushUpdate(context,AppWidgetManager.getInstance(context),false);
}else {
ImageRequest imageRequest = ImageRequestBuilder
.newBuilderWithSource(uri)
.setProgressiveRenderingEnabled(true)
.build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
DataSource<CloseableReference<CloseableImage>>
dataSource = imagePipeline.fetchDecodedImage(imageRequest, 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;
albumMap.put(albumuri,noBit);
}
pushUpdate(context,AppWidgetManager.getInstance(context),false);
}
@Override
public void onFailureImpl(DataSource dataSource) {
// No cleanup required here.
noBit = BitmapFactory.decodeResource(context.getResources(), R.drawable.placeholder_disk_210);
albumMap.put(albumuri,noBit);
pushUpdate(context,AppWidgetManager.getInstance(context), false);
}
},
CallerThreadExecutor.getInstance());
}
}
}
}
}
// 相当于获得所有本程序创建的appwidget
ComponentName componentName = new ComponentName(context,SimpleWidgetProvider.class);
appWidgetManager.updateAppWidget(componentName, remoteView);
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
pushUpdate(context,appWidgetManager ,false);
}
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
super.onDeleted(context, appWidgetIds);
albumMap.clear();
}
// 接收广播的回调函数
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d("harvic", "action:"+action);
if (intent.hasCategory(Intent.CATEGORY_ALTERNATIVE)) {
Uri data = intent.getData();
int buttonId = Integer.parseInt(data.getSchemeSpecificPart());
switch (buttonId) {
case R.id.widget_play:
pushAction(context, MediaService.TOGGLEPAUSE_ACTION);
break;
case R.id.widget_pre:
pushAction(context, MediaService.PREVIOUS_ACTION);
break;
case R.id.widget_next:
pushAction(context, MediaService.NEXT_ACTION);
break;
case R.id.widget_love:
long[] favlists = PlaylistsManager.getInstance(context).getPlaylistIds(IConstants.FAV_PLAYLIST);
for(long i : favlists){
if(currentId == i){
isFav = true;
break;
}
}
if (isFav) {
PlaylistsManager.getInstance(context).removeItem(context, IConstants.FAV_PLAYLIST,
MusicPlayer.getCurrentAudioId());
isFav = false;
} else {
try {
MusicInfo info = MusicPlayer.getPlayinfos().get(MusicPlayer.getCurrentAudioId());
PlaylistsManager.getInstance(context).insertMusic(context,IConstants.FAV_PLAYLIST,info);
} catch (Exception e) {
e.printStackTrace();
}
isFav = true;
}
pushUpdate(context,AppWidgetManager.getInstance(context) ,true);
break;
}
} else if(action.equals(MediaService.META_CHANGED)){
isPlaying = intent.getBooleanExtra("playing",false);
pushUpdate(context,AppWidgetManager.getInstance(context) ,false);
} else if(action.equals(MediaService.SEND_PROGRESS)){
Log.e("widget"," " + duration + " " + position);
duration = intent.getLongExtra("duration",0);
position = intent.getLongExtra("position",0);
pushUpdate(context,AppWidgetManager.getInstance(context) ,true);
} else if(action.equals(MediaService.MUSIC_CHANGED)){
trackname = intent.getStringExtra("track");
art = intent.getStringExtra("artist");
albumuri = intent.getStringExtra("albumuri");
isTrackLocal = intent.getBooleanExtra("islocal",true);
currentId = intent.getLongExtra("id",-1);
isPlaying = intent.getBooleanExtra("playing",false);
Log.e("harvic","art = " + art + " trackname = " + trackname);
pushUpdate(context,AppWidgetManager.getInstance(context) ,false);
}
super.onReceive(context, intent);
}
private void pushAction(Context context, String ACTION) {
Log.e("widget","action = " + ACTION);
Intent startIntent = new Intent(context,MediaService.class);
startIntent.setAction(ACTION);
context.startService(startIntent);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/abc_btn_switch_to_on_mtrl_00012r" />
<item android:drawable="@drawable/abc_btn_switch_to_on_mtrl_00001r" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/abc_btn_switch_to_on_mtrl_00012r" />
<item android:drawable="@drawable/abc_btn_switch_to_on_mtrl_00001r" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<nine-patch android:src="@drawable/skin_dld_bar_big" />
</item>
<item android:id="@android:id/progress">
<scale android:drawable="@drawable/skin_dld_bar_big_curr" android:scaleWidth="100%" />
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="133" android:drawable="@drawable/loading1" />
<item android:duration="133" android:drawable="@drawable/loading2" />
<item android:duration="133" android:drawable="@drawable/loading3" />
<item android:duration="133" android:drawable="@drawable/loading4" />
<item android:duration="133" android:drawable="@drawable/loading3" />
<item android:duration="133" android:drawable="@drawable/loading2" />
</animation-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/desk_next_prs" />
<item android:drawable="@drawable/desk_next" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/desk_pause_prs" />
<item android:drawable="@drawable/desk_pause" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/desk_play_prs" />
<item android:drawable="@drawable/desk_play" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/desk_pre_prs" />
<item android:drawable="@drawable/desk_pre" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<nine-patch android:src="@drawable/desk_bar_bg" android:dither="true" />
</item>
<item android:id="@android:id/progress">
<clip android:gravity="left" android:drawable="@drawable/desk_bar_curr" android:clipOrientation="horizontal" />
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/desk_love_prs" />
<item android:drawable="@drawable/desk_love" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/desk_switch_prs" />
<item android:drawable="@drawable/desk_switch" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/desk_btn_loved_prs" />
<item android:drawable="@drawable/desk_btn_loved" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/whaite_text" />
<solid android:color="@color/white_text" />
<stroke
android:color="@color/test_color"
android:width="1px">
......
<?xml version="1.0" encoding="utf-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="133" android:drawable="@drawable/loading1" />
<item android:duration="133" android:drawable="@drawable/loading2" />
<item android:duration="133" android:drawable="@drawable/loading3" />
<item android:duration="133" android:drawable="@drawable/loading4" />
<item android:duration="133" android:drawable="@drawable/loading3" />
<item android:duration="133" android:drawable="@drawable/loading2" />
</animation-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<nine-patch android:src="@drawable/play_plybar_bg" />
</item>
<item android:id="@android:id/secondaryProgress">
<scale android:scaleWidth="100%">
<nine-patch android:src="@drawable/play_plybar_ready" />
</scale>
</item>
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%">
<nine-patch android:src="@drawable/play_plybar_red" />
</scale>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/switch_thumb_disabled_material_light" />
<item android:color="@color/switch_thumb_normal_material_light" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<nine-patch android:src="@drawable/play_volumebar_bg" />
</item>
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%">
<nine-patch android:src="@drawable/play_volumebar_red" />
</scale>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<rotate android:fromDegrees="0.0" android:toDegrees="360.0" android:pivotX="50.0%" android:pivotY="50.0%"
xmlns:android="http://schemas.android.com/apk/res/android">
<shape android:shape="ring" android:thicknessRatio="11.0" android:useLevel="false">
<gradient android:startColor="#33ffffff" android:endColor="#ffffffff" android:useLevel="false" android:type="sweep" android:centerColor="#ffffffff" />
</shape>
</rotate>
\ No newline at end of file
......@@ -17,7 +17,7 @@
android:id="@+id/lock_root"
android:layout_height="match_parent">
<TextView
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:layout_marginTop="70dp"
android:layout_marginLeft="39dp"
android:layout_alignParentTop="true"
......@@ -28,7 +28,7 @@
android:layout_height="wrap_content" />
<TextView
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:layout_marginTop="5dp"
android:layout_alignLeft="@+id/lock_time"
android:layout_below="@+id/lock_time"
......@@ -37,7 +37,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:layout_marginTop="15dp"
android:layout_alignLeft="@+id/lock_time"
android:layout_below="@+id/lock_date"
......@@ -46,7 +46,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:layout_marginTop="5dp"
android:layout_alignLeft="@+id/lock_time"
android:layout_below="@+id/lock_music_name"
......@@ -55,7 +55,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:layout_marginBottom="30dp"
android:layout_centerHorizontal="true"
android:layout_above="@+id/lock_control"
......@@ -99,7 +99,7 @@
<com.wm.remusic.widget.CustomTextView
android:layout_centerHorizontal="true"
android:text=">>> 滑动解锁"
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:textSize="20sp"
android:layout_marginBottom="30dp"
android:layout_alignParentBottom="true"
......
......@@ -34,9 +34,10 @@
<FrameLayout
android:id="@+id/headerView"
android:layout_marginTop="-6dp"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
app:layout_heightPercent="60%">
<android.support.percent.PercentRelativeLayout
......@@ -60,13 +61,18 @@
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal" />
<View
android:id="@+id/view_line"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="1.0dip"
android:background="@drawable/play_topbar_line" />
<ImageView
android:layout_below="@+id/view_line"
android:id="@+id/needle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="-16dp"
android:rotation="-30"
android:src="@drawable/play_needle"
......@@ -86,6 +92,34 @@
app:layout_heightPercent="70%"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/volume_layout"
android:layout_marginTop="22dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
android:src="@drawable/play_icn_speaker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<SeekBar
android:layout_gravity="center_vertical"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:id="@+id/volume_seek"
android:progress="30"
android:layout_marginRight="40dp"
android:layout_marginLeft="20dp"
android:progressDrawable="@drawable/volume_seekbar"
android:focusable="true"
android:maxHeight="2dp"
android:minHeight="2dp"
android:thumb="@drawable/play_volumebar_btn"
android:thumbOffset="3.0dip"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:focusable="false"
......@@ -103,6 +137,8 @@
android:layout_height="30dp" />
<com.wm.remusic.lrc.LrcView
android:layout_marginTop="10dp"
android:layout_below="@+id/volume_layout"
android:id="@+id/lrcview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
......@@ -175,16 +211,20 @@
android:gravity="right"
android:singleLine="true"
android:text="00:00"
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:textSize="10sp" />
<SeekBar
<com.wm.remusic.widget.PlayerSeekBar
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:id="@+id/play_seek"
android:progressDrawable="@drawable/play_seekbar"
android:layout_width="0dp"
android:secondaryProgress="0"
android:layout_height="wrap_content"
android:maxHeight="8dp"
android:minHeight="8dp"
android:layout_gravity="center_vertical"
android:thumb="@drawable/play_plybar_btn"
android:layout_weight="22" />
<TextView
......@@ -195,7 +235,7 @@
android:layout_weight="1"
android:singleLine="true"
android:text="00:00"
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:textSize="10sp" />
</LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="HardcodedText"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/ll_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:layout_marginLeft="3dp"
android:gravity="center_vertical"
android:focusable="true"
android:focusableInTouchMode="true"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UI卡顿超时时间(单位毫秒):"
android:textColor="#131313"
android:textSize="18sp"
/>
<EditText
android:id="@+id/et_slow_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#131313"
android:textSize="18sp"
android:inputType="number"
android:text="200"
/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ll_info"
android:layout_above="@+id/btn_monitor"
>
<TextView
android:id="@+id/tv_ui_monitor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#131313"
android:textSize="18sp"
/>
</ScrollView>
<Button
android:id="@+id/btn_monitor"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="44dp"
android:layout_marginRight="44dp"
android:layout_marginBottom="10dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="开始检测"
android:textSize="20dp"
android:gravity="center"
android:singleLine="true"
android:ellipsize="end"
android:textColor="@android:color/white"
/>
</RelativeLayout>
\ No newline at end of file
......@@ -39,7 +39,7 @@
android:id="@+id/playbar_info"
android:layout_width="wrap_content"
android:layout_height="23dp"
android:ellipsize="end"
android:ellipsize="marquee"
android:maxLines="1"
android:textSize="17dp" />
......
......@@ -30,7 +30,7 @@
android:fadingEdgeLength="10dp"
android:singleLine="true"
android:text=""
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:textSize="16sp" />
<TextView
......
......@@ -16,7 +16,6 @@
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
android:scaleType="centerCrop" />
<View
android:layout_width="match_parent"
......
......@@ -5,7 +5,6 @@
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:layout_width="match_parent"
android:layout_gravity="center"
......@@ -20,4 +19,4 @@
android:layout_height="match_parent"
android:layout_gravity="center"
app:layout_widthPercent="52%" />
</android.support.percent.PercentFrameLayout>
</android.support.percent.PercentFrameLayout>
\ No newline at end of file
......@@ -28,7 +28,7 @@
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/bar_search"
android:text="本地音乐"
android:textColor="@color/whaite_text"
android:textColor="@color/white_text"
android:textSize="20sp" />
<ImageView
......
......@@ -18,7 +18,7 @@
android:layout_height="20dp"
android:padding="1dp"
app:imageTint="@color/theme_color_primary"
android:src="@drawable/loadanimation" />
android:src="@drawable/list_loading" />
<TextView
android:layout_marginTop="60dp"
......
......@@ -4,9 +4,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/rotate"
android:src="@drawable/loading_big"
<ProgressBar
android:id="@+id/progress"
android:indeterminate="true"
android:progressDrawable="@drawable/white_progressbar"
android:layout_width="60dp"
android:layout_height="60dp" />
<!--<ImageView-->
<!--android:id="@+id/rotate"-->
<!--android:src="@drawable/loading_big"-->
<!--android:layout_width="60dp"-->
<!--android:layout_height="60dp" />-->
</LinearLayout>
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册