+ android:layout_marginLeft="@dimen/dp_70"
+ android:layout_marginTop="@dimen/dp_10">
+ android:paddingBottom="@dimen/dp_20" />
diff --git a/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_company.png b/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_company.png
new file mode 100644
index 0000000000..47b1217f4a
Binary files /dev/null and b/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_company.png differ
diff --git a/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_home.png b/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_home.png
new file mode 100644
index 0000000000..e0ccc8bcb0
Binary files /dev/null and b/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_home.png differ
diff --git a/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_move2_current_location.png b/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_move2_current_location.png
new file mode 100644
index 0000000000..9d3d1e8b2a
Binary files /dev/null and b/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_move2_current_location.png differ
diff --git a/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_search.png b/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_search.png
new file mode 100644
index 0000000000..27b414c367
Binary files /dev/null and b/modules/mogo-module-map/src/main/res/drawable-xhdpi/module_map_ic_search.png differ
diff --git a/modules/mogo-module-map/src/main/res/drawable/module_map_dw_common_corner_bkg.xml b/modules/mogo-module-map/src/main/res/drawable/module_map_dw_common_corner_bkg.xml
new file mode 100644
index 0000000000..da35984c9d
--- /dev/null
+++ b/modules/mogo-module-map/src/main/res/drawable/module_map_dw_common_corner_bkg.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-map/src/main/res/drawable/module_map_dw_upload_road_condition_bkg.xml b/modules/mogo-module-map/src/main/res/drawable/module_map_dw_upload_road_condition_bkg.xml
new file mode 100644
index 0000000000..01523fc210
--- /dev/null
+++ b/modules/mogo-module-map/src/main/res/drawable/module_map_dw_upload_road_condition_bkg.xml
@@ -0,0 +1,9 @@
+
+
+ -
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-map/src/main/res/layout/module_map_fragment_map.xml b/modules/mogo-module-map/src/main/res/layout/module_map_fragment_map.xml
index 696bce61e8..038b269721 100644
--- a/modules/mogo-module-map/src/main/res/layout/module_map_fragment_map.xml
+++ b/modules/mogo-module-map/src/main/res/layout/module_map_fragment_map.xml
@@ -1,5 +1,6 @@
@@ -7,4 +8,121 @@
android:id="@+id/module_map_id_map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-map/src/main/res/values/strings.xml b/modules/mogo-module-map/src/main/res/values/strings.xml
index fab4c86972..344eed0558 100644
--- a/modules/mogo-module-map/src/main/res/values/strings.xml
+++ b/modules/mogo-module-map/src/main/res/values/strings.xml
@@ -1,3 +1,5 @@
mogo-module-map
+ 搜索目的地
+ 上报\n路况
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServiceProvider.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServiceProvider.java
index 4f786c1ddd..2b916dfedd 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServiceProvider.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServiceProvider.java
@@ -101,7 +101,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
case ServiceConst.MSG_TYPE_REFRESH_DECREASE:
mRefreshRemainingTime -= ServiceConst.DECREASE_INTERVAL;
if ( mRefreshRemainingTime == 0 ) {
- notifyRefreshData( mAutoRefreshCallback );
+ notifyRefreshData( mLastAutoRefreshLocation, 2_000, mAutoRefreshCallback );
} else {
mHandler.sendEmptyMessageDelayed( msg.what, ServiceConst.DECREASE_INTERVAL );
}
@@ -334,19 +334,26 @@ public class MogoServiceProvider implements IMogoModuleProvider,
// 手动刷新触发
if ( mLastZoomLevel - zoom > mCustomRefreshStrategy.getZoomOutLevel() ) {
// 缩放级别缩小
- notifyRefreshData( mCustomRefreshCallback );
+ notifyRefreshData( latLng, getQueryRadius(), mCustomRefreshCallback );
mLastCustomRefreshCenterLocation = latLng;
mLastZoomLevel = zoom;
} else if ( mLastZoomLevel == zoom ) {
// 手动平移
if ( invokeRefreshWhenTranslationByUser( latLng ) ) {
- notifyRefreshData( mCustomRefreshCallback );
+ notifyRefreshData( latLng, getQueryRadius(), mCustomRefreshCallback );
mLastCustomRefreshCenterLocation = latLng;
}
}
Logger.d( TAG, "current map status: %s, zoom = %f, tilt = %f, bearing = %f", latLng, zoom, tilt, bearing );
}
+ private int getQueryRadius() {
+ if ( mIsVertical ) {
+ return ( ( int ) ( getMapCameraFactWidth() / 2 ) );
+ }
+ return ( ( int ) ( getMapCameraFactHeight() / 2 ) );
+ }
+
/**
* 平移地图刷新策略
*
@@ -379,11 +386,11 @@ public class MogoServiceProvider implements IMogoModuleProvider,
// 自动刷新触发
if ( mLastAutoRefreshLocation == null ) {
mLastAutoRefreshLocation = new MogoLatLng( location.getLatitude(), location.getLongitude() );
- notifyRefreshData( mAutoRefreshCallback );
+ notifyRefreshData( mLastAutoRefreshLocation, 2_000, mAutoRefreshCallback );
} else {
float distance = Utils.calculateLineDistance( mLastAutoRefreshLocation, new MogoLatLng( location.getLatitude(), location.getLongitude() ) );
if ( distance > mAutoRefreshStrategy.getDistance() ) {
- notifyRefreshData( mAutoRefreshCallback );
+ notifyRefreshData( mLastAutoRefreshLocation, 2_000, mAutoRefreshCallback );
}
}
}
@@ -391,9 +398,9 @@ public class MogoServiceProvider implements IMogoModuleProvider,
/**
* 刷新数据
*/
- private void notifyRefreshData( RefreshCallback callback ) {
+ private void notifyRefreshData( MogoLatLng latLng, int radius, RefreshCallback callback ) {
Logger.d( TAG, mAutoRefreshCallback == callback ? "触发自动刷新" : "触发手动刷新" );
- mRefreshModel.refreshData( callback );
+ mRefreshModel.refreshData( latLng, radius, callback );
}
@Override
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
index 875fa04b98..82497488e6 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshApiService.java
@@ -6,7 +6,10 @@ import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Single;
+import retrofit2.http.FieldMap;
+import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
+import retrofit2.http.POST;
import retrofit2.http.QueryMap;
/**
@@ -17,6 +20,8 @@ import retrofit2.http.QueryMap;
*/
public interface RefreshApiService {
- @GET( "" )
- Observable< BaseData > refreshData( @QueryMap Map< String, Object > params );
+ @FormUrlEncoded
+ @POST( "" )
+ Observable< BaseData > refreshData( @QueryMap Map< String, Object > params,
+ @FieldMap Map< String, Object > parameters );
}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshBody.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshBody.java
new file mode 100644
index 0000000000..2200ed394a
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshBody.java
@@ -0,0 +1,29 @@
+package com.mogo.module.service.network;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author congtaowang
+ * @since 2020-01-06
+ *
+ * 刷新地图信息接口
+ */
+public class RefreshBody {
+
+ public List< String > dataType = new ArrayList<>();
+ public int limit = 50;// 请求数量
+ public int radius = 2_000; // 地理围栏半径(米)
+ public LatLon location;
+
+ public static class LatLon {
+
+ private double lat;
+ private double lon;
+
+ public LatLon( double lat, double lon ) {
+ this.lat = lat;
+ this.lon = lon;
+ }
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshModel.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshModel.java
index 5fdbce5600..1da0a385cb 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshModel.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/network/RefreshModel.java
@@ -6,10 +6,14 @@ import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.network.ParamsProvider;
import com.mogo.commons.network.SubscribeImpl;
+import com.mogo.commons.network.Utils;
+import com.mogo.map.MogoLatLng;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.network.IMogoNetwork;
import com.mogo.utils.network.RequestOptions;
+import com.mogo.utils.network.utils.GsonUtil;
+import java.util.HashMap;
import java.util.Map;
import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -33,14 +37,21 @@ public class RefreshModel {
this.mRefreshApiService = network.create( RefreshApiService.class, "http://www.baidu.com/" );
}
- public void refreshData( final RefreshCallback callback ) {
+ public void refreshData( MogoLatLng latLng, int radius, final RefreshCallback callback ) {
if ( callback != null ) {
callback.onSuccess();
return;
}
if ( mRefreshApiService != null ) {
- final Map< String, Object > params = new ParamsProvider.Builder( mContext ).build();
- mRefreshApiService.refreshData( params )
+ final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
+ final Map< String, Object > field = new HashMap<>();
+ field.put( "sn", query.get( "sn" ) );
+ final RefreshBody refreshBody = new RefreshBody();
+ refreshBody.limit = 50;
+ refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
+ refreshBody.radius = radius;
+ field.put( "data", GsonUtil.jsonFromObject( refreshBody ) );
+ mRefreshApiService.refreshData( query, field )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< BaseData >( RequestOptions.create( mContext ) ) {
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluCardViewFragment.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluCardViewFragment.java
index 1b4781b8f0..e09dcdd482 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluCardViewFragment.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/fragment/TanluCardViewFragment.java
@@ -1,5 +1,6 @@
package com.mogo.tanlu.fragment;
+import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
@@ -25,6 +26,7 @@ import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
import com.mogo.map.search.poisearch.MogoPoiResult;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.service.MogoServicePaths;
+import com.mogo.service.imageloader.IMogoImageLoaderListener;
import com.mogo.service.imageloader.IMogoImageloader;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.tanlu.R;
@@ -144,10 +146,46 @@ public class TanluCardViewFragment extends MvpFragment>
//图片显示
autoZoomInImageView.setVisibility(View.VISIBLE);
simpleCoverVideoPlayer.setVisibility(View.GONE);
- mogoImageloader.displayImage(imageUrl, autoZoomInImageView);
+// mogoImageloader.displayImage(imageUrl, autoZoomInImageView);
+ mogoImageloader.downloadImage(getActivity(), imageUrl, new IMogoImageLoaderListener() {
+ @Override
+ public void onStart() {
+ Logger.d(TAG, "onStart ------>");
+ }
+
+ @Override
+ public void onCompleted(Bitmap bitmap) {
+ Logger.d(TAG, "onCompleted ------>");
+ autoZoomInImageView.setImageBitmap(bitmap);
+ //动画
+ handleImageAnimation();
+ }
+
+ @Override
+ public void onFailure(Exception e) {
+ Logger.e(TAG, "onFailure -----E->" + e);
+ }
+ });
+
}
}
+ /**
+ * 执行图片动画
+ */
+ private void handleImageAnimation() {
+ autoZoomInImageView.post(new Runnable() {
+ @Override
+ public void run() {
+ //放大增量是0.3,放大时间是1000毫秒,放大开始时间是1000毫秒以后
+ autoZoomInImageView.init()
+ .startZoomInByScaleDeltaAndDuration(0.3f, 1000, 1500);
+ }
+ });
+
+ }
+
+
/**
* marker点击事件 TODO
*
@@ -171,14 +209,14 @@ public class TanluCardViewFragment extends MvpFragment>
//TODO C位事件,如何获取数据,需要有默认数据
@Override
public void onPerform() {
- Logger.d(TAG, "卡片2有效");
+ Logger.d(TAG, "tanlu卡片 有效");
}
//TODO 离开C位事件
@Override
public void onDisable() {
- Logger.d(TAG, "卡片2无效");
+ Logger.e(TAG, "tanlu卡片 无效");
}
@Override
@@ -226,7 +264,7 @@ public class TanluCardViewFragment extends MvpFragment>
// }
}
-
+
@Override
public void onMapClick(MogoLatLng latLng) {
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/view/AutoZoomInImageView.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/view/AutoZoomInImageView.java
new file mode 100644
index 0000000000..102d772568
--- /dev/null
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/view/AutoZoomInImageView.java
@@ -0,0 +1,259 @@
+package com.mogo.tanlu.view;
+
+import com.mogo.service.imageloader.MogoImageView;
+
+import android.animation.Animator;
+import android.animation.ValueAnimator;
+import android.content.Context;
+import android.graphics.Matrix;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.view.View;
+
+
+/**
+ * @author lixiaopeng
+ * @description
+ * @since 2020-01-06
+ */
+public class AutoZoomInImageView extends MogoImageView {
+ private int mDrawableW;
+ private int mDrawableH;
+ private int mImageViewW;
+ private int mImageViewH;
+ private long mDurationMillis = 700;
+
+ private float[] mValues = new float[9];
+ private float mScaleDelta = 0.2f;
+
+ private Drawable mDrawable;
+ private Matrix mMatrix;
+
+ public AutoZoomInImageView(Context context) {
+ super(context);
+ this.setScaleType(ScaleType.MATRIX);
+ }
+
+ public AutoZoomInImageView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setScaleType(ScaleType.MATRIX);
+ }
+
+ public AutoZoomInImageView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ this.setScaleType(ScaleType.MATRIX);
+ }
+
+ public AutoZoomInImageView init() {
+ initInternalValues();
+ initPicturePosition();
+ return this;
+ }
+
+ public void init(Drawable drawable) {
+ initInternalValues(drawable);
+ initPicturePosition();
+ }
+
+ private void initInternalValues() {
+ mDrawable = getDrawable();
+
+ if (mDrawable == null) {
+ throw new IllegalArgumentException("please set the source of AutoZoomInImageView");
+ }
+
+ mDrawableW = mDrawable.getIntrinsicWidth();
+ mDrawableH = mDrawable.getIntrinsicHeight();
+
+ mImageViewW = getMeasuredWidth();
+ mImageViewH = getMeasuredHeight();
+
+ mMatrix = getImageMatrix();
+ mMatrix.getValues(mValues);
+ }
+
+ private void initInternalValues(Drawable drawable) {
+ mDrawable = drawable;
+
+ if (mDrawable == null) {
+ throw new IllegalArgumentException("please set the source of AutoZoomInImageView");
+ }
+
+ mDrawableW = mDrawable.getIntrinsicWidth();
+ mDrawableH = mDrawable.getIntrinsicHeight();
+
+ mImageViewW = getMeasuredWidth();
+ mImageViewH = getMeasuredHeight();
+
+ mMatrix = getImageMatrix();
+ mMatrix.getValues(mValues);
+ }
+
+ private void initPicturePosition() {
+ updateMatrixValuesOrigin(mMatrix, mValues, mDrawableW, mDrawableH, mImageViewW, mImageViewH);
+ setImageMatrix(mMatrix);
+ }
+
+ 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() {
+
+ @Override
+ public void onAnimationUpdate(ValueAnimator animation) {
+ float value = (Float) animation.getAnimatedValue();
+ if (mOnZoomListener != null)
+ mOnZoomListener.onUpdate(AutoZoomInImageView.this, value / scaleDelta);
+ updateMatrixValuesSpan(mValues, mDrawableW, mDrawableH, mImageViewW, mImageViewH,
+ oriScaleX, oriScaleY, value);
+ mMatrix.setValues(mValues);
+ setImageMatrix(mMatrix);
+ }
+ });
+ va.addListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ if (mOnZoomListener != null) mOnZoomListener.onStart(AutoZoomInImageView.this);
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (mOnZoomListener != null) mOnZoomListener.onEnd(AutoZoomInImageView.this);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ }
+ });
+ va.setDuration(duration);
+ va.start();
+ }
+
+ /**
+ * start zooming in
+ *
+ * @param scaleDelta the scale that the image will add to original scale
+ * @param durationMillis the duration of zoomin animation, in millisecond.
+ * @param delayMillis the delayed time of starting zoomin animation, in millisecond.
+ */
+ public void startZoomInByScaleDeltaAndDuration(final float scaleDelta, final long durationMillis, long delayMillis) {
+ if (scaleDelta < 0) {
+ throw new IllegalArgumentException("scaleDelta should be larger than 0, now scaleDelta is " + scaleDelta);
+ }
+ if (durationMillis < 0) {
+ throw new IllegalArgumentException("durationMillis should not be less than 0, now durationMillis is " + durationMillis);
+ }
+ if (delayMillis < 0) {
+ throw new IllegalArgumentException("delayMillis should not be less than 0, now delayMillis is " + delayMillis);
+ }
+ postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ startZoomInByScaleDelta(scaleDelta, durationMillis);
+ }
+ }, delayMillis);
+ }
+
+ /**
+ * the scale that the image will add to original scale
+ *
+ * @param scaleDelta
+ * @return
+ */
+ public AutoZoomInImageView setScaleDelta(float scaleDelta) {
+ mScaleDelta = scaleDelta;
+ return this;
+ }
+
+ /**
+ * the duration of zoomin animation, in millisecond.
+ *
+ * @param durationMillis
+ * @return
+ */
+ public AutoZoomInImageView setDurationMillis(long durationMillis) {
+ mDurationMillis = durationMillis;
+ return this;
+ }
+
+ /**
+ * callback when zoomin animation finished
+ *
+ * @param onZoomListener
+ * @return
+ */
+ public AutoZoomInImageView setOnZoomListener(OnZoomListener onZoomListener) {
+ mOnZoomListener = onZoomListener;
+ return this;
+ }
+
+ /**
+ * start animation of zoomin
+ *
+ * @param delayMillis the delayed time of starting zoomin animation, in millisecond.
+ */
+ public void start(long delayMillis) {
+ postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ startZoomInByScaleDelta(mScaleDelta, mDurationMillis);
+ }
+ }, delayMillis);
+ }
+
+ private void updateMatrixValuesOrigin(Matrix outMatrix, float[] outValues, float drawW, float drawH, float imageW, float imageH) {
+ if (outMatrix == null || outValues == null) {
+ throw new IllegalArgumentException("please set the source of AutoZoomInImageView's matrix and values");
+ }
+ outMatrix.reset();
+ if ((imageH * drawW > drawH * imageW)) {
+ float scale1 = (imageH) / (drawH);
+ float offset1 = (drawW * scale1 - imageW) / 2;
+ outMatrix.postScale(scale1, scale1);
+ outMatrix.postTranslate(-offset1, 0);
+ } else {
+ float scale2 = (imageW) / (drawW);
+ float offset2 = (drawH * scale2 - imageH) / 2;
+ outMatrix.postScale(scale2, scale2);
+ outMatrix.postTranslate(0, -offset2);
+ }
+ outMatrix.getValues(outValues);
+ }
+
+ private void updateMatrixValuesSpan(float[] outValues,
+ float drawW, float drawH,
+ float imageW, float imageH,
+ float oriScaleX, float oriScaleY,
+ float scaleDelta) {
+ outValues[0] = oriScaleX * (1 + scaleDelta);
+ outValues[4] = oriScaleY * (1 + scaleDelta);
+ float offsetwidth = (drawW * outValues[0] - imageW) / 2;
+ outValues[2] = -offsetwidth;
+ float offsetHeight = (drawH * outValues[4] - imageH) / 2;
+ outValues[5] = -offsetHeight;
+ }
+
+ private OnZoomListener mOnZoomListener;
+
+ public interface OnZoomListener {
+ /**
+ * callback when zoom in animation is updating
+ *
+ * @param view AutoZoomInImageView
+ * @param progress return the progress of animation, scope is [0,1]
+ */
+ void onUpdate(View view, float progress);
+
+ void onEnd(View view);
+
+ void onStart(View view);
+ }
+
+}
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/view/AutoZoomInImageView.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/view/AutoZoomInImageView.kt
deleted file mode 100644
index 391727aa8d..0000000000
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/tanlu/view/AutoZoomInImageView.kt
+++ /dev/null
@@ -1,222 +0,0 @@
-package com.mogo.tanlu.view
-
-import android.animation.Animator
-import android.animation.ValueAnimator
-import android.content.Context
-import android.graphics.Matrix
-import android.graphics.drawable.Drawable
-import android.util.AttributeSet
-import android.util.Log
-import android.view.View
-import android.widget.ImageView
-import com.mogo.service.imageloader.MogoImageView
-
-class AutoZoomInImageView : MogoImageView {
-
- companion object {
- const val TAG = "AutoZoomInImageView"
- }
-
- private var mDrawableW: Int = 0
- private var mDrawableH: Int = 0
- private var mImageViewW: Int = 0
- private var mImageViewH: Int = 0
- private var mDurationMillis = 3000L
-
- private var mValues = FloatArray(9)
- var isInit: Boolean = false
- private var mScaleDelta = 0.2f
- private var va: ValueAnimator = ValueAnimator.ofFloat(0f, mScaleDelta)
-
- private lateinit var mDrawable: Drawable
- private lateinit var mMatrix: Matrix
-
- private var onStart: (View.() -> Unit)? = null
-
- private var onUpdate: ((view: View, progress: Float) -> Unit)? = null
-
- private var onEnd: (View.() -> Unit)? = null
-
- infix fun onStart(onStart: View.() -> Unit) :AutoZoomInImageView{
- this.onStart = onStart
- return this
- }
-
- infix fun onUpdate(onUpdate: (view: View, progress: Float) -> Unit) :AutoZoomInImageView{
- this.onUpdate = onUpdate
- return this
- }
-
- infix fun onEnd(onEnd: View.() -> Unit):AutoZoomInImageView {
- this.onEnd = onEnd
- return this
- }
-
- constructor(context: Context?) : super(context) {
- this.scaleType = ScaleType.MATRIX
- }
-
- constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
- this.scaleType = ScaleType.MATRIX
- }
-
- constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
- context,
- attrs,
- defStyleAttr
- ) {
- this.scaleType = ScaleType.MATRIX
- }
-
-
- fun init(): AutoZoomInImageView {
- initInternalValues()
- initPicturePosition()
- isInit = true
- return this
- }
-
- fun init(drawable: Drawable) {
- initInternalValues(drawable)
- initPicturePosition()
- }
-
- private fun initInternalValues() {
- mDrawable = drawable
-
- mDrawableW = mDrawable.intrinsicWidth
- mDrawableH = mDrawable.intrinsicHeight
-
- mImageViewW = measuredWidth
- mImageViewH = measuredHeight
-
- mMatrix = imageMatrix
- mMatrix.getValues(mValues)
- }
-
- private fun initInternalValues(drawable: Drawable) {
- mDrawable = drawable
-
- mDrawableW = mDrawable.intrinsicWidth
- mDrawableH = mDrawable.intrinsicHeight
-
- mImageViewW = measuredWidth
- mImageViewH = measuredHeight
-
- mMatrix = imageMatrix
- mMatrix.getValues(mValues)
- }
-
- private fun initPicturePosition() {
- updateMatrixValuesOrigin(
- mMatrix,
- mValues,
- mDrawableW.toFloat(),
- mDrawableH.toFloat(),
- mImageViewW.toFloat(),
- mImageViewH.toFloat()
- )
- imageMatrix = mMatrix
- }
-
- fun setDurationMillis(durationMillis: Long): AutoZoomInImageView {
- mDurationMillis = durationMillis
- return this
- }
-
- fun startZoomInByScaleDelta(scaleDelta: Float = 0.2f, duration: Long = 3000) {
- val oriScaleX = mValues[0]
- val oriScaleY = mValues[4]
-
- va.addUpdateListener { animation ->
- val value = animation.animatedValue as Float
- onUpdate?.invoke(this@AutoZoomInImageView, value / scaleDelta)
- updateMatrixValuesSpan(
- mValues,
- mDrawableW.toFloat(),
- mDrawableH.toFloat(),
- mImageViewW.toFloat(),
- mImageViewH.toFloat(),
- oriScaleX,
- oriScaleY,
- value
- )
- mMatrix.setValues(mValues)
- imageMatrix = mMatrix
- }
- va.addListener(object : Animator.AnimatorListener {
- override fun onAnimationStart(animation: Animator) {
- onStart?.invoke(this@AutoZoomInImageView)
- }
-
- override fun onAnimationEnd(animation: Animator) {
- onEnd?.invoke(this@AutoZoomInImageView)
- }
-
- override fun onAnimationCancel(animation: Animator) {}
- override fun onAnimationRepeat(animation: Animator) {}
- })
- va.duration = duration
- va.start()
- }
-
- fun zoomPause() {
- if (va.isRunning) {
- Log.d(TAG, "pause")
- va.pause()
- }
- }
-
-
- fun zoomResume() {
- if (va.isStarted && va.isPaused) {
- Log.d(TAG, "resume")
- va.resume()
- } else {
- Log.d(TAG, "restart")
- va.start()
- }
- }
-
- private fun updateMatrixValuesOrigin(
- outMatrix: Matrix?,
- outValues: FloatArray?,
- drawW: Float,
- drawH: Float,
- imageW: Float,
- imageH: Float
- ) {
- if (outMatrix == null || outValues == null) {
- throw IllegalArgumentException("please set the source of AutoZoomInImageView's matrix and values")
- }
- outMatrix.reset()
-
- if (imageH * drawW > drawH * imageW) {
- val scale1 = imageH / drawH
- val offset1 = (drawW * scale1 - imageW) / 2
- outMatrix.postScale(scale1, scale1)
- outMatrix.postTranslate(-offset1, 0f)
- } else {
- val scale2 = imageW / drawW
- val offset2 = (drawH * scale2 - imageH) / 2
- outMatrix.postScale(scale2, scale2)
- outMatrix.postTranslate(0f, -offset2)
- }
- outMatrix.getValues(outValues)
- }
-
- private fun updateMatrixValuesSpan(
- outValues: FloatArray,
- drawW: Float, drawH: Float,
- imageW: Float, imageH: Float,
- oriScaleX: Float, oriScaleY: Float,
- scaleDelta: Float
- ) {
- outValues[0] = oriScaleX * (1 + scaleDelta)
- outValues[4] = oriScaleY * (1 + scaleDelta)
- val offsetwidth = (drawW * outValues[0] - imageW) / 2
- outValues[2] = -offsetwidth
- val offsetHeight = (drawH * outValues[4] - imageH) / 2
- outValues[5] = -offsetHeight
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_main_media_recycler.xml b/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_main_media_recycler.xml
index ccbb8d827b..81879ac41c 100644
--- a/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_main_media_recycler.xml
+++ b/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_main_media_recycler.xml
@@ -51,6 +51,7 @@
diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/glide/GlideImageLoader.java b/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/glide/GlideImageLoader.java
index 2d577f3dc0..b1eaa394cb 100644
--- a/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/glide/GlideImageLoader.java
+++ b/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/glide/GlideImageLoader.java
@@ -2,7 +2,9 @@ package com.mogo.service.impl.imageloader.glide;
import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.facade.annotation.Route;
@@ -10,7 +12,10 @@ import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
+import com.bumptech.glide.request.target.ImageViewTarget;
+import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
+import com.bumptech.glide.request.transition.Transition;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.imageloader.IMogoImageLoaderListener;
import com.mogo.service.imageloader.IMogoImageloader;
@@ -21,6 +26,8 @@ import com.mogo.service.impl.imageloader.glide.transform.GlideRoundBitmapTransfo
import com.mogo.service.impl.imageloader.glide.utils.DiskLruCacheManager;
import com.mogo.utils.glide.GlideApp;
+import java.io.File;
+
/**
* @author congtaowang
* @since 2019-12-23
@@ -142,22 +149,24 @@ public class GlideImageLoader implements IMogoImageloader {
GlideApp.with( context.getApplicationContext() )
.asBitmap()
.load( url )
- .listener( new RequestListener< Bitmap >() {
-
+ .into( new SimpleTarget< Bitmap >() {
@Override
- public boolean onLoadFailed( @Nullable GlideException e, Object model, Target< Bitmap > target, boolean isFirstResource ) {
- if ( listener != null ) {
- listener.onFailure( e );
- }
- return false;
- }
-
- @Override
- public boolean onResourceReady( Bitmap resource, Object model, Target< Bitmap > target, DataSource dataSource, boolean isFirstResource ) {
+ public void onResourceReady( @NonNull Bitmap resource, @Nullable Transition< ? super Bitmap > transition ) {
if ( listener != null ) {
listener.onCompleted( resource );
}
- return false;
+ }
+
+ @Override
+ public void onLoadStarted( @Nullable Drawable placeholder ) {
+ super.onLoadStarted( placeholder );
+ }
+
+ @Override
+ public void onLoadFailed( @Nullable Drawable errorDrawable ) {
+ if ( listener != null ) {
+ listener.onFailure( new Exception( "download failed." ) );
+ }
}
} );
}