This commit is contained in:
wangcongtao
2020-01-03 10:35:44 +08:00
100 changed files with 1075 additions and 177 deletions

View File

@@ -75,13 +75,9 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
protected void initViews() {
position = getArguments().getInt("position");
mNaviMode = findViewById(R.id.demo_module_id_navi_mode);
TanluServiceHandler.getPoiSearch().setPoiSearchListener(this);
mLocation = TanluServiceHandler.getLocationClient().getLastKnowLocation();
m2D3D = findViewById(R.id.demo_module_id_2d3d);
mLocInfo = findViewById(R.id.demo_module_id_loc_info);
mLoc = findViewById(R.id.demo_module_id_loc);
mLoc.setOnClickListener(
@@ -161,78 +157,6 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
}
});
findViewById(R.id.demo_module_id_start_navi).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getNavi().startNavi(!mNaviMode.isChecked());
}
});
findViewById(R.id.demo_module_id_stop_navi).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getNavi().stopNavi();
}
});
findViewById(R.id.demo_module_id_traffic).setOnClickListener(new View.OnClickListener() {
private boolean enable = true;
@Override
public void onClick(View v) {
TanluServiceHandler.getMapUIController().setTrafficEnabled(enable = !enable);
}
});
findViewById(R.id.demo_module_id_zoom_in).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getMapUIController().changeZoom(true);
}
});
findViewById(R.id.demo_module_id_zoom_out).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getMapUIController().changeZoom(false);
}
});
findViewById(R.id.demo_module_id_day_light).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getMapUIController().changeMapMode(EnumMapUI.Type_Light);
}
});
findViewById(R.id.demo_module_id_day_night).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getMapUIController().changeMapMode(EnumMapUI.Type_Night);
}
});
findViewById(R.id.demo_module_id_display_overlay).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getMapUIController().displayOverview();
}
});
findViewById(R.id.demo_module_id_reverse_lock).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getMapUIController().recoverLockMode();
}
});
TanluServiceHandler.getLocationClient().addLocationListener(new IMogoLocationListener() {
@Override
public void onLocationChanged(MogoLocation location) {

View File

@@ -0,0 +1,12 @@
package com.mogo.tanlu.constant;
/**
* @author congtaowang
* @since 2019-12-24
* <p>
* 描述
*/
public class TanluConstants {
public static final String TAG = "/tanlu/ui";
}

View File

@@ -0,0 +1,298 @@
package com.mogo.tanlu.fragment;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mogo.commons.mvp.IView;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.commons.mvp.Presenter;
import com.mogo.map.MogoLatLng;
import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.model.MogoPoi;
import com.mogo.map.search.geo.MogoPoiItem;
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
import com.mogo.map.search.poisearch.MogoPoiResult;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.tanlu.R;
import com.mogo.tanlu.constant.TanluConstants;
import com.mogo.utils.TipToast;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* @author lixiaopeng
* @description
* @since 2020-01-02
*/
public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
implements IView,
IMogoMarkerClickListener,
IMogoModuleLifecycle,
IMogoMapListener,
IMogoPoiSearchListener,
IMogoLocationListener {
private static final String TAG = "TanluCardViewFragment";
private Button mAddMarker;
private Button mAddMarkers;
private Bitmap mMarkerIcon;
private Bitmap mClickedMarkerIcon;
private TextView mLocInfo;
private TextView mLoc;
private Button m2D3D;
private CheckBox mNaviMode;
private IMogoMarker mLastClickedMarker;
private TanluInfoWindowAdapter mDemoInfoWindowAdapter;
private MogoLocation mLocation;
private int position = -1;
@Override
protected int getLayoutId() {
return R.layout.tanlu_card_view;
}
@Override
protected void initViews() {
position = getArguments().getInt("position");
TanluServiceHandler.getPoiSearch().setPoiSearchListener(this);
mLocation = TanluServiceHandler.getLocationClient().getLastKnowLocation();
mLocInfo = findViewById(R.id.demo_module_id_loc_info);
mLoc = findViewById(R.id.demo_module_id_loc);
mLoc.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getLocationClient().start(4_000L);
}
}
);
mDemoInfoWindowAdapter = new TanluInfoWindowAdapter(getContext(), TanluServiceHandler.getNavi(), TanluServiceHandler.getImageloader());
mMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_search_poi_location);
mClickedMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_search_choice_point);
mAddMarker = findViewById(R.id.demo_module_id_add_marker);
mAddMarker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MogoMarkerOptions options = new MogoMarkerOptions()
.icon(mMarkerIcon)
.latitude(39.974525d)
.owner(TanluConstants.TAG)
.longitude(116.41733d);
IMogoMarker marker = TanluServiceHandler.getMarkerManager().addMarker(TanluConstants.TAG, options);
marker.setInfoWindowAdapter(mDemoInfoWindowAdapter);
marker.setOnMarkerClickListener(TanluCardViewFragment.this);
}
});
mAddMarkers = findViewById(R.id.demo_module_id_add_markers);
mAddMarkers.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ArrayList<MogoMarkerOptions> optionsList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
MogoMarkerOptions options = new MogoMarkerOptions()
.owner(TanluConstants.TAG)
.latitude(39.974525d + new Random().nextDouble())
.longitude(116.41733d + new Random().nextDouble());
if (i % 2 == 0) {
options.icon(mMarkerIcon);
} else {
options.icon(mDemoInfoWindowAdapter.getMarkerView(options));
}
optionsList.add(options);
}
List<IMogoMarker> iMogoMarkers = TanluServiceHandler.getMarkerManager().addMarkers(TanluConstants.TAG, optionsList, true);
for (IMogoMarker iMogoMarker : iMogoMarkers) {
iMogoMarker.setInfoWindowAdapter(mDemoInfoWindowAdapter);
iMogoMarker.setOnMarkerClickListener(TanluCardViewFragment.this);
}
}
});
findViewById(R.id.demo_module_id_clear).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getMarkerManager().removeMarkers(TanluConstants.TAG);
}
});
m2D3D.setOnClickListener(new View.OnClickListener() {
private EnumMapUI ui = EnumMapUI.NorthUP_2D;
@Override
public void onClick(View v) {
TanluServiceHandler.getMapUIController().changeMapMode(ui = ui.next());
m2D3D.setText(ui.toString());
}
});
findViewById(R.id.demo_module_id_current).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TanluServiceHandler.getMapUIController().moveToCenter(new MogoLatLng(mLocation.getLatitude(), mLocation.getLongitude()));
}
});
TanluServiceHandler.getLocationClient().addLocationListener(new IMogoLocationListener() {
@Override
public void onLocationChanged(MogoLocation location) {
mLocation = location;
Logger.d(TAG, "demo模块定位定位间隔4s");
}
});
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getViewLifecycleOwner().getLifecycle().addObserver(mPresenter);
}
@Override
public boolean onMarkerClicked(IMogoMarker marker) {
// if ( mLastClickedMarker != null ) {
// mLastClickedMarker.setIcon( this.mMarkerIcon );
// }
// marker.setIcon( mClickedMarkerIcon );
// mLastClickedMarker = marker;
// marker.showInfoWindow();
return true;
}
@NonNull
@Override
protected Presenter createPresenter() {
return new Presenter(this) {
};
}
//TODO C位事件
@Override
public void onPerform() {
Logger.d(TAG, "卡片2有效");
}
//TODO 离开C位事件
@Override
public void onDisable() {
Logger.d(TAG, "卡片2无效");
}
@Override
public void accOn() {
}
@Override
public void onMapLoaded() {
Logger.d(TAG, "地图加载事件");
}
@Override
public void onTouch(MotionEvent motionEvent) {
// Logger.d( TAG, "地图触摸事件" );
}
@Override
public void onPOIClick(MogoPoi poi) {
if (poi != null) {
TipToast.shortTip(poi.getName());
}
TanluServiceHandler.getPoiSearch().searchPOIIdAsyn(poi.getPoiId());
}
@Override
public void onPoiSearched(MogoPoiResult result, int errorCode) {
}
private IMogoMarker mPoiMarker;
@Override
public void onPoiItemSearched(MogoPoiItem item, int errorCode) {
if (item == null) {
return;
}
if (mPoiMarker != null) {
mPoiMarker.destroy();
}
mPoiMarker = TanluServiceHandler.getMarkerManager().addMarker(TanluConstants.TAG, new MogoMarkerOptions()
.longitude(item.getPoint().lng)
.latitude(item.getPoint().lat)
.icon(mMarkerIcon));
if (mPoiMarker != null) {
mPoiMarker.setInfoWindowAdapter(mDemoInfoWindowAdapter);
mPoiMarker.setObject(item);
mPoiMarker.showInfoWindow();
}
}
@Override
public void onLocationChanged(MogoLocation location) {
mLocation = location;
Logger.i(TAG, "接受到的地图模块定位信息");
if (mLocInfo != null) {
if (location.getErrCode() == 0) {
mLocInfo.setText("当前位置:" + location.getAddress());
} else {
mLocInfo.setText(location.getErrInfo());
}
}
}
@Override
public void onMapClick(MogoLatLng latLng) {
}
@Override
public void onLockMap(boolean isLock) {
}
@Override
public void onMapModeChanged(EnumMapUI ui) {
Logger.d(TAG, ui.name());
}
@Override
public void onDestroyView() {
Logger.w(TAG, "onDestroyView position=" + position);
super.onDestroyView();
getViewLifecycleOwner().getLifecycle().removeObserver(mPresenter);
TanluServiceHandler.getLocationClient().removeLocationListener(this);
if (mLastClickedMarker != null) {
mLastClickedMarker.destroy();
mLastClickedMarker = null;
}
}
}

