Skip to content

Commit

Permalink
Revert "修复一些问题和UI改善"
Browse files Browse the repository at this point in the history
This reverts commit 8a48ebe.
  • Loading branch information
aa112901 committed Jan 20, 2017
1 parent 8a48ebe commit 9e2b7df
Show file tree
Hide file tree
Showing 21 changed files with 329 additions and 510 deletions.
Binary file modified app-release.apk
Binary file not shown.
14 changes: 7 additions & 7 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@
<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" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<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" />
Expand Down
91 changes: 37 additions & 54 deletions app/src/main/java/com/wm/remusic/activity/PlayingActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.ParcelFileDescriptor;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
Expand All @@ -23,7 +22,6 @@
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand Down Expand Up @@ -58,7 +56,6 @@
import com.wm.remusic.lrc.DefaultLrcParser;
import com.wm.remusic.lrc.LrcRow;
import com.wm.remusic.lrc.LrcView;
import com.wm.remusic.provider.MusicPlaybackState;
import com.wm.remusic.provider.PlaylistsManager;
import com.wm.remusic.service.MediaService;
import com.wm.remusic.service.MusicPlayer;
Expand Down Expand Up @@ -109,7 +106,6 @@ public class PlayingActivity extends BaseActivity implements IConstants {
private TextView tryGetLrc;
private LinearLayout musicTool;
private SeekBar mVolumeSeek;
private Handler mHandler;
private boolean print = true;
private String TAG = PlayingActivity.class.getSimpleName();

Expand Down Expand Up @@ -163,13 +159,13 @@ public void onClick(View v) {
mVolumeSeek = (SeekBar) findViewById(R.id.volume_seek);
mProgress.setIndeterminate(false);
mProgress.setProgress(1);
mProgress.setMax(1000);

if (MusicPlayer.isTrackLocal()) {
mProgress.setSecondaryProgress(100);
}
loadOther();
setViewPager();
initLrcView();

mHandler = HandlerUtil.getInstance(this);
mHandler.postDelayed(up, 0);
// setViewPager();
}

Expand Down Expand Up @@ -282,8 +278,8 @@ private List<LrcRow> getLrcRows() {
}

private void loadOther() {
needleAnim = ObjectAnimator.ofFloat(needle, "rotation", -25, 0);
needleAnim.setDuration(100);
needleAnim = ObjectAnimator.ofFloat(needle, "rotation", -30, 0);
needleAnim.setDuration(200);
needleAnim.setRepeatMode(0);
needleAnim.setInterpolator(new LinearInterpolator());

Expand Down Expand Up @@ -337,7 +333,7 @@ public void onPageSelected(final int pPosition) {
public void run() {
MusicPlayer.previous(PlayingActivity.this, true);
}
}, 500);
}, 396);


} else if (pPosition > MusicPlayer.getQueuePosition() + 1) {
Expand All @@ -346,7 +342,7 @@ public void run() {
public void run() {
MusicPlayer.next();
}
}, 500);
}, 396);

}
}
Expand Down Expand Up @@ -408,9 +404,7 @@ public void onClick(View v) {
animator.end();
animator = null;
}
mHandler.removeCallbacks(nextl);
mHandler.postDelayed(nextl,500);
// MusicPlayer.next();
MusicPlayer.next();
}
});

Expand Down Expand Up @@ -460,13 +454,6 @@ public void onClick(View v) {

}

