1. 优化小智动画实现

2. 入口按钮添加白天模式的阴影
3. 大而全数据(短链+长链)-> 单独短链
4. 内存优化
This commit is contained in:
wangcongtao
2020-09-08 15:33:40 +08:00
parent c609e31385
commit e9880f35a3
27 changed files with 131 additions and 49 deletions

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>

View File

@@ -160,7 +160,7 @@ targetSdkVersion : 22,
gpssimulatornoop : "com.mogo.module:module-gps-simulator-noop:${MOGO_MODULE_GPS_SIMULATOR_NOOP_VERSION}",
adasapi : "com.zhidao.autopilot.support:adas:1.0.1",
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.0.8",
adasconfigapi : "com.zhidao.adasconfig:adasconfig:1.0.9",
// 个人中心的SDK
personalsdk : "com.zhidaoauto.person.info:data:1.0.1",

View File

@@ -47,7 +47,6 @@ public abstract class MvpFragment<V extends IView, P extends Presenter<V>> exten
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initViews(savedInstanceState);
}
/**
@@ -61,6 +60,7 @@ public abstract class MvpFragment<V extends IView, P extends Presenter<V>> exten
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initViews();
initViews(savedInstanceState);
mPresenter = createPresenter();
getViewLifecycleOwner().getLifecycle().addObserver(mPresenter);
}

View File

@@ -70,7 +70,7 @@ public class AMapViewWrapper implements IMogoMapView,
AMap.OnCameraChangeListener,
AMap.OnMyLocationChangeListener {
private static final String TAG = "AMapNaviViewWrapper";
private static final String TAG = "AMapViewWrapper";
private final MapView mMapView;
private IMogoMap mIMap;
@@ -243,6 +243,9 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onLowMemory() {
if ( mMapView != null ) {
mMapView.onLowMemory();
}
Logger.d( TAG, "map onLowMemory" );
}

View File

@@ -28,17 +28,8 @@ public class AnimWrapper implements Anim {
public void initAnim( ImageView target ) {
mTarget = target;
if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {
ThreadPoolService.execute( () -> {
final AnimationDrawable drawable = new AnimationDrawable();
for ( int i = 0; i < AnimRes.sRes.length; i++ ) {
drawable.addFrame( target.getResources().getDrawable( AnimRes.sRes[i] ), 100 );
}
UiThreadHandler.post( () -> {
target.setBackground( drawable );
mDelegate = new OthersAnim( drawable );
start();
} );
} );
mDelegate = new OthersAnim( target );
start();
} else {
mTarget.setImageResource( R.drawable.mogo_tts_icon_00000 );
}

View File

@@ -1,6 +1,9 @@
package com.mogo.module.apps.anim;
import android.graphics.drawable.AnimationDrawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.widget.ImageView;
/**
* @author congtaowang
@@ -8,25 +11,44 @@ import android.graphics.drawable.AnimationDrawable;
* <p>
* 描述
*/
public class OthersAnim implements Anim{
public class OthersAnim implements Anim {
private AnimationDrawable mDrawable;
private int mStartIndex = 0;
public OthersAnim( AnimationDrawable drawable ) {
this.mDrawable = drawable;
private final static int MSG_LOOP = 3003;
public static final long INTERVAL = 100L;
private boolean mStarted = false;
private final ImageView mImageView;
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
switch ( msg.what ) {
case MSG_LOOP:
if ( mStarted ) {
mImageView.setImageResource( AnimRes.sRes[mStartIndex++ % AnimRes.sRes.length] );
mHandler.sendEmptyMessageDelayed( MSG_LOOP, INTERVAL );
}
break;
}
}
};
public OthersAnim( ImageView imageView ) {
this.mImageView = imageView;
}
@Override
public void start() {
if ( mDrawable != null ) {
mDrawable.start();
}
mStarted = true;
mHandler.sendEmptyMessage( MSG_LOOP );
}
@Override
public void stop() {
if ( mDrawable != null ) {
mDrawable.stop();
}
mStarted = false;
mHandler.removeMessages( MSG_LOOP );
}
}

View File

@@ -1052,5 +1052,6 @@
<dimen name="sp_40">40px</dimen>
<dimen name="sp_42">42px</dimen>
<dimen name="sp_48">48px</dimen>
<dimen name="module_common_shadow_width">-10px</dimen>
</resources>

View File