View File

@@ -0,0 +1,79 @@
package com.mogo.tanlu.fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.navi.IMogoNaviListener;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.tanlu.constant.TanluConstants;
import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
* @since 2019-12-24
* <p>
* 描述
*/
@Route( path = TanluConstants.TAG )
public class TanluCardViewProvider implements IMogoModuleProvider {
private static final String TAG = "TanluCardViewProvider";
private TanluCardViewFragment fragment;
@Override
public Fragment createFragment( Context context, Bundle data ) {
fragment = new TanluCardViewFragment();
fragment.setArguments( data );
Logger.i( TAG, "createFragment" );
return fragment;
}
@Override
public void init( Context context ) {
TanluServiceHandler.init( context );
}
@Override
public String getModuleName() {
return "CARD_TYPE_ROAD_CODITION";
}
@Override
public IMogoModuleLifecycle getCardLifecycle() {
return fragment;
}
@Override
public View createView( Context context ) {
// don't
return null;
}
@Override
public IMogoMapListener getMapListener() {
return fragment;
}
@Override
public int getType() {
return IMogoModuleProvider.TYPE_FRAGMENT;
}
@Override
public IMogoNaviListener getNaviListener() {
return null;
}
@Override
public IMogoLocationListener getLocationListener() {
return fragment;
}
}