Runnable nextl = new Runnable() {
@Override
public void run() {
MusicPlayer.next();
}
};

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// handle item selection
Expand Down Expand Up @@ -523,7 +510,6 @@ protected void onStart() {
@Override
public void onResume() {
super.onResume();
lastAlbum = -1;
}


Expand Down Expand Up @@ -557,18 +543,9 @@ public void updateLrc() {
}

public void updateTrack() {
mHandler.removeCallbacks(up);
if(MusicPlayer.getCurrentAlbumId() != lastAlbum)
mHandler.postDelayed(up, 1600);
new setBlurredAlbumArt().execute();
}

private Runnable up = new Runnable() {
@Override
public void run() {
new setBlurredAlbumArt().execute();
}
};

public void updateTrackInfo() {

if (MusicPlayer.getQueueSize() == 0) {
Expand Down Expand Up @@ -615,13 +592,19 @@ public void updateTrackInfo() {
duration.setText(MusicUtils.makeShortTimeString(PlayingActivity.this.getApplication(), MusicPlayer.duration() / 1000));
//mProgress.setMax((int) MusicPlayer.duration());

mProgress.postDelayed(mUpdateProgress, 10);


animatorSet = new AnimatorSet();
if (MusicPlayer.isPlaying()) {
mProgress.removeCallbacks(mUpdateProgress);
mProgress.postDelayed(mUpdateProgress, 200);
control.setImageResource(R.drawable.play_rdi_btn_pause);

} else {
control.setImageResource(R.drawable.play_rdi_btn_play);
}


animatorSet = new AnimatorSet();
if (MusicPlayer.isPlaying()) {
if (animatorSet != null && animator != null && !animator.isRunning()) {
//修复从playactivity回到Main界面null
if (needleAnim == null) {
Expand All @@ -635,8 +618,6 @@ public void updateTrackInfo() {
}

} else {
mProgress.removeCallbacks(mUpdateProgress);
control.setImageResource(R.drawable.play_rdi_btn_play);
if (needleAnim != null) {
needleAnim.reverse();
needleAnim.end();
Expand All @@ -657,9 +638,16 @@ public void updateTrackInfo() {

}

@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) {
mProgress.setSecondaryProgress(p*10);
mProgress.setSecondaryProgress(p);
}

@Override
Expand All @@ -675,16 +663,12 @@ public void run() {
if (mProgress != null) {
long position = MusicPlayer.position();
long duration = MusicPlayer.duration();
if (duration > 0 && duration < 627080716){
Log.e("durate","position = " + position + " , duration = " + duration);
mProgress.setProgress((int) (1000 * position / duration));
timePlayed.setText(MusicUtils.makeTimeString( position ));
}
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, 200);
}else {
mProgress.removeCallbacks(mUpdateProgress);
mProgress.postDelayed(mUpdateProgress, 100);
}
}
}
Expand All @@ -698,11 +682,11 @@ private void setSeekBarListener() {

@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
i = (int) (i * MusicPlayer.duration() / 1000);
i = (int) (i * MusicPlayer.duration() / 100);
mLrcView.seekTo(i, true, b);
if (b) {
MusicPlayer.seek((long)i);
timePlayed.setText(MusicUtils.makeTimeString( i ));
MusicPlayer.seek((long) i);
timePlayed.setText(MusicUtils.makeShortTimeString(PlayingActivity.this.getApplication(), i / 1000));
}
}

Expand Down Expand Up @@ -802,14 +786,13 @@ public void transformPage(View view, float position) {
}

private Bitmap mBitmap;
private long lastAlbum;
private class setBlurredAlbumArt extends AsyncTask<Void, Void, Drawable> {

private class setBlurredAlbumArt extends AsyncTask<Void, Void, Drawable> {
long albumid = MusicPlayer.getCurrentAlbumId();

@Override
protected Drawable doInBackground(Void... loadedImage) {
lastAlbum = albumid;

Drawable drawable = null;
mBitmap = null;
if (newOpts == null) {
Expand Down Expand Up @@ -991,4 +974,4 @@ public void setmDuration(int animTime) {
}


}
}
33 changes: 25 additions & 8 deletions app/src/main/java/com/wm/remusic/activity/RecentActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -28,7 +27,6 @@
import com.wm.remusic.service.MusicPlayer;
import com.wm.remusic.uitl.CommonUtils;
import com.wm.remusic.uitl.IConstants;
import com.wm.remusic.uitl.L;
import com.wm.remusic.uitl.MusicUtils;
import com.wm.remusic.widget.DividerItemDecoration;

Expand All @@ -47,10 +45,19 @@ public class RecentActivity extends BaseActivity {
private Toolbar toolbar;
private List<Song> mList;
private RecyclerView recyclerView;
private String TAG = "RecentActivity";
private boolean d = true;
private LinearLayoutManager layoutManager;
//接受歌曲播放变化和列表变化广播,刷新列表
private BroadcastReceiver mStatusListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(MediaService.META_CHANGED)) {
reloadAdapter();
} else if (action.equals(MediaService.PLAYLIST_CHANGED)) {
reloadAdapter();
}
}
};

@Override
public void onCreate(final Bundle savedInstanceState) {
Expand Down Expand Up @@ -88,9 +95,20 @@ public void onClick(View v) {


//刷新列表
public void updateTrack() {
L.D(d,TAG,"reload");
mAdapter.updateDataSet(mList);
private void reloadAdapter() {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(final Void... unused) {
//List<MusicInfo> songList = MusicUtils.getMusicLists(getContext(), recentStore.getRecentIds());
//mAdapter.updateDataSet(songList);
return null;
}

@Override
protected void onPostExecute(Void aVoid) {
mAdapter.notifyDataSetChanged();
}
}.execute();
}

//异步加载recyclerview界面
Expand Down Expand Up @@ -134,7 +152,6 @@ public Adapter(List<Song> list) {
//更新adpter的数据
public void updateDataSet(List<Song> list) {
this.mList = list;
notifyDataSetChanged();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


/**
* Created by wm on 2016/12/13.
*/
Expand Down
14 changes: 1 addition & 13 deletions app/src/main/java/com/wm/remusic/fragment/BaseFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,13 @@ public void onAttach(Activity activity){
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

}

@Override
public void onResume() {
super.onResume();
((BaseActivity) getActivity()).setMusicStateListenerListener(this);
}

@Override
public void onStop() {
super.onStop();
((BaseActivity) getActivity()).removeMusicStateListenerListener(this);
}

@Override
public void onDestroy() {
super.onDestroy();

((BaseActivity) getActivity()).removeMusicStateListenerListener(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void onRefresh() {
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
if (isVisibleToUser && mContext != null) {
//相当于Fragment的onResume
reloadAdapter();
}
Expand Down
Loading

0 comments on commit 9e2b7df

Please sign in to comment.