@@ -1043,4 +1043,5 @@
<dimen name="sp_40">21.8750px</dimen>
<dimen name="sp_42">22.9688px</dimen>
<dimen name="sp_48">26.2500px</dimen>
<dimen name="module_common_shadow_width">-8px</dimen>
</resources>

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -8,11 +8,12 @@
android:id="@+id/module_ext_id_weather_container"
android:layout_width="wrap_content"
android:layout_height="@dimen/module_ext_height"
android:background="@drawable/module_ext_drawable_weather_bkg"
android:background="@drawable/module_ext_shadow_bkg"
android:gravity="center"
android:paddingStart="@dimen/module_ext_weather_container_paddingLeft"
android:paddingEnd="@dimen/module_ext_weather_container_paddingRight"
android:visibility="invisible"
android:translationY="@dimen/module_common_shadow_width"
app:layout_goneMarginLeft="@dimen/module_ext_notice_margin_start"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@+id/module_ext_id_msg"
@@ -37,23 +38,24 @@
tools:text="28°" />
</LinearLayout>
<FrameLayout
<RelativeLayout
android:id="@+id/module_ext_id_msg"
android:layout_width="@dimen/module_ext_height"
android:layout_height="@dimen/module_ext_height"
android:layout_marginStart="@dimen/module_ext_notice_margin_start"
android:translationY="@dimen/module_common_shadow_width"
android:layout_marginEnd="@dimen/module_ext_msg_marginRight"
android:background="@drawable/module_ext_drawable_msg_container_bkg"
android:background="@drawable/module_ext_shadow_bkg"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/ivUserHeadImg"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@+id/ivUserHeadImg"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible">
<ImageView
android:id="@+id/module_ext_id_msg_icon_counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:scaleType="fitXY"
android:src="@drawable/module_ext_ic_message2" />
@@ -61,23 +63,20 @@
android:id="@+id/module_ext_id_msg_counter"
android:layout_width="@dimen/module_ext_msg_counter_width"
android:layout_height="@dimen/module_ext_msg_counter_height"
android:layout_gravity="center"
android:layout_marginLeft="@dimen/module_ext_msg_dot_marginLeft"
android:layout_marginBottom="@dimen/module_ext_msg_dot_marginRight"
android:background="@drawable/module_ext_drawable_msg_bkg"
android:gravity="center"
android:layout_alignParentRight="true"
android:textColor="#FFFFFF"
android:textSize="@dimen/module_ext_msg_counter_textSize"
tools:text="···" />
</FrameLayout>
</RelativeLayout>
<ImageView
android:id="@+id/ivUserHeadImg"
android:layout_width="@dimen/module_ext_height"
android:layout_height="@dimen/module_ext_height"
android:src="@drawable/model_ext_default_user_head"
app:layout_constraintBottom_toBottomOf="@+id/module_ext_id_weather_container"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/module_ext_id_weather_container"
tools:visibility="gone" />
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
</merge>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="module_ext_msg_counter_margin">26px</dimen>
</resources>

View File

@@ -55,7 +55,7 @@
<dimen name="module_entrance_id_button_marginTop">20px</dimen>
<!-- module_ext_layout_extensions.xml-->
<dimen name="module_ext_height">100px</dimen>
<dimen name="module_ext_height">120px</dimen>
<dimen name="module_ext_paddingRight">60px</dimen>
<dimen name="module_ext_paddingLeft">60px</dimen>
<dimen name="module_ext_voice_textSize">32px</dimen>
@@ -145,4 +145,5 @@
<dimen name="module_ext_display_overview_icon_marginTop">20px</dimen>
<dimen name="module_ext_top_over_navi_height">40px</dimen>
<dimen name="module_ext_msg_counter_margin">45px</dimen>
</resources>

View File

@@ -55,7 +55,7 @@
<dimen name="module_entrance_id_button_marginTop">20px</dimen>
<!-- module_ext_layout_extensions.xml-->
<dimen name="module_ext_height">120px</dimen>
<dimen name="module_ext_height">140px</dimen>
<dimen name="module_ext_paddingRight">60px</dimen>
<dimen name="module_ext_paddingLeft">60px</dimen>
<dimen name="module_ext_voice_textSize">32px</dimen>
@@ -147,4 +147,5 @@
<dimen name="module_ext_top_over_navi_height">34px</dimen>
<dimen name="module_ext_notice_margin_start">175px</dimen>
<dimen name="module_ext_weather_margin_start">30px</dimen>
<dimen name="module_ext_msg_counter_margin">45px</dimen>
</resources>

View File

@@ -56,7 +56,7 @@
<dimen name="module_entrance_id_button_marginTop">8px</dimen>
<!-- module_ext_layout_extensions.xml-->
<dimen name="module_ext_height">66px</dimen>
<dimen name="module_ext_height">82px</dimen>
<dimen name="module_ext_paddingRight">32px</dimen>
<dimen name="module_ext_paddingLeft">32px</dimen>
@@ -152,5 +152,6 @@
<dimen name="module_ext_top_over_navi_height">19px</dimen>
<dimen name="module_ext_weather_margin_start">16px</dimen>
<dimen name="module_ext_msg_counter_margin">26px</dimen>
</resources>