View File

@@ -0,0 +1,131 @@
package com.mogo.tanlu.fragment;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.mogo.map.marker.IMogoInfoWindowAdapter;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.navi.MogoNaviConfig;
import com.mogo.map.search.geo.MogoPoiItem;
import com.mogo.service.imageloader.IMogoImageLoaderListener;
import com.mogo.service.imageloader.IMogoImageloader;
import com.mogo.service.imageloader.MogoImageView;
import com.mogo.tanlu.R;
import com.mogo.utils.WindowUtils;
import com.mogo.utils.logger.Logger;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author congtaowang
* @since 2019-12-24
* <p>
* 描述
*/
public class TanluInfoWindowAdapter implements IMogoInfoWindowAdapter {
private static final String TAG = "DemoInfoWindowAdapter";
private Context mContext;
private IMogoNavi mNavi;
private IMogoImageloader mImageloader;
public TanluInfoWindowAdapter(Context mContext, IMogoNavi mNavi, IMogoImageloader iMogoImageloader ) {
this.mContext = mContext;
this.mNavi = mNavi;
this.mImageloader = iMogoImageloader;
}
@Override
public View getInfoWindow( IMogoMarker marker ) {
if ( marker.getObject() instanceof MogoPoiItem ) {
View view = LayoutInflater.from( mContext ).inflate( R.layout.tanlu_poi_info_window, null );
renderPoiVew( view, marker, ( ( MogoPoiItem ) marker.getObject() ) );
return view;
} else {
View view = LayoutInflater.from( mContext ).inflate( R.layout.tanlu_info_window, null );
renderView( view, marker );
return view;
}
}
private void renderView( View view, final IMogoMarker marker ) {
final TextView time = view.findViewById( R.id.demo_module_id_iw_time );
Button refresh = view.findViewById( R.id.demo_module_id_iw_refresh );
time.setText( new SimpleDateFormat( "yyyyMMdd HHMMSS" ).format( new Date() ) );
refresh.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View v ) {
marker.showInfoWindow();
}
} );
Button navi2 = view.findViewById( R.id.demo_module_id_iw_navito );
navi2.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View v ) {
if ( mNavi != null ) {
mNavi.naviTo( marker.getPosition(), new MogoNaviConfig() );
}
}
} );
Button stopNavi = view.findViewById( R.id.demo_module_id_iw_navi_stop );
stopNavi.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View v ) {
if ( mNavi != null ) {
mNavi.stopNavi();
}
}
} );
}
private void renderPoiVew( View view, final IMogoMarker marker, MogoPoiItem item ) {
final TextView time = view.findViewById( R.id.demo_module_id_iw_poi_title );
time.setText( item.getTitle() );
Button navi2 = view.findViewById( R.id.demo_module_id_iw_poi_navito );
navi2.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View v ) {
if ( mNavi != null ) {
mNavi.naviTo( marker.getPosition(), new MogoNaviConfig() );
}
marker.hideInfoWindow();
marker.remove();
}
} );
}
public View getMarkerView( final MogoMarkerOptions options ) {
final View view = LayoutInflater.from( mContext ).inflate( R.layout.tanlu_bubble_marker, null );
final MogoImageView icon = view.findViewById( R.id.icon );
mImageloader.displayImage( "http://imgnews.gmw.cn/attachement/jpg/site2/20191229/00d86176ed0b1f71f4580f.jpg", icon, WindowUtils.dip2px( mContext, 50 ), WindowUtils.dip2px( mContext, 50 ),
new IMogoImageLoaderListener() {
@Override
public void onStart() {
}
@Override
public void onCompleted( Bitmap bitmap ) {
// 刷新图标
Logger.d( TAG, "loaded." );
options.icon( view );
options.notifyObservers();
}
@Override
public void onFailure( Exception e ) {
}
} );
return view;
}
}

