优化卡片滑动性能:探路视频播放、C位事件逻辑;定制化app列表;修改小智动画策略;其他优化;
This commit is contained in:
@@ -4,6 +4,9 @@ import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -72,14 +75,12 @@ import com.mogo.module.tanlu.model.event.MarkerInfo;
|
||||
import com.mogo.module.tanlu.model.event.PushTypeInfo;
|
||||
import com.mogo.module.tanlu.model.event.SharedialogEvent;
|
||||
import com.mogo.module.tanlu.util.Utils;
|
||||
import com.mogo.module.tanlu.video.FullMediaActivity;
|
||||
import com.mogo.module.tanlu.video.SimpleCoverVideoPlayer;
|
||||
import com.mogo.module.tanlu.view.AutoZoomInImageView;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.datamanager.IMogoDataChangedListener;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.imageloader.IMogoImageLoaderListener;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
@@ -168,7 +169,12 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
private String mKeywords;
|
||||
private boolean isCurrentPage;
|
||||
|
||||
|
||||
private Handler mMsgHandler = new Handler( Looper.getMainLooper() ){
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
}
|
||||
};
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.tanlu_item_main_media_recycler;
|
||||
@@ -772,9 +778,8 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
mNextTv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//展示第一个数据
|
||||
MarkerExploreWay markerExploreWay = markerExploreWayList.get(0);
|
||||
handleMarkerExploreWay(markerExploreWay);
|
||||
//延时展示第一个数据
|
||||
mMsgHandler.postDelayed( mDelayRunnable, 1_000L );
|
||||
} else {
|
||||
mEmptyLayout.setVisibility(View.VISIBLE);
|
||||
mRootLayout.setVisibility(View.GONE);
|
||||
@@ -782,6 +787,31 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
}
|
||||
}
|
||||
|
||||
private MarkerExploreWay mLastPlayEntity = null;
|
||||
|
||||
// 播放第一个数据需要延时,避免滑动卡顿
|
||||
private Runnable mDelayRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if ( isCurrentPage && !isRemoving() && !isDetached() ) {
|
||||
try {
|
||||
final MarkerExploreWay markerExploreWay = markerExploreWayList.get(0);
|
||||
if ( mLastPlayEntity == markerExploreWay ) {
|
||||
if ( markerExploreWay.getFileType() == 1 ) {
|
||||
// 视频的话重新播放
|
||||
simpleCoverVideoPlayer.getGSYVideoManager().start();
|
||||
}
|
||||
} else {
|
||||
mLastPlayEntity = markerExploreWay;
|
||||
handleMarkerExploreWay(markerExploreWay);
|
||||
}
|
||||
} catch( Exception e ){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onDataSetChanged( Object data ) {
|
||||
Logger.d( TAG, "receive data changed." );
|
||||
@@ -811,6 +841,28 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
public void onDisable() {
|
||||
Logger.d(TAG, "tanlu卡片 无效 ----->");
|
||||
isCurrentPage = false;
|
||||
mMsgHandler.removeCallbacks( mDelayRunnable );
|
||||
if ( mLastPlayEntity != null ) {
|
||||
if ( mLastPlayEntity.getFileType() == 1 ) {
|
||||
try {
|
||||
if ( simpleCoverVideoPlayer.getVisibility() == View.VISIBLE ) {
|
||||
// 卡片滑动过去之后停止播放
|
||||
simpleCoverVideoPlayer.getGSYVideoManager().pause();
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
if ( autoZoomInImageView.getVisibility() == View.VISIBLE ) {
|
||||
autoZoomInImageView.stopCurrentAnimator();
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AIAssist.getInstance(getActivity()).unregisterUnWakeupCommand(TanluConstants.PLAY_VIDEO);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,13 +94,15 @@ public class AutoZoomInImageView extends MogoImageView {
|
||||
setImageMatrix(mMatrix);
|
||||
}
|
||||
|
||||
private ValueAnimator mCurrentAnimator;
|
||||
|
||||
private void startZoomInByScaleDelta(final float scaleDelta, long duration) {
|
||||
|
||||
final float oriScaleX = mValues[0];
|
||||
final float oriScaleY = mValues[4];
|
||||
|
||||
ValueAnimator va = ValueAnimator.ofFloat(0, scaleDelta);
|
||||
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
mCurrentAnimator = ValueAnimator.ofFloat(0, scaleDelta);
|
||||
mCurrentAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
@@ -113,7 +115,7 @@ public class AutoZoomInImageView extends MogoImageView {
|
||||
setImageMatrix(mMatrix);
|
||||
}
|
||||
});
|
||||
va.addListener(new Animator.AnimatorListener() {
|
||||
mCurrentAnimator.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
if (mOnZoomListener != null) mOnZoomListener.onStart(AutoZoomInImageView.this);
|
||||
@@ -122,18 +124,31 @@ public class AutoZoomInImageView extends MogoImageView {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (mOnZoomListener != null) mOnZoomListener.onEnd(AutoZoomInImageView.this);
|
||||
mCurrentAnimator = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
mCurrentAnimator = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
}
|
||||
});
|
||||
va.setDuration(duration);
|
||||
va.start();
|
||||
mCurrentAnimator.setDuration(duration);
|
||||
mCurrentAnimator.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止动画
|
||||
*/
|
||||
public void stopCurrentAnimator(){
|
||||
if ( mCurrentAnimator != null ) {
|
||||
if ( mCurrentAnimator.isRunning() ) {
|
||||
mCurrentAnimator.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user