View File

@@ -30,6 +30,7 @@ import com.mogo.map.navi.MogoTraffic;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.common.MogoModule;
import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.common.map.MapCenterPointStrategy;
import com.mogo.module.common.map.Scene;
import com.mogo.module.service.intent.IntentHandlerFactory;
@@ -224,9 +225,10 @@ public class MogoServices implements IMogoMapListener,
/**
* 手动刷新回调
*/
private RefreshCallback mCustomRefreshCallback = new RefreshCallback() {
private RefreshCallback mCustomRefreshCallback = new RefreshCallback< MarkerResponse >() {
@Override
public void onSuccess( Object o ) {
public void onSuccess( MarkerResponse o ) {
MapMarkerManager.getInstance().onSyncMarkerResponse( o );
mLoopRequest = false;
// 用户手动操作地图刷新成功后,设置状态为 true引发延时策略
mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, true );
@@ -241,9 +243,10 @@ public class MogoServices implements IMogoMapListener,
/**
* 自动刷新回调
*/
private RefreshCallback mAutoRefreshCallback = new RefreshCallback() {
private RefreshCallback mAutoRefreshCallback = new RefreshCallback<MarkerResponse>() {
@Override
public void onSuccess( Object o ) {
public void onSuccess( MarkerResponse o ) {
MapMarkerManager.getInstance().onSyncMarkerResponse( o );
mLoopRequest = false;
Logger.d( TAG, "request Success." );
invokeAutoRefreshStrategy();
@@ -436,7 +439,7 @@ public class MogoServices implements IMogoMapListener,
Logger.w( TAG, "lonLat is null." );
return;
}
mRefreshModel.refreshData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
mRefreshModel.refreshExplorerWayData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
MapMarkerManager.getInstance().getOnlineCarDataByAutoRefreshStrategy( ro.mLonLat );
Logger.i( TAG, "刷新半径 = %s, 点 = %s, zoomLevel = %s, amount = %s", ro.mRadius, ro.mLonLat, mLastZoomLevel, ro.mAmount );

View File

@@ -109,8 +109,8 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
mContext = context.getApplicationContext();
mRefreshModel = new RefreshModel( mContext );
// 长连接
MarkerServiceHandler.getMogoSocketManager().registerOnMessageListener( 401001, this );
// 长连接 - 长链变短链
// MarkerServiceHandler.getMogoSocketManager().registerOnMessageListener( 401001, this );
MarkerServiceHandler.getActionManager().registerBizActionDoneListener( this );
MarkerServiceHandler.getApis().getRegisterCenterApi().registerADASControlStatusChangedListener( TAG, this );
}
@@ -703,6 +703,16 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
} );
}
public void onSyncMarkerResponse(MarkerResponse response){
if ( ignoreDrawRequest() ) {
return;
}
Logger.d( TAG, "接收到了地图大而全数据" );
runOnTargetThread( () -> {
drawMapMarker( response );
} );
}
public void syncLocation( double lon, double lat ) {
mCarLatLng = new MogoLatLng( lat, lon );
}

View File

@@ -110,6 +110,51 @@ public class RefreshModel {
}
}
public void refreshExplorerWayData( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
if ( mRefreshApiService != null ) {
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
final RefreshBody refreshBody = new RefreshBody();
refreshBody.limit = limit;
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
refreshBody.radius = radius;
refreshBody.dataType.add( ServiceConst.CARD_TYPE_ROAD_CONDITION );
String data = GsonUtil.jsonFromObject( refreshBody );
query.put( "data", data );
Logger.d( TAG, data );
mRefreshApiService.refreshDataSync( query )
.subscribeOn( Schedulers.io() )
.observeOn( AndroidSchedulers.mainThread() )
.subscribe( new SubscribeImpl< MarkerResponse >( RequestOptions.create( mContext ) ) {
@Override
public void onSuccess( MarkerResponse o ) {
super.onSuccess( o );
if ( callback != null ) {
callback.onSuccess( o );
}
}
@Override
public void onError( Throwable e ) {
super.onError( e );
if ( callback != null ) {
callback.onFail();
}
}
@Override
public void onError( String message, int code ) {
super.onError( message, code );
if ( callback != null ) {
callback.onFail();
}
}
} );
}
}
public void refreshDataSync( MogoLatLng latLng, int radius, int limit, final RefreshCallback callback ) {
if ( mRefreshApiService != null ) {
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB