getStringSet( String key ) {
+ return sSharedPrefs.getStringSet( key, null );
+ }
+
}
\ No newline at end of file
diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java
index a21558e292..372ad92698 100644
--- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java
@@ -118,7 +118,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
// 设置是否显示道路信息view
options.setLaneInfoShow( false );
// 设置是否自动改变缩放等级
- options.setAutoChangeZoom( false );
+ options.setAutoChangeZoom( true );
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
options.setAutoDisplayOverview( false );
// 设置路线转向箭头隐藏和显示
diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java
index e56f375244..c36b011c69 100644
--- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java
+++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/marker/AMapMarkerWrapper.java
@@ -298,6 +298,7 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
return mMarker;
}
+ @Override
public MogoMarkerOptions getMogoMarkerOptions() {
return mMogoMarkerOptions;
}
diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java
index e9640ab43c..881ff0fbc9 100644
--- a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java
+++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarker.java
@@ -222,4 +222,11 @@ public interface IMogoMarker {
* @param position window 的位置。
*/
void setPositionByPixels( Point position );
+
+ /**
+ * Marker 配置
+ * @return
+ */
+ MogoMarkerOptions getMogoMarkerOptions();
+
}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppFilterImpl.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppFilterImpl.java
index d4e8a280d8..d271162e24 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppFilterImpl.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppFilterImpl.java
@@ -4,8 +4,13 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
+import com.mogo.module.apps.model.AppEnum;
+import com.mogo.module.apps.model.AppEnumHelper;
+
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* @author congtaowang
@@ -18,6 +23,7 @@ public class AppFilterImpl implements AppFilter {
private final Context mContext;
private List< String > mFilterPackages;
+
public AppFilterImpl( Context context ) {
mContext = context;
final String[] values = context.getResources().getStringArray( R.array.module_apps_array_filter_packages );
@@ -37,6 +43,9 @@ public class AppFilterImpl implements AppFilter {
if ( noLaunchIntent( packageInfo ) ) {
return true;
}
+ if ( !AppEnumHelper.isCustomizedApp( packageInfo.packageName ) ) {
+ return true;
+ }
return false;
}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsAdapter.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsAdapter.java
index 88eb41f68b..b3fdeed31e 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsAdapter.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsAdapter.java
@@ -56,7 +56,11 @@ public class AppsAdapter extends BaseAdapter {
holder = ( ( AppViewHolder ) convertView.getTag() );
}
AppInfo appInfo = getItem( position );
- holder.mIcon.setImageDrawable( appInfo.getIcon() );
+ if ( appInfo.getIconResId() <= 0 ) {
+ holder.mIcon.setImageDrawable( appInfo.getIcon() );
+ } else {
+ holder.mIcon.setImageResource( appInfo.getIconResId() );
+ }
holder.mName.setText( appInfo.getName() );
return holder.mItemView;
}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsFragment.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsFragment.java
index 244745cff1..96b2ac1e5b 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsFragment.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsFragment.java
@@ -14,7 +14,7 @@ import com.alibaba.android.arouter.launcher.ARouter;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.module.apps.model.AppInfo;
-import com.mogo.module.apps.view.LinePageIndicator;
+import com.mogo.module.apps.view.PagerSlidingTabStripV2;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.utils.logger.Logger;
@@ -40,7 +40,7 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
private IMogoFragmentManager mMogoFragmentManager;
private View mLoadingView;
- private LinePageIndicator mIndicator;
+ private PagerSlidingTabStripV2 mIndicator;
@Override
protected int getLayoutId() {
@@ -77,6 +77,7 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
mLoadingView = findViewById( R.id.module_apps_id_loading );
mLoadingView.setVisibility( View.VISIBLE );
mIndicator = findViewById( R.id.module_apps_id_indicator );
+ mIndicator.setOpenPadding( true );
}
@NonNull
@@ -93,6 +94,7 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
@Override
public void renderApps( Map< Integer, List< AppInfo > > appInfos ) {
+ mAppsPager.setOffscreenPageLimit( appInfos.size() );
mLoadingView.setVisibility( View.GONE );
if ( mAppsPagerAdapter == null ) {
mAppsPagerAdapter = new AppsPagerAdapter( appInfos );
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPagerAdapter.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPagerAdapter.java
index c15b211d07..472f22a110 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPagerAdapter.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPagerAdapter.java
@@ -1,5 +1,6 @@
package com.mogo.module.apps;
+import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -8,8 +9,12 @@ import android.widget.GridView;
import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;
+import androidx.viewpager.widget.ViewPager;
import com.mogo.module.apps.model.AppInfo;
+import com.mogo.module.apps.view.PagerIndicator;
+import com.mogo.module.apps.view.PagerSlidingTabStripV2;
+import com.mogo.utils.ResourcesHelper;
import java.util.List;
import java.util.Map;
@@ -20,7 +25,7 @@ import java.util.Map;
*
* 描述
*/
-public class AppsPagerAdapter extends PagerAdapter {
+public class AppsPagerAdapter extends PagerAdapter implements PagerSlidingTabStripV2.ViewTabProvider {
private Map< Integer, List< AppInfo > > mPagedApps;
private OnAppClickedListener mOnAppClickedListener;
@@ -82,4 +87,9 @@ public class AppsPagerAdapter extends PagerAdapter {
public interface OnAppClickedListener {
void onClick( AppInfo appInfo, int position );
}
+
+ @Override
+ public View getPageTabView( Context context, int position ) {
+ return new PagerIndicator( context );
+ }
}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java
index 8a640f2ab7..3b86efe5d1 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/AppsPresenter.java
@@ -15,6 +15,7 @@ import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.cardmanager.IMogoCardManager;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.UiThreadHandler;
+import com.mogo.utils.logger.Logger;
import java.util.HashMap;
import java.util.Map;
@@ -58,6 +59,8 @@ public class AppsPresenter extends Presenter< AppsView > {
private void renderAppsList() {
ThreadPoolService.execute( () -> {
AppsModel.getInstance( getContext() ).load( appInfoList -> {
+
+ Logger.d( TAG, "apps: %s", appInfoList );
UiThreadHandler.post( () -> {
if ( mView != null ) {
mView.renderApps( appInfoList );
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppEnum.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppEnum.java
new file mode 100644
index 0000000000..dbdf93576a
--- /dev/null
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppEnum.java
@@ -0,0 +1,90 @@
+package com.mogo.module.apps.model;
+
+/**
+ * @author congtaowang
+ * @since 2020-02-12
+ *
+ * 定制化的 app 列表
+ *
+ *
+ * 自研类:QQ音乐、车聊聊、探路、新鲜事、福利、蘑菇小队、行车记录仪、懒人听书、一键清理、系统升级
+ * 第三方:车机微信助手、爱奇艺、喜马拉雅
+ * 基础类:均衡器、方控学习、蓝牙、FM、车载设置、AUX
+ */
+public enum AppEnum {
+
+ //"QQ音乐",
+ QQMusic( "com.pvetec.musics", 0 ),
+
+ //"车聊聊",
+ Im( "com.zhidao.imdemo", 0 ),
+
+ //"探路",
+ RoadCondition( "com.zhidao.roadcondition", 0 ),
+ RoadConditionSlit( "com.zhidao.roadcondition.split", 0 ),
+
+ //"福利",
+ Welfare( "com.zhidaohulian.welfare.car", 0 ),
+
+ //"蘑菇小队",
+ Fleet( "com.zhidao.fleet", 0 ),
+
+ //"行车记录仪",
+ CarCorder( "com.zhidao.carcorder", 0 ),
+
+ //"懒人听书",
+ Lrts( "com.zhidao.lrts", 0 ),
+
+ //"一键清理",
+ CleanMaster( "com.zhidao.cleanmaster", 0 ),
+
+ //"系统升级",
+ Fota( "com.abupdate.fota_demo_iot", 0 ),
+
+ //"微信车机助手",
+ WecahtHelper( "com.zhidao.wechathelper", 0 ),
+
+ //"爱奇艺HD",
+ Qiyi( "com.qiyi.video.pad", 0 ),
+
+ //"喜马拉雅",
+ Ximalaya( "com.ximalaya.ting.android.car", 0 ),
+
+ //"均衡器",
+ Equlizer( "com.zhidao.equalizer", 0 ),
+
+ //"方控学习",
+ SteerProduct( "com.zd.steerproduct", 0 ),
+
+ //"蓝牙音乐",
+ BTMusic( "com.nwd.bt.music", 0 ),
+
+ //"车载设置",
+ CarSettings( "com.zhidao.settings", 0 ),
+
+ //"AUX",
+ AUX( "com.nwd.auxin", 0 ),
+
+ //FM
+ FM( " com.nwd.radio", 0 ),
+
+ // 新鲜事
+ FreshThins( "com.zhidao.fresh.things", 0 ),
+ ;
+
+ private String mPkg;
+ private int mIconResId;
+
+ AppEnum( String pkg, int iconResId ) {
+ this.mPkg = pkg;
+ this.mIconResId = iconResId;
+ }
+
+ public String getPkg() {
+ return mPkg;
+ }
+
+ public int getIconResId() {
+ return mIconResId;
+ }
+}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppEnumHelper.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppEnumHelper.java
new file mode 100644
index 0000000000..866310e26c
--- /dev/null
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppEnumHelper.java
@@ -0,0 +1,34 @@
+package com.mogo.module.apps.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author congtaowang
+ * @since 2020-02-12
+ *
+ * 定制化的app
+ */
+public class AppEnumHelper {
+
+ private static Map< String, AppEnum > sCustomizedApps = new HashMap<>();
+
+ static {
+ AppEnum[] customizedApps = AppEnum.values();
+ for ( AppEnum customizedApp : customizedApps ) {
+ sCustomizedApps.put( customizedApp.getPkg(), customizedApp );
+ }
+ }
+
+ public static boolean isCustomizedApp( String pkg ) {
+ return sCustomizedApps.containsKey( pkg );
+ }
+
+ public static int getCustomizedAppIconResId( String pkg ) {
+ AppEnum appEnum = sCustomizedApps.get( pkg );
+ if ( appEnum != null ) {
+ return appEnum.getIconResId();
+ }
+ return 0;
+ }
+}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppInfo.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppInfo.java
index 3f0896a955..134cb0b33f 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppInfo.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppInfo.java
@@ -15,13 +15,19 @@ public class AppInfo {
private final String mVersionName;
private final int mVersionCode;
private final Drawable mIcon;
+ private final int mIconResId;
- public AppInfo( String name, String mPackageName, String mVersionName, int versionCode, Drawable icon ) {
- this.mName = name;
+ public AppInfo( String mName, String mPackageName, String mVersionName, int mVersionCode, Drawable mIcon, int mIconResId ) {
+ this.mName = mName;
this.mPackageName = mPackageName;
this.mVersionName = mVersionName;
- this.mVersionCode = versionCode;
- this.mIcon = icon;
+ this.mVersionCode = mVersionCode;
+ this.mIcon = mIcon;
+ this.mIconResId = mIconResId;
+ }
+
+ public int getIconResId() {
+ return mIconResId;
}
public String getName() {
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java
index f0d6b0b6c4..cb4386e134 100644
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/AppsModel.java
@@ -79,7 +79,7 @@ public class AppsModel {
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
- AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon );
+ AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon, AppEnumHelper.getCustomizedAppIconResId( packageName ) );
mPagedApps.get( page ).add( appInfo );
}
if ( callback != null ) {
@@ -106,7 +106,7 @@ public class AppsModel {
String versionName = packageInfo.versionName;
int versionCode = packageInfo.versionCode;
Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
- AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon );
+ AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon, AppEnumHelper.getCustomizedAppIconResId( packageName ) );
int pageIndex = getPageIndex( packageName, true );
if ( !mPagedApps.containsKey( pageIndex ) ) {
mPagedApps.put( pageIndex, new ArrayList<>() );
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/CardAppInfo.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/CardAppInfo.java
deleted file mode 100644
index 50a5fa55f6..0000000000
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/model/CardAppInfo.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.mogo.module.apps.model;
-
-/**
- * @author congtaowang
- * @since 2020-02-09
- *
- * 描述
- */
-public class CardAppInfo extends AppInfo {
-
- private String mCardType;
-
- public CardAppInfo( AppInfo app, String cardType ) {
- super( app.getName(), app.getPackageName(), app.getVersionName(), app.getVersionCode(), app.getIcon() );
- this.mCardType = cardType;
- }
-}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/LinePageIndicator.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/LinePageIndicator.java
deleted file mode 100644
index 5805586a92..0000000000
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/LinePageIndicator.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Copyright (C) 2012 Jake Wharton
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.mogo.module.apps.view;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.drawable.Drawable;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewConfiguration;
-import androidx.core.view.MotionEventCompat;
-import androidx.core.view.ViewConfigurationCompat;
-import androidx.viewpager.widget.ViewPager;
-
-import com.mogo.module.apps.R;
-
-/**
- * Draws a line for each page. The current page line is colored differently
- * than the unselected page lines.
- */
-public class LinePageIndicator extends View implements PageIndicator {
- private static final int INVALID_POINTER = -1;
-
- private final Paint mPaintUnselected = new Paint(Paint.ANTI_ALIAS_FLAG);
- private final Paint mPaintSelected = new Paint(Paint.ANTI_ALIAS_FLAG);
- private ViewPager mViewPager;
- private ViewPager.OnPageChangeListener mListener;
- private int mCurrentPage;
- private boolean mCentered;
- private float mLineWidth;
- private float mGapWidth;
-
- private int mTouchSlop;
- private float mLastMotionX = -1;
- private int mActivePointerId = INVALID_POINTER;
- private boolean mIsDragging;
-
-
- public LinePageIndicator(Context context) {
- this(context, null);
- }
-
- public LinePageIndicator(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.vpiLinePageIndicatorStyle);
- }
-
- public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- if (isInEditMode()) {
- return;
- }
-
- final Resources res = getResources();
-
- //Load defaults from resources
- final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
- final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
- final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
- final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
- final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
- final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);
-
- //Retrieve styles attributes
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);
-
- mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
- mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
- mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
- setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
- mPaintUnselected.setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
- mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));
-
- Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
- if (background != null) {
- setBackgroundDrawable(background);
- }
-
- a.recycle();
-
- final ViewConfiguration configuration = ViewConfiguration.get(context);
- mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
- }
-
-
- public void setCentered(boolean centered) {
- mCentered = centered;
- invalidate();
- }
-
- public boolean isCentered() {
- return mCentered;
- }
-
- public void setUnselectedColor(int unselectedColor) {
- mPaintUnselected.setColor(unselectedColor);
- invalidate();
- }
-
- public int getUnselectedColor() {
- return mPaintUnselected.getColor();
- }
-
- public void setSelectedColor(int selectedColor) {
- mPaintSelected.setColor(selectedColor);
- invalidate();
- }
-
- public int getSelectedColor() {
- return mPaintSelected.getColor();
- }
-
- public void setLineWidth(float lineWidth) {
- mLineWidth = lineWidth;
- invalidate();
- }
-
- public float getLineWidth() {
- return mLineWidth;
- }
-
- public void setStrokeWidth(float lineHeight) {
- mPaintSelected.setStrokeWidth(lineHeight);
- mPaintUnselected.setStrokeWidth(lineHeight);
- invalidate();
- }
-
- public float getStrokeWidth() {
- return mPaintSelected.getStrokeWidth();
- }
-
- public void setGapWidth(float gapWidth) {
- mGapWidth = gapWidth;
- invalidate();
- }
-
- public float getGapWidth() {
- return mGapWidth;
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
-
- if (mViewPager == null) {
- return;
- }
- final int count = mViewPager.getAdapter().getCount();
- if (count == 0) {
- return;
- }
-
- if (mCurrentPage >= count) {
- setCurrentItem(count - 1);
- return;
- }
-
- final float lineWidthAndGap = mLineWidth + mGapWidth;
- final float indicatorWidth = (count * lineWidthAndGap) - mGapWidth;
- final float paddingTop = getPaddingTop();
- final float paddingLeft = getPaddingLeft();
- final float paddingRight = getPaddingRight();
-
- float verticalOffset = paddingTop + ((getHeight() - paddingTop - getPaddingBottom()) / 2.0f);
- float horizontalOffset = paddingLeft;
- if (mCentered) {
- horizontalOffset += ((getWidth() - paddingLeft - paddingRight) / 2.0f) - (indicatorWidth / 2.0f);
- }
-
- //Draw stroked circles
- for (int i = 0; i < count; i++) {
- float dx1 = horizontalOffset + (i * lineWidthAndGap);
- float dx2 = dx1 + mLineWidth;
- canvas.drawLine(dx1, verticalOffset, dx2, verticalOffset, (i == mCurrentPage) ? mPaintSelected : mPaintUnselected);
- }
- }
-
- public boolean onTouchEvent(MotionEvent ev) {
- if (super.onTouchEvent(ev)) {
- return true;
- }
- if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
- return false;
- }
-
- final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
- mLastMotionX = ev.getX();
- break;
-
- case MotionEvent.ACTION_MOVE: {
- final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
- final float x = MotionEventCompat.getX(ev, activePointerIndex);
- final float deltaX = x - mLastMotionX;
-
- if (!mIsDragging) {
- if (Math.abs(deltaX) > mTouchSlop) {
- mIsDragging = true;
- }
- }
-
- if (mIsDragging) {
- mLastMotionX = x;
- if (mViewPager.isFakeDragging() || mViewPager.beginFakeDrag()) {
- mViewPager.fakeDragBy(deltaX);
- }
- }
-
- break;
- }
-
- case MotionEvent.ACTION_CANCEL:
- case MotionEvent.ACTION_UP:
- if (!mIsDragging) {
- final int count = mViewPager.getAdapter().getCount();
- final int width = getWidth();
- final float halfWidth = width / 2f;
- final float sixthWidth = width / 6f;
-
- if ((mCurrentPage > 0) && (ev.getX() < halfWidth - sixthWidth)) {
- if (action != MotionEvent.ACTION_CANCEL) {
- mViewPager.setCurrentItem(mCurrentPage - 1);
- }
- return true;
- } else if ((mCurrentPage < count - 1) && (ev.getX() > halfWidth + sixthWidth)) {
- if (action != MotionEvent.ACTION_CANCEL) {
- mViewPager.setCurrentItem(mCurrentPage + 1);
- }
- return true;
- }
- }
-
- mIsDragging = false;
- mActivePointerId = INVALID_POINTER;
- if (mViewPager.isFakeDragging()) {
- mViewPager.endFakeDrag();
- }
- break;
-
- case MotionEventCompat.ACTION_POINTER_DOWN: {
- final int index = MotionEventCompat.getActionIndex(ev);
- mLastMotionX = MotionEventCompat.getX(ev, index);
- mActivePointerId = MotionEventCompat.getPointerId(ev, index);
- break;
- }
-
- case MotionEventCompat.ACTION_POINTER_UP:
- final int pointerIndex = MotionEventCompat.getActionIndex(ev);
- final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
- if (pointerId == mActivePointerId) {
- final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
- mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
- }
- mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
- break;
- default:
- break;
- }
-
- return true;
- }
-
- @Override
- public void setViewPager(ViewPager viewPager) {
- if (mViewPager == viewPager) {
- return;
- }
- if (mViewPager != null) {
- //Clear us from the old pager.
- // mViewPager.setOnPageChangeListener(null);
- }
- if (viewPager.getAdapter() == null) {
- throw new IllegalStateException("ViewPager does not have adapter instance.");
- }
- mViewPager = viewPager;
- mViewPager.setOnPageChangeListener(this);
- invalidate();
- }
-
- @Override
- public void setViewPager(ViewPager view, int initialPosition) {
- setViewPager(view);
- setCurrentItem(initialPosition);
- }
-
- @Override
- public void setCurrentItem(int item) {
- if (mViewPager == null) {
- throw new IllegalStateException("ViewPager has not been bound.");
- }
- mViewPager.setCurrentItem(item);
- mCurrentPage = item;
- invalidate();
- }
-
- @Override
- public void notifyDataSetChanged() {
- invalidate();
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
- if (mListener != null) {
- mListener.onPageScrollStateChanged(state);
- }
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- if (mListener != null) {
- mListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
- }
- }
-
- @Override
- public void onPageSelected(int position) {
- mCurrentPage = position;
- invalidate();
-
- if (mListener != null) {
- mListener.onPageSelected(position);
- }
- }
-
- @Override
- public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) {
- mListener = listener;
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- setMeasuredDimension(measureWidth(widthMeasureSpec), measureHeight(heightMeasureSpec));
- }
-
- /**
- * Determines the width of this view
- *
- * @param measureSpec
- * A measureSpec packed into an int
- * @return The width of the view, honoring constraints from measureSpec
- */
- private int measureWidth(int measureSpec) {
- float result;
- int specMode = MeasureSpec.getMode(measureSpec);
- int specSize = MeasureSpec.getSize(measureSpec);
-
- if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) {
- //We were told how big to be
- result = specSize;
- } else {
- //Calculate the width according the views count
- final int count = mViewPager.getAdapter().getCount();
- result = getPaddingLeft() + getPaddingRight() + (count * mLineWidth) + ((count - 1) * mGapWidth);
- //Respect AT_MOST value if that was what is called for by measureSpec
- if (specMode == MeasureSpec.AT_MOST) {
- result = Math.min(result, specSize);
- }
- }
- return (int)Math.ceil(result);
- }
-
- /**
- * Determines the height of this view
- *
- * @param measureSpec
- * A measureSpec packed into an int
- * @return The height of the view, honoring constraints from measureSpec
- */
- private int measureHeight(int measureSpec) {
- float result;
- int specMode = MeasureSpec.getMode(measureSpec);
- int specSize = MeasureSpec.getSize(measureSpec);
-
- if (specMode == MeasureSpec.EXACTLY) {
- //We were told how big to be
- result = specSize;
- } else {
- //Measure the height
- result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
- //Respect AT_MOST value if that was what is called for by measureSpec
- if (specMode == MeasureSpec.AT_MOST) {
- result = Math.min(result, specSize);
- }
- }
- return (int)Math.ceil(result);
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- SavedState savedState = (SavedState)state;
- super.onRestoreInstanceState(savedState.getSuperState());
- mCurrentPage = savedState.currentPage;
- requestLayout();
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- SavedState savedState = new SavedState(superState);
- savedState.currentPage = mCurrentPage;
- return savedState;
- }
-
- static class SavedState extends BaseSavedState {
- int currentPage;
-
- public SavedState(Parcelable superState) {
- super(superState);
- }
-
- private SavedState(Parcel in) {
- super(in);
- currentPage = in.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
- dest.writeInt(currentPage);
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public static final Creator CREATOR = new Creator() {
- @Override
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- @Override
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-}
\ No newline at end of file
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/PageIndicator.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/PageIndicator.java
deleted file mode 100644
index bc6148071a..0000000000
--- a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/PageIndicator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 Patrik Akerfeldt
- * Copyright (C) 2011 Jake Wharton
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.mogo.module.apps.view;
-
-
-import androidx.viewpager.widget.ViewPager;
-
-/**
- * A PageIndicator is responsible to show an visual indicator on the total views
- * number and the current visible view.
- */
-public interface PageIndicator extends ViewPager.OnPageChangeListener {
- /**
- * Bind the indicator to a ViewPager.
- *
- * @param view
- */
- void setViewPager( ViewPager view );
-
- /**
- * Bind the indicator to a ViewPager.
- *
- * @param view
- * @param initialPosition
- */
- void setViewPager( ViewPager view, int initialPosition );
-
- /**
- * Set the current page of both the ViewPager and indicator.
- *
- * This must be used if you need to set the page before
- * the views are drawn on screen (e.g., default start page).
- *
- * @param item
- */
- void setCurrentItem( int item );
-
- /**
- * Set a page change listener which will receive forwarded events.
- *
- * @param listener
- */
- void setOnPageChangeListener( ViewPager.OnPageChangeListener listener );
-
- /**
- * Notify the indicator that the fragment list has changed.
- */
- void notifyDataSetChanged();
-}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/PagerIndicator.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/PagerIndicator.java
new file mode 100644
index 0000000000..0a7dc54191
--- /dev/null
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/PagerIndicator.java
@@ -0,0 +1,41 @@
+package com.mogo.module.apps.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import androidx.annotation.Nullable;
+
+import com.mogo.module.apps.R;
+
+/**
+ * @author congtaowang
+ * @since 2020-02-11
+ *
+ * 描述
+ */
+public class PagerIndicator extends LinearLayout implements PagerSlidingTabStripV2.SelectedState {
+
+ private View mIndicator;
+
+ public PagerIndicator( Context context ) {
+ this( context, null );
+ }
+
+ public PagerIndicator( Context context, @Nullable AttributeSet attrs ) {
+ this( context, attrs, 0 );
+ }
+
+ public PagerIndicator( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
+ super( context, attrs, defStyleAttr );
+ LayoutInflater.from( context ).inflate( R.layout.modle_apps_page_indicator, this, true );
+ mIndicator = findViewById( R.id.module_apps_id_indicator_dot );
+ }
+
+ @Override
+ public void setSelectedState( boolean isSelected ) {
+ mIndicator.setSelected( isSelected );
+ }
+}
diff --git a/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/PagerSlidingTabStripV2.java b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/PagerSlidingTabStripV2.java
new file mode 100644
index 0000000000..70443ce345
--- /dev/null
+++ b/modules/mogo-module-apps/src/main/java/com/mogo/module/apps/view/PagerSlidingTabStripV2.java
@@ -0,0 +1,763 @@
+/*
+ * Copyright (C) 2013 Andreas Stuetz
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.mogo.module.apps.view;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Paint.Style;
+import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.text.TextPaint;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
+import android.widget.HorizontalScrollView;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.viewpager.widget.ViewPager;
+
+
+import com.mogo.module.apps.R;
+import com.mogo.utils.WindowUtils;
+
+import java.util.Locale;
+
+/**
+ * Reference : http://doc.okbase.net/HarryWeasley/archive/121430.html
+ */
+public class PagerSlidingTabStripV2 extends HorizontalScrollView {
+
+ public interface IconTabProvider {
+ public int getPageIconResId( int position );
+ }
+
+ public interface ViewTabProvider {
+ public View getPageTabView( Context context, int position );
+ }
+
+ public interface SelectedState {
+ void setSelectedState( boolean isSelected );
+ }
+
+ // @formatter:off
+ private static final int[] ATTRS = new int[]{
+ android.R.attr.textSize,
+ android.R.attr.textColor
+ };
+ // @formatter:on
+
+ public interface OnBeforeTabAction {
+ boolean doAction( int position );
+ }
+
+ private LinearLayout.LayoutParams defaultTabLayoutParams;
+ private LinearLayout.LayoutParams expandedTabLayoutParams;
+
+ private final PageListener pageListener = new PageListener();
+ public ViewPager.OnPageChangeListener delegatePageListener;
+
+ private LinearLayout tabsContainer;
+ private ViewPager pager;
+
+ private int tabCount;
+
+ private int currentPosition = 0;
+ private int selectedPosition = 0;
+ private float currentPositionOffset = 0f;
+
+ private Paint rectPaint;
+ private Paint dividerPaint;
+
+ private int indicatorColor = 0xFF666666;
+ private int underlineColor = 0x1A000000;
+ private int dividerColor = 0x1A000000;
+
+ private boolean shouldExpand = false;
+ private boolean textAllCaps = true;
+
+ private int scrollOffset = 52;
+ private int indicatorHeight = 8;
+ private int underlineHeight = 2;
+ private int dividerPadding = 12;
+ private int tabPadding = 24;
+ private int dividerWidth = 1;
+ private int indicatorMarginBottom = 0;
+ private int indicatorMarginLeft = 0;
+ private int indicatorMarginRight = 0;
+
+ private int tabTextSize = 13;
+ private int tabTextColor = 0xFF666666;
+ private int selectedTabTextColor = 0xFF666666;
+
+ private Typeface tabTypeface = null;
+ private int tabTypefaceStyle = Typeface.NORMAL;
+
+ private int lastScrollX = 0;
+
+ private int tabBackgroundResId = R.drawable.module_apps_pager_sliding_background_tab;
+
+ public static final int INDICATOR_MODE_UNDERLINE = -1;
+ public static final int INDICATOR_MODE_SHADOW = 1;
+ public static final int INDICATOR_MODE_RES = 2;
+ private int indicatorMode = INDICATOR_MODE_SHADOW;
+
+ private Drawable indicatorRes;
+
+ public static final int INDICATOR_FIT_MODE_AUTO = 0;
+ public static final int INDICATOR_FIT_MODE_FIXED = 1;
+ private int indicatorFitMode = INDICATOR_FIT_MODE_AUTO;
+
+ private float indicatorFixedSize = 0;
+
+ private Locale locale;
+
+ private OnBeforeTabAction onBeforeTabAction;
+ private boolean openPadding = false;
+
+
+ public boolean isOpenPadding() {
+ return openPadding;
+ }
+
+ public void setOpenPadding( boolean openPadding ) {
+ this.openPadding = openPadding;
+ }
+
+ public PagerSlidingTabStripV2( Context context ) {
+ this( context, null );
+ }
+
+ public PagerSlidingTabStripV2( Context context, AttributeSet attrs ) {
+ this( context, attrs, 0 );
+ }
+
+ public PagerSlidingTabStripV2( Context context, AttributeSet attrs, int defStyle ) {
+ super( context, attrs, defStyle );
+
+ setFillViewport( true );
+ setWillNotDraw( false );
+
+ tabsContainer = new LinearLayout( context );
+ tabsContainer.setOrientation( LinearLayout.HORIZONTAL );
+ tabsContainer.setLayoutParams( new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT ) );
+ addView( tabsContainer );
+
+ DisplayMetrics dm = getResources().getDisplayMetrics();
+
+ scrollOffset = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm );
+ indicatorHeight = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm );
+ underlineHeight = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm );
+ dividerPadding = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm );
+ tabPadding = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm );
+ dividerWidth = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm );
+ tabTextSize = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm );
+ indicatorMarginBottom = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, indicatorMarginBottom, dm );
+ indicatorMarginLeft = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, indicatorMarginLeft, dm );
+ indicatorMarginRight = ( int ) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, indicatorMarginRight, dm );
+
+ // get system attrs (android:textSize and android:textColor)
+
+ TypedArray a = context.obtainStyledAttributes( attrs, ATTRS );
+
+ tabTextSize = a.getDimensionPixelSize( 0, tabTextSize );
+ tabTextColor = a.getColor( 1, tabTextColor );
+
+ a.recycle();
+
+ // get custom attrs
+
+ a = context.obtainStyledAttributes( attrs, R.styleable.PagerSlidingTabStripV2 );
+
+ indicatorColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorColor, indicatorColor );
+ //tab文字选中时的颜色,默认和滑动指示器的颜色一致
+ selectedTabTextColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2SelectedTabTextColor, indicatorColor );
+ tabTextColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2TabTextColorValue, tabTextColor );
+ underlineColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2UnderlineColor, underlineColor );
+ dividerColor = a.getColor( R.styleable.PagerSlidingTabStripV2_pstsV2DividerColor, dividerColor );
+ indicatorHeight = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorHeight, indicatorHeight );
+ underlineHeight = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2UnderlineHeight, underlineHeight );
+ dividerPadding = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2DividerPadding, dividerPadding );
+ tabPadding = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2TabPaddingLeftRight, tabPadding );
+ tabBackgroundResId = a.getResourceId( R.styleable.PagerSlidingTabStripV2_pstsV2TabBackground, tabBackgroundResId );
+ shouldExpand = a.getBoolean( R.styleable.PagerSlidingTabStripV2_pstsV2ShouldExpand, shouldExpand );
+ scrollOffset = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2ScrollOffset, scrollOffset );
+ textAllCaps = a.getBoolean( R.styleable.PagerSlidingTabStripV2_pstsV2TextAllCaps, textAllCaps );
+ indicatorMarginBottom = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorMarginBottom, indicatorMarginBottom );
+ indicatorMarginLeft = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorMarginLeft, indicatorMarginLeft );
+ indicatorMarginRight = a.getDimensionPixelSize( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorMarginRight, indicatorMarginRight );
+ indicatorMode = a.getInt( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorMode, INDICATOR_MODE_SHADOW );
+ indicatorRes = a.getDrawable( R.styleable.PagerSlidingTabStripV2_pstsV2IndicatorRes );
+ a.recycle();
+
+ rectPaint = new Paint();
+ rectPaint.setAntiAlias( true );
+ rectPaint.setStyle( Style.FILL );
+
+ dividerPaint = new Paint();
+ dividerPaint.setAntiAlias( true );
+ dividerPaint.setStrokeWidth( dividerWidth );
+
+ defaultTabLayoutParams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT );
+ expandedTabLayoutParams = new LinearLayout.LayoutParams( 0, LayoutParams.MATCH_PARENT, 1.0f );
+
+ if ( locale == null ) {
+ locale = getResources().getConfiguration().locale;
+ }
+ }
+
+ public OnBeforeTabAction getOnBeforeTabAction() {
+ return onBeforeTabAction;
+ }
+
+ public void setOnBeforeTabAction( OnBeforeTabAction onBeforeTabAction ) {
+ this.onBeforeTabAction = onBeforeTabAction;
+ }
+
+ public void setViewPager( ViewPager pager ) {
+ this.pager = pager;
+ this.currentPosition = this.selectedPosition = pager.getCurrentItem();
+
+ if ( pager.getAdapter() == null ) {
+ throw new IllegalStateException( "ViewPager does not have adapter instance." );
+ }
+
+ pager.removeOnPageChangeListener( pageListener );
+ pager.addOnPageChangeListener( pageListener );
+
+ notifyDataSetChanged();
+ }
+
+ public void setOnPageChangeListener( ViewPager.OnPageChangeListener listener ) {
+ this.delegatePageListener = listener;
+ }
+
+ public void notifyDataSetChanged() {
+
+ indicatorLineOffset = -1;
+ tabsContainer.removeAllViews();
+
+ tabCount = pager.getAdapter().getCount();
+
+ for ( int i = 0; i < tabCount; i++ ) {
+
+ if ( pager.getAdapter() instanceof ViewTabProvider ) {
+ addViewTab( i, ( ( ViewTabProvider ) pager.getAdapter() ).getPageTabView( getContext(), i ) );
+ } else {
+ addTextTab( i, TextUtils.isEmpty( pager.getAdapter().getPageTitle( i ) ) ? "" : pager.getAdapter().getPageTitle( i ).toString() );
+ }
+
+ }
+
+ updateTabStyles();
+
+ getViewTreeObserver().addOnGlobalLayoutListener( new OnGlobalLayoutListener() {
+
+ @Override
+ public void onGlobalLayout() {
+ getViewTreeObserver().removeGlobalOnLayoutListener( this );
+ currentPosition = pager.getCurrentItem();
+ scrollToChild( currentPosition, 0 );
+ }
+ } );
+
+ }
+
+ private void addTextTab( final int position, String title ) {
+
+ TextView tab = new TextView( getContext() );
+ tab.setText( title );
+ tab.setGravity( Gravity.CENTER );
+ tab.setSingleLine();
+ tab.setPadding( WindowUtils.dip2px( getContext(), 10 ),
+ WindowUtils.dip2px( getContext(), 3 ),
+ WindowUtils.dip2px( getContext(), 10 ),
+ WindowUtils.dip2px( getContext(), 3 ) );
+
+ LinearLayout linearLayout = new LinearLayout( getContext() );
+ LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT );
+ linearLayout.addView( tab, layoutParams );
+ linearLayout.setGravity( Gravity.CENTER );
+ addTab( position, linearLayout );
+ }
+
+ private void addIconTab( final int position, int resId ) {
+
+ ImageButton tab = new ImageButton( getContext() );
+ tab.setImageResource( resId );
+
+ addTab( position, tab );
+
+ }
+
+ private void addViewTab( final int position, View v ) {
+ addTab( position, v );
+ }
+
+ public void setCurrentTab( final int position ) {
+ pager.post( new Runnable() {
+ @Override
+ public void run() {
+ pager.setCurrentItem( position, false );
+ }
+ } );
+ }
+
+ private void addTab( final int position, View tab ) {
+ tab.setFocusable( true );
+ tab.setOnClickListener( new OnClickListener() {
+ @Override
+ public void onClick( View v ) {
+ if ( getOnBeforeTabAction() != null ) {
+ if ( getOnBeforeTabAction().doAction( position ) ) {
+ pager.setCurrentItem( position, false );
+ }
+ } else {
+ pager.setCurrentItem( position, false );
+ }
+ }
+ } );
+
+ if ( openPadding ) {
+ tab.setPadding( position == 0 ? 0 : tabPadding, 0, tabPadding, 0 );
+ }
+
+ tabsContainer.addView( tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams );
+ }
+
+ private void updateTabStyles() {
+
+ for ( int i = 0; i < tabCount; i++ ) {
+
+ View v = tabsContainer.getChildAt( i );
+
+ if ( v instanceof SelectedState ) {
+ ( ( SelectedState ) v ).setSelectedState( i == selectedPosition );
+ } else if ( v instanceof LinearLayout ) {
+
+ TextView tab = ( TextView ) ( ( LinearLayout ) v ).getChildAt( 0 );
+ tab.setTextSize( TypedValue.COMPLEX_UNIT_PX, tabTextSize );
+ tab.setTypeface( tabTypeface, tabTypefaceStyle );
+ tab.setTextColor( tabTextColor );
+
+ if ( textAllCaps ) {
+ tab.setAllCaps( true );
+ }
+
+ if ( i == selectedPosition ) {
+ tab.setTextColor( selectedTabTextColor );
+ if ( indicatorMode == INDICATOR_MODE_SHADOW ) {
+ tab.setBackgroundResource( R.drawable.module_apps_shape_deep_blue );
+ }
+ } else {
+ tab.setTextColor( tabTextColor );
+ tab.setBackgroundResource( 0 );
+ }
+ }
+ }
+ }
+
+ private void scrollToChild( int position, int offset ) {
+
+ if ( tabCount == 0 ) {
+ return;
+ }
+
+ int newScrollX = tabsContainer.getChildAt( position ).getLeft() + offset;
+
+ if ( position > 0 || offset > 0 ) {
+ newScrollX -= scrollOffset;
+ }
+
+ if ( newScrollX != lastScrollX ) {
+ lastScrollX = newScrollX;
+ scrollTo( newScrollX, 0 );
+ }
+
+ }
+
+ @Override
+ protected void onDraw( Canvas canvas ) {
+ super.onDraw( canvas );
+
+ if ( isInEditMode() || tabCount == 0 ) {
+ return;
+ }
+
+ final int height = getHeight();
+
+
+ // draw indicator line
+
+ rectPaint.setColor( indicatorColor );
+
+ // default: line below current tab
+ View currentTab = tabsContainer.getChildAt( currentPosition );
+ float lineLeft = currentTab.getLeft();
+ float lineRight = currentTab.getRight();
+
+ // if there is an offset, start interpolating left and right coordinates between current and next tab
+ if ( currentPositionOffset > 0f && currentPosition < tabCount - 1 ) {
+
+ View nextTab = tabsContainer.getChildAt( currentPosition + 1 );
+ final float nextTabLeft = nextTab.getLeft();
+ final float nextTabRight = nextTab.getRight();
+
+ lineLeft = ( currentPositionOffset * nextTabLeft + ( 1f - currentPositionOffset ) * lineLeft );
+ lineRight = ( currentPositionOffset * nextTabRight + ( 1f - currentPositionOffset ) * lineRight );
+ }
+
+ if ( indicatorMode == INDICATOR_MODE_UNDERLINE ) {
+ float lineOffset = getLineOffset();
+ float left, right, top, bottom;
+ if ( indicatorFitMode == INDICATOR_FIT_MODE_AUTO ) {
+ left = lineLeft + lineOffset + indicatorMarginLeft;
+ right = lineRight - lineOffset - indicatorMarginRight;
+ top = height - indicatorHeight - indicatorMarginBottom;
+ bottom = height - indicatorMarginBottom;
+ } else {
+ left = lineLeft + lineOffset;
+ right = lineRight - lineOffset;
+ top = height - indicatorHeight - indicatorMarginBottom;
+ bottom = height - indicatorMarginBottom;
+ }
+
+ if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ) {
+ canvas.drawRoundRect( left, top, right, bottom, 90, 90, rectPaint );
+ } else {
+ canvas.drawRect( left, top, right, bottom, rectPaint );
+ }
+ }
+
+ if ( indicatorMode == INDICATOR_MODE_RES ) {
+ if ( indicatorRes != null ) {
+ int lineOffset = ( int ) getLineOffset();
+ int left, right, top, bottom;
+ int width = indicatorRes.getIntrinsicWidth();
+ left = ( int ) lineLeft + lineOffset;
+ right = ( int ) lineRight - lineOffset;
+ top = height - indicatorRes.getIntrinsicHeight() - indicatorMarginBottom;
+ left = left + ( right - left - width ) / 2;
+ right = left + width;
+ bottom = height - indicatorMarginBottom;
+ indicatorRes.setBounds( left, top, right, bottom );
+ indicatorRes.draw( canvas );
+ }
+ }
+
+ // draw underline
+
+ rectPaint.setColor( underlineColor );
+ canvas.drawRect( 0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint );
+
+ // draw divider
+
+ dividerPaint.setColor( dividerColor );
+ for ( int i = 0; i < tabCount - 1; i++ ) {
+ View tab = tabsContainer.getChildAt( i );
+ canvas.drawLine( tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint );
+ }
+ }
+
+ private float indicatorLineOffset = -1;
+
+ private float getLineOffset() {
+
+ if ( tabsContainer.getChildCount() == 0 ) {
+ return 0;
+ }
+ if ( !shouldExpand ) {
+ return 0;
+ }
+ if ( indicatorLineOffset != -1 ) {
+ return indicatorLineOffset;
+ }
+
+ float minViewMeasuredWidth = tabsContainer.getChildAt( 0 ).getMeasuredWidth();
+ float minContentWidth = getTabContentWidth( tabsContainer.getChildAt( 0 ) );
+ for ( int i = 1; i < tabsContainer.getChildCount(); i++ ) {
+ float nextContentWidth = getTabContentWidth( tabsContainer.getChildAt( i ) );
+ if ( minContentWidth > nextContentWidth ) {
+ minContentWidth = nextContentWidth;
+ }
+ }
+ float offset = ( minViewMeasuredWidth - minContentWidth ) / 2;
+ return indicatorLineOffset = offset == 0 ? WindowUtils.dip2px( getContext(), 25 ) : offset;
+ }
+
+ private float getTabContentWidth( View tab ) {
+ if ( tab instanceof TextView ) {
+ TextPaint paint = ( ( TextView ) tab ).getPaint();
+ return paint.measureText( ( ( TextView ) tab ).getText().toString() );
+ }
+ return tab.getMeasuredWidth();
+ }
+
+ private class PageListener implements ViewPager.OnPageChangeListener {
+
+ @Override
+ public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
+
+ currentPosition = position;
+ currentPositionOffset = positionOffset;
+
+ scrollToChild( position, ( int ) ( positionOffset * tabsContainer.getChildAt( position ).getWidth() ) );
+
+ invalidate();
+
+ if ( delegatePageListener != null ) {
+ delegatePageListener.onPageScrolled( position, positionOffset, positionOffsetPixels );
+ }
+ }
+
+ @Override
+ public void onPageScrollStateChanged( int state ) {
+ if ( state == ViewPager.SCROLL_STATE_IDLE ) {
+ scrollToChild( pager.getCurrentItem(), 0 );
+ }
+
+ if ( delegatePageListener != null ) {
+ delegatePageListener.onPageScrollStateChanged( state );
+ }
+ }
+
+ @Override
+ public void onPageSelected( int position ) {
+ selectedPosition = position;
+ updateTabStyles();
+ if ( delegatePageListener != null ) {
+ delegatePageListener.onPageSelected( position );
+ }
+ }
+
+ }
+
+ public void setIndicatorColor( int indicatorColor ) {
+ this.indicatorColor = indicatorColor;
+ invalidate();
+ }
+
+ public void setIndicatorColorResource( int resId ) {
+ this.indicatorColor = getResources().getColor( resId );
+ invalidate();
+ }
+
+ public int getIndicatorColor() {
+ return this.indicatorColor;
+ }
+
+ public void setIndicatorHeight( int indicatorLineHeightPx ) {
+ this.indicatorHeight = indicatorLineHeightPx;
+ invalidate();
+ }
+
+ public int getIndicatorHeight() {
+ return indicatorHeight;
+ }
+
+ public void setUnderlineColor( int underlineColor ) {
+ this.underlineColor = underlineColor;
+ invalidate();
+ }
+
+ public void setUnderlineColorResource( int resId ) {
+ this.underlineColor = getResources().getColor( resId );
+ invalidate();
+ }
+
+ public int getUnderlineColor() {
+ return underlineColor;
+ }
+
+ public void setDividerColor( int dividerColor ) {
+ this.dividerColor = dividerColor;
+ invalidate();
+ }
+
+ public void setDividerColorResource( int resId ) {
+ this.dividerColor = getResources().getColor( resId );
+ invalidate();
+ }
+
+ public int getDividerColor() {
+ return dividerColor;
+ }
+
+ public void setUnderlineHeight( int underlineHeightPx ) {
+ this.underlineHeight = underlineHeightPx;
+ invalidate();
+ }
+
+ public int getUnderlineHeight() {
+ return underlineHeight;
+ }
+
+ public void setDividerPadding( int dividerPaddingPx ) {
+ this.dividerPadding = dividerPaddingPx;
+ invalidate();
+ }
+
+ public int getDividerPadding() {
+ return dividerPadding;
+ }
+
+ public void setScrollOffset( int scrollOffsetPx ) {
+ this.scrollOffset = scrollOffsetPx;
+ invalidate();
+ }
+
+ public int getScrollOffset() {
+ return scrollOffset;
+ }
+
+ public void setShouldExpand( boolean shouldExpand ) {
+ this.shouldExpand = shouldExpand;
+ notifyDataSetChanged();
+ }
+
+ public boolean getShouldExpand() {
+ return shouldExpand;
+ }
+
+ public boolean isTextAllCaps() {
+ return textAllCaps;
+ }
+
+ public void setAllCaps( boolean textAllCaps ) {
+ this.textAllCaps = textAllCaps;
+ }
+
+ public void setTextSize( int textSizePx ) {
+ this.tabTextSize = textSizePx;
+ updateTabStyles();
+ }
+
+ public int getTextSize() {
+ return tabTextSize;
+ }
+
+ public void setTextColor( int textColor ) {
+ this.tabTextColor = textColor;
+ updateTabStyles();
+ }
+
+ public void setTextColorResource( int resId ) {
+ this.tabTextColor = getResources().getColor( resId );
+ updateTabStyles();
+ }
+
+ public int getTextColor() {
+ return tabTextColor;
+ }
+
+ public void setSelectedTextColor( int textColor ) {
+ this.selectedTabTextColor = textColor;
+ updateTabStyles();
+ }
+
+ public void setSelectedTextColorResource( int resId ) {
+ this.selectedTabTextColor = getResources().getColor( resId );
+ updateTabStyles();
+ }
+
+ public int getSelectedTextColor() {
+ return selectedTabTextColor;
+ }
+
+ public void setTypeface( Typeface typeface, int style ) {
+ this.tabTypeface = typeface;
+ this.tabTypefaceStyle = style;
+ updateTabStyles();
+ }
+
+ public void setTabBackground( int resId ) {
+ this.tabBackgroundResId = resId;
+ updateTabStyles();
+ }
+
+ public int getTabBackground() {
+ return tabBackgroundResId;
+ }
+
+ public void setTabPaddingLeftRight( int paddingPx ) {
+ this.tabPadding = paddingPx;
+ updateTabStyles();
+ }
+
+ public int getTabPaddingLeftRight() {
+ return tabPadding;
+ }
+
+ @Override
+ public void onRestoreInstanceState( Parcelable state ) {
+ SavedState savedState = ( SavedState ) state;
+ super.onRestoreInstanceState( savedState.getSuperState() );
+ currentPosition = savedState.currentPosition;
+ requestLayout();
+ }
+
+ @Override
+ public Parcelable onSaveInstanceState() {
+ Parcelable superState = super.onSaveInstanceState();
+ SavedState savedState = new SavedState( superState );
+ savedState.currentPosition = currentPosition;
+ return savedState;
+ }
+
+ static class SavedState extends BaseSavedState {
+ int currentPosition;
+
+ public SavedState( Parcelable superState ) {
+ super( superState );
+ }
+
+ private SavedState( Parcel in ) {
+ super( in );
+ currentPosition = in.readInt();
+ }
+
+ @Override
+ public void writeToParcel( Parcel dest, int flags ) {
+ super.writeToParcel( dest, flags );
+ dest.writeInt( currentPosition );
+ }
+
+ public static final Creator< SavedState > CREATOR = new Creator< SavedState >() {
+ @Override
+ public SavedState createFromParcel( Parcel in ) {
+ return new SavedState( in );
+ }
+
+ @Override
+ public SavedState[] newArray( int size ) {
+ return new SavedState[size];
+ }
+ };
+ }
+
+}
diff --git a/modules/mogo-module-apps/src/main/res/drawable/module_apps_pager_indicator.xml b/modules/mogo-module-apps/src/main/res/drawable/module_apps_pager_indicator.xml
new file mode 100644
index 0000000000..1a2fabf863
--- /dev/null
+++ b/modules/mogo-module-apps/src/main/res/drawable/module_apps_pager_indicator.xml
@@ -0,0 +1,25 @@
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/mogo-module-apps/src/main/res/drawable/module_apps_pager_sliding_background_tab.xml b/modules/mogo-module-apps/src/main/res/drawable/module_apps_pager_sliding_background_tab.xml
new file mode 100644
index 0000000000..f37210ee5f
--- /dev/null
+++ b/modules/mogo-module-apps/src/main/res/drawable/module_apps_pager_sliding_background_tab.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-apps/src/main/res/drawable/module_apps_shape_deep_blue.xml b/modules/mogo-module-apps/src/main/res/drawable/module_apps_shape_deep_blue.xml
new file mode 100644
index 0000000000..7ff2e3423a
--- /dev/null
+++ b/modules/mogo-module-apps/src/main/res/drawable/module_apps_shape_deep_blue.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-apps/src/main/res/layout/modle_apps_page_indicator.xml b/modules/mogo-module-apps/src/main/res/layout/modle_apps_page_indicator.xml
new file mode 100644
index 0000000000..48ee3ce82b
--- /dev/null
+++ b/modules/mogo-module-apps/src/main/res/layout/modle_apps_page_indicator.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml b/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml
index 6370c5abda..523f1dafa2 100644
--- a/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml
+++ b/modules/mogo-module-apps/src/main/res/layout/module_apps_fragment_apps.xml
@@ -41,16 +41,13 @@
android:layout_marginTop="@dimen/module_apps_pager_marginTop"
android:overScrollMode="never" />
-
+ app:pstsV2TabPaddingLeftRight="@dimen/module_apps_indicator_interval" />
117px
2.7px
16px
+ 2.3px
54.9px
64px
64px
diff --git a/modules/mogo-module-apps/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-apps/src/main/res/values-xhdpi/dimens.xml
index 0a30fed7cc..ff19f10f5d 100644
--- a/modules/mogo-module-apps/src/main/res/values-xhdpi/dimens.xml
+++ b/modules/mogo-module-apps/src/main/res/values-xhdpi/dimens.xml
@@ -3,6 +3,7 @@
260px
5px
30px
+ 4px
103px
120px
120px
diff --git a/modules/mogo-module-apps/src/main/res/values/dimens.xml b/modules/mogo-module-apps/src/main/res/values/dimens.xml
index 0a30fed7cc..604c52ddec 100644
--- a/modules/mogo-module-apps/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-apps/src/main/res/values/dimens.xml
@@ -3,6 +3,7 @@
260px
5px
30px
+ 2.3px
103px
120px
120px
diff --git a/modules/mogo-module-apps/src/main/res/values/page_indicator_attrs.xml b/modules/mogo-module-apps/src/main/res/values/page_indicator_attrs.xml
deleted file mode 100644
index 7d9ad6acb3..0000000000
--- a/modules/mogo-module-apps/src/main/res/values/page_indicator_attrs.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/modules/mogo-module-apps/src/main/res/values/page_indicator_values.xml b/modules/mogo-module-apps/src/main/res/values/page_indicator_values.xml
deleted file mode 100644
index d770d81352..0000000000
--- a/modules/mogo-module-apps/src/main/res/values/page_indicator_values.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
- @dimen/dp_15
- 12dp
- 4dp
- 1dp
- #FF33B5E5
- #FFBBBBBB
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/modules/mogo-module-apps/src/main/res/values/psts_attrs_v2.xml b/modules/mogo-module-apps/src/main/res/values/psts_attrs_v2.xml
new file mode 100644
index 0000000000..5af7a74dac
--- /dev/null
+++ b/modules/mogo-module-apps/src/main/res/values/psts_attrs_v2.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-back/build.gradle b/modules/mogo-module-back/build.gradle
index d4b9127efe..28579c4416 100644
--- a/modules/mogo-module-back/build.gradle
+++ b/modules/mogo-module-back/build.gradle
@@ -37,14 +37,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- implementation 'androidx.appcompat:appcompat:1.0.2'
- implementation 'androidx.core:core-ktx:1.0.2'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test:runner:1.2.0'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ implementation rootProject.ext.dependencies.kotlinstdlibjdk7
implementation rootProject.ext.dependencies.androidxappcompat
+ implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/MarkerUserInfo.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/MarkerUserInfo.java
index 2ee2a01ab2..e13d18d782 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/MarkerUserInfo.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/MarkerUserInfo.java
@@ -14,64 +14,77 @@ public class MarkerUserInfo implements Serializable {
private String userName;//用户昵称
private String userHead;//用户头像
private String gender;//gender": "男|女|无(也可以0|1|2根据实际库存返回即可)
- private int age;// 年龄段,可以为空,与车聊聊一致
+ private Integer age;// 年龄段,可以为空,与车聊聊一致
- public void setAge(int age) {
+ public void setAge(Integer age) {
this.age = age;
}
public int getAgeNumber() {
- return age;
+ if (age != null) {
+ return age;
+ }
+ return -1;
}
public String getAge() {
- Calendar cal = Calendar.getInstance();
- int year = cal.get(Calendar.YEAR);
+ try {
+ if (getAgeNumber() >= 0) {
- //2020-30=1990
- double ageDiffer = year - age;
- String ageStr = "" + ageDiffer;
- char[] ageChars = ageStr.toCharArray();
+ Calendar cal = Calendar.getInstance();
+ int year = cal.get(Calendar.YEAR);
- //1990
- char ageChar = ageChars[2];
+ //2020-30=1990
+ double ageDiffer = year - getAgeNumber();
+ String ageStr = "" + ageDiffer;
+ char[] ageChars = ageStr.toCharArray();
- String ageString = "未设置";
+ //1990
+ char ageChar = ageChars[2];
- switch (ageChar) {
- case '0':
- ageString = "00后";
- break;
- case '1':
- ageString = "10后";
- break;
- case '2':
- ageString = "20后";
- break;
- case '3':
- ageString = "30后";
- break;
- case '4':
- ageString = "40后";
- break;
- case '5':
- ageString = "50后";
- break;
- case '6':
- ageString = "60后";
- break;
- case '7':
- ageString = "70后";
- break;
- case '8':
- ageString = "80后";
- break;
- case '9':
- ageString = "90后";
- break;
+ String ageString = "未设置";
+
+ switch (ageChar) {
+ case '0':
+ ageString = "00后";
+ break;
+ case '1':
+ ageString = "10后";
+ break;
+ case '2':
+ ageString = "20后";
+ break;
+ case '3':
+ ageString = "30后";
+ break;
+ case '4':
+ ageString = "40后";
+ break;
+ case '5':
+ ageString = "50后";
+ break;
+ case '6':
+ ageString = "60后";
+ break;
+ case '7':
+ ageString = "70后";
+ break;
+ case '8':
+ ageString = "80后";
+ break;
+ case '9':
+ ageString = "90后";
+ break;
+ }
+
+ return ageString;
+ } else {
+ return "";
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "";
}
-
- return ageString;
}
public int getGenderValue() {
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsFragment.java
index 3395db70fd..4aa2e5b311 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsFragment.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsFragment.java
@@ -1,5 +1,6 @@
package com.mogo.module.extensions;
+import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
@@ -18,6 +19,7 @@ import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.utils.UiThreadHandler;
+import com.mogo.utils.logger.Logger;
/**
* @author congtaowang
@@ -27,8 +29,11 @@ import com.mogo.utils.UiThreadHandler;
*/
public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsPresenter > implements ExtensionsView {
- private JSurfaceView mVoiceIcon;
- private View mVoiceMsg;
+ private static final String TAG = "ExtensionsFragment";
+
+ private ImageView mVoiceIcon;
+ private AnimationDrawable mAnim;
+ private TextView mVoiceMsg;
private TextView mTime;
private TextView mDate;
@@ -52,6 +57,7 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
@Override
protected void initViews() {
mVoiceIcon = findViewById( R.id.module_ext_id_voice );
+ mAnim = ( AnimationDrawable ) mVoiceIcon.getBackground();
mVoiceMsg = findViewById( R.id.module_ext_id_voice_msg );
mVoiceIcon.setOnClickListener( view -> {
@@ -76,7 +82,7 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
} );
mMsgCounter = findViewById( R.id.module_ext_id_msg_counter );
- mVoiceIcon.setFrames( AnimRes.sRes );
+// mVoiceIcon.setFrames( AnimRes.sRes );
mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( getContext() );
mMogoFragmentManager.addMainFragmentStackTransactionListener( size -> {
@@ -98,19 +104,22 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
super.onActivityCreated( savedInstanceState );
mAnalytics = ( IMogoAnalytics ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_ANALYTICS ).navigation( getContext() );
- mVoiceIcon.startAnim();
}
@Override
public void onResume() {
super.onResume();
- mVoiceIcon.startAnim();
+ if ( mAnim != null ) {
+ mAnim.start();
+ }
}
@Override
public void onStop() {
super.onStop();
- mVoiceIcon.stop();
+ if ( mAnim != null ) {
+ mAnim.stop();
+ }
}
@Override
@@ -141,4 +150,12 @@ public class ExtensionsFragment extends MvpFragment< ExtensionsView, ExtensionsP
mMsgContainer.setVisibility( hasMsg ? View.VISIBLE : View.GONE );
mMsgCounter.setText( amount > 99 ? getString( R.string.module_ext_str_dots ) : String.valueOf( amount ) );
}
+
+ @Override
+ public void renderAITipWords( String word ) {
+ if ( !TextUtils.isEmpty( word ) ) {
+ Logger.d( TAG, "current word: %s", word );
+ mVoiceMsg.setText( word );
+ }
+ }
}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java
index 17572c38e0..b24bcea2b1 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsPresenter.java
@@ -4,6 +4,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
@@ -19,7 +22,16 @@ import com.mogo.service.statusmanager.IMogoMsgCenter;
import com.mogo.service.statusmanager.IMogoMsgCenterListener;
import com.mogo.utils.logger.Logger;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Calendar;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+import java.util.Random;
+import java.util.Set;
/**
@@ -36,6 +48,31 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements
private WeatherModel mWeatherModel;
+ public static final int MSG_SWITCH_AI_TIP_WORDS = 4000;
+ public static final long INTERVAL_TIME = 8_000L;
+ private String[] mAITipWords;
+ private int mCurrentIndex = 0;
+ private Handler mHandler = new Handler( Looper.getMainLooper() ) {
+ @Override
+ public void handleMessage( Message msg ) {
+ super.handleMessage( msg );
+ if ( msg.what == MSG_SWITCH_AI_TIP_WORDS ) {
+ if ( mView != null ) {
+ if ( mCurrentIndex < mAITipWords.length ) {
+ mView.renderAITipWords( mAITipWords[mCurrentIndex++] );
+ } else {
+ mCurrentIndex = 0;
+ mHasTipWords = generateTipWordsSequence();
+ }
+ }
+ if ( mHasTipWords ) {
+ mHandler.sendEmptyMessageDelayed( MSG_SWITCH_AI_TIP_WORDS, INTERVAL_TIME );
+ }
+ }
+ }
+ };
+ private boolean mHasTipWords = false;
+
/**
* 接收时间变化的广播
*/
@@ -52,10 +89,30 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements
private IMogoMsgCenter mMsgCenter;
+ private boolean generateTipWordsSequence() {
+ if ( mAITipWords != null && mAITipWords.length > 0 ) {
+ Random random = new Random( System.currentTimeMillis() );
+ int loop = mAITipWords.length / 2;
+ int bound = mAITipWords.length;
+ for ( int i = 0; i < loop; i++ ) {
+ int target = random.nextInt( bound );
+ int sweepTarget = random.nextInt( bound );
+ if ( target != sweepTarget ) {
+ String targetStr = mAITipWords[target];
+ mAITipWords[target] = mAITipWords[sweepTarget];
+ mAITipWords[sweepTarget] = targetStr;
+ }
+ }
+ Logger.d( TAG, "next generate sequence: " + mAITipWords );
+ return true;
+ }
+ return false;
+ }
public ExtensionsPresenter( ExtensionsView view ) {
super( view );
mWeeks = getContext().getResources().getStringArray( R.array.module_ext_str_arr_week );
+ mAITipWords = getContext().getResources().getStringArray( R.array.module_ext_str_arr_ai_tips );
mWeatherModel = new WeatherModel( getContext() );
}
@@ -68,6 +125,7 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements
refreshTimeAndDate();
mMsgCenter = ( IMogoMsgCenter ) ARouter.getInstance().build( MogoServicePaths.PATH_MSG_CENTER ).navigation();
mMsgCenter.registerMsgCenterListener( this );
+ mHasTipWords = generateTipWordsSequence();
}
/**
@@ -115,6 +173,22 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements
}
}
+ @Override
+ public void onResume( @NonNull LifecycleOwner owner ) {
+ super.onResume( owner );
+ if ( mHasTipWords ) {
+ mHandler.sendEmptyMessageDelayed( MSG_SWITCH_AI_TIP_WORDS, INTERVAL_TIME );
+ }
+ }
+
+ @Override
+ public void onPause( @NonNull LifecycleOwner owner ) {
+ super.onPause( owner );
+ if ( mHasTipWords ) {
+ mHandler.removeMessages( MSG_SWITCH_AI_TIP_WORDS );
+ }
+ }
+
@Override
public void onDestroy( @NonNull LifecycleOwner owner ) {
super.onDestroy( owner );
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsView.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsView.java
index 3ab09a0b41..91f3d5e19c 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsView.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/ExtensionsView.java
@@ -35,4 +35,11 @@ public interface ExtensionsView extends IView {
* @param amount 消息数量
*/
void renderMsgInfo( boolean hasMsg, int amount );
+
+ /**
+ * 更换小智语音提示词
+ *
+ * @param word
+ */
+ void renderAITipWords( String word );
}
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/anim/JSurfaceView.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/anim/JSurfaceView.java
index 4fb5fb5a95..5d89ecdddc 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/anim/JSurfaceView.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/anim/JSurfaceView.java
@@ -39,6 +39,8 @@ public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder
*/
private int[] mFrames;
+ private Thread mThread;
+
// 使用 BitmapFactory.Option.inBitmap 属性复用 bitmap 对象
private Bitmap mContainerBitmap = null;
@@ -78,12 +80,20 @@ public class JSurfaceView extends SurfaceView implements Runnable, SurfaceHolder
if ( bRunning ) {
return;
}
- ThreadPoolService.execute( this );
bRunning = true;
+ mThread = new Thread( this );
+ mThread.setName( TAG + "thread" );
+ mThread.start();
}
public void stop() {
bRunning = false;
+ try {
+ mThread.interrupt();
+ mThread = null;
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
}
@Override
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_map_ic_company.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_map_ic_company.png
index e385bd7426..e44aafa371 100755
Binary files a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_map_ic_company.png and b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_map_ic_company.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_map_ic_home.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_map_ic_home.png
index ca0841b550..367de87958 100755
Binary files a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_map_ic_home.png and b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/module_map_ic_home.png differ
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_000.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00000.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_000.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00000.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_001.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00001.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_001.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00001.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_002.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00002.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_002.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00002.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_003.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00003.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_003.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00003.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_004.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00004.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_004.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00004.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_005.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00005.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_005.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00005.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_006.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00006.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_006.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00006.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_007.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00007.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_007.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00007.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_008.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00008.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_008.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00008.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_009.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00009.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_009.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00009.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_010.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00010.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_010.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00010.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_011.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00011.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_011.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00011.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_012.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00012.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_012.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00012.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_013.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00013.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_013.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00013.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_014.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00014.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_014.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00014.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_015.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00015.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_015.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00015.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_016.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00016.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_016.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00016.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_017.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00017.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_017.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00017.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_018.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00018.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_018.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00018.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_019.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00019.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_019.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00019.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_020.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00020.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_020.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00020.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_021.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00021.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_021.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00021.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_022.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00022.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_022.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00022.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_023.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00023.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_023.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00023.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_024.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00024.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_024.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00024.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_025.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00025.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_025.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00025.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_026.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00026.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_026.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00026.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_027.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00027.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_027.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00027.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_028.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00028.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_028.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00028.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_029.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00029.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_029.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00029.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_030.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00030.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_030.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00030.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_031.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00031.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_031.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00031.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_032.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00032.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_032.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00032.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_033.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00033.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_033.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00033.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_034.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00034.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_034.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00034.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_035.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00035.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_035.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00035.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_036.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00036.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_036.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00036.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_037.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00037.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_037.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00037.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_038.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00038.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_038.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00038.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_039.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00039.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_039.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00039.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_040.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00040.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_040.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00040.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_041.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00041.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_041.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00041.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_042.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00042.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_042.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00042.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_043.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00043.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_043.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00043.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_044.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00044.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_044.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00044.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_045.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00045.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_045.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00045.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_046.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00046.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_046.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00046.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_047.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00047.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_047.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00047.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_048.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00048.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_048.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00048.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_049.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00049.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_049.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00049.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_050.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00050.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_050.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00050.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_051.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00051.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_051.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00051.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_052.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00052.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_052.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00052.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_053.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00053.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_053.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00053.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_054.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00054.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_054.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00054.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_055.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00055.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_055.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00055.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_056.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00056.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_056.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00056.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_057.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00057.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_057.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00057.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_058.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00058.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_058.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00058.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_059.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00059.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_059.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00059.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_060.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00060.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_060.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00060.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_061.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00061.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_061.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00061.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_062.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00062.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_062.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00062.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_063.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00063.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_063.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00063.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_064.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00064.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_064.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00064.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_065.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00065.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_065.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00065.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_066.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00066.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_066.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00066.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_067.png b/modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00067.png
similarity index 100%
rename from modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00_067.png
rename to modules/mogo-module-extensions/src/main/res/drawable-ldpi/mogo_tts_icon_00067.png
diff --git a/modules/mogo-module-extensions/src/main/res/drawable/module_ext_frame_anim_voice.xml b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_frame_anim_voice.xml
new file mode 100644
index 0000000000..f4844fcff0
--- /dev/null
+++ b/modules/mogo-module-extensions/src/main/res/drawable/module_ext_frame_anim_voice.xml
@@ -0,0 +1,207 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
index 2ea2761fe9..73a1e40567 100644
--- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
+++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_entrance.xml
@@ -18,7 +18,7 @@
android:paddingLeft="@dimen/module_ext_search_paddingLeft"
android:paddingRight="@dimen/module_ext_search_paddingRight"
android:text="@string/module_map_str_search_hint"
- android:textColor="#99FFFFFF"
+ android:textColor="#FFFFFF"
android:textSize="@dimen/module_ext_search_textSize"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
diff --git a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_extensions.xml b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_extensions.xml
index d4824c6446..f3d6298784 100644
--- a/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_extensions.xml
+++ b/modules/mogo-module-extensions/src/main/res/layout/module_ext_layout_extensions.xml
@@ -8,13 +8,17 @@
android:paddingLeft="@dimen/module_ext_paddingLeft"
android:paddingRight="@dimen/module_ext_paddingRight">
-
+ app:layout_constraintTop_toTopOf="parent"
+ android:layout_width="@dimen/module_ext_voice_icon_width"
+ android:layout_height="@dimen/module_ext_voice_icon_height"
+ android:background="@drawable/module_ext_frame_anim_voice"/>
+
+
+
diff --git a/modules/mogo-module-extensions/src/main/res/values/strings.xml b/modules/mogo-module-extensions/src/main/res/values/strings.xml
index 784f01f88e..1d68dcdcab 100644
--- a/modules/mogo-module-extensions/src/main/res/values/strings.xml
+++ b/modules/mogo-module-extensions/src/main/res/values/strings.xml
@@ -20,4 +20,26 @@
退出导航
继续导航
退出全览
+
+
+ - 你好小智,播放音乐
+ - 你好小智,我要听音乐
+ - 你好小智,播放赵磊的歌
+ - 你好小智,我想听成都
+ - 你好小智,打开导航
+ - 你好小智,我要去拉萨
+ - 你好小智,我要去加油站
+ - 你好小智,导航去西单商场
+ - 你好小智,打开行车记录仪
+ - 你好小智,打开收音机
+ - 你好小智,调频到97.4
+ - 你好小智,调频到103.9
+ - 你好小智,今天天气怎么样
+ - 你好小智,北京明天天气怎么样
+ - 你好小智,打开车聊聊
+ - 你好小智,我想聊天
+ - 你好小智,中关村堵不堵
+ - 你好小智,打开探路
+ - 你好小智,附近路况
+
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java
index 44a29e9d19..02bd6ed7df 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java
@@ -2,6 +2,9 @@ package com.mogo.module.main;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
@@ -27,6 +30,7 @@ import com.mogo.module.main.cards.MogoModulesManager;
import com.mogo.module.main.cards.OnPageChangeListenerAdapter;
import com.mogo.module.main.cards.OrientedViewPager;
import com.mogo.module.main.cards.VerticalStackTransformer;
+import com.mogo.module.main.constants.MainConstants;
import com.mogo.module.main.windowview.WindowViewHandler;
import com.mogo.module.service.ServiceConst;
import com.mogo.service.MogoServicePaths;
@@ -47,7 +51,7 @@ import java.util.Map;
*
* 描述:加载各个模块
*/
-public class MainActivity extends MvpActivity implements MainView,
+public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView,
IMogoLocationListener,
IMogoMarkerClickListener {
@@ -67,6 +71,7 @@ public class MainActivity extends MvpActivity implement
private View mApps;
private View mEntrance;
private FrameLayout mFloatingLayout;
+ private FrameLayout mCoverUpLayout;
private View mLeftShadowFrame;
private View mTopShadowFrame;
@@ -82,8 +87,39 @@ public class MainActivity extends MvpActivity implement
private long mCardStartShowTime = 0;
+ // 埋点接口
private IMogoAnalytics mAnalytics;
+ private Handler mMsgHandler = new Handler( Looper.getMainLooper() ) {
+ @Override
+ public void handleMessage( Message msg ) {
+ super.handleMessage( msg );
+ switch ( msg.what ) {
+ case MainConstants.MSG_LOAD_CARD_MODULES:
+ loadCardModules();
+ mMsgHandler.sendEmptyMessageDelayed( MainConstants.MSG_LOAD_INVOKE_FIRST_CARD_PERFORM_EVENT, 1_000L );
+ break;
+ case MainConstants.MSG_LOAD_INVOKE_FIRST_CARD_PERFORM_EVENT:
+ if ( mOnPageChangeListener != null ) {
+ // 默认触发第一个卡片
+ mOnPageChangeListener.onPageSelected( 0 );
+ }
+ break;
+ case MainConstants.MSG_TRACK_LAST_CARD_DISPLAY_EVENT:
+ trackLastCardShowEvent( ( IMogoModuleProvider ) msg.obj );
+ break;
+ case MainConstants.MSG_TRACK_CARD_FLIP_EVENT:
+ trackCardFlipEvent(( IMogoModuleProvider ) msg.obj);
+ break;
+ case MainConstants.MSG_HIDE_MAP_COVER_FRAME:
+ mCoverUpLayout.setVisibility( View.GONE );
+ break;
+ }
+ }
+ };
+
+ private ViewPager.OnPageChangeListener mOnPageChangeListener;
+
@Override
protected int getLayoutId() {
return R.layout.module_main_activity_main;
@@ -91,189 +127,202 @@ public class MainActivity extends MvpActivity implement
@Override
protected void initViews() {
- mCardsContainer = findViewById(R.id.module_main_id_cards_container);
- mCardsContainer.setOrientation(OrientedViewPager.Orientation.VERTICAL);
+ mCardsContainer = findViewById( R.id.module_main_id_cards_container );
+ mCardsContainer.setOrientation( OrientedViewPager.Orientation.VERTICAL );
- mCardsContainer.setOnPageChangeListener(new OnPageChangeListenerAdapter() {
+ mCardsContainer.setOnPageChangeListener( mOnPageChangeListener = new OnPageChangeListenerAdapter() {
private boolean mIsLast = true;
private boolean mCardFlipStatus = false;
@Override
- public void onPageSelected(int position) {
+ public void onPageSelected( int position ) {
+ final long start = System.currentTimeMillis();
try {
- IMogoModuleProvider provider = mCardModulesAdapter.getProvider(mCurrentPosition);
- trackLastCardShowEvent(provider);
+ IMogoModuleProvider provider = mCardModulesAdapter.getProvider( mCurrentPosition );
+ Message msg = Message.obtain();
+ msg.what = MainConstants.MSG_TRACK_LAST_CARD_DISPLAY_EVENT;
+ msg.obj = provider;
+ mMsgHandler.sendMessage( msg );
mCurrentPosition = position;
- provider = mCardModulesAdapter.getProvider(mCurrentPosition);
- mMogoModuleHandler.setModuleEnable(provider.getModuleName());
- if (!isClickMarker) {
- mMogoCardManager.invoke(position, mMogoModuleHandler.getCurrentModuleName());
+ provider = mCardModulesAdapter.getProvider( mCurrentPosition );
+ mMogoModuleHandler.setModuleEnable( provider.getModuleName() );
+ if ( !isClickMarker ) {
+ mMogoCardManager.invoke( position, mMogoModuleHandler.getCurrentModuleName() );
}
- } catch (Exception e) {
+ } catch ( Exception e ) {
e.printStackTrace();
}
+ Log.i( TAG, "onPageSelected cost " + ( System.currentTimeMillis() - start ) + "ms" );
}
@Override
- public void onPageScrollStateChanged(int state) {
- super.onPageScrollStateChanged(state);
- if (state == ViewPager.SCROLL_STATE_DRAGGING) {
- if (!mCardFlipStatus) {
+ public void onPageScrollStateChanged( int state ) {
+ final long start = System.currentTimeMillis();
+ super.onPageScrollStateChanged( state );
+ if ( state == ViewPager.SCROLL_STATE_DRAGGING ) {
+ if ( !mCardFlipStatus ) {
mCardFlipStatus = true;
- final IMogoModuleProvider provider = mCardModulesAdapter.getProvider(mCurrentPosition);
- trackCardFlipEvent(provider);
+ final IMogoModuleProvider provider = mCardModulesAdapter.getProvider( mCurrentPosition );
+ Message msg = Message.obtain();
+ msg.what = MainConstants.MSG_TRACK_CARD_FLIP_EVENT;
+ msg.obj = provider;
+ mMsgHandler.sendMessage( msg );
}
- } else if (state == ViewPager.SCROLL_STATE_IDLE) {
+ } else if ( state == ViewPager.SCROLL_STATE_IDLE ) {
mCardFlipStatus = false;
}
int cardSize = mCardModulesAdapter.getCount();
- if (state == ViewPager.SCROLL_STATE_SETTLING) {
+ if ( state == ViewPager.SCROLL_STATE_SETTLING ) {
mIsLast = false;
- } else if (state == ViewPager.SCROLL_STATE_IDLE && mIsLast) {
+ } else if ( state == ViewPager.SCROLL_STATE_IDLE && mIsLast ) {
//此处为你需要的情况,再加入当前页码判断可知道是第一页还是最后一页
- if (cardSize != 1 && mCurrentPosition == (cardSize - 1)) {
- mCardsContainer.setCurrentItem(0, false);
- } else if (cardSize != 1 && mCurrentPosition == 0) {
- mCardsContainer.setCurrentItem(cardSize - 1, false);
+ if ( cardSize != 1 && mCurrentPosition == ( cardSize - 1 ) ) {
+ mCardsContainer.setCurrentItem( 0, false );
+ } else if ( cardSize != 1 && mCurrentPosition == 0 ) {
+ mCardsContainer.setCurrentItem( cardSize - 1, false );
}
} else {
mIsLast = true;
}
+ Log.i( TAG, "onPageScrollStateChanged cost " + ( System.currentTimeMillis() - start ) + "ms" );
}
+ } );
- /**
- * 卡片展示时长埋点
- * @param provider
- */
- private void trackLastCardShowEvent(IMogoModuleProvider provider) {
- if (provider == null) {
- return;
- }
- Map properties = new HashMap<>();
- 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();
- }
-
- /**
- * 卡片滑动埋点,WTF
- */
- private void trackCardFlipEvent(IMogoModuleProvider provider) {
- if (provider == null) {
- return;
- }
- Map properties = new HashMap<>();
- properties.put("appname", provider.getAppName());
- properties.put("packagename", provider.getAppPackage());
- properties.put("type", provider.getModuleName());
- mAnalytics.track("Launcher_Card_Slide", properties);
- }
- });
-
- mMogoFragmentManager = (IMogoFragmentManager) ARouter.getInstance().build(MogoServicePaths.PATH_FRAGMENT_MANAGER).navigation(this);
- mMogoFragmentManager.init(this, R.id.module_main_id_search_fragment);
- mMogoFragmentManager.registerMainFragmentStackTransactionListener((size) -> {
- if (size == 0) {
+ mMogoFragmentManager = ( IMogoFragmentManager ) ARouter.getInstance().build( MogoServicePaths.PATH_FRAGMENT_MANAGER ).navigation( this );
+ mMogoFragmentManager.init( this, R.id.module_main_id_search_fragment );
+ mMogoFragmentManager.registerMainFragmentStackTransactionListener( ( size ) -> {
+ if ( size == 0 ) {
showLayout();
- } else if (size == 1) {
+ } else if ( size == 1 ) {
hideLayout();
}
- });
- mHeader = findViewById(R.id.module_main_id_header_fragment_container);
- mCards = findViewById(R.id.module_main_id_cards_container);
- mApps = findViewById(R.id.module_main_id_apps_fragment_container);
- mEntrance = findViewById(R.id.module_main_id_entrance_fragment_container);
- mFloatingLayout = findViewById(R.id.module_main_id_floating_view);
- mLeftShadowFrame = findViewById(R.id.module_main_id_map_left_shadow_frame);
- mTopShadowFrame = findViewById(R.id.module_main_id_map_top_shadow_frame);
+ } );
+ mHeader = findViewById( R.id.module_main_id_header_fragment_container );
+ mCards = findViewById( R.id.module_main_id_cards_container );
+ mApps = findViewById( R.id.module_main_id_apps_fragment_container );
+ mEntrance = findViewById( R.id.module_main_id_entrance_fragment_container );
+ mFloatingLayout = findViewById( R.id.module_main_id_floating_view );
+ mLeftShadowFrame = findViewById( R.id.module_main_id_map_left_shadow_frame );
+ mTopShadowFrame = findViewById( R.id.module_main_id_map_top_shadow_frame );
+ mCoverUpLayout = findViewById( R.id.module_main_id_cover_up );
- WindowViewHandler.init(mFloatingLayout);
+ WindowViewHandler.init( mFloatingLayout );
+ }
+
+
+ /**
+ * 卡片展示时长埋点
+ *
+ * @param provider
+ */
+ private void trackLastCardShowEvent( IMogoModuleProvider provider ) {
+ if ( provider == null ) {
+ return;
+ }
+ Map< String, Object > properties = new HashMap<>();
+ 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();
+ }
+
+ /**
+ * 卡片滑动埋点,WTF
+ */
+ private void trackCardFlipEvent( IMogoModuleProvider provider ) {
+ if ( provider == null ) {
+ return;
+ }
+ 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 );
}
// 隐藏布局
private void hideLayout() {
- mHeader.setVisibility(View.GONE);
- mCards.setVisibility(View.GONE);
- mApps.setVisibility(View.GONE);
- mEntrance.setVisibility(View.GONE);
- mFloatingLayout.setVisibility(View.GONE);
- mLeftShadowFrame.setVisibility(View.GONE);
+ mHeader.setVisibility( View.GONE );
+ mCards.setVisibility( View.GONE );
+ mApps.setVisibility( View.GONE );
+ mEntrance.setVisibility( View.GONE );
+ mFloatingLayout.setVisibility( View.GONE );
+ mLeftShadowFrame.setVisibility( View.GONE );
}
// 显示布局
private void showLayout() {
- mHeader.setVisibility(View.VISIBLE);
- mCards.setVisibility(View.VISIBLE);
- mApps.setVisibility(View.VISIBLE);
- mEntrance.setVisibility(View.VISIBLE);
- mFloatingLayout.setVisibility(View.VISIBLE);
- mLeftShadowFrame.setVisibility(View.VISIBLE);
+ mHeader.setVisibility( View.VISIBLE );
+ mCards.setVisibility( View.VISIBLE );
+ mApps.setVisibility( View.VISIBLE );
+ mEntrance.setVisibility( View.VISIBLE );
+ mFloatingLayout.setVisibility( View.VISIBLE );
+ mLeftShadowFrame.setVisibility( View.VISIBLE );
}
@Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ protected void onCreate( @Nullable Bundle savedInstanceState ) {
+ super.onCreate( savedInstanceState );
- MogoModulePaths.addModule(new MogoModule(ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY));
+ MogoModulePaths.addModule( new MogoModule( ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY ) );
- mMogoModuleHandler = new MogoModulesManager(this);
- mMogoMapService = (IMogoMapService) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation();
- if (mMogoMapService != null) {
- mMogoMapService.getHostListenerRegister().registerHostMapListener(mMogoModuleHandler);
- mMogoMapService.getHostListenerRegister().registerHostNaviListener(mMogoModuleHandler);
- mMogoMapService.getHostListenerRegister().registerMarkerClickListener(this);
+ mMogoModuleHandler = new MogoModulesManager( this );
+ mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation();
+ if ( mMogoMapService != null ) {
+ mMogoMapService.getHostListenerRegister().registerHostMapListener( mMogoModuleHandler );
+ mMogoMapService.getHostListenerRegister().registerHostNaviListener( mMogoModuleHandler );
+ mMogoMapService.getHostListenerRegister().registerMarkerClickListener( this );
}
- mMogoModuleHandler.setMapLoadedCallback(() -> {
- Logger.d(TAG, "map loaded." + Thread.currentThread().getName());
+ mMogoModuleHandler.setMapLoadedCallback( () -> {
+ Logger.d( TAG, "map loaded." + Thread.currentThread().getName() );
// 加载地图,触发地图加载完毕回调,在初始化其他卡片模块,保证卡片模块可以正确获取地图相关服务。
mMogoModuleHandler.loadModules();
loadContainerModules();
- new Handler().postDelayed(() -> loadCardModules(), 5000);
+ mMsgHandler.sendEmptyMessageDelayed( MainConstants.MSG_LOAD_CARD_MODULES, 5_000L );
+ mMsgHandler.sendEmptyMessageDelayed( MainConstants.MSG_HIDE_MAP_COVER_FRAME, 1_000L );
// 显示左边遮罩
- mLeftShadowFrame.setVisibility(View.VISIBLE);
- mTopShadowFrame.setVisibility(View.VISIBLE);
+ mLeftShadowFrame.setVisibility( View.VISIBLE );
+ mTopShadowFrame.setVisibility( View.VISIBLE );
// 右移地图中心点
mMogoMapUIController = mMogoMapService.getMapUIController();
- mMogoMapUIController.setPointToCenter(0.66145, 0.590688);
+ mMogoMapUIController.setPointToCenter( 0.66145, 0.590688 );
// 开启定位
startLocation();
- });
- mMogoModuleHandler.loadMapModule(R.id.module_main_id_map_fragment_container);
+ } );
+ mMogoModuleHandler.loadMapModule( R.id.module_main_id_map_fragment_container );
- mMogoCardManager = (IMogoCardManager) ARouter.getInstance().build(MogoServicePaths.PATH_CARD_MANAGER).navigation(this);
- mAnalytics = (IMogoAnalytics) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation(this);
+ mMogoCardManager = ( IMogoCardManager ) ARouter.getInstance().build( MogoServicePaths.PATH_CARD_MANAGER ).navigation( this );
+ mAnalytics = ( IMogoAnalytics ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_ANALYTICS ).navigation( this );
}
private void startLocation() {
- mLocationClient = mMogoMapService.getSingletonLocationClient(getApplicationContext());
- mLocationClient.addLocationListener(this);
- mLocationClient.start();
+ mLocationClient = mMogoMapService.getSingletonLocationClient( getApplicationContext() );
+ mLocationClient.addLocationListener( this );
+ mLocationClient.start(10_000L);
}
private void loadContainerModules() {
- mMogoModuleHandler.loadAppsListModule(R.id.module_main_id_apps_fragment_container);
- mMogoModuleHandler.loadExtensionsModule(R.id.module_main_id_header_fragment_container);
- mMogoModuleHandler.loadEntrancesModule(R.id.module_main_id_entrance_fragment_container);
+ mMogoModuleHandler.loadAppsListModule( R.id.module_main_id_apps_fragment_container );
+ mMogoModuleHandler.loadExtensionsModule( R.id.module_main_id_header_fragment_container );
+ mMogoModuleHandler.loadEntrancesModule( R.id.module_main_id_entrance_fragment_container );
}
private void loadCardModules() {
- List providers = mMogoModuleHandler.loadCardsModule();
- mCardModulesAdapter = new CardModulesAdapter(this, providers);
- mCardsContainer.setOffscreenPageLimit(providers.size());
- mCardsContainer.setPageTransformer(true, new VerticalStackTransformer(this));
- mCardsContainer.setAdapter(mCardModulesAdapter);
- mCardsContainer.setCurrentItem(mCurrentPosition);
+ List< IMogoModuleProvider > providers = mMogoModuleHandler.loadCardsModule();
+ mCardModulesAdapter = new CardModulesAdapter( this, providers );
+ mCardsContainer.setOffscreenPageLimit( providers.size() );
+ mCardsContainer.setPageTransformer( true, new VerticalStackTransformer( this ) );
+ mCardsContainer.setAdapter( mCardModulesAdapter );
mCardStartShowTime = System.currentTimeMillis();
}
@@ -282,62 +331,62 @@ public class MainActivity extends MvpActivity implement
@NonNull
@Override
protected MainPresenter createPresenter() {
- return new MainPresenter(this);
+ return new MainPresenter( this );
}
@Override
- public void onLocationChanged(MogoLocation location) {
- if (mMogoModuleHandler != null) {
- mMogoModuleHandler.onLocationChanged(location);
+ public void onLocationChanged( MogoLocation location ) {
+ if ( mMogoModuleHandler != null ) {
+ mMogoModuleHandler.onLocationChanged( location );
}
}
@Override
- public boolean onMarkerClicked(IMogoMarker marker) {
+ public boolean onMarkerClicked( IMogoMarker marker ) {
isClickMarker = true;
- switch2(marker.getOwner());
- if (mMogoModuleHandler != null) {
- mMogoModuleHandler.onMarkerClicked(marker);
+ switch2( marker.getOwner() );
+ if ( mMogoModuleHandler != null ) {
+ mMogoModuleHandler.onMarkerClicked( marker );
}
isClickMarker = false;
return false;
}
@Override
- public void switch2(String cardType) {
- if (mCardModulesAdapter != null) {
+ public void switch2( String cardType ) {
+ if ( mCardModulesAdapter != null ) {
- int position = mCardModulesAdapter.getProviderPosition(cardType);
- if (position != -1) {
- int lastFactPosition = mCardModulesAdapter.getFactPosition(mCurrentPosition);
- mCardsContainer.setCurrentItem(mCurrentPosition + position - lastFactPosition, Math.abs(lastFactPosition - position) == 1);
- if (!isClickMarker) {
- mMogoCardManager.invoke(position, mMogoModuleHandler.getCurrentModuleName());
+ int position = mCardModulesAdapter.getProviderPosition( cardType );
+ if ( position != -1 ) {
+ int lastFactPosition = mCardModulesAdapter.getFactPosition( mCurrentPosition );
+ mCardsContainer.setCurrentItem( mCurrentPosition + position - lastFactPosition, Math.abs( lastFactPosition - position ) == 1 );
+ if ( !isClickMarker ) {
+ mMogoCardManager.invoke( position, mMogoModuleHandler.getCurrentModuleName() );
}
} else {
- Logger.e(TAG, "Can't find type of %s's position", cardType);
+ Logger.e( TAG, "Can't find type of %s's position", cardType );
}
}
}
@Override
protected void onResume() {
- MapBroadCastHelper.getInstance(this).mapFrount();
+ MapBroadCastHelper.getInstance( this ).mapFrount();
super.onResume();
}
@Override
protected void onPause() {
- MapBroadCastHelper.getInstance(this).mapBackground();
+ MapBroadCastHelper.getInstance( this ).mapBackground();
super.onPause();
}
@Override
public void onBackPressed() {
- if (mMogoFragmentManager.getStackSize() == 0) {
+ if ( mMogoFragmentManager.getStackSize() == 0 ) {
return;
}
- if (mMogoFragmentManager != null) {
+ if ( mMogoFragmentManager != null ) {
mMogoFragmentManager.pop();
}
}
@@ -346,12 +395,12 @@ public class MainActivity extends MvpActivity implement
@Override
protected void onDestroy() {
super.onDestroy();
- if (mLocationClient != null) {
- mLocationClient.removeLocationListener(this);
+ if ( mLocationClient != null ) {
+ mLocationClient.removeLocationListener( this );
mLocationClient.destroy();
}
mLocationClient = null;
- if (mMogoModuleHandler != null) {
+ if ( mMogoModuleHandler != null ) {
mMogoModuleHandler.destroy();
}
mMogoModuleHandler = null;
@@ -360,6 +409,6 @@ public class MainActivity extends MvpActivity implement
mMogoCardManager = null;
mMogoFragmentManager = null;
- AIAssist.getInstance(this).release();
+ AIAssist.getInstance( this ).release();
}
}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java
index ad7c519538..d78ff9e0b8 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java
@@ -1,9 +1,7 @@
package com.mogo.module.main.cards;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
@@ -28,14 +26,21 @@ import com.mogo.module.extensions.ExtensionsModuleConst;
import com.mogo.module.main.MainActivity;
import com.mogo.module.main.assist.MapBroadCastHelper;
import com.mogo.module.main.registercenter.MogoRegisterCenterHandler;
+import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
-import com.mogo.service.map.IMogoMapService;
+import com.mogo.service.intent.IMogoIntentListener;
+import com.mogo.service.intent.IMogoIntentManager;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.module.ModuleType;
import com.mogo.utils.ResourcesHelper;
import com.mogo.utils.logger.Logger;
+import com.mogo.utils.network.utils.GsonUtil;
+import com.mogo.utils.storage.SharedPrefsMgr;
+
+import org.json.JSONArray;
+import org.json.JSONException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -50,35 +55,40 @@ import java.util.Map;
* 卡片加载
*/
public class MogoModulesManager implements MogoModulesHandler,
- IMogoMapListener,
- IMogoNaviListener,
- IMogoLocationListener {
+ IMogoMapListener,
+ IMogoNaviListener,
+ IMogoLocationListener,
+ IMogoIntentListener {
private static final String TAG = "MogoModulesManager";
private MainActivity mActivity;
- private Map mModuleProviders = new HashMap<>();
+ private Map< MogoModule, IMogoModuleProvider > mModuleProviders = new HashMap<>();
+ // 空间换效率
+ private Map< String, IMogoModuleProvider > mModuleNameProviders = new HashMap<>();
private IMogoAnalytics mTrackManager;
- private IMogoMapService mapService;
private String mEnableModuleName = null;
private Runnable mMapLoadedCallback;
- private BroadcastReceiver mReceiver;
+ public static final String KEY_SORTED_CARD_MODULES = "sortedCards";
+ private List< String > mSortedCards = new ArrayList<>();
- public MogoModulesManager(MainActivity activity) {
- if (activity == null) {
- throw new NullPointerException("activity can't be null.");
+ private IMogoIntentManager mMogoIntentManager;
+
+ public MogoModulesManager( MainActivity activity ) {
+ if ( activity == null ) {
+ throw new NullPointerException( "activity can't be null." );
}
this.mActivity = activity;
- mTrackManager = (IMogoAnalytics) ARouter.getInstance()
- .build(MogoServicePaths.PATH_UTILS_ANALYTICS)
- .navigation();
+ mTrackManager = ( IMogoAnalytics ) ARouter.getInstance()
+ .build( MogoServicePaths.PATH_UTILS_ANALYTICS )
+ .navigation();
- mapService = (IMogoMapService) ARouter.getInstance().build(
- MogoServicePaths.PATH_SERVICES_MAP
- ).navigation();
+ mMogoIntentManager = ( IMogoIntentManager ) ARouter.getInstance()
+ .build( MogoServicePaths.PATH_INTENT_MANAGER )
+ .navigation();
registerReceiver();
}
@@ -93,283 +103,311 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void loadModules() {
- final List modules = MogoModulePaths.getModules();
- if (modules != null && !modules.isEmpty()) {
- for (MogoModule module : modules) {
- IMogoModuleProvider provider = load(module.getPath());
- if (provider != null) {
- mModuleProviders.put(module, provider);
+ final List< MogoModule > modules = MogoModulePaths.getModules();
+ if ( modules != null && !modules.isEmpty() ) {
+ for ( MogoModule module : modules ) {
+ IMogoModuleProvider provider = load( module.getPath() );
+ if ( provider != null ) {
+ mModuleProviders.put( module, provider );
+ mModuleNameProviders.put( module.getName(), provider );
}
}
}
}
@Override
- public void setMapLoadedCallback(Runnable callback) {
+ public void setMapLoadedCallback( Runnable callback ) {
mMapLoadedCallback = callback;
}
@Override
- public List loadCardsModule() {
- final List modules = MogoModulePaths.getModules();
- final ArrayList providers = new ArrayList<>();
- for (MogoModule module : modules) {
- IMogoModuleProvider provider = mModuleProviders.get(module);
- if (provider.getType() == ModuleType.TYPE_CARD_FRAGMENT) {
- if (mEnableModuleName == null) {
+ public List< IMogoModuleProvider > loadCardsModule() {
+
+ String sortedJson = SharedPrefsMgr.getInstance( getContext() ).getString( KEY_SORTED_CARD_MODULES );
+ try {
+ JSONArray array = new JSONArray( sortedJson );
+ mSortedCards = new ArrayList<>( array.length() );
+ for ( int i = 0; i < array.length(); i++ ) {
+ mSortedCards.add( array.getString( i ) );
+ }
+ Logger.d( TAG, "Last cache card: %s", mSortedCards );
+ } catch ( JSONException e ) {
+ e.printStackTrace();
+ }
+
+ final List< MogoModule > modules = MogoModulePaths.getModules();
+ final ArrayList< IMogoModuleProvider > providers = new ArrayList<>();
+ for ( MogoModule module : modules ) {
+ IMogoModuleProvider provider = mModuleProviders.get( module );
+ if ( provider.getType() == ModuleType.TYPE_CARD_FRAGMENT ) {
+ if ( mEnableModuleName == null ) {
mEnableModuleName = provider.getModuleName();
}
- providers.add(provider);
+ providers.add( provider );
}
}
- return providers;
+ return sort( providers );
+ }
+
+ private List< IMogoModuleProvider > sort( List< IMogoModuleProvider > modules ) {
+ if ( modules == null || modules.size() == 0 ) {
+ return modules;
+ }
+ if ( mSortedCards == null ) {
+ mSortedCards = new ArrayList<>();
+ }
+ List< IMogoModuleProvider > sortedList = new ArrayList<>( modules.size() );
+
+ for ( String sortedCard : mSortedCards ) {
+ for ( IMogoModuleProvider module : modules ) {
+ if ( TextUtils.equals( module.getModuleName(), sortedCard ) ) {
+ sortedList.add( module );
+ Logger.d( TAG, "%s sorted.", sortedCard );
+ break;
+ }
+ }
+ }
+ for ( IMogoModuleProvider module : modules ) {
+ if ( !sortedList.contains( module ) ) {
+ sortedList.add( module );
+ }
+ }
+ mSortedCards.clear();
+ for ( IMogoModuleProvider provider : sortedList ) {
+ mSortedCards.add( provider.getModuleName() );
+ }
+ return sortedList;
}
@Override
- public void loadMapModule(int containerId) {
- IMogoModuleProvider provider = (IMogoModuleProvider) ARouter.getInstance()
- .build(MogoModulePaths.PATH_MODULE_MAP)
- .navigation(getContext());
- addFragment(provider, containerId);
+ public void loadMapModule( int containerId ) {
+ IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
+ .build( MogoModulePaths.PATH_MODULE_MAP )
+ .navigation( getContext() );
+ addFragment( provider, containerId );
}
@Override
- public void loadAppsListModule(int containerId) {
- IMogoModuleProvider provider = (IMogoModuleProvider) ARouter.getInstance()
- .build(MogoModulePaths.PATH_MODULE_APPS)
- .navigation(getContext());
- addFragment(provider, containerId);
+ public void loadAppsListModule( int containerId ) {
+ IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
+ .build( MogoModulePaths.PATH_MODULE_APPS )
+ .navigation( getContext() );
+ addFragment( provider, containerId );
}
@Override
- public void loadExtensionsModule(int containerId) {
- IMogoModuleProvider provider = (IMogoModuleProvider) ARouter.getInstance()
- .build(ExtensionsModuleConst.PATH_EXTENSION)
- .navigation(getContext());
- addFragment(provider, containerId);
+ public void loadExtensionsModule( int containerId ) {
+ IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
+ .build( ExtensionsModuleConst.PATH_EXTENSION )
+ .navigation( getContext() );
+ addFragment( provider, containerId );
}
@Override
- public void loadEntrancesModule(int containerId) {
- IMogoModuleProvider provider = (IMogoModuleProvider) ARouter.getInstance()
- .build(ExtensionsModuleConst.PATH_ENTRANCE)
- .navigation(getContext());
- addFragment(provider, containerId);
+ public void loadEntrancesModule( int containerId ) {
+ IMogoModuleProvider provider = ( IMogoModuleProvider ) ARouter.getInstance()
+ .build( ExtensionsModuleConst.PATH_ENTRANCE )
+ .navigation( getContext() );
+ addFragment( provider, containerId );
}
- private IMogoModuleProvider load(String path) {
- return (IMogoModuleProvider) ARouter.getInstance().build(path).navigation(getContext());
+ private IMogoModuleProvider load( String path ) {
+ return ( IMogoModuleProvider ) ARouter.getInstance().build( path ).navigation( getContext() );
}
- private void addFragment(IMogoModuleProvider provider, int containerId) {
- if (provider == null) {
- Logger.e(TAG, "add fragment fail cause provider == null, container is %s",
- ResourcesHelper.getResNameById(getApplicationContext(), containerId));
+ private void addFragment( IMogoModuleProvider provider, int containerId ) {
+ if ( provider == null ) {
+ Logger.e( TAG, "add fragment fail cause provider == null, container is %s",
+ ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
return;
}
- final Fragment fragment = provider.createFragment(getContext(), null);
- if (fragment == null) {
- Logger.e(TAG, "add fragment fail cause fragment == null, container is %s",
- ResourcesHelper.getResNameById(getApplicationContext(), containerId));
+ final Fragment fragment = provider.createFragment( getContext(), null );
+ if ( fragment == null ) {
+ Logger.e( TAG, "add fragment fail cause fragment == null, container is %s",
+ ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
return;
}
mActivity.getSupportFragmentManager().beginTransaction()
- .add(containerId, fragment, provider.getModuleName())
- .commitAllowingStateLoss();
+ .add( containerId, fragment, provider.getModuleName() )
+ .commitAllowingStateLoss();
}
@Override
- public void setModuleEnable(String module) {
-
+ public void setModuleEnable( String module ) {
+ final long start1 = System.currentTimeMillis();
// 仅操作上一个模块和当前模块
- Iterator iterator = mModuleProviders.values().iterator();
+ Iterator< IMogoModuleProvider > iterator = mModuleProviders.values().iterator();
int counter = 0;
- while (iterator.hasNext()) {
- IMogoModuleProvider provider = iterator.next();
- if (provider == null) {
- continue;
- }
- if (provider.getType() != ModuleType.TYPE_CARD_FRAGMENT) {
- continue;
- }
- if (TextUtils.equals(mEnableModuleName, provider.getModuleName())) {
- final IMogoModuleLifecycle lifecycle =
- MogoRegisterCenterHandler.getInstance().getLifecycleListener(mEnableModuleName);
- if (lifecycle != null) {
- try {
- final long start = System.currentTimeMillis();
- lifecycle.onDisable();
- Logger.i(TAG,
- "set %s module disable event cost " + (System.currentTimeMillis()
- - start) + "ms", mEnableModuleName);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
- }
+
+ // 上一个卡片设置为 disable
+ IMogoModuleProvider prev = mModuleNameProviders.get( mEnableModuleName );
+ if ( prev != null ) {
+ final IMogoModuleLifecycle lifecycle = MogoRegisterCenterHandler.getInstance().getLifecycleListener( mEnableModuleName );
+ if ( lifecycle != null ) {
+ try {
+ final long start = System.currentTimeMillis();
+ lifecycle.onDisable();
+ Logger.i( TAG, "set %s module disable event cost " + ( System.currentTimeMillis() - start ) + "ms", mEnableModuleName );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
- counter++;
- continue;
}
- if (TextUtils.equals(module, provider.getModuleName())) {
- final IMogoModuleLifecycle lifecycle =
- MogoRegisterCenterHandler.getInstance().getLifecycleListener(module);
- if (lifecycle != null) {
- try {
- final long start = System.currentTimeMillis();
- lifecycle.onPerform();
- Logger.i(TAG,
- "set %s module perform event cost " + (System.currentTimeMillis()
- - start) + "ms", module);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
- }
+ }
+
+ // 当前卡片设置为 perform
+ IMogoModuleProvider current = mModuleNameProviders.get( module );
+ if ( current != null ) {
+ final IMogoModuleLifecycle lifecycle = MogoRegisterCenterHandler.getInstance().getLifecycleListener( module );
+ if ( lifecycle != null ) {
+ try {
+ final long start = System.currentTimeMillis();
+ lifecycle.onPerform();
+ Logger.i( TAG, "set %s module perform event cost " + ( System.currentTimeMillis() - start ) + "ms", module );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
- counter++;
- continue;
- }
- if (counter == 2) {
- break;
}
}
mEnableModuleName = module;
+ mSortedCards.remove( mEnableModuleName );
+ mSortedCards.add( 0, mEnableModuleName );
+ SharedPrefsMgr.getInstance( getContext() ).putString( KEY_SORTED_CARD_MODULES, GsonUtil.jsonFromObject( mSortedCards ) );
+ Log.i( TAG, "enable & disable card cost " + ( System.currentTimeMillis() - start1 ) + "ms" );
}
@Override
public void onMapLoaded() {
- if (mMapLoadedCallback != null) {
+ if ( mMapLoadedCallback != null ) {
mMapLoadedCallback.run();
mMapLoadedCallback = null;
}
}
@Override
- public void onTouch(MotionEvent motionEvent) {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getMapListeners();
- if (iterator == null) {
+ public void onTouch( MotionEvent motionEvent ) {
+ Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoMapListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
- listener.onTouch(motionEvent);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ listener.onTouch( motionEvent );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
}
@Override
- public void onPOIClick(MogoPoi poi) {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getMapListeners();
- if (iterator == null) {
+ public void onPOIClick( MogoPoi poi ) {
+ Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoMapListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
- listener.onPOIClick(poi);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ listener.onPOIClick( poi );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
}
@Override
- public void onMapClick(MogoLatLng latLng) {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getMapListeners();
- if (iterator == null) {
+ public void onMapClick( MogoLatLng latLng ) {
+ Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoMapListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
- listener.onMapClick(latLng);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ listener.onMapClick( latLng );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
}
@Override
- public void onLockMap(boolean isLock) {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getMapListeners();
- if (iterator == null) {
+ public void onLockMap( boolean isLock ) {
+ Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoMapListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
- listener.onLockMap(isLock);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ listener.onLockMap( isLock );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
}
@Override
- public void onMapModeChanged(EnumMapUI ui) {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getMapListeners();
- if (iterator == null) {
+ public void onMapModeChanged( EnumMapUI ui ) {
+ Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoMapListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
- listener.onMapModeChanged(ui);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ listener.onMapModeChanged( ui );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
}
@Override
- public void onMapChanged(MogoLatLng location, float zoom, float tilt, float bearing) {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getMapListeners();
- if (iterator == null) {
+ public void onMapChanged( MogoLatLng location, float zoom, float tilt, float bearing ) {
+
+ final long start = System.currentTimeMillis();
+ Iterator< IMogoMapListener > iterator = MogoRegisterCenterHandler.getInstance().getMapListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoMapListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
- listener.onMapChanged(location, zoom, tilt, bearing);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ listener.onMapChanged( location, zoom, tilt, bearing );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
+ Log.i( TAG, "onMapChanged event cost " + ( System.currentTimeMillis() - start ) + "ms" );
}
@Override
public void onInitNaviFailure() {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getNaviListeners();
- if (iterator == null) {
+ Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoNaviListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
listener.onInitNaviFailure();
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
@@ -377,39 +415,37 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onInitNaviSuccess() {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getNaviListeners();
- if (iterator == null) {
+ Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoNaviListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
listener.onInitNaviSuccess();
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
}
@Override
- public void onNaviInfoUpdate(MogoNaviInfo naviinfo) {
- MapBroadCastHelper.getInstance(getApplicationContext()).notifyXiaozhi(naviinfo);
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getNaviListeners();
+ public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
+ MapBroadCastHelper.getInstance( getApplicationContext() ).notifyXiaozhi( naviinfo );
+ Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
- if (iterator == null) {
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoNaviListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
- listener.onNaviInfoUpdate(naviinfo);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ listener.onNaviInfoUpdate( naviinfo );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
@@ -417,21 +453,20 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onStartNavi() {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getNaviListeners();
- mTrackManager.track("Navigation_begin", new HashMap<>());
+ Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
+ mTrackManager.track( "Navigation_begin", new HashMap<>() );
- MapBroadCastHelper.getInstance(getApplicationContext()).startNavi();
- if (iterator == null) {
+ MapBroadCastHelper.getInstance( getApplicationContext() ).startNavi();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoNaviListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
listener.onStartNavi();
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
@@ -439,20 +474,19 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onStopNavi() {
- mTrackManager.track("Navigation_end", new HashMap<>());
- MapBroadCastHelper.getInstance(getApplicationContext()).stopNavi();
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getNaviListeners();
- if (iterator == null) {
+ mTrackManager.track( "Navigation_end", new HashMap<>() );
+ MapBroadCastHelper.getInstance( getApplicationContext() ).stopNavi();
+ Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoNaviListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
listener.onStopNavi();
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
@@ -460,18 +494,17 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onCalculateSuccess() {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getNaviListeners();
- if (iterator == null) {
+ Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoNaviListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
listener.onCalculateSuccess();
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
@@ -479,95 +512,104 @@ public class MogoModulesManager implements MogoModulesHandler,
@Override
public void onoCalculateFailed() {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getNaviListeners();
- if (iterator == null) {
+ Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoNaviListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
listener.onoCalculateFailed();
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
}
@Override
- public void onUpdateTraffic(MogoTraffic traffic) {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getNaviListeners();
- if (iterator == null) {
+ public void onUpdateTraffic( MogoTraffic traffic ) {
+ Iterator< IMogoNaviListener > iterator = MogoRegisterCenterHandler.getInstance().getNaviListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoNaviListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
- listener.onUpdateTraffic(traffic);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ listener.onUpdateTraffic( traffic );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
}
@Override
- public void onLocationChanged(MogoLocation location) {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getLocationListeners();
- if (iterator == null) {
+ public void onLocationChanged( MogoLocation location ) {
+ final long start = System.currentTimeMillis();
+ Iterator< IMogoLocationListener > iterator = MogoRegisterCenterHandler.getInstance().getLocationListeners();
+ if ( iterator == null ) {
return;
}
- while (iterator.hasNext()) {
+ while ( iterator.hasNext() ) {
IMogoLocationListener listener = iterator.next();
- if (listener != null) {
+ if ( listener != null ) {
try {
- listener.onLocationChanged(location);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ listener.onLocationChanged( location );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
}
+ Log.i( TAG, "onLocationChanged event cost " + ( System.currentTimeMillis() - start ) + "ms" );
}
public void registerReceiver() {
- mReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- final String action = intent.getAction();
- if (TextUtils.equals(action, Intent.ACTION_POWER_CONNECTED)) {
- Iterator iterator =
- MogoRegisterCenterHandler.getInstance().getLifecycleListeners();
- if (iterator.hasNext()) {
- iterator.next().accOn();
- }
- } else if (TextUtils.equals(action, Intent.ACTION_POWER_DISCONNECTED)) {
+ mMogoIntentManager.registerIntentListener( Intent.ACTION_POWER_CONNECTED, this );
+ mMogoIntentManager.registerIntentListener( Intent.ACTION_POWER_DISCONNECTED, this );
+ mMogoIntentManager.registerIntentListener( MogoReceiver.ACTION_NWD_ACC, this );
+ }
+ @Override
+ public void onIntentReceived( String intentStr, Intent intent ) {
+
+ Iterator< IMogoModuleLifecycle > iterator = MogoRegisterCenterHandler.getInstance().getLifecycleListeners();
+ if ( Intent.ACTION_POWER_CONNECTED.equals( intentStr ) ) {
+ while ( iterator.hasNext() ) {
+ IMogoModuleLifecycle lifecycle = iterator.next();
+ if ( lifecycle != null ) {
+ lifecycle.accOn();
}
}
- };
- IntentFilter inputFilter = new IntentFilter();
- inputFilter.addAction(Intent.ACTION_POWER_CONNECTED);
- inputFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
- getApplicationContext().registerReceiver(mReceiver, inputFilter);
+ } else if ( Intent.ACTION_POWER_DISCONNECTED.equals( intentStr ) ) {
+ } else if ( MogoReceiver.ACTION_NWD_ACC.equals( intentStr ) ) {
+ int state = intent.getByteExtra( MogoReceiver.PARAM_ACC_STATUS, ( byte ) 0 );
+ if ( state == 1 ) {
+ while ( iterator.hasNext() ) {
+ IMogoModuleLifecycle lifecycle = iterator.next();
+ if ( lifecycle != null ) {
+ lifecycle.accOn();
+ }
+ }
+ }
+ }
+
+ if ( iterator.hasNext() ) {
+ iterator.next().accOn();
+ }
}
@Override
public void destroy() {
- if (mReceiver != null) {
- try {
- getApplicationContext().unregisterReceiver(mReceiver);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ if ( mMogoIntentManager != null ) {
+ mMogoIntentManager.unregisterIntentListener( Intent.ACTION_POWER_CONNECTED );
+ mMogoIntentManager.unregisterIntentListener( Intent.ACTION_POWER_DISCONNECTED );
+ mMogoIntentManager.unregisterIntentListener( MogoReceiver.ACTION_NWD_ACC );
}
- mReceiver = null;
mActivity = null;
- if (mModuleProviders != null) {
+ if ( mModuleProviders != null ) {
mModuleProviders.clear();
}
mModuleProviders = null;
@@ -576,14 +618,13 @@ public class MogoModulesManager implements MogoModulesHandler,
}
@Override
- public boolean onMarkerClicked(IMogoMarker marker) {
- IMogoMarkerClickListener listener =
- MogoRegisterCenterHandler.getInstance().getMarkerListener(marker.getOwner());
- if (listener != null) {
+ public boolean onMarkerClicked( IMogoMarker marker ) {
+ IMogoMarkerClickListener listener = MogoRegisterCenterHandler.getInstance().getMarkerListener( marker.getOwner() );
+ if ( listener != null ) {
try {
- return listener.onMarkerClicked(marker);
- } catch (Exception e) {
- Logger.e(TAG, e, "error.");
+ return listener.onMarkerClicked( marker );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
}
}
return false;
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/constants/MainConstants.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/constants/MainConstants.java
new file mode 100644
index 0000000000..cad52a91c9
--- /dev/null
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/constants/MainConstants.java
@@ -0,0 +1,35 @@
+package com.mogo.module.main.constants;
+
+/**
+ * @author congtaowang
+ * @since 2020-02-12
+ *
+ * 描述
+ */
+public class MainConstants {
+
+ /**
+ * 消息:加载卡片模块
+ */
+ public static final int MSG_LOAD_CARD_MODULES = 5000;
+
+ /**
+ * 消息:触发第一张卡片的onPerform 时间
+ */
+ public static final int MSG_LOAD_INVOKE_FIRST_CARD_PERFORM_EVENT = 5001;
+
+ /**
+ * 消息:卡片展示事件
+ */
+ public static final int MSG_TRACK_LAST_CARD_DISPLAY_EVENT = 5002;
+
+ /**
+ * 消息:卡片滑动事件
+ */
+ public static final int MSG_TRACK_CARD_FLIP_EVENT = 5003;
+
+ /**
+ * 消息:隐藏地图遮罩(避免地图加载白屏)
+ */
+ public static final int MSG_HIDE_MAP_COVER_FRAME = 5004;
+}
diff --git a/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
index 23343b9186..8f0fe91943 100644
--- a/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
+++ b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
@@ -89,4 +89,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
+
\ No newline at end of file
diff --git a/modules/mogo-module-search/build.gradle b/modules/mogo-module-search/build.gradle
index 31d10b703e..a9cf9244be 100644
--- a/modules/mogo-module-search/build.gradle
+++ b/modules/mogo-module-search/build.gradle
@@ -45,8 +45,6 @@ dependencies {
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
implementation rootProject.ext.dependencies.room
- implementation 'androidx.appcompat:appcompat:1.1.0'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
kapt rootProject.ext.dependencies.roomAnnotationProcessor
implementation rootProject.ext.dependencies.roomRxjava
implementation rootProject.ext.dependencies.androidxrecyclerview
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java
index 33b6a55df7..ce8f8cafb9 100644
--- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java
@@ -1,49 +1,22 @@
package com.mogo.module.service;
import android.content.Context;
-import android.os.Handler;
-import android.os.Looper;
-import android.view.View;
import com.alibaba.android.arouter.launcher.ARouter;
-import com.mogo.map.MogoLatLng;
import com.mogo.map.location.IMogoLocationClient;
-import com.mogo.map.marker.IMogoMarker;
-import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.IMogoMarkerManager;
-import com.mogo.map.marker.MogoMarkerOptions;
-import com.mogo.map.marker.MogoMarkersHandler;
import com.mogo.map.navi.IMogoNavi;
import com.mogo.map.uicontroller.IMogoMapUIController;
-import com.mogo.module.common.entity.MarkerCarChat;
-import com.mogo.module.common.entity.MarkerCardResult;
-import com.mogo.module.common.entity.MarkerExploreWay;
-import com.mogo.module.common.entity.MarkerLocation;
-import com.mogo.module.common.entity.MarkerNoveltyInfo;
-import com.mogo.module.common.entity.MarkerOnlineCar;
-import com.mogo.module.common.entity.MarkerPoiTypeEnum;
import com.mogo.module.common.entity.MarkerResponse;
-import com.mogo.module.common.entity.MarkerShareMusic;
import com.mogo.module.common.entity.MarkerShowEntity;
-import com.mogo.module.service.marker.MapMarkerAdapter;
+import com.mogo.module.service.marker.MapMarkerManager;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
-import com.mogo.service.cardmanager.IMogoCardChangedListener;
import com.mogo.service.cardmanager.IMogoCardManager;
-import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.service.connection.IMogoSocketManager;
import com.mogo.service.imageloader.IMogoImageloader;
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;
/**
* author : donghongyu
@@ -55,7 +28,6 @@ import java.util.Map;
public class MarkerServiceHandler {
private static final String TAG = "MarkerServiceHandler";
- private static MoGoMarkerClickListener mogoMarkerClickListener;
private static IMogoMapService mMapService;
private static IMogoMarkerManager mMarkerManager;
@@ -70,17 +42,13 @@ public class MarkerServiceHandler {
private static IMogoCardManager mMogoCardManager;
private static IMogoAnalytics mMogoAnalytics;
- private static Context mContext;
+ private static MapMarkerManager mMapMarkerManager;
- // 第一次请求到地图的Marker数据
- private static boolean isFirstMarker = true;
public static void init(final Context context) {
- mContext = context;
mMapService = (IMogoMapService) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation(context);
mImageloader = (IMogoImageloader) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_IMAGE_LOADER).navigation(context);
mMogoStatusManager = (IMogoStatusManager) ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation(context);
- mMogoStatusManager = (IMogoStatusManager) ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation(context);
mMogoSocketManager = (IMogoSocketManager) ARouter.getInstance().build(MogoServicePaths.PATH_SOCKET_MANAGER).navigation();
mMogoCardManager = (IMogoCardManager) ARouter.getInstance().build(MogoServicePaths.PATH_CARD_MANAGER).navigation();
mMogoAnalytics = (IMogoAnalytics) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation();
@@ -89,40 +57,9 @@ public class MarkerServiceHandler {
mNavi = mMapService.getNavi(context);
mMapUIController = mMapService.getMapUIController();
mLocationClient = mMapService.getLocationClient(context);
- mogoMarkerClickListener = new MoGoMarkerClickListener();
- // 长连接
- mMogoSocketManager.registerOnMessageListener(401001, new IMogoOnMessageListener() {
-
- @Override
- public Class target() {
- return MarkerResponse.class;
- }
-
- @Override
- public void onMsgReceived(final MarkerResponse response) {
- Logger.e(TAG, "======MarkerResponse:" + response);
- if (!getMogoStatusManager().isSearchUIShow() && !getMogoStatusManager().isV2XShow()) {
- isFirstMarker = true;
- Handler handler = new Handler(Looper.getMainLooper());
- handler.post(new Runnable() {
- @Override
- public void run() {
- drawMapMarker(response);
- }
- });
- }
- }
- });
-
- getMogoCardManager().registerCardChangedListener("LAUNCHER_MARKER_MODULE", new IMogoCardChangedListener() {
-
- @Override
- public void onSwitched(int position, String moduleName) {
- Logger.e(TAG, "======moduleName:" + moduleName);
- highlightedMarker(moduleName);
- }
- });
+ mMapMarkerManager = MapMarkerManager.getInstance(context);
+ mMapMarkerManager.init(context);
}
public static IMogoMapService getMapService() {
@@ -161,356 +98,44 @@ public class MarkerServiceHandler {
return mMogoAnalytics;
}
- private static IMogoMarker lastMarker;
-
- /**
- * 地图上的Marker点击回调
- */
- static class MoGoMarkerClickListener implements IMogoMarkerClickListener {
-
- @Override
- public boolean onMarkerClicked(IMogoMarker marker) {
- Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker:" + marker);
- try {
- if (lastMarker != null) {
- // 判断点击的是否是同一个
- if (marker.equals(lastMarker)) {
- Logger.w(TAG, "onMarkerClicked 与上一次点击的Marker一样,不做处理:" + marker);
- return false;
- }
-
- // 将上次选中 Marker 设置为未选中状态
- MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) lastMarker.getObject();
-
- Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker lastMarkerShowEntity:" + lastMarkerShowEntity);
-
- lastMarkerShowEntity.setChecked(false);
- lastMarkerShowEntity.setHighlighted(false);
-
- drawMapMarker(lastMarkerShowEntity);
-
- lastMarker.remove();
- }
-
- // 将当前的Marker设置为选中
- MarkerShowEntity markerShowEntity = (MarkerShowEntity) marker.getObject();
- Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker markerShowEntity:" + markerShowEntity);
-
- markerShowEntity.setChecked(true);
- markerShowEntity.setHighlighted(true);
-
- lastMarker = drawMapMarker(markerShowEntity);
- if (lastMarker != null) {
- lastMarker.setAlpha(1f);
- }
-
- marker.remove();
-
- final Map properties = new HashMap<>();
- switch (lastMarker.getOwner()) {
- case ServiceConst.CARD_TYPE_CARS_CHATTING:
- properties.put("type", 3);
- break;
- case ServiceConst.CARD_TYPE_USER_DATA:
- properties.put("type", 5);
- break;
- case ServiceConst.CARD_TYPE_ROAD_CONDITION:
- properties.put("type", 2);
- break;
- case ServiceConst.CARD_TYPE_NOVELTY:
- MarkerShowEntity showEntity = (MarkerShowEntity) lastMarker.getObject();
- Object bindObj = showEntity.getBindObj();
- if (bindObj instanceof MarkerNoveltyInfo) {
- switch (((MarkerNoveltyInfo) bindObj).getPoiType()) {
- case MarkerPoiTypeEnum.GAS_STATION:
- properties.put("type", 4);
- break;
- case MarkerPoiTypeEnum.TRAFFIC_CHECK:
- properties.put("type", 8);
- break;
- case MarkerPoiTypeEnum.ROAD_CLOSED:
- properties.put("type", 7);
- break;
- case MarkerPoiTypeEnum.SHOP_DISCOUNT:
- properties.put("type", 9);
- break;
- case MarkerPoiTypeEnum.FOURS_SHOP:
- properties.put("type", 10);
- break;
- }
- }
- break;
- case ServiceConst.CARD_TYPE_SHARE_MUSIC:
- properties.put("type", 6);
- break;
- }
-
- getMogoAnalytics().track("Launcher_Icon_Click", properties);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- return false;
- }
+ public static IMogoLocationClient getMogoLocationClient() {
+ return mLocationClient;
}
- // 对指定类型高亮处理
- public static void highlightedMarker(String typeTag) {
- try {
- Map> allMarker = getMarkerManager().getAllMarkers();
- for (Map.Entry> entry : allMarker.entrySet()) {
- String keyStr = entry.getKey();
- List markerList = entry.getValue();
+ public static MapMarkerManager getMapMarkerManager() {
+ return mMapMarkerManager;
+ }
- if (keyStr.equals(typeTag)) {
- for (IMogoMarker marker : markerList) {
- marker.setAlpha(1f);
- }
- } else {
- for (IMogoMarker marker : markerList) {
- marker.setAlpha(0.7f);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
+ //TODO -------------以下方法是临时过度使用的,后面统一使用,getMapMarkerManager进行调用
+
+ /**
+ * 绘制Marker
+ * 建议使用
+ * @see MapMarkerManager#drawMapMarker(MarkerResponse)
+ */
+ @Deprecated
+ public static void drawMapMarker(MarkerResponse response) {
+ getMapMarkerManager().drawMapMarker(response);
}
/**
* 绘制Marker
+ * 建议使用
+ * @see MapMarkerManager#drawMapMarker(MarkerShowEntity)
*/
- public static void drawMapMarker(MarkerResponse response) {
- lastMarker = null;
-
- JSONArray array = new JSONArray();
-
- // 解析不同的Marker类型,然后对应的进行绘制
- if (response != null && response.getResult() != null) {
-
- MarkerCardResult markerCardResult = response.getResult();
-
- // 语音触发的在线车辆搜索,采用增量的形式绘制
- if (markerCardResult.getDataType() != null &&
- markerCardResult.getDataType().size() == 1 &&
- markerCardResult.getDataType().contains(ServiceConst.CARD_TYPE_USER_DATA)) {
- getMarkerManager().removeMarkers(ServiceConst.CARD_TYPE_USER_DATA);
- getMogoCardManager().switch2(ServiceConst.CARD_TYPE_USER_DATA);
- isFirstMarker = true;
- } else {
- // 清空所有地图上绘制的Marker
- getMarkerManager().removeMarkers();
- }
-
- List carChatList = markerCardResult.getCarChat();
- List onlineCarList = markerCardResult.getOnlineCar();
- List exploreWayList = markerCardResult.getExploreWay();
- List shareMusicList = markerCardResult.getShareMusic();
- List noveltyInfoList = markerCardResult.getNoveltyInfo();
-
- if (carChatList != null) {
- for (MarkerCarChat markerCarChat : carChatList) {
- MarkerLocation markerLocation = markerCarChat.getLocation();
-
- MarkerShowEntity markerShowEntity = new MarkerShowEntity();
- markerShowEntity.setBindObj(markerCarChat);
- markerShowEntity.setMarkerLocation(markerLocation);
- markerShowEntity.setMarkerType(markerCarChat.getType());
- markerShowEntity.setTextContent(markerCarChat.getUserInfo().getUserName());
- markerShowEntity.setIconUrl(markerCarChat.getUserInfo().getUserHead());
-
- drawMapMarker(markerShowEntity);
- }
- }
-
- if (onlineCarList != null) {
- IMogoMarker nearlyMogoMarker = null;
- double nearlyDistance = Double.MAX_VALUE;
- for (MarkerOnlineCar markerOnlineCar : onlineCarList) {
- MarkerLocation markerLocation = markerOnlineCar.getLocation();
-
- MarkerShowEntity markerShowEntity = new MarkerShowEntity();
- markerShowEntity.setBindObj(markerOnlineCar);
- markerShowEntity.setMarkerLocation(markerLocation);
- markerShowEntity.setMarkerType(markerOnlineCar.getType());
- markerShowEntity.setTextContent(markerOnlineCar.getUserInfo().getUserName());
- markerShowEntity.setIconUrl(markerOnlineCar.getUserInfo().getUserHead());
-
- IMogoMarker iMogoMarker = drawMapMarker(markerShowEntity);
- // 计算在线车辆距离当前车辆的距离,每次都与最后一次距离最近的进行比较,保留距离最近的车辆,进行卡片展示
- try {
- double calculateDistance = Utils.calculateLineDistance(
- new MogoLatLng(markerLocation.getLat(), markerLocation.getLat()),
- new MogoLatLng(mLocationClient.getLastKnowLocation().getLatitude(), mLocationClient.getLastKnowLocation().getLongitude())
- );
-
- // 进行比较,保留最近的一个数据
- if (calculateDistance < nearlyDistance) {
- nearlyMogoMarker = iMogoMarker;
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- fillNumberTrackEventBody(array, 3, onlineCarList.size());
-
- try {
- // 在ACC on 之后第一次获取到了在线车辆数据,选中最近的一个Marker
- if (isFirstMarker) {
- if (nearlyMogoMarker != null) {
-// getMogoCardManager().switch2(ServiceConst.CARD_TYPE_USER_DATA);
-// MarkerShowEntity markerShowEntity = (MarkerShowEntity) nearlyMogoMarker.getObject();
-// MarkerOnlineCar markerOnlineCar = (MarkerOnlineCar) markerShowEntity.getBindObj();
-// onLineCarCardViewProvider.updateView(markerOnlineCar);
- MogoMarkersHandler.getInstance().onMarkerClicked(nearlyMogoMarker);
- isFirstMarker = false;
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- if (exploreWayList != null) {
- for (MarkerExploreWay markerExploreWay : exploreWayList) {
- if (!markerExploreWay.getCanLive()) {
- MarkerLocation markerLocation = markerExploreWay.getLocation();
-
- MarkerShowEntity markerShowEntity = new MarkerShowEntity();
- markerShowEntity.setBindObj(markerExploreWay);
- markerShowEntity.setMarkerLocation(markerLocation);
- markerShowEntity.setMarkerType(markerExploreWay.getType());
- markerShowEntity.setTextContent(markerExploreWay.getAddr());
-
- drawMapMarker(markerShowEntity);
- }
- }
- fillNumberTrackEventBody(array, 1, exploreWayList.size());
- }
-
- if (shareMusicList != null) {
- for (MarkerShareMusic markerShareMusic : shareMusicList) {
- MarkerLocation markerLocation = markerShareMusic.getLocation();
-
- MarkerShowEntity markerShowEntity = new MarkerShowEntity();
- markerShowEntity.setBindObj(markerShareMusic);
- markerShowEntity.setMarkerLocation(markerLocation);
- markerShowEntity.setMarkerType(markerShareMusic.getType());
- markerShowEntity.setTextContent(markerShareMusic.getMediaName());
- markerShowEntity.setIconUrl(markerShareMusic.getMediaImg());
-
- drawMapMarker(markerShowEntity);
- }
- fillNumberTrackEventBody(array, 4, shareMusicList.size());
- }
-
- if (noveltyInfoList != null) {
- int num_gas_station = 0;
- int num_traffic_check = 0;
- int num_road_closed = 0;
- int num_shop_discount = 0;
- int num_fours_shop = 0;
-
- for (MarkerNoveltyInfo noveltyInfo : noveltyInfoList) {
- MarkerLocation markerLocation = noveltyInfo.getLocation();
-
- MarkerShowEntity markerShowEntity = new MarkerShowEntity();
- markerShowEntity.setBindObj(noveltyInfo);
- markerShowEntity.setMarkerLocation(markerLocation);
- markerShowEntity.setMarkerType(noveltyInfo.getType());
- markerShowEntity.setTextContent(noveltyInfo.getLocation().getAddress());
-
- drawMapMarker(markerShowEntity);
-
- switch (noveltyInfo.getPoiType()) {
- case MarkerPoiTypeEnum.GAS_STATION:
- num_gas_station++;
- break;
- case MarkerPoiTypeEnum.TRAFFIC_CHECK:
- num_traffic_check++;
- break;
- case MarkerPoiTypeEnum.ROAD_CLOSED:
- num_road_closed++;
- break;
- case MarkerPoiTypeEnum.SHOP_DISCOUNT:
- num_shop_discount++;
- break;
- case MarkerPoiTypeEnum.FOURS_SHOP:
- num_fours_shop++;
- break;
- }
- }
- 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();
- }
+ @Deprecated
+ public static void drawMapMarker(MarkerShowEntity markerShowEntity) {
+ getMapMarkerManager().drawMapMarker(markerShowEntity);
}
/**
- * 统计地图内数据获取
- *
- * @param array 埋点数据
+ * 对指定类型高亮处理
+ * 建议使用
+ * @see MapMarkerManager#highlightedMarker(String)
*/
- private static void analyticData(JSONArray array) {
- try {
- if (array == null || array.length() == 0) {
- return;
- }
- final Map properties = new HashMap<>();
- properties.put("data", array.toString());
- getMogoAnalytics().track("Launcher_Data_Get", properties);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ @Deprecated
+ public static void highlightedMarker(String typeTag) {
+ getMapMarkerManager().highlightedMarker(typeTag);
}
-
- /**
- * 绘制Marker,这里绘制的会使用markerShowEntities队列进行维护
- */
- public static IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity) {
-// Logger.i(TAG, "绘制Marker====drawMapMarker:" + markerShowEntity);
- try {
- if (markerShowEntity.getMarkerLocation() != null) {
-
- MogoMarkerOptions options = new MogoMarkerOptions()
- .owner(markerShowEntity.getMarkerType())
- .alpha(0.7f)
- .object(markerShowEntity)
- .latitude(markerShowEntity.getMarkerLocation().getLat())
- .longitude(markerShowEntity.getMarkerLocation().getLon());
- View markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
- options.icon(markerView);
-
- IMogoMarker marker = getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
- marker.setOnMarkerClickListener(mogoMarkerClickListener);
- return marker;
- } else {
- Logger.e(TAG, "Location 必须进行初始化!!!!!");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
}
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 e9f5c31658..c04af82978 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
@@ -49,6 +49,7 @@ import com.mogo.service.statusmanager.IMogoStatusManager;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.logger.Logger;
+import java.util.Iterator;
import java.util.List;
/**
@@ -118,10 +119,15 @@ public class MogoServiceProvider implements IMogoModuleProvider,
super.handleMessage( msg );
switch ( msg.what ) {
case ServiceConst.MSG_TYPE_REFRESH_DECREASE:
+ if ( mStatusManager.isSearchUIShow() ) {
+ stopAutoRefreshStrategy();
+ return;
+ }
mRefreshRemainingTime -= ServiceConst.DECREASE_INTERVAL;
if ( mRefreshRemainingTime == 0 ) {
- mStatusManager.setUserInteractionStatus(ServiceConst.TYPE, true, false );
- mUiController.moveToCenter(mLastAutoRefreshLocation);
+ Logger.d( TAG, "move to center and refresh data." );
+ mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false );
+ mUiController.moveToCenter( mLastAutoRefreshLocation );
notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
} else {
mHandler.sendEmptyMessageDelayed( msg.what, ServiceConst.DECREASE_INTERVAL );
@@ -366,6 +372,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
}
private void stopAutoRefreshStrategy() {
+ Logger.d( TAG, "stop auto refresh strategy" );
mHandler.removeMessages( ServiceConst.MSG_TYPE_REFRESH_DECREASE );
}
@@ -489,8 +496,8 @@ public class MogoServiceProvider implements IMogoModuleProvider,
}
Logger.d( TAG, mAutoRefreshCallback == callback ? "触发自动刷新" : "触发手动刷新" );
int amount = mLastZoomLevel >= 10 ? 5 : 10;
- mRefreshModel.refreshData( latLng, radius, mLastZoomLevel >= 10 ? 5 : 10, callback );
- Logger.i( TAG, "刷新半径 = %d, 点 = %s, amount = %d", radius, latLng, amount );
+ mRefreshModel.refreshData( latLng, radius, amount, callback );
+ Logger.i( TAG, "刷新半径 = %d, 点 = %s, zoomLevel = %f, amount = %d", radius, latLng, mLastZoomLevel, amount );
}
@Override
@@ -517,8 +524,9 @@ public class MogoServiceProvider implements IMogoModuleProvider,
@Override
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
+ Logger.d( TAG, "状态发生改变---descriptor---" + descriptor + "----isTrue---" + isTrue );
switch ( descriptor ) {
- case USER_INTERACTED:
+ case USER_INTERACTED:
if ( isTrue && !mRefreshRemainingTimeStatus ) {
mRefreshRemainingTimeStatus = true;
mRefreshRemainingTime += mAutoRefreshStrategy.getInterruptInterval();
@@ -526,7 +534,6 @@ public class MogoServiceProvider implements IMogoModuleProvider,
}
break;
case SEARCH_UI:
- case V2X_UI:
if ( isTrue ) {
// 搜索时,不在自动刷新打点策略
stopAutoRefreshStrategy();
@@ -537,9 +544,33 @@ public class MogoServiceProvider implements IMogoModuleProvider,
}
}
break;
+ case V2X_UI:
+ try {
+ if ( isTrue ) {
+ // V2X_UI时,不在自动刷新打点策略
+ stopAutoRefreshStrategy();
+ } else {
+ // 主动刷新
+ refreshStrategy();
+ // V2X_UI后,打开打点策略
+ if ( mAutoRefreshCallback != null ) {
+ mAutoRefreshCallback.onSuccess();
+ }
+ }
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ break;
}
}
+ public void refreshStrategy() {
+ Logger.d( TAG, "move to center and refresh data." );
+ mStatusManager.setUserInteractionStatus( ServiceConst.TYPE, true, false );
+ mUiController.moveToCenter( mLastAutoRefreshLocation );
+ notifyRefreshData( mLastAutoRefreshLocation, getQueryRadius(), mAutoRefreshCallback );
+ }
+
@Override
public void onCalculateSuccess() {
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/datamanager/MogoDataHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/datamanager/MogoDataHandler.java
new file mode 100644
index 0000000000..7421c475fe
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/datamanager/MogoDataHandler.java
@@ -0,0 +1,76 @@
+package com.mogo.module.service.datamanager;
+
+import android.text.TextUtils;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.service.MogoServicePaths;
+import com.mogo.service.datamanager.IMogoDataChangedListener;
+import com.mogo.service.datamanager.IMogoDataManager;
+import com.mogo.utils.logger.Logger;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author congtaowang
+ * @since 2020-02-11
+ *
+ * 描述
+ */
+public class MogoDataHandler {
+
+ private static final String TAG = "MogoDataHandler";
+
+ private Map< String, List< IMogoDataChangedListener > > mListeners = new HashMap<>();
+
+ private MogoDataHandler() {
+ // private constructor
+ }
+
+ private static final class InstanceHolder {
+ private static final MogoDataHandler INSTANCE = new MogoDataHandler();
+ }
+
+ public static MogoDataHandler getInstance() {
+ return InstanceHolder.INSTANCE;
+ }
+
+ public synchronized void registerDataListener( String tag, IMogoDataChangedListener listener ) {
+ if ( listener == null || TextUtils.isEmpty( tag ) ) {
+ return;
+ }
+ if ( !mListeners.containsKey( tag ) || mListeners.get( tag ) == null ) {
+ mListeners.put( tag, new ArrayList< IMogoDataChangedListener >() );
+ }
+ mListeners.get( tag ).add( listener );
+ }
+
+ public synchronized void unregisterListener( String tag, IMogoDataChangedListener listener ) {
+ if ( listener == null || TextUtils.isEmpty( tag ) ) {
+ return;
+ }
+ if ( mListeners.containsKey( tag ) && mListeners.get( tag ) != null ) {
+ mListeners.get( tag ).remove( listener );
+ }
+ }
+
+ public void invoke( String tag, Object data ) {
+ if ( tag == null || mListeners.get( tag ) == null ) {
+ return;
+ }
+ try {
+ Iterator< IMogoDataChangedListener > iterator = mListeners.get( tag ).iterator();
+ while ( iterator.hasNext() ) {
+ IMogoDataChangedListener listener = iterator.next();
+ if ( listener != null ) {
+ listener.onDataSetChanged( data );
+ }
+ }
+ } catch( Exception e ){
+ Logger.e(TAG, e, "error.");
+ }
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/datamanager/MogoDataManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/datamanager/MogoDataManager.java
new file mode 100644
index 0000000000..e94071aeb2
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/datamanager/MogoDataManager.java
@@ -0,0 +1,33 @@
+package com.mogo.module.service.datamanager;
+
+import android.content.Context;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.service.MogoServicePaths;
+import com.mogo.service.datamanager.IMogoDataChangedListener;
+import com.mogo.service.datamanager.IMogoDataManager;
+
+/**
+ * @author congtaowang
+ * @since 2020-02-11
+ *
+ * 描述
+ */
+@Route( path = MogoServicePaths.PATH_DATA_MANAGER )
+public class MogoDataManager implements IMogoDataManager {
+
+ @Override
+ public void registerDataListener( String tag, IMogoDataChangedListener listener ) {
+ MogoDataHandler.getInstance().registerDataListener( tag, listener );
+ }
+
+ @Override
+ public void unregisterListener( String tag, IMogoDataChangedListener listener ) {
+ MogoDataHandler.getInstance().unregisterListener( tag, listener );
+ }
+
+ @Override
+ public void init( Context context ) {
+
+ }
+}
diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java
new file mode 100644
index 0000000000..10a74a29a8
--- /dev/null
+++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java
@@ -0,0 +1,505 @@
+package com.mogo.module.service.marker;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Looper;
+import android.view.View;
+
+import com.mogo.map.MogoLatLng;
+import com.mogo.map.marker.IMogoMarker;
+import com.mogo.map.marker.IMogoMarkerClickListener;
+import com.mogo.map.marker.MogoMarkerOptions;
+import com.mogo.map.marker.MogoMarkersHandler;
+import com.mogo.module.common.entity.MarkerCarChat;
+import com.mogo.module.common.entity.MarkerCardResult;
+import com.mogo.module.common.entity.MarkerExploreWay;
+import com.mogo.module.common.entity.MarkerLocation;
+import com.mogo.module.common.entity.MarkerNoveltyInfo;
+import com.mogo.module.common.entity.MarkerOnlineCar;
+import com.mogo.module.common.entity.MarkerPoiTypeEnum;
+import com.mogo.module.common.entity.MarkerResponse;
+import com.mogo.module.common.entity.MarkerShareMusic;
+import com.mogo.module.common.entity.MarkerShowEntity;
+import com.mogo.module.service.MarkerServiceHandler;
+import com.mogo.module.service.ServiceConst;
+import com.mogo.module.service.Utils;
+import com.mogo.module.service.datamanager.MogoDataHandler;
+import com.mogo.service.cardmanager.IMogoCardChangedListener;
+import com.mogo.service.connection.IMogoOnMessageListener;
+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;
+
+/**
+ * author : donghongyu
+ * e-mail : 1358506549@qq.com
+ * date : 2020-02-1010:44
+ * desc : 大而全的Marker管理
+ * version: 1.0
+ */
+public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessageListener {
+ private static final String TAG = "MarkerManager";
+ // 第一次请求到地图的Marker数据
+ private boolean isFirstMarker = true;
+ private boolean isOnLineCard = false;
+ private Context mContext;
+ private static IMogoMarker lastMarker;
+ private static MapMarkerManager mMarkerManager;
+
+ private MapMarkerManager() {
+ }
+
+ public static synchronized MapMarkerManager getInstance(Context context) {
+ synchronized (MapMarkerManager.class) {
+ if (mMarkerManager == null) {
+ mMarkerManager = new MapMarkerManager();
+ }
+ }
+ return mMarkerManager;
+ }
+
+
+ /**
+ * 初始化大而全的 Marker 管理
+ *
+ * @param context
+ */
+ public void init(Context context) {
+ mContext = context;
+ // 长连接
+ MarkerServiceHandler
+ .getMogoSocketManager()
+ .registerOnMessageListener(401001, this);
+
+ MarkerServiceHandler.getMogoCardManager()
+ .registerCardChangedListener("LAUNCHER_MARKER_MODULE", new IMogoCardChangedListener() {
+
+ @Override
+ public void onSwitched(int position, String moduleName) {
+ Logger.e(TAG, "======moduleName:" + moduleName);
+ highlightedMarker(moduleName);
+
+ if (moduleName.equals(ServiceConst.CARD_TYPE_USER_DATA)) {
+ isOnLineCard = true;
+ } else {
+ isOnLineCard = false;
+ }
+ }
+ });
+ }
+
+
+ /**
+ * 地图上的Marker点击回调
+ */
+ @Override
+ public boolean onMarkerClicked(IMogoMarker marker) {
+ Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker:" + marker);
+ try {
+ if (lastMarker != null) {
+ // 判断点击的是否是同一个
+ if (marker.equals(lastMarker)) {
+ Logger.w(TAG, "onMarkerClicked 与上一次点击的Marker一样,不做处理:" + marker);
+ return false;
+ }
+
+ // 将上次选中 Marker 设置为未选中状态
+ MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) lastMarker.getObject();
+
+ Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker lastMarkerShowEntity:" + lastMarkerShowEntity);
+
+ lastMarkerShowEntity.setChecked(false);
+ lastMarkerShowEntity.setHighlighted(false);
+
+ drawMapMarker(lastMarkerShowEntity);
+
+ lastMarker.remove();
+ }
+
+ // 将当前的Marker设置为选中
+ MarkerShowEntity markerShowEntity = (MarkerShowEntity) marker.getObject();
+ Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker markerShowEntity:" + markerShowEntity);
+
+ markerShowEntity.setChecked(true);
+ markerShowEntity.setHighlighted(true);
+
+ lastMarker = drawMapMarker(markerShowEntity);
+ if (lastMarker != null) {
+ lastMarker.setAlpha(1f);
+ }
+
+ marker.remove();
+
+ final Map properties = new HashMap<>();
+ switch (lastMarker.getOwner()) {
+ case ServiceConst.CARD_TYPE_CARS_CHATTING:
+ properties.put("type", 3);
+ break;
+ case ServiceConst.CARD_TYPE_USER_DATA:
+ properties.put("type", 5);
+ break;
+ case ServiceConst.CARD_TYPE_ROAD_CONDITION:
+ properties.put("type", 2);
+ break;
+ case ServiceConst.CARD_TYPE_NOVELTY:
+ MarkerShowEntity showEntity = (MarkerShowEntity) lastMarker.getObject();
+ Object bindObj = showEntity.getBindObj();
+ if (bindObj instanceof MarkerNoveltyInfo) {
+ switch (((MarkerNoveltyInfo) bindObj).getPoiType()) {
+ case MarkerPoiTypeEnum.GAS_STATION:
+ properties.put("type", 4);
+ break;
+ case MarkerPoiTypeEnum.TRAFFIC_CHECK:
+ properties.put("type", 8);
+ break;
+ case MarkerPoiTypeEnum.ROAD_CLOSED:
+ properties.put("type", 7);
+ break;
+ case MarkerPoiTypeEnum.SHOP_DISCOUNT:
+ properties.put("type", 9);
+ break;
+ case MarkerPoiTypeEnum.FOURS_SHOP:
+ properties.put("type", 10);
+ break;
+ }
+ }
+ break;
+ case ServiceConst.CARD_TYPE_SHARE_MUSIC:
+ properties.put("type", 6);
+ break;
+ }
+
+ MarkerServiceHandler.getMogoAnalytics().track("Launcher_Icon_Click", properties);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+
+ // 对指定类型高亮处理
+ public synchronized static void highlightedMarker(final String typeTag) {
+ Handler handler = new Handler();
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Map> allMarker = MarkerServiceHandler.getMarkerManager().getAllMarkers();
+ for (Map.Entry> entry : allMarker.entrySet()) {
+ String keyStr = entry.getKey();
+ List markerList = entry.getValue();
+
+ if (keyStr.equals(typeTag)) {
+ for (IMogoMarker marker : markerList) {
+ marker.setAlpha(1f);
+ }
+ } else {
+ for (IMogoMarker marker : markerList) {
+ marker.setAlpha(0.7f);
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ /**
+ * 关闭 Marker 详情
+ *
+ * @param marker 要关闭的Marker
+ */
+ public synchronized void closeMarkerSelect(IMogoMarker marker) {
+ // 将上次选中 Marker 设置为未选中状态
+ if (marker != null) {
+ Logger.i(TAG, "closeMarkerSelect 将出Marker详情关闭:" + marker);
+
+ // 将上次选中 Marker 设置为未选中状态
+ MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) marker.getObject();
+ lastMarkerShowEntity.setChecked(false);
+ lastMarkerShowEntity.setHighlighted(false);
+
+ drawMapMarker(lastMarkerShowEntity);
+ marker.remove();
+
+ lastMarker = null;
+ }
+ }
+
+ /**
+ * 绘制Marker
+ */
+ public synchronized void drawMapMarker(MarkerResponse response) {
+ lastMarker = null;
+
+ JSONArray array = new JSONArray();
+
+ // 解析不同的Marker类型,然后对应的进行绘制
+ if (response != null && response.getResult() != null) {
+
+ MarkerCardResult markerCardResult = response.getResult();
+
+ // 语音触发的在线车辆搜索,采用增量的形式绘制
+ if (markerCardResult.getDataType() != null &&
+ markerCardResult.getDataType().size() == 1 &&
+ markerCardResult.getDataType().contains(ServiceConst.CARD_TYPE_USER_DATA)) {
+ MarkerServiceHandler.getMarkerManager().removeMarkers(ServiceConst.CARD_TYPE_USER_DATA);
+ MarkerServiceHandler.getMogoCardManager().switch2(ServiceConst.CARD_TYPE_USER_DATA);
+ isFirstMarker = true;
+ } else {
+ // 清空所有地图上绘制的Marker
+ MarkerServiceHandler.getMarkerManager().removeMarkers();
+ }
+
+ List carChatList = markerCardResult.getCarChat();
+ List onlineCarList = markerCardResult.getOnlineCar();
+ List exploreWayList = markerCardResult.getExploreWay();
+ List shareMusicList = markerCardResult.getShareMusic();
+ List noveltyInfoList = markerCardResult.getNoveltyInfo();
+
+// if (carChatList != null) {
+// for (MarkerCarChat markerCarChat : carChatList) {
+// MarkerLocation markerLocation = markerCarChat.getLocation();
+//
+// MarkerShowEntity markerShowEntity = new MarkerShowEntity();
+// markerShowEntity.setBindObj(markerCarChat);
+// markerShowEntity.setMarkerLocation(markerLocation);
+// markerShowEntity.setMarkerType(markerCarChat.getType());
+// markerShowEntity.setTextContent(markerCarChat.getUserInfo().getUserName());
+// markerShowEntity.setIconUrl(markerCarChat.getUserInfo().getUserHead());
+//
+// drawMapMarker(markerShowEntity);
+// }
+// }
+
+ if (onlineCarList != null) {
+ IMogoMarker nearlyMogoMarker = null;
+ double nearlyDistance = Double.MAX_VALUE;
+ for (MarkerOnlineCar markerOnlineCar : onlineCarList) {
+ MarkerLocation markerLocation = markerOnlineCar.getLocation();
+
+ MarkerShowEntity markerShowEntity = new MarkerShowEntity();
+ markerShowEntity.setBindObj(markerOnlineCar);
+ markerShowEntity.setMarkerLocation(markerLocation);
+ markerShowEntity.setMarkerType(markerOnlineCar.getType());
+ markerShowEntity.setTextContent(markerOnlineCar.getUserInfo().getUserName());
+ markerShowEntity.setIconUrl(markerOnlineCar.getUserInfo().getUserHead());
+
+ IMogoMarker iMogoMarker = drawMapMarker(markerShowEntity);
+ // 计算在线车辆距离当前车辆的距离,每次都与最后一次距离最近的进行比较,保留距离最近的车辆,进行卡片展示
+ try {
+ double calculateDistance = Utils.calculateLineDistance(
+ new MogoLatLng(markerLocation.getLat(), markerLocation.getLat()),
+ new MogoLatLng(
+ MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLatitude(),
+ MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLongitude()
+ )
+ );
+
+ // 进行比较,保留最近的一个数据
+ if (calculateDistance < nearlyDistance) {
+ nearlyMogoMarker = iMogoMarker;
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ fillNumberTrackEventBody(array, 3, onlineCarList.size());
+
+ try {
+ // 在ACC on 之后第一次获取到了在线车辆数据,选中最近的一个Marker
+ if (isFirstMarker && isOnLineCard) {
+ if (nearlyMogoMarker != null) {
+// getMogoCardManager().switch2(ServiceConst.CARD_TYPE_USER_DATA);
+// MarkerShowEntity markerShowEntity = (MarkerShowEntity) nearlyMogoMarker.getObject();
+// MarkerOnlineCar markerOnlineCar = (MarkerOnlineCar) markerShowEntity.getBindObj();
+// onLineCarCardViewProvider.updateView(markerOnlineCar);
+ MogoMarkersHandler.getInstance().onMarkerClicked(nearlyMogoMarker);
+ isFirstMarker = false;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ // 将数据同步给探路,避免探路每次 perform 的时候去拉取,造成消耗
+ MogoDataHandler.getInstance().invoke(ServiceConst.CARD_TYPE_ROAD_CONDITION, exploreWayList);
+ if (exploreWayList != null) {
+ for (MarkerExploreWay markerExploreWay : exploreWayList) {
+ if (!markerExploreWay.getCanLive()) {
+ MarkerLocation markerLocation = markerExploreWay.getLocation();
+
+ MarkerShowEntity markerShowEntity = new MarkerShowEntity();
+ markerShowEntity.setBindObj(markerExploreWay);
+ markerShowEntity.setMarkerLocation(markerLocation);
+ markerShowEntity.setMarkerType(markerExploreWay.getType());
+ markerShowEntity.setTextContent(markerExploreWay.getAddr());
+
+ drawMapMarker(markerShowEntity);
+ }
+ }
+ fillNumberTrackEventBody(array, 1, exploreWayList.size());
+ }
+
+ if (shareMusicList != null) {
+ for (MarkerShareMusic markerShareMusic : shareMusicList) {
+ MarkerLocation markerLocation = markerShareMusic.getLocation();
+
+ MarkerShowEntity markerShowEntity = new MarkerShowEntity();
+ markerShowEntity.setBindObj(markerShareMusic);
+ markerShowEntity.setMarkerLocation(markerLocation);
+ markerShowEntity.setMarkerType(markerShareMusic.getType());
+ markerShowEntity.setTextContent(markerShareMusic.getMediaName());
+ markerShowEntity.setIconUrl(markerShareMusic.getMediaImg());
+
+ drawMapMarker(markerShowEntity);
+ }
+ fillNumberTrackEventBody(array, 4, shareMusicList.size());
+ }
+
+ if (noveltyInfoList != null) {
+ int num_gas_station = 0;
+ int num_traffic_check = 0;
+ int num_road_closed = 0;
+ int num_shop_discount = 0;
+ int num_fours_shop = 0;
+
+ for (MarkerNoveltyInfo noveltyInfo : noveltyInfoList) {
+ MarkerLocation markerLocation = noveltyInfo.getLocation();
+
+ MarkerShowEntity markerShowEntity = new MarkerShowEntity();
+ markerShowEntity.setBindObj(noveltyInfo);
+ markerShowEntity.setMarkerLocation(markerLocation);
+ markerShowEntity.setMarkerType(noveltyInfo.getType());
+ markerShowEntity.setTextContent(noveltyInfo.getLocation().getAddress());
+
+ drawMapMarker(markerShowEntity);
+
+ switch (noveltyInfo.getPoiType()) {
+ case MarkerPoiTypeEnum.GAS_STATION:
+ num_gas_station++;
+ break;
+ case MarkerPoiTypeEnum.TRAFFIC_CHECK:
+ num_traffic_check++;
+ break;
+ case MarkerPoiTypeEnum.ROAD_CLOSED:
+ num_road_closed++;
+ break;
+ case MarkerPoiTypeEnum.SHOP_DISCOUNT:
+ num_shop_discount++;
+ break;
+ case MarkerPoiTypeEnum.FOURS_SHOP:
+ num_fours_shop++;
+ break;
+ }
+ }
+ 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 synchronized 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();
+ }
+ }
+
+ /**
+ * 统计地图内数据获取
+ *
+ * @param array 埋点数据
+ */
+ private synchronized static void analyticData(JSONArray array) {
+ try {
+ if (array == null || array.length() == 0) {
+ return;
+ }
+ final Map properties = new HashMap<>();
+ properties.put("data", array.toString());
+ MarkerServiceHandler.getMogoAnalytics().track("Launcher_Data_Get", properties);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 绘制Marker,这里绘制的会使用markerShowEntities队列进行维护
+ *
+ * @param markerShowEntity marker 绘制数据实体
+ * @return 绘制的Marker
+ */
+ public synchronized IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity) {
+ //Logger.i(TAG, "绘制Marker====drawMapMarker:" + markerShowEntity);
+ try {
+ if (markerShowEntity.getMarkerLocation() != null) {
+
+ MogoMarkerOptions options = new MogoMarkerOptions()
+ .owner(markerShowEntity.getMarkerType())
+ .alpha(0.7f)
+ .object(markerShowEntity)
+ .latitude(markerShowEntity.getMarkerLocation().getLat())
+ .longitude(markerShowEntity.getMarkerLocation().getLon());
+ View markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
+ options.icon(markerView);
+
+ IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
+ marker.setOnMarkerClickListener(this);
+ return marker;
+ } else {
+ Logger.e(TAG, "Location 必须进行初始化!!!!!");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
+ @Override
+ public Class target() {
+ return MarkerResponse.class;
+ }
+
+ @Override
+ public void onMsgReceived(final MarkerResponse response) {
+ Logger.e(TAG, "MarkerResponse======" + response);
+ if (!MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() &&
+ !MarkerServiceHandler.getMogoStatusManager().isV2XShow()) {
+ isFirstMarker = true;
+ Handler handler = new Handler(Looper.getMainLooper());
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ drawMapMarker(response);
+ }
+ });
+ }
+ }
+}
diff --git a/modules/mogo-module-service/src/main/res/layout/view_map_marker.xml b/modules/mogo-module-service/src/main/res/layout/view_map_marker.xml
index 0613e51004..cc0f489a99 100644
--- a/modules/mogo-module-service/src/main/res/layout/view_map_marker.xml
+++ b/modules/mogo-module-service/src/main/res/layout/view_map_marker.xml
@@ -12,7 +12,6 @@
android:layout_width="@dimen/dp_34"
android:layout_height="@dimen/dp_64"
android:src="@drawable/icon_map_marker_car_gray"
- android:translationY="-10dp"
app:layout_constraintEnd_toEndOf="@+id/ivBg"
app:layout_constraintStart_toStartOf="@+id/ivBg"
app:layout_constraintTop_toBottomOf="@+id/ivBg" />
diff --git a/modules/mogo-module-service/src/main/res/layout/view_map_marker_info.xml b/modules/mogo-module-service/src/main/res/layout/view_map_marker_info.xml
index 19b71da718..ae9abe9dfe 100644
--- a/modules/mogo-module-service/src/main/res/layout/view_map_marker_info.xml
+++ b/modules/mogo-module-service/src/main/res/layout/view_map_marker_info.xml
@@ -13,7 +13,6 @@
android:layout_width="@dimen/dp_34"
android:layout_height="@dimen/dp_64"
android:src="@drawable/icon_map_marker_car_gray"
- android:translationY="-10dp"
app:layout_constraintEnd_toEndOf="@+id/ivReverseTriangle"
app:layout_constraintStart_toStartOf="@+id/ivReverseTriangle"
app:layout_constraintTop_toBottomOf="@+id/ivReverseTriangle" />
diff --git a/modules/mogo-module-share/build.gradle b/modules/mogo-module-share/build.gradle
index b65f63c235..e5c4435c47 100644
--- a/modules/mogo-module-share/build.gradle
+++ b/modules/mogo-module-share/build.gradle
@@ -32,14 +32,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- implementation 'androidx.appcompat:appcompat:1.0.2'
- implementation 'androidx.core:core-ktx:1.0.2'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test:runner:1.2.0'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ implementation rootProject.ext.dependencies.kotlinstdlibjdk7
implementation rootProject.ext.dependencies.androidxappcompat
+ implementation rootProject.ext.dependencies.androidxccorektx
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
diff --git a/modules/mogo-module-share/src/main/res/values/colors.xml b/modules/mogo-module-share/src/main/res/values/colors.xml
index d6a88ad3d2..4313d3f44b 100644
--- a/modules/mogo-module-share/src/main/res/values/colors.xml
+++ b/modules/mogo-module-share/src/main/res/values/colors.xml
@@ -11,6 +11,7 @@
#F8F8F8
#333333
#DADAE2
+ #1C1C1C
#545362
#99191C25
#666666
diff --git a/modules/mogo-module-share/src/test/java/com/example/mogo_module_share/ExampleUnitTest.kt b/modules/mogo-module-share/src/test/java/com/example/mogo_module_share/ExampleUnitTest.kt
deleted file mode 100644
index 5f9bdcdccd..0000000000
--- a/modules/mogo-module-share/src/test/java/com/example/mogo_module_share/ExampleUnitTest.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.example.mogo_module_share
-
-import org.junit.Test
-
-import org.junit.Assert.*
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * See [testing documentation](http://d.android.com/tools/testing).
- */
-class ExampleUnitTest {
- @Test
- fun addition_isCorrect() {
- assertEquals(4, 2 + 2)
- }
-}
diff --git a/modules/mogo-module-tanlu/build.gradle b/modules/mogo-module-tanlu/build.gradle
index fa62f531e0..8a280b205d 100644
--- a/modules/mogo-module-tanlu/build.gradle
+++ b/modules/mogo-module-tanlu/build.gradle
@@ -51,22 +51,23 @@ dependencies {
implementation rootProject.ext.dependencies.mogoutils
implementation rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.mogoserviceapi
- implementation rootProject.ext.dependencies.modulecommon
- implementation rootProject.ext.dependencies.moduleservice
+ compileOnly rootProject.ext.dependencies.modulecommon
+ compileOnly rootProject.ext.dependencies.moduleservice
implementation rootProject.ext.dependencies.moduleshare
} else {
implementation project(":libraries:mogo-map")
implementation project(":foudations:mogo-utils")
api project(":foudations:mogo-commons")
implementation project(':services:mogo-service-api')
- implementation project(':modules:mogo-module-common')
- implementation project(':modules:mogo-module-service')
+ compileOnly project(':modules:mogo-module-common')
+ compileOnly project(':modules:mogo-module-service')
implementation project(':modules:mogo-module-share')
}
- implementation 'com.shuyu:gsyVideoPlayer-armv7a:7.1.1'
- implementation 'com.shuyu:gsyVideoPlayer-arm64:7.1.1'
- implementation 'com.shuyu:gsyVideoPlayer-java:7.1.1'
+ implementation rootProject.ext.dependencies.videoarmv7
+ implementation rootProject.ext.dependencies.videoarm64
+ implementation rootProject.ext.dependencies.videojava
+ implementation rootProject.ext.dependencies.eventbus
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/callback/DataSetChangedAdapter.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/callback/DataSetChangedAdapter.java
new file mode 100644
index 0000000000..a13c7e2ff1
--- /dev/null
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/callback/DataSetChangedAdapter.java
@@ -0,0 +1,44 @@
+package com.mogo.module.tanlu.callback;
+
+import com.mogo.service.datamanager.IMogoDataChangedListener;
+
+/**
+ * @author congtaowang
+ * @since 2020-02-12
+ *
+ * 描述
+ */
+public class DataSetChangedAdapter implements IMogoDataChangedListener {
+
+ private Object mData;
+
+ private DataSetChangedAdapter(){
+ // private constructor
+ }
+
+ private static final class InstanceHolder{
+ private static final DataSetChangedAdapter INSTANCE = new DataSetChangedAdapter();
+ }
+
+ private IMogoDataChangedListener mDelegate;
+
+ public void setDelegate( IMogoDataChangedListener delegate ) {
+ this.mDelegate = delegate;
+ }
+
+ public static DataSetChangedAdapter getInstance(){
+ return InstanceHolder.INSTANCE;
+ }
+
+ @Override
+ public void onDataSetChanged( Object data ) {
+ mData = data;
+ if ( mDelegate != null ) {
+ mDelegate.onDataSetChanged( data );
+ }
+ }
+
+ public Object getData() {
+ return mData;
+ }
+}
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java
index 3d709d5c42..c0f1ba3e59 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewFragment.java
@@ -4,6 +4,9 @@ import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
import android.text.Html;
import android.text.TextUtils;
import android.util.Log;
@@ -55,6 +58,7 @@ import com.mogo.module.common.entity.MarkerUserInfo;
import com.mogo.module.service.receiver.MogoReceiver;
import com.mogo.module.share.ShareControl;
import com.mogo.module.tanlu.R;
+import com.mogo.module.tanlu.callback.DataSetChangedAdapter;
import com.mogo.module.tanlu.callback.NaviCallback;
import com.mogo.module.tanlu.callback.RoadLineCallback;
import com.mogo.module.tanlu.callback.UploadShareCallback;
@@ -76,6 +80,7 @@ import com.mogo.module.tanlu.view.AutoZoomInImageView;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.cardmanager.IMogoCardManager;
+import com.mogo.service.datamanager.IMogoDataChangedListener;
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
import com.mogo.service.imageloader.IMogoImageLoaderListener;
import com.mogo.service.imageloader.IMogoImageloader;
@@ -116,7 +121,8 @@ public class TanluCardViewFragment extends MvpFragment>
IMogoMapListener,
IMogoPoiSearchListener,
IMogoLocationListener,
- View.OnClickListener {
+ View.OnClickListener,
+ IMogoDataChangedListener {
private static final String TAG = "TanluCardViewFragment";
SimpleCoverVideoPlayer simpleCoverVideoPlayer;
@@ -134,7 +140,7 @@ public class TanluCardViewFragment extends MvpFragment>
//声音控制文字
private String voiceGetInfoMationTts;
- private String[] searchingVoiceStrings;
+// private String[] searchingVoiceStrings;
private String[] searchfaileVoiceStrings;
//media
@@ -163,7 +169,12 @@ public class TanluCardViewFragment extends MvpFragment>
private String mKeywords;
private boolean isCurrentPage;
-
+ private Handler mMsgHandler = new Handler( Looper.getMainLooper() ){
+ @Override
+ public void handleMessage( Message msg ) {
+ super.handleMessage( msg );
+ }
+ };
@Override
protected int getLayoutId() {
return R.layout.tanlu_item_main_media_recycler;
@@ -189,17 +200,6 @@ public class TanluCardViewFragment extends MvpFragment>
simpleCoverVideoPlayer.setVisibility(View.VISIBLE);
autoZoomInImageView.setVisibility(View.GONE);
-
- //视频点击
-// simpleCoverVideoPlayer.getStartButton().setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View view) {
-// Logger.d(TAG, "simpleCoverVideoPlayer onClick -------> ");
-// gsyVideoOptionBuilder.setUrl(mVideoUrl).setCacheWithPlay(false).setPlayTag(TAG)
-// .build(simpleCoverVideoPlayer);
-//// simpleCoverVideoPlayer.getStartButton().performClick();
-// }
-// });
}
@@ -291,10 +291,12 @@ public class TanluCardViewFragment extends MvpFragment>
poiSearch.searchPOIAsyn();
}
} else {
+ Logger.e(TAG, "onGeocodeSearched -----geocodeResult == null");
speakFailVoice(searchfaileVoiceStrings[2]);
}
}
});
+ DataSetChangedAdapter.getInstance().setDelegate( this );
}
@Override
@@ -307,6 +309,8 @@ public class TanluCardViewFragment extends MvpFragment>
initMap();
initStrings();
initListener();
+ // 数据先到,卡片后创建
+ initData( DataSetChangedAdapter.getInstance().getData() );
}
private void initModelData() {
@@ -472,10 +476,12 @@ public class TanluCardViewFragment extends MvpFragment>
public void onCmdSelected(String cmd) {
Log.d(TAG, "mogoVoiceListener cmd = " + cmd);
if (cmd.equals(TanluConstants.PLAY_VIDEO)) { //播放路况 --ok
+ //语音会中断播放
+// AIAssist.getInstance(getContext()).speakTTSVoice(getString(R.string.tanlu_prepare_play), null);
gsyVideoOptionBuilder.setUrl(mVideoUrl).setCacheWithPlay(false).setPlayTag(TAG)
.build(simpleCoverVideoPlayer);
simpleCoverVideoPlayer.getStartButton().performClick();
- traceVideoPlayStatusData("1");
+ traceVideoPlayStatusData();
}
}
@@ -552,7 +558,6 @@ public class TanluCardViewFragment extends MvpFragment>
return null;
}
-
/**
* @param view
*/
@@ -602,7 +607,6 @@ public class TanluCardViewFragment extends MvpFragment>
autoZoomInImageView.post(new Runnable() {
@Override
public void run() {
- Log.d(TAG, "handleImageAnimation run -------->");
//放大增量是0.3,放大时间是1000毫秒,放大开始时间是500毫秒以后
autoZoomInImageView.init()
.startZoomInByScaleDeltaAndDuration(0.2f, 1000, 300);
@@ -667,7 +671,7 @@ public class TanluCardViewFragment extends MvpFragment>
gsyVideoOptionBuilder.setUrl(videoUrl).setCacheWithPlay(false).setPlayTag(TAG)
.build(simpleCoverVideoPlayer);
simpleCoverVideoPlayer.getStartButton().performClick();
- traceVideoPlayStatusData("2");
+ traceVideoPlayStatusData();
if (mImageUrl == null) {
return;
@@ -676,15 +680,10 @@ public class TanluCardViewFragment extends MvpFragment>
/**
* 上传播放
- * @param type
- * type=1 主动触发播放
*
- * type=2 自动播放
*/
- private void traceVideoPlayStatusData(String type) {
- Map properties = new HashMap<>();
- properties.put("type", type);
- mAnalytics.track(TanluConstants.CARNET_USER_VIDEO_PLAY, properties);
+ private void traceVideoPlayStatusData() {
+ mAnalytics.track(TanluConstants.CARNET_USER_VIDEO_PLAY, null);
}
@@ -747,23 +746,20 @@ public class TanluCardViewFragment extends MvpFragment>
isCurrentPage = true;
Logger.d(TAG, "tanlu卡片 onPerform 有效 ---->");
- mMarkerManager = mMogoMapService.getMarkerManager(getActivity());
- List markers = mMarkerManager.getMarkers(TanluConstants.MODEL_NAME);
+ renderCardViews();
+ }
- if (markers != null && markers.size() > 0) {
+ /**
+ * 根究数据展示页面
+ */
+ private void renderCardViews(){
+ if (markerExploreWayList != null && markerExploreWayList.size() > 0) {
mEmptyLayout.setVisibility(View.GONE);
mRootLayout.setVisibility(View.VISIBLE);
- Logger.d(TAG, "onPerform markers.size() =" + markers.size());
- for (int i = 0; i < markers.size(); i++) {
- MarkerExploreWay exploreWay = extractFromMarker(markers.get(i));
- if (exploreWay == null) {
- break;
- }
- markerExploreWayList.add(exploreWay);
- }
+ Logger.d(TAG, "onPerform markers.size() =" + markerExploreWayList.size());
Log.d("TAG", "tanlu卡片 onPerform 有效 markerExploreWayList.size() =" + markerExploreWayList.size());
- if (markers.size() == 1) {
+ if (markerExploreWayList.size() == 1) {
mPreviousTv.setVisibility(View.GONE);
mNextTv.setVisibility(View.GONE);
} else {
@@ -771,9 +767,8 @@ public class TanluCardViewFragment extends MvpFragment>
mNextTv.setVisibility(View.VISIBLE);
}
- //展示第一个数据
- MarkerExploreWay markerExploreWay = markerExploreWayList.get(0);
- handleMarkerExploreWay(markerExploreWay);
+ //延时展示第一个数据
+ mMsgHandler.postDelayed( mDelayRunnable, 1_000L );
} else {
mEmptyLayout.setVisibility(View.VISIBLE);
mRootLayout.setVisibility(View.GONE);
@@ -781,6 +776,53 @@ public class TanluCardViewFragment extends MvpFragment>
}
}
+ private MarkerExploreWay mLastPlayEntity = null;
+
+ // 播放第一个数据需要延时,避免滑动卡顿
+ private Runnable mDelayRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if ( isCurrentPage && !isRemoving() && !isDetached() ) {
+ try {
+ final MarkerExploreWay markerExploreWay = markerExploreWayList.get(0);
+ if ( mLastPlayEntity == markerExploreWay ) {
+ if ( markerExploreWay.getFileType() == 1 ) {
+ // 视频的话重新播放
+ simpleCoverVideoPlayer.getGSYVideoManager().start();
+ }
+ } else {
+ mLastPlayEntity = markerExploreWay;
+ handleMarkerExploreWay(markerExploreWay);
+ }
+ } catch( Exception e ){
+ e.printStackTrace();
+ }
+ }
+ }
+ };
+
+ @Override
+ public void onDataSetChanged( Object data ) {
+ Logger.d( TAG, "receive data changed." );
+ initData( data );
+ if ( isCurrentPage ) {
+ renderCardViews();
+ }
+ }
+
+ private void initData(Object data ){
+ if ( markerExploreWayList != null ) {
+ markerExploreWayList.clear();
+ } else {
+ markerExploreWayList = new ArrayList<>();
+ }
+ try {
+ markerExploreWayList.addAll( (List)data );
+ } catch ( Exception e ) {
+ Logger.e( TAG, e, "error." );
+ }
+ }
+
/**
* 离开C位事件
*/
@@ -788,6 +830,28 @@ public class TanluCardViewFragment extends MvpFragment>
public void onDisable() {
Logger.d(TAG, "tanlu卡片 无效 ----->");
isCurrentPage = false;
+ mMsgHandler.removeCallbacks( mDelayRunnable );
+ if ( mLastPlayEntity != null ) {
+ if ( mLastPlayEntity.getFileType() == 1 ) {
+ try {
+ if ( simpleCoverVideoPlayer.getVisibility() == View.VISIBLE ) {
+ // 卡片滑动过去之后停止播放
+ simpleCoverVideoPlayer.getGSYVideoManager().pause();
+ }
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ if ( autoZoomInImageView.getVisibility() == View.VISIBLE ) {
+ autoZoomInImageView.stopCurrentAnimator();
+ }
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+ }
+
AIAssist.getInstance(getActivity()).unregisterUnWakeupCommand(TanluConstants.PLAY_VIDEO);
}
@@ -893,8 +957,10 @@ public class TanluCardViewFragment extends MvpFragment>
} else if (event.type.equals("3")) { //封路 10003
poiType = "10003";
mMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_road_closure);
- } else {
- mMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_block_up);
+ }
+ else {
+ poiType = "-1";
+// mMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_block_up);
}
double lat = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLatitude();
@@ -924,7 +990,7 @@ public class TanluCardViewFragment extends MvpFragment>
/**
* 上报分享信息
*/
- private void uploadShareInfo(String poiType, String poiImgUrl, String nickname, String headImgUrl) {
+ private void uploadShareInfo(final String poiType, String poiImgUrl, String nickname, String headImgUrl) {
double lat = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLatitude();
double lon = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLongitude();
String addressStr = TanluServiceHandler.getLocationClient().getLastKnowLocation().getAddress();
@@ -933,14 +999,18 @@ public class TanluCardViewFragment extends MvpFragment>
new UploadShareCallback() {
@Override
public void onSuccess(BaseData data) {
- Log.d(TAG, "uploadShareInfo onSuccess ----->");
- AIAssist.getInstance(getContext()).speakTTSVoice(getString(R.string.tanlu_share_success), null);
+ Log.d(TAG, "uploadShareInfo onSuccess -----> poiType = " + poiType);
+ if (!poiType.equals("-1")) {
+ AIAssist.getInstance(getContext()).speakTTSVoice(getString(R.string.tanlu_share_success), null);
+ }
}
@Override
public void onFail(String message, int code) {
- Log.e(TAG, "uploadShareInfo onFail ----->");
- AIAssist.getInstance(getContext()).speakTTSVoice(getString(R.string.tanlu_share_failed), null);
+ Log.e(TAG, "uploadShareInfo onFail -----> poiType = " + poiType);
+ if (!poiType.equals("-1")) {
+ AIAssist.getInstance(getContext()).speakTTSVoice(getString(R.string.tanlu_share_failed), null);
+ }
}
});
}
@@ -970,21 +1040,6 @@ public class TanluCardViewFragment extends MvpFragment>
* 导航路线数据事件
*/
public void getNavigationData() {
-// Double lat = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLatitude();
-// Double lon = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLongitude();
-// Logger.e(TAG, "getNavigationLine lon = " + lon + ">>>>> lat= " + lat);
-// mTanluModelData.getNavigationLineData(lon, lat, new AlongTheWayCallback() {
-// @Override
-// public void onSuccess(InformationAndLiveCarResult data) {
-// //不做任何处理,直接出发推送,重新请求接口,划线
-// }
-//
-// @Override
-// public void onFail(String message, int code) {
-//
-// }
-// });
-
mTanluModelData.getNaviInformation(mMogoMapService.getNavi(getContext()).getCalculatedPathPos(),
new NaviCallback() {
@Override
@@ -995,6 +1050,18 @@ public class TanluCardViewFragment extends MvpFragment>
return;
}
+ if (markerExploreWayList != null && markerExploreWayList.size() > 0) {
+ markerExploreWayList.clear(); //刷新之前先删除之前的,然后再添加成请求的
+ currentPosition = 0;
+ }
+
+ //转换数据结构
+ convertData(informationList);
+ //切换到探路卡片
+ if (!isCurrentPage) {
+ iMogoCardManager.switch2(TanluConstants.MODEL_NAME);
+ }
+
//清除探路之前的数据
mMarkerManager.removeMarkers(TanluConstants.MODEL_NAME);
@@ -1023,6 +1090,9 @@ public class TanluCardViewFragment extends MvpFragment>
}
Logger.d(TAG, "getNavigationData optionList.size() = " + optionList.size());
mMarkerManager.addMarkers(TanluConstants.MODEL_NAME, optionList, true);
+
+ //直接使用当前数据list,作为切换的数据源,切换左侧列表到最新的数据
+ handleMarkerExploreWay(markerExploreWayList.get(0));
}
@Override
@@ -1175,7 +1245,6 @@ public class TanluCardViewFragment extends MvpFragment>
.longitude(informationList.get(i).lon);
optionList.add(options);
-// Log.d(TAG, "getVoiceControlRoadData lat =" + informationList.get(i).lat + ">>>lon =" + informationList.get(i).lon);
}
Logger.d(TAG, "getVoiceControlRoadData optionList.size() = " + optionList.size());
mMarkerManager.addMarkers(TanluConstants.MODEL_NAME, optionList, true);
@@ -1263,35 +1332,41 @@ public class TanluCardViewFragment extends MvpFragment>
private void speakSuccessVoice(List informations, String
trafficStatus) {
+ Log.d(TAG, "speakSuccessVoice informations.size() = " + informations.size());
switch (informations.size()) {
case 0:
- Logger.d(TAG, "speakSuccessVoice ----> " + random.nextInt(3));
+ Logger.d(TAG, "speakSuccessVoice --0----> " + random.nextInt(3));
speakFailVoice(searchfaileVoiceStrings[random.nextInt(3)]);
break;
case 1:
+ Logger.d(TAG, "speakSuccessVoice ---1---> ");
trackVoiceSearch(1);
AIAssist.getInstance(getContext()).speakTTSVoice((
String.format(voiceGetInfoMationTts, "1") + trafficStatus), null);
+ break;
case 2:
trackVoiceSearch(1);
+ Logger.d(TAG, "speakSuccessVoice ---2---> ");
AIAssist.getInstance(getContext()).speakTTSVoice((
String.format(
voiceGetInfoMationTts,
"2"
) + trafficStatus), null);
-
-
+ break;
case 3:
+ Logger.d(TAG, "speakSuccessVoice ---3---> ");
trackVoiceSearch(1);
AIAssist.getInstance(getContext()).speakTTSVoice((
String.format(
voiceGetInfoMationTts,
"3"
) + trafficStatus), null);
+ break;
default:
+ Logger.d(TAG, "speakSuccessVoice ---default-> ");
trackVoiceSearch(1);
AIAssist.getInstance(getContext()).speakTTSVoice((
String.format(
@@ -1304,8 +1379,8 @@ public class TanluCardViewFragment extends MvpFragment>
private void initStrings() {
voiceGetInfoMationTts =
getContext().getResources().getString(R.string.voice_get_informations_tts);
- searchingVoiceStrings =
- getContext().getResources().getStringArray(R.array.searching_voice_string_array);
+// searchingVoiceStrings =
+// getContext().getResources().getStringArray(R.array.searching_voice_string_array);
searchfaileVoiceStrings =
getContext().getResources().getStringArray(R.array.search_fail_voice_array);
}
@@ -1315,7 +1390,7 @@ public class TanluCardViewFragment extends MvpFragment>
}
private void speakSearchingVoice() {
- AIAssist.getInstance(getContext()).speakTTSVoice(searchingVoiceStrings[random.nextInt(3)], null);
+// AIAssist.getInstance(getContext()).speakTTSVoice(searchingVoiceStrings[random.nextInt(3)], null);
}
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java
index cdc123a787..645707060f 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java
@@ -11,6 +11,7 @@ import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.navi.IMogoNaviListener;
+import com.mogo.module.tanlu.callback.DataSetChangedAdapter;
import com.mogo.service.module.IMogoModuleLifecycle;
import com.mogo.service.module.IMogoModuleProvider;
import com.mogo.service.module.ModuleType;
@@ -40,6 +41,7 @@ public class TanluCardViewProvider implements IMogoModuleProvider {
@Override
public void init( Context context ) {
TanluServiceHandler.init( context );
+ TanluServiceHandler.getDataManager().registerDataListener( TanluConstants.MODEL_NAME, DataSetChangedAdapter.getInstance() );
Logger.d(TAG, "init ----------> ");
}
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceHandler.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceHandler.java
index c066dbb319..d93a4bec33 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceHandler.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluServiceHandler.java
@@ -10,6 +10,8 @@ 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.datamanager.IMogoDataChangedListener;
+import com.mogo.service.datamanager.IMogoDataManager;
import com.mogo.service.imageloader.IMogoImageloader;
import com.mogo.service.map.IMogoMapService;
@@ -28,6 +30,7 @@ public class TanluServiceHandler {
private static IMogoNavi mNavi;
private static IMogoMapUIController mMapUIController;
private static IMogoImageloader mImageloader;
+ private static IMogoDataManager mDataManager;
public static void init( Context context ) {
mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( context );
@@ -38,6 +41,7 @@ public class TanluServiceHandler {
mMarkerManager = mMapService.getMarkerManager( context );
mNavi = mMapService.getNavi( context );
mMapUIController = mMapService.getMapUIController();
+ mDataManager = (IMogoDataManager)ARouter.getInstance().build( MogoServicePaths.PATH_DATA_MANAGER ).navigation(context);
}
public static IMogoMapService getMapService() {
@@ -67,4 +71,8 @@ public class TanluServiceHandler {
public static IMogoImageloader getImageloader() {
return mImageloader;
}
+
+ public static IMogoDataManager getDataManager() {
+ return mDataManager;
+ }
}
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/MarkerInfo.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/MarkerInfo.java
index ce9e85c264..d5d8b1afd6 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/MarkerInfo.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/model/event/MarkerInfo.java
@@ -10,10 +10,10 @@ import java.io.Serializable;
public class MarkerInfo implements Serializable {
public String type; //封路,还是上报
public String imageUrl; //上传完cos图片
- public Long lon; //经度
- public Long lat; //纬度
+ public double lon; //经度
+ public double lat; //纬度
- public MarkerInfo(String type, String imageUrl, Long lon, Long lat) {
+ public MarkerInfo(String type, String imageUrl, double lon, double lat) {
this.type = type;
this.imageUrl = imageUrl;
this.lon = lon;
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt
index effe820e7e..505463804e 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/receiver/MarkerInfoReceiver.kt
@@ -15,8 +15,8 @@ class MarkerInfoReceiver : BroadcastReceiver() {
if (intent.action == "com.zhidao.roadcondition.marker.info"){
var type = intent.getStringExtra("type")
var imageUrl = intent.getStringExtra("imageUrl")
- var lat = intent.getLongExtra("lat",0)
- var lon = intent.getLongExtra("lon",0) //经度
+ var lat = intent.getDoubleExtra("lat",0.0)
+ var lon = intent.getDoubleExtra("lon",0.0) //经度
Log.d("MarkerInfoReceiver", "type =" + type + "---->lat =" + lat + "----lon =" + lon + "---imageUrl =" + imageUrl)
EventBus.getDefault().post(MarkerInfo(type, imageUrl,lon, lat))
}
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt
index b07cd17667..6beb5337d1 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/MediaCoverVideoPlayer.kt
@@ -66,13 +66,8 @@ class MediaCoverVideoPlayer : StandardGSYVideoPlayer {
return GSYVideoManager.instance()
}
- override fun setProgressAndTime(
- progress: Int,
- secProgress: Int,
- currentTime: Int,
- totalTime: Int
- ) {
- super.setProgressAndTime(progress, secProgress, currentTime, totalTime)
+ override fun setProgressAndTime(progress: Int, secProgress: Int, currentTime: Int, totalTime: Int, forceChange: Boolean) {
+ super.setProgressAndTime(progress, secProgress, currentTime, totalTime, forceChange)
if (progress != 0) {
mProgressBar.progress = progress
}
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt
index 02f0674e68..ffce64b4e6 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/video/SimpleCoverVideoPlayer.kt
@@ -45,13 +45,9 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
return GSYVideoManager.instance()
}
- override fun setProgressAndTime(
- progress: Int,
- secProgress: Int,
- currentTime: Int,
- totalTime: Int
- ) {
- super.setProgressAndTime(progress, secProgress, currentTime, totalTime)
+ override fun setProgressAndTime(progress: Int, secProgress: Int, currentTime: Int, totalTime: Int, forceChange: Boolean) {
+ super.setProgressAndTime(progress, secProgress, currentTime, totalTime, forceChange)
+// Log.e("liyz", "setProgressAndTime progress = $progress --->currentTime = $currentTime --->totalTime = $totalTime")
if (progress != 0) {
mProgressBar.progress = progress
}
@@ -78,12 +74,12 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
override fun changeUiToCompleteShow() {
super.changeUiToCompleteShow()
// setViewShowState(mBottomContainer, View.INVISIBLE)
+ mBottomContainer.visibility = View.INVISIBLE
Log.d("liyz", "changeUiToCompleteShow ------------>")
}
override fun hideAllWidget() {
super.hideAllWidget()
- Log.d("liyz", "hideAllWidget ------------>")
mBottomContainer.visibility = View.VISIBLE
}
@@ -125,8 +121,17 @@ class SimpleCoverVideoPlayer : StandardGSYVideoPlayer {
override fun onClick(v: View?) {
super.onClick(v)
- }
+ v?.let {
+ when (v) {
+ start -> {
+ }
+ else -> {
+
+ }
+ }
+ }
+ }
override fun onPrepared() {
super.onPrepared()
diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/view/AutoZoomInImageView.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/view/AutoZoomInImageView.java
index 20737ab449..cd34a35832 100644
--- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/view/AutoZoomInImageView.java
+++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/view/AutoZoomInImageView.java
@@ -94,13 +94,15 @@ public class AutoZoomInImageView extends MogoImageView {
setImageMatrix(mMatrix);
}
+ private ValueAnimator mCurrentAnimator;
+
private void startZoomInByScaleDelta(final float scaleDelta, long duration) {
final float oriScaleX = mValues[0];
final float oriScaleY = mValues[4];
- ValueAnimator va = ValueAnimator.ofFloat(0, scaleDelta);
- va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ mCurrentAnimator = ValueAnimator.ofFloat(0, scaleDelta);
+ mCurrentAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
@@ -113,7 +115,7 @@ public class AutoZoomInImageView extends MogoImageView {
setImageMatrix(mMatrix);
}
});
- va.addListener(new Animator.AnimatorListener() {
+ mCurrentAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
if (mOnZoomListener != null) mOnZoomListener.onStart(AutoZoomInImageView.this);
@@ -122,18 +124,31 @@ public class AutoZoomInImageView extends MogoImageView {
@Override
public void onAnimationEnd(Animator animation) {
if (mOnZoomListener != null) mOnZoomListener.onEnd(AutoZoomInImageView.this);
+ mCurrentAnimator = null;
}
@Override
public void onAnimationCancel(Animator animation) {
+ mCurrentAnimator = null;
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
- va.setDuration(duration);
- va.start();
+ mCurrentAnimator.setDuration(duration);
+ mCurrentAnimator.start();
+ }
+
+ /**
+ * 停止动画
+ */
+ public void stopCurrentAnimator(){
+ if ( mCurrentAnimator != null ) {
+ if ( mCurrentAnimator.isRunning() ) {
+ mCurrentAnimator.cancel();
+ }
+ }
}
/**
diff --git a/modules/mogo-module-tanlu/src/main/res/drawable/small_video_seekbar_style.xml b/modules/mogo-module-tanlu/src/main/res/drawable/small_video_seekbar_style.xml
index 80f30fbb27..c48724bdd8 100644
--- a/modules/mogo-module-tanlu/src/main/res/drawable/small_video_seekbar_style.xml
+++ b/modules/mogo-module-tanlu/src/main/res/drawable/small_video_seekbar_style.xml
@@ -3,6 +3,7 @@
-
+
-
@@ -15,7 +16,12 @@
-
-
+
+
+
+
diff --git a/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_video_cover.xml b/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_video_cover.xml
index 362eb31478..15c0e8e2c8 100644
--- a/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_video_cover.xml
+++ b/modules/mogo-module-tanlu/src/main/res/layout/tanlu_item_video_cover.xml
@@ -37,7 +37,6 @@
android:layout_width="match_parent"
android:layout_height="@dimen/tanlu_module_full_bottom_height"
android:layout_alignParentBottom="true"
- android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/tanlu_module_full_bottom_margin"
android:orientation="horizontal">
diff --git a/modules/mogo-module-tanlu/src/main/res/values-ldpi/dimens.xml b/modules/mogo-module-tanlu/src/main/res/values-ldpi/dimens.xml
index 345e90786e..4ca666a0be 100644
--- a/modules/mogo-module-tanlu/src/main/res/values-ldpi/dimens.xml
+++ b/modules/mogo-module-tanlu/src/main/res/values-ldpi/dimens.xml
@@ -26,7 +26,7 @@
352px
12px
- 32px
+ 31px
4px
1px
327px
diff --git a/modules/mogo-module-tanlu/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-tanlu/src/main/res/values-xhdpi/dimens.xml
index 57993dcf50..c0a49c55c2 100644
--- a/modules/mogo-module-tanlu/src/main/res/values-xhdpi/dimens.xml
+++ b/modules/mogo-module-tanlu/src/main/res/values-xhdpi/dimens.xml
@@ -15,7 +15,7 @@
96px
100px
700px
- 5px
+ 7px
135px
50px
@@ -27,7 +27,7 @@
660px
24px
- 58px
+ 56px
8px
2px
613px
diff --git a/modules/mogo-module-tanlu/src/main/res/values/dimens.xml b/modules/mogo-module-tanlu/src/main/res/values/dimens.xml
index a2953cf57c..438de99179 100644
--- a/modules/mogo-module-tanlu/src/main/res/values/dimens.xml
+++ b/modules/mogo-module-tanlu/src/main/res/values/dimens.xml
@@ -15,7 +15,7 @@
96px
144px
760px
- 5px
+ 7px
135px
50px
diff --git a/modules/mogo-module-tanlu/src/main/res/values/strings.xml b/modules/mogo-module-tanlu/src/main/res/values/strings.xml
index 75dba528ee..2eb49abe1e 100644
--- a/modules/mogo-module-tanlu/src/main/res/values/strings.xml
+++ b/modules/mogo-module-tanlu/src/main/res/values/strings.xml
@@ -19,6 +19,8 @@
下一条
分享成功
分享失败
+ 将为您播放
+
- 正在为您搜索路况
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java b/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java
index e7d2a80761..09e1fb760e 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java
@@ -109,5 +109,10 @@ public class MogoServicePaths {
*/
public static final String PATH_SERACH_CENTER = "/searchcenter/api";
+ /**
+ * 大而全数据管理中心
+ */
+ public static final String PATH_DATA_MANAGER = "/datamanager/api";
+
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/datamanager/IMogoDataChangedListener.java b/services/mogo-service-api/src/main/java/com/mogo/service/datamanager/IMogoDataChangedListener.java
new file mode 100644
index 0000000000..2e2d76ff12
--- /dev/null
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/datamanager/IMogoDataChangedListener.java
@@ -0,0 +1,19 @@
+package com.mogo.service.datamanager;
+
+import java.util.List;
+
+/**
+ * @author congtaowang
+ * @since 2020-02-11
+ *
+ * 描述
+ */
+public interface IMogoDataChangedListener {
+
+ /**
+ * 大而全数据变化回调
+ *
+ * @param data
+ */
+ void onDataSetChanged( Object data );
+}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/datamanager/IMogoDataManager.java b/services/mogo-service-api/src/main/java/com/mogo/service/datamanager/IMogoDataManager.java
new file mode 100644
index 0000000000..ce42987763
--- /dev/null
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/datamanager/IMogoDataManager.java
@@ -0,0 +1,27 @@
+package com.mogo.service.datamanager;
+
+import com.alibaba.android.arouter.facade.template.IProvider;
+
+/**
+ * @author congtaowang
+ * @since 2020-02-11
+ *
+ * 大而全的数据管理
+ */
+public interface IMogoDataManager extends IProvider {
+
+ /**
+ * 注册大而全数据变化监听
+ *
+ * @param tag 监听模块
+ * @param listener
+ */
+ void registerDataListener( String tag, IMogoDataChangedListener listener );
+
+ /**
+ * 注销大而全数据变换监听
+ *
+ * @param tag
+ */
+ void unregisterListener( String tag , IMogoDataChangedListener listener);
+}
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 b1eaa394cb..983997a8a0 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
@@ -25,6 +25,7 @@ import com.mogo.service.impl.imageloader.glide.transform.GlideCircleBitmapTransf
import com.mogo.service.impl.imageloader.glide.transform.GlideRoundBitmapTransform;
import com.mogo.service.impl.imageloader.glide.utils.DiskLruCacheManager;
import com.mogo.utils.glide.GlideApp;
+import com.mogo.utils.logger.Logger;
import java.io.File;
@@ -36,6 +37,8 @@ import java.io.File;
*/
public class GlideImageLoader implements IMogoImageloader {
+ private static final String TAG = "GlideImageLoader";
+
private static volatile GlideImageLoader sInstance;
private GlideImageLoader() {
@@ -75,6 +78,8 @@ public class GlideImageLoader implements IMogoImageloader {
@Override
public void displayImage( String url, MogoImageView imageView, int width, int height, final IMogoImageLoaderListener listener ) {
+ Logger.d(TAG, "url = %s", url);
+
if ( listener != null ) {
listener.onStart();
}
diff --git a/upload.sh b/upload.sh
index 16a2bafedb..b6c85e5845 100755
--- a/upload.sh
+++ b/upload.sh
@@ -17,3 +17,4 @@
./gradlew :modules:mogo-module-extensions:clean :modules:mogo-module-extensions:uploadArchives
./gradlew :modules:mogo-module-search:clean :modules:mogo-module-search:uploadArchives
./gradlew :modules:mogo-module-main:clean :modules:mogo-module-main:uploadArchives
+./gradlew :modules:mogo-module-back:clean :modules:mogo-module-back:uploadArchives