View File

@@ -0,0 +1,70 @@
package com.mogo.tanlu.fragment;
import android.content.Context;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.map.location.IMogoLocationClient;
import com.mogo.map.marker.IMogoMarkerManager;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.search.poisearch.IMogoPoiSearch;
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.imageloader.IMogoImageloader;
import com.mogo.service.map.IMogoMapService;
/**
* @author congtaowang
* @since 2019-12-30
* <p>
* 持有服务接口实例
*/
public class TanluServiceHandler {
private static IMogoMapService mMapService;
private static IMogoPoiSearch mPoiSearch;
private static IMogoLocationClient mLocationClient;
private static IMogoMarkerManager mMarkerManager;
private static IMogoNavi mNavi;
private static IMogoMapUIController mMapUIController;
private static IMogoImageloader mImageloader;
public static void init( Context context ) {
mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( context );
mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( context );
mImageloader = ( IMogoImageloader ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_IMAGE_LOADER ).navigation( context );
mPoiSearch = mMapService.getPoiSearch( context, new MogoPoiSearchQuery() );
mLocationClient = mMapService.getLocationClient( context );
mMarkerManager = mMapService.getMarkerManager( context );
mNavi = mMapService.getNavi( context );
mMapUIController = mMapService.getMapUIController();
}
public static IMogoMapService getMapService() {
return mMapService;
}
public static IMogoPoiSearch getPoiSearch() {
return mPoiSearch;
}
public static IMogoLocationClient getLocationClient() {
return mLocationClient;
}
public static IMogoMarkerManager getMarkerManager() {
return mMarkerManager;
}
public static IMogoNavi getNavi() {
return mNavi;
}
public static IMogoMapUIController getMapUIController() {
return mMapUIController;
}
public static IMogoImageloader getImageloader() {
return mImageloader;
}
}

