opt
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<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>
|
||||
@@ -75,6 +75,8 @@ public class ParamsUtil {
|
||||
public static Map< String, Object > getAnalyticsCustomParams() {
|
||||
Map< String, Object > map = new ArrayMap<>();
|
||||
map.put( "debug", DebugConfig.isDebug() ? 1 : 0 );
|
||||
map.put( "systemversion", Utils.getFotaVersion() );
|
||||
map.put( "sn", Utils.getSn() );
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,15 +55,24 @@ public class Utils {
|
||||
|
||||
public static final String GET = "get";
|
||||
public static final String GSM_SERIAL = "gsm.serial";
|
||||
public static final String FOTA_VERSION = "ro.fota.version";
|
||||
public static final String PROPERTIES = "android.os.SystemProperties";
|
||||
|
||||
public static String getSn() {
|
||||
String serial = "";
|
||||
return getSystemProperties( GSM_SERIAL );
|
||||
}
|
||||
|
||||
public static String getFotaVersion() {
|
||||
return getSystemProperties( FOTA_VERSION );
|
||||
}
|
||||
|
||||
public static String getSystemProperties( String name ) {
|
||||
String value = "";
|
||||
|
||||
try {
|
||||
Class< ? > c = Class.forName( PROPERTIES );
|
||||
Method get = c.getMethod( GET, String.class );
|
||||
serial = ( String ) get.invoke( c, GSM_SERIAL );
|
||||
value = ( String ) get.invoke( c, GSM_SERIAL );
|
||||
} catch ( ClassNotFoundException var3 ) {
|
||||
var3.printStackTrace();
|
||||
} catch ( NoSuchMethodException var4 ) {
|
||||
@@ -73,7 +82,6 @@ public class Utils {
|
||||
} catch ( IllegalAccessException var6 ) {
|
||||
var6.printStackTrace();
|
||||
}
|
||||
|
||||
return serial;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,16 @@ import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.mogo.utils.ThreadPoolService;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder.Callback {
|
||||
|
||||
private static final String TAG = "JSurfaceView";
|
||||
|
||||
private SurfaceHolder mHolder;
|
||||
|
||||
/**
|
||||
@@ -33,6 +40,15 @@ public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder
|
||||
*/
|
||||
private int[] mFrames;
|
||||
|
||||
// 使用 BitmapFactory.Option.inBitmap 属性复用 bitmap 对象
|
||||
private Bitmap mContainerBitmap = null;
|
||||
|
||||
// mContainerBitmap 是否生效
|
||||
private boolean mContainerBitmapStatus = true;
|
||||
|
||||
// mContainerBitmapStatus 为 false 时,使用该缓存方案
|
||||
private Map< Integer, WeakReference< Bitmap > > mBitmapRefMap = new HashMap<>();
|
||||
|
||||
public JSurfaceView( Context context ) {
|
||||
super( context );
|
||||
init();
|
||||
@@ -87,28 +103,60 @@ public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder
|
||||
|
||||
private void drawBitmap() {
|
||||
//获取画布并锁定
|
||||
Canvas mCanvas = mHolder.lockCanvas();
|
||||
if ( mCanvas == null ) {
|
||||
Canvas canvas = mHolder.lockCanvas();
|
||||
if ( canvas == null ) {
|
||||
return;
|
||||
}
|
||||
//绘制透明色
|
||||
mCanvas.drawColor( Color.TRANSPARENT, PorterDuff.Mode.CLEAR );
|
||||
Bitmap mBitmap = BitmapFactory.decodeResource( getResources(), mFrames[mCurrentPos % mFrames.length] );
|
||||
canvas.drawColor( Color.TRANSPARENT, PorterDuff.Mode.CLEAR );
|
||||
|
||||
int factPosition = mCurrentPos % mFrames.length;
|
||||
|
||||
if ( mContainerBitmapStatus ) {
|
||||
if ( mContainerBitmap == null ) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inMutable = true;
|
||||
mContainerBitmap = BitmapFactory.decodeResource( getResources(), mFrames[factPosition], options );
|
||||
} else {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inMutable = true;
|
||||
options.inBitmap = mContainerBitmap;
|
||||
try {
|
||||
BitmapFactory.decodeResource( getResources(), mFrames[factPosition], options );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
mContainerBitmapStatus = false;
|
||||
mContainerBitmap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !mContainerBitmapStatus ) {
|
||||
WeakReference< Bitmap > ref = mBitmapRefMap.get( factPosition );
|
||||
if ( ref != null && ref.get() != null && !ref.get().isRecycled() ) {
|
||||
mContainerBitmap = ref.get();
|
||||
} else {
|
||||
mContainerBitmap = BitmapFactory.decodeResource( getResources(), mFrames[factPosition] );
|
||||
mBitmapRefMap.put( factPosition, new WeakReference<>( mContainerBitmap ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( mContainerBitmap == null || mContainerBitmap.isRecycled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
Paint paint = new Paint();
|
||||
Rect mSrcRect = new Rect( 0,
|
||||
0,
|
||||
mBitmap.getWidth(),
|
||||
mBitmap.getHeight() ); // 图片绘制
|
||||
mContainerBitmap.getWidth(),
|
||||
mContainerBitmap.getHeight() ); // 图片绘制
|
||||
Rect mDestRect = new Rect( 0,
|
||||
0,
|
||||
getWidth(),
|
||||
getHeight() );// 图片绘制位置
|
||||
|
||||
mCanvas.drawBitmap( mBitmap, mSrcRect, mDestRect, paint );
|
||||
canvas.drawBitmap( mContainerBitmap, mSrcRect, mDestRect, paint );
|
||||
//解锁画布,并展示bitmap到surface
|
||||
mHolder.unlockCanvasAndPost( mCanvas );
|
||||
mBitmap.recycle();
|
||||
mHolder.unlockCanvasAndPost( canvas );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.module.main;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@@ -112,11 +111,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
||||
super.onPageScrolled( position, positionOffset, positionOffsetPixels );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged( int state ) {
|
||||
super.onPageScrollStateChanged( state );
|
||||
@@ -143,6 +137,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
properties.put( "appname", provider.getAppName() );
|
||||
properties.put( "packagename", provider.getAppPackage() );
|
||||
properties.put( "activeTime", System.currentTimeMillis() - mCardStartShowTime );
|
||||
properties.put( "type", provider.getModuleName() );
|
||||
mAnalytics.track( "Launcher_Card_Show", properties );
|
||||
mCardStartShowTime = System.currentTimeMillis();
|
||||
}
|
||||
@@ -157,6 +152,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
Map< String, Object > properties = new HashMap<>();
|
||||
properties.put( "appname", provider.getAppName() );
|
||||
properties.put( "packagename", provider.getAppPackage() );
|
||||
properties.put( "type", provider.getModuleName() );
|
||||
mAnalytics.track( "Launcher_Card_Slide", properties );
|
||||
}
|
||||
} );
|
||||
|
||||
@@ -32,6 +32,10 @@ import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -263,6 +267,8 @@ public class MarkerServiceHandler {
|
||||
lastMarker = null;
|
||||
getMarkerManager().removeMarkers();
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
|
||||
// 解析不同的Marker类型,然后对应的进行绘制
|
||||
if (response != null && response.getResult() != null) {
|
||||
MarkerCardResult markerCardResult = response.getResult();
|
||||
@@ -301,7 +307,7 @@ public class MarkerServiceHandler {
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
}
|
||||
analyticData(3, onlineCarList.size());
|
||||
fillNumberTrackEventBody(array, 3, onlineCarList.size());
|
||||
}
|
||||
|
||||
if (exploreWayList != null) {
|
||||
@@ -318,7 +324,7 @@ public class MarkerServiceHandler {
|
||||
drawMapMarker(markerShowEntity);
|
||||
}
|
||||
}
|
||||
analyticData(1, exploreWayList.size());
|
||||
fillNumberTrackEventBody(array, 1, exploreWayList.size());
|
||||
}
|
||||
|
||||
if (shareMusicList != null) {
|
||||
@@ -334,7 +340,7 @@ public class MarkerServiceHandler {
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
}
|
||||
analyticData(4, shareMusicList.size());
|
||||
fillNumberTrackEventBody(array, 4, shareMusicList.size());
|
||||
}
|
||||
|
||||
if (noveltyInfoList != null) {
|
||||
@@ -373,27 +379,42 @@ public class MarkerServiceHandler {
|
||||
break;
|
||||
}
|
||||
}
|
||||
analyticData(2, num_gas_station);
|
||||
analyticData(6, num_road_closed);
|
||||
analyticData(5, num_traffic_check);
|
||||
analyticData(7, num_shop_discount);
|
||||
analyticData(8, num_fours_shop);
|
||||
fillNumberTrackEventBody(array,2, num_gas_station);
|
||||
fillNumberTrackEventBody(array,6, num_road_closed);
|
||||
fillNumberTrackEventBody(array,5, num_traffic_check);
|
||||
fillNumberTrackEventBody(array,7, num_shop_discount);
|
||||
fillNumberTrackEventBody(array,8, num_fours_shop);
|
||||
}
|
||||
analyticData(array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void fillNumberTrackEventBody(JSONArray arr, int type, int size){
|
||||
JSONObject object = new JSONObject( );
|
||||
try {
|
||||
object.put( "type", type );
|
||||
object.put( "num", size);
|
||||
if ( arr != null ) {
|
||||
arr.put( object );
|
||||
}
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
getMapUIController().changeZoom(12);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计地图内数据获取
|
||||
*
|
||||
* @param type 类型
|
||||
* @param num marker数量
|
||||
* @param array 埋点数据
|
||||
*/
|
||||
private static void analyticData(int type, int num) {
|
||||
private static void analyticData(JSONArray array) {
|
||||
try {
|
||||
if ( array == null || array.length() == 0 ) {
|
||||
return;
|
||||
}
|
||||
final Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("type", type);
|
||||
properties.put("num", num);
|
||||
properties.put("data", array.toString());
|
||||
getMogoAnalytics().track("Launcher_Data_Get", properties);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -411,14 +432,14 @@ public class MarkerServiceHandler {
|
||||
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(markerShowEntity.getMarkerType())
|
||||
.alpha( 0.7f )
|
||||
.object( markerShowEntity )
|
||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||
.longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||
options.icon(markerView);
|
||||
|
||||
IMogoMarker marker = getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
||||
marker.setOnMarkerClickListener(mogoMarkerClickListener);
|
||||
marker.setObject(markerShowEntity);
|
||||
marker.setAlpha(0.7f);
|
||||
return marker;
|
||||
} else {
|
||||
Logger.e(TAG, "Location 必须进行初始化!!!!!");
|
||||
|
||||
@@ -116,7 +116,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
case ServiceConst.MSG_TYPE_REFRESH_DECREASE:
|
||||
mRefreshRemainingTime -= ServiceConst.DECREASE_INTERVAL;
|
||||
if ( mRefreshRemainingTime == 0 ) {
|
||||
notifyRefreshData( mLastAutoRefreshLocation, 2_000, mAutoRefreshCallback );
|
||||
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
|
||||
} else {
|
||||
mHandler.sendEmptyMessageDelayed( msg.what, ServiceConst.DECREASE_INTERVAL );
|
||||
}
|
||||
@@ -435,11 +435,11 @@ public class MogoServiceProvider implements IMogoModuleProvider,
|
||||
// 自动刷新触发
|
||||
if ( mLastAutoRefreshLocation == null ) {
|
||||
mLastAutoRefreshLocation = new MogoLatLng( location.getLatitude(), location.getLongitude() );
|
||||
notifyRefreshData( mLastAutoRefreshLocation, 2_000, mAutoRefreshCallback );
|
||||
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
|
||||
} else {
|
||||
float distance = Utils.calculateLineDistance( mLastAutoRefreshLocation, new MogoLatLng( location.getLatitude(), location.getLongitude() ) );
|
||||
if ( distance > mAutoRefreshStrategy.getDistance() ) {
|
||||
notifyRefreshData( mLastAutoRefreshLocation, 2_000, mAutoRefreshCallback );
|
||||
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
/**
|
||||
* ADAS
|
||||
*/
|
||||
public static final String ADAS_ACTION = "com.mogo.launcher.adas";
|
||||
public static final String ADAS_ACTION = "com.zhidao.autopilot.adas";
|
||||
// ADAS 状态 0 - 关闭 1 - 打开
|
||||
public static final String PARAM_ADAS_STATUS = "adas_drawer_status";
|
||||
|
||||
|
||||
@@ -64,6 +64,8 @@ public class MogoImageView extends GenericDraweeView {
|
||||
mIsBlur = arrays.getBoolean( R.styleable.MogoImageView_miv_isBlur, false );
|
||||
mBlurRadius = arrays.getInt( R.styleable.MogoImageView_miv_blurRadius, 25 );
|
||||
arrays.recycle();
|
||||
|
||||
setImageResource( mPlaceHolder );
|
||||
}
|
||||
|
||||
public void setRadius( float radius ) {
|
||||
|
||||
Reference in New Issue
Block a user