View File

@@ -0,0 +1,229 @@
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
class AutoZoomInImageView : ImageView {
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
if (mDrawable == null) {
throw IllegalArgumentException("please set the source of AutoZoomInImageView")
}
mDrawableW = mDrawable.intrinsicWidth
mDrawableH = mDrawable.intrinsicHeight
mImageViewW = measuredWidth
mImageViewH = measuredHeight
mMatrix = imageMatrix
mMatrix.getValues(mValues)
}
private fun initInternalValues(drawable: Drawable) {
mDrawable = drawable
if (mDrawable == null) {
throw IllegalArgumentException("please set the source of AutoZoomInImageView")
}
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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 742 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="1080.0">
<shape
android:shape="ring"
android:thickness="4mm"
android:useLevel="false">
<gradient
android:endColor="@color/colorAccent"
android:startColor="@color/color_171F7FFF"
android:type="sweep"/>
</shape>
</rotate>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/main_enlarge_btn_press" android:state_pressed="true" />
<item android:drawable="@mipmap/main_enlarge_btn_normal" android:state_pressed="false" />
<item android:drawable="@mipmap/main_enlarge_btn_normal" />
</selector>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:topLeftRadius="0mm"
android:topRightRadius="0mm"
android:bottomLeftRadius="6mm"
android:bottomRightRadius="6mm"/>
<solid android:color="@color/color_222533"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:topLeftRadius="6mm"
android:topRightRadius="6mm"
android:bottomLeftRadius="0mm"
android:bottomRightRadius="0mm"/>
<solid android:color="@color/color_222533"/>
</shape>

View File

@@ -36,7 +36,6 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
@@ -54,104 +53,5 @@
android:text="当前位置" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<Button
android:id="@+id/demo_module_id_2d3d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2D/3D" />
<Button
android:id="@+id/demo_module_id_traffic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="交通态势" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<Button
android:id="@+id/demo_module_id_start_navi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="开始导航" />
<Button
android:id="@+id/demo_module_id_stop_navi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="停止导航" />
<CheckBox
android:id="@+id/demo_module_id_navi_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="模拟导航" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<Button
android:id="@+id/demo_module_id_zoom_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="放大" />
<Button
android:id="@+id/demo_module_id_zoom_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="缩小" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<Button
android:id="@+id/demo_module_id_day_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="白天" />
<Button
android:id="@+id/demo_module_id_day_night"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="黑夜" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<Button
android:id="@+id/demo_module_id_display_overlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="全览" />
<Button
android:id="@+id/demo_module_id_reverse_lock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="继续导航" />
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<com.zhidao.roadcondition.video.MediaCoverVideoPlayer
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:longClickable="true" />
<com.zhidao.roadcondition.view.AutoZoomInImageView
android:id="@+id/iv_pager_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:longClickable="true"
android:visibility="gone" />
</RelativeLayout>

View File

@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="400mm"
android:layout_height="400mm"
android:layout_marginTop="30mm">
<RelativeLayout
android:id="@+id/layout_top_view"
android:layout_width="match_parent"
android:layout_height="94mm"
android:background="@drawable/shape_bg_222533_6px_top">
<TextView
android:id="@+id/tv_information_media_content"
android:layout_width="match_parent"
android:layout_height="28mm"
android:layout_marginLeft="20mm"
android:layout_marginTop="22mm"
android:layout_marginRight="20mm"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/main_empty_location"
android:textColor="@color/white"
android:textSize="22mm" />
<TextView
android:id="@+id/tv_distance_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_information_media_content"
android:layout_marginLeft="20mm"
android:layout_marginTop="3mm"
android:layout_marginBottom="18mm"
android:textSize="20mm" />
</RelativeLayout>
<com.zhidao.roadcondition.video.SimpleCoverVideoPlayer
android:id="@+id/video_player_main"
android:layout_width="400mm"
android:layout_height="225mm"
android:layout_below="@+id/layout_top_view" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="81mm"
android:layout_below="@+id/video_player_main"
android:background="@drawable/shape_bg_222533_6px_bottom">
<ImageView
android:id="@+id/username_image_video"
android:layout_width="40mm"
android:layout_height="40mm"
android:layout_centerVertical="true"
android:layout_marginLeft="20mm" />
<TextView
android:id="@+id/tv_username_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10mm"
android:layout_toRightOf="@+id/username_image_video"
android:textColor="@color/white"
android:textSize="18mm" />
<TextView
android:id="@+id/tv_information_media_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:paddingLeft="15mm"
android:paddingRight="17mm"
android:textColor="@color/color_9A9A9A"
android:textSize="16mm" />
</RelativeLayout>
</RelativeLayout>

View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="400mm"
android:layout_height="400mm"
android:layout_marginTop="30mm">
<TextView
android:id="@+id/tv_information_content"
android:layout_width="match_parent"
android:layout_height="28mm"
android:layout_marginLeft="20mm"
android:layout_marginTop="22mm"
android:layout_marginRight="5mm"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/main_empty_location"
android:textColor="@color/white"
android:textSize="22mm" />
<TextView
android:id="@+id/tv_distance_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_information_content"
android:layout_marginLeft="20mm"
android:layout_marginTop="3mm"
android:layout_marginBottom="14mm"
android:textSize="20mm" />
<com.zhidao.roadcondition.view.AutoZoomInImageView
android:id="@+id/recycle_photo_imageView"
android:layout_width="400mm"
android:layout_height="225mm"
android:layout_below="@+id/tv_distance_photo" />
<ProgressBar
android:id="@+id/pb_loading"
android:layout_width="48mm"
android:layout_height="48mm"
android:layout_centerInParent="true"
android:indeterminateDrawable="@drawable/loading_bg"
android:visibility="gone" />
<Button
android:id="@+id/btn_enlarge"
android:layout_width="30mm"
android:layout_height="30mm"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginRight="14mm"
android:layout_marginBottom="95mm"
android:background="@drawable/selector_bg_btn_enlarge" />
<!--bottom-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="81mm"
android:layout_below="@+id/recycle_photo_imageView">
<ImageView
android:id="@+id/username_image_photo"
android:layout_width="40mm"
android:layout_height="40mm"
android:layout_centerVertical="true"
android:layout_marginLeft="20mm" />
<TextView
android:id="@+id/tv_username_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10mm"
android:layout_toRightOf="@+id/username_image_photo"
android:textColor="@color/white"
android:textSize="18mm" />
<TextView
android:id="@+id/tv_information_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="20mm"
android:textColor="@color/white"
android:textSize="18mm" />
</RelativeLayout>
</RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -1,3 +1,30 @@
<resources>
<string name="app_name">tanlu</string>
<string name="affirm">返回</string>
<string name="cancel">取消授权</string>
<string name="splash_agreement">《探路共享计划》</string>
<string name="start_already_agreement">已同意</string>
<string name="splash_agreement_bt">探路共享计划 >> </string>
<string name="splash_agreement_dialog_title">探路APP用户服务协议</string>
<string name="main_empty_content"><Data><![CDATA[<font color="#69718B">未找到其他用户分享的路况,<br/>您可以试试</font><font color="#F7B500">上报路况</font>]]></Data></string>
<string name="main_empty_location">未知区域</string>
<string name="custom_send_road_condition">上报路况</string>
<string name="text_searching_information">正在更新情报数据</string>
<string name="first_week_tts_content">欢迎使用探路,您可以在探路内查看到周边的实时路况,也可以通过关键词“上报路况”来分享一段视频给其他车主</string>
<string name="first_custom_send_content">您还可以试试语音上报</string>
<string name="voice_get_informations_tts">为您找到%s条路况信息</string>
<string name="start_mogo_car_connect">开启小智车联</string>
<string name="start_mogo_share">共享计划</string>
<array name="searching_voice_string_array">
<item >正在为您搜索路况</item>
<item >探路系统正在为您搜索</item>
<item >小智这就去查,您稍等一下</item>
</array>
<array name="search_fail_voice_array">
<item>找不到相关地址</item>
<item>找不到地址,是小智不好</item>
<item>未找到其他车主分享的路况信息</item>
</array>
</resources>