dev
@@ -27,6 +27,11 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-06
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppNavigatorFragment extends MvpFragment< IView, Presenter< IView > > implements IView {
|
||||
|
||||
private View mNavigation;
|
||||
private View mMusic;
|
||||
private View mChat;
|
||||
private View mApps;
|
||||
|
||||
private IMogoCardManager mCardManager;
|
||||
|
||||
private AppsFragment mAppsFragment;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_apps_fragment_apps_navigator;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
mCardManager = ( IMogoCardManager ) ARouter.getInstance().build( MogoServicePaths.PATH_CARD_MANAGER ).navigation( getContext() );
|
||||
|
||||
mNavigation = findViewById( R.id.module_apps_id_navigation );
|
||||
mMusic = findViewById( R.id.module_apps_id_music );
|
||||
mChat = findViewById( R.id.module_apps_id_chat );
|
||||
mApps = findViewById( R.id.module_apps_id_apps );
|
||||
mNavigation.setOnClickListener( view -> {
|
||||
mCardManager.switch2( "CARD_TYPE_NAVIGATION" );
|
||||
} );
|
||||
mMusic.setOnClickListener( view -> {
|
||||
mCardManager.switch2( "CARD_TYPE_SHARE_MUSIC" );
|
||||
} );
|
||||
mChat.setOnClickListener( view -> {
|
||||
mCardManager.switch2( "CARD_TYPE_CARS_CHATTING" );
|
||||
} );
|
||||
mApps.setOnClickListener( view -> {
|
||||
new AppsFragment().show( getChildFragmentManager(), AppsFragment.TAG );
|
||||
} );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Presenter< IView > createPresenter() {
|
||||
return new Presenter< IView >( this ) {
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -10,8 +12,11 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.mogo.commons.mvp.MvpDialogFragment;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.module.apps.model.AppInfo;
|
||||
import com.mogo.utils.BitmapHelper;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,9 +26,11 @@ import java.util.List;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > implements AppsView {
|
||||
public class AppsFragment extends MvpDialogFragment< AppsView, AppsPresenter > implements AppsView {
|
||||
|
||||
private BottomSheetBehavior mBottomSheetBehavior;
|
||||
public static final String TAG = "AppsFragment";
|
||||
|
||||
// private BottomSheetBehavior mBottomSheetBehavior;
|
||||
private RecyclerView mAppsList;
|
||||
private AppsAdapter mAppsAdapter;
|
||||
|
||||
@@ -35,22 +42,36 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
|
||||
@Override
|
||||
protected void initViews() {
|
||||
mAppsList = findViewById( R.id.module_apps_id_apps );
|
||||
mAppsList.setLayoutManager( new GridLayoutManager( getContext(), 3 ) );
|
||||
|
||||
mBottomSheetBehavior = BottomSheetBehavior.from( mAppsList );
|
||||
mBottomSheetBehavior.setSkipCollapsed( true );
|
||||
mBottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged( @NonNull View bottomSheet, int newState ) {
|
||||
mAppsList.setLayoutManager( new GridLayoutManager( getContext(), 8 ) );
|
||||
// mBottomSheetBehavior = BottomSheetBehavior.from( mAppsList );
|
||||
// mBottomSheetBehavior.setSkipCollapsed( true );
|
||||
// mBottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() {
|
||||
// @Override
|
||||
// public void onStateChanged( @NonNull View bottomSheet, int newState ) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSlide( @NonNull View bottomSheet, float slideOffset ) {
|
||||
//
|
||||
// }
|
||||
// } );
|
||||
// mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_COLLAPSED );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
super.onStart();
|
||||
final Dialog dialog = getDialog();
|
||||
if ( dialog != null ) {
|
||||
if ( dialog.getWindow() != null ) {
|
||||
final WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
|
||||
params.width = WindowUtils.getScreenWidth( getContext() );
|
||||
params.height = WindowUtils.getScreenHeight( getContext() );
|
||||
dialog.getWindow().setAttributes( params );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlide( @NonNull View bottomSheet, float slideOffset ) {
|
||||
|
||||
}
|
||||
} );
|
||||
mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_COLLAPSED );
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -76,11 +97,9 @@ public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > impleme
|
||||
}
|
||||
|
||||
private void bindListener() {
|
||||
mAppsAdapter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
AppInfo tag = (AppInfo) v.getTag();
|
||||
|
||||
}
|
||||
});
|
||||
mAppsAdapter.setOnClickListener( view -> {
|
||||
AppInfo app = ( AppInfo ) view.getTag();
|
||||
mPresenter.launch( app );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ import com.mogo.service.module.ModuleType;
|
||||
@Route( path = MogoModulePaths.PATH_MODULE_APPS )
|
||||
public class AppsFragmentProvider implements IMogoModuleProvider {
|
||||
|
||||
private AppsFragment mAppsFragment;
|
||||
private AppNavigatorFragment mAppsFragment;
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
mAppsFragment = new AppsFragment();
|
||||
mAppsFragment = new AppNavigatorFragment();
|
||||
mAppsFragment.setArguments( data );
|
||||
return mAppsFragment;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.module.apps;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -83,4 +84,17 @@ public class AppsPresenter extends Presenter< AppsView > {
|
||||
return appInfos;
|
||||
}
|
||||
|
||||
public void launch( AppInfo appInfo ) {
|
||||
if ( appInfo == null ) {
|
||||
return;
|
||||
}
|
||||
Intent intent = getContext().getPackageManager().getLaunchIntentForPackage( appInfo.getPackageName() );
|
||||
if ( intent == null ) {
|
||||
Logger.e( TAG, "can't launch app: %s", appInfo.toString() );
|
||||
return;
|
||||
}
|
||||
intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
getContext().startActivity( intent );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,4 +43,14 @@ public class AppInfo {
|
||||
public Drawable getIcon() {
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AppInfo{" +
|
||||
"mName='" + mName + '\'' +
|
||||
", mPackageName='" + mPackageName + '\'' +
|
||||
", mVersionName='" + mVersionName + '\'' +
|
||||
", mVersionCode=" + mVersionCode +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
BIN
modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_apps.png
Executable file
|
After Width: | Height: | Size: 16 KiB |
BIN
modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_chat.png
Executable file
|
After Width: | Height: | Size: 16 KiB |
BIN
modules/mogo-module-apps/src/main/res/drawable-xhdpi/module_apps_ic_music.png
Executable file
|
After Width: | Height: | Size: 8.8 KiB |
|
After Width: | Height: | Size: 10 KiB |
@@ -1,5 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<?xml version="1.0" encoding="utf-8"?><!--<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
|
||||
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent">-->
|
||||
|
||||
<!-- <androidx.recyclerview.widget.RecyclerView-->
|
||||
<!-- android:id="@+id/module_apps_id_apps"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="match_parent"-->
|
||||
<!-- app:behavior_hideable="false"-->
|
||||
<!-- app:behavior_peekHeight="76dp"-->
|
||||
<!-- app:layout_behavior="@string/bottom_sheet_behavior" />-->
|
||||
<!--</androidx.coordinatorlayout.widget.CoordinatorLayout>-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
@@ -9,6 +22,5 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:behavior_hideable="false"
|
||||
app:behavior_peekHeight="76dp"
|
||||
app:layout_behavior="@string/bottom_sheet_behavior" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
app:behavior_peekHeight="76dp" />
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
android:paddingBottom="@dimen/dp_33">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_apps_id_navigation"
|
||||
android:layout_width="@dimen/dp_119"
|
||||
android:layout_height="@dimen/dp_119"
|
||||
android:src="@drawable/module_apps_ic_navigation" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_apps_id_music"
|
||||
android:layout_width="@dimen/dp_119"
|
||||
android:layout_height="@dimen/dp_119"
|
||||
android:layout_marginLeft="@dimen/dp_61"
|
||||
android:src="@drawable/module_apps_ic_music" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_apps_id_chat"
|
||||
android:layout_width="@dimen/dp_119"
|
||||
android:layout_height="@dimen/dp_119"
|
||||
android:layout_marginLeft="@dimen/dp_61"
|
||||
android:src="@drawable/module_apps_ic_chat" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_apps_id_apps"
|
||||
android:layout_width="@dimen/dp_119"
|
||||
android:layout_height="@dimen/dp_119"
|
||||
android:layout_marginLeft="@dimen/dp_61"
|
||||
android:src="@drawable/module_apps_ic_apps" />
|
||||
</LinearLayout>
|
||||
@@ -3,6 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
@@ -13,5 +14,7 @@
|
||||
<TextView
|
||||
android:id="@+id/module_apps_id_app_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:maxLines="2" />
|
||||
</LinearLayout>
|
||||
@@ -48,4 +48,9 @@ public interface ModuleType {
|
||||
* 小智、天气、时间等
|
||||
*/
|
||||
int TYPE_EXTENSION = 8;
|
||||
|
||||
/**
|
||||
* 操作快捷入口
|
||||
*/
|
||||
int TYPE_ENTRANCE = 9;
|
||||
}
|
||||
|
||||
@@ -27,13 +27,16 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
targetCompatibility 1.8
|
||||
sourceCompatibility 1.8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
|
||||
@@ -8,9 +8,19 @@ package com.mogo.module.extensions;
|
||||
*/
|
||||
public class ExtensionsModuleConst {
|
||||
|
||||
/**
|
||||
* 顶部UI
|
||||
*/
|
||||
public static final String PATH_EXTENSION = "/extension/ui";
|
||||
|
||||
/**
|
||||
* 快捷操作入口:定位、
|
||||
*/
|
||||
public static final String PATH_ENTRANCE = "/extension/entrance";
|
||||
|
||||
|
||||
public static final String TYPE = "extension";
|
||||
|
||||
public static final String TYPE_ENTRANCE = "entrance";
|
||||
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public class ExtensionsPresenter extends Presenter< ExtensionsView > implements
|
||||
String temp = getContext().getResources().getString( R.string.module_ext_str_weather_temp_format, weatherInfo.getTemperature() );
|
||||
Phenomena phenomena = Phenomena.getById( weatherInfo.getPhenomena() );
|
||||
String desc = phenomena == null ? "" : phenomena.nameCn;
|
||||
int resId = 0;
|
||||
int resId = phenomena.resId;
|
||||
mView.renderWeatherInfo( temp, desc, resId );
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.extensions.R;
|
||||
import com.mogo.module.extensions.navi.NaviInfoView;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-07
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresenter > implements EntranceView, IMogoNaviListener {
|
||||
|
||||
|
||||
private View mSearch;
|
||||
|
||||
private View mCommonAddress;
|
||||
private View mHome;
|
||||
private View mCompany;
|
||||
|
||||
private View mUploadRoadCondition;
|
||||
|
||||
private View mVRMode;
|
||||
private View mMove2CurrentLocation;
|
||||
|
||||
private NaviInfoView mNaviInfo;
|
||||
private View mExitNavi;
|
||||
|
||||
private IMogoMapService mService;
|
||||
private IMogoMapUIController mMApUIController;
|
||||
private IMogoLocationClient mMogoLocationClient;
|
||||
private IMogoNavi mMogoNavi;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_ext_layout_entrance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
mCommonAddress = findViewById( R.id.module_map_id_common_address );
|
||||
|
||||
mSearch = findViewById( R.id.module_map_id_search );
|
||||
mSearch.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mHome = findViewById( R.id.module_map_id_home );
|
||||
mHome.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mCompany = findViewById( R.id.module_map_id_company );
|
||||
mCompany.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mUploadRoadCondition = findViewById( R.id.module_map_id_upload_road_condition );
|
||||
mUploadRoadCondition.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mVRMode = findViewById( R.id.module_map_id_vr_mode );
|
||||
mVRMode.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mMove2CurrentLocation = findViewById( R.id.module_map_id_move2_current_location );
|
||||
mMove2CurrentLocation.setOnClickListener( view -> {
|
||||
final MogoLocation location = mMogoLocationClient.getLastKnowLocation();
|
||||
if ( location != null ) {
|
||||
mMApUIController.moveToCenter( new MogoLatLng( location.getLatitude(), location.getLongitude() ) );
|
||||
}
|
||||
} );
|
||||
|
||||
mNaviInfo = findViewById( R.id.module_map_id_navi_info_panel );
|
||||
mExitNavi = findViewById( R.id.module_map_id_exit_navi );
|
||||
mExitNavi.setOnClickListener( view -> {
|
||||
if ( mMogoNavi != null ) {
|
||||
mMogoNavi.stopNavi();
|
||||
}
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected EntrancePresenter createPresenter() {
|
||||
return new EntrancePresenter( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||
super.onActivityCreated( savedInstanceState );
|
||||
mService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
|
||||
mMApUIController = mService.getMapUIController();
|
||||
mMogoLocationClient = mService.getLocationClient( getContext() );
|
||||
mMogoNavi = mService.getNavi( getContext() );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitNaviFailure() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitNaviSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) {
|
||||
if ( naviinfo == null ) {
|
||||
return;
|
||||
}
|
||||
mNaviInfo.notifyChanged( naviinfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() {
|
||||
mCommonAddress.setVisibility( View.GONE );
|
||||
mNaviInfo.setVisibility( View.VISIBLE );
|
||||
mExitNavi.setVisibility( View.VISIBLE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
mCommonAddress.setVisibility( View.VISIBLE );
|
||||
mNaviInfo.setVisibility( View.GONE );
|
||||
mExitNavi.setVisibility( View.GONE );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-07
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class EntrancePresenter extends Presenter<EntranceView> {
|
||||
|
||||
public EntrancePresenter( EntranceView view ) {
|
||||
super( view );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-07
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = ExtensionsModuleConst.PATH_ENTRANCE )
|
||||
public class EntranceProvider implements IMogoModuleProvider {
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
EntranceFragment fragment = new EntranceFragment();
|
||||
fragment.setArguments( data );
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView( Context context ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoModuleLifecycle getCardLifecycle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapListener getMapListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return ModuleType.TYPE_ENTRANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mogo.module.extensions.entrance;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-07
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public interface EntranceView extends IView {
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.mogo.module.extensions.navi;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.map.impl.amap.utils.IconTypeUtils;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-03
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public abstract class BaseNaviInfoView extends RelativeLayout {
|
||||
|
||||
public BaseNaviInfoView( Context context ) {
|
||||
this( context, null );
|
||||
}
|
||||
|
||||
public BaseNaviInfoView( Context context, @Nullable AttributeSet attrs ) {
|
||||
this( context, attrs, 0 );
|
||||
}
|
||||
|
||||
public BaseNaviInfoView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
}
|
||||
|
||||
public void notifyChanged( MogoNaviInfo naviInfo ) {
|
||||
|
||||
}
|
||||
|
||||
protected void fillNextCrossTurning( TextView target, int nextIconType ) {
|
||||
target.setText( "后" + IconTypeUtils.getNameByIconType( nextIconType ) );
|
||||
}
|
||||
|
||||
protected void fillNextCrossIconType( ImageView target, int iconId ) {
|
||||
if ( iconId > 0 ) {
|
||||
target.setImageResource( iconId );
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillNextCrossDistance( TextView target, TextView unit, int distance ) {
|
||||
if ( distance >= 1000 ) {
|
||||
target.setText( String.format( "%.1f", distance / 1000f ) );
|
||||
unit.setText( "公里" );
|
||||
} else {
|
||||
target.setText( distance + "" );
|
||||
unit.setText( "米" );
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillFormatSurplusDistance( int m, StringBuilder builder ) {
|
||||
if ( m >= 1000 ) {
|
||||
builder.append( String.format( "%.1f公里", m / 1000f ) );
|
||||
} else {
|
||||
builder.append( m ).append( "米" );
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillFormatTime( int seconds, StringBuilder builder ) {
|
||||
int days = seconds / ( 24 * 60 * 60 );
|
||||
if ( days > 0 ) {
|
||||
builder.append( days ).append( "天" );
|
||||
}
|
||||
seconds -= days * 24 * 60 * 60;
|
||||
int hours = seconds / ( 60 * 60 );
|
||||
if ( hours > 0 ) {
|
||||
builder.append( hours ).append( "小时" );
|
||||
}
|
||||
seconds -= hours * 60 * 60;
|
||||
int min = seconds / 60;
|
||||
builder.append( min > 1 ? min : 1 ).append( "分钟" );
|
||||
}
|
||||
|
||||
protected void fillArriveTime( int seconds, StringBuilder builder ) {
|
||||
|
||||
int days = seconds / ( 24 * 60 * 60 );
|
||||
if ( days > 0 ) {
|
||||
builder.append( days ).append( "天后" );
|
||||
} else {
|
||||
seconds -= days * 24 * 60 * 60;
|
||||
int hours = seconds / ( 60 * 60 );
|
||||
seconds -= hours * 60 * 60;
|
||||
int min = seconds / 60;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int curHour = calendar.get( Calendar.HOUR_OF_DAY );
|
||||
int curMin = calendar.get( Calendar.MINUTE );
|
||||
if ( curHour + hours + ( curMin + min ) / 60 > 24 ) {
|
||||
builder.append( "一天后" );
|
||||
} else {
|
||||
calendar.add( Calendar.HOUR_OF_DAY, hours );
|
||||
calendar.add( Calendar.MINUTE, min );
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat( "HH:mm" );
|
||||
builder.append( dateFormat.format( calendar.getTime() ) );
|
||||
}
|
||||
}
|
||||
builder.append( "到达" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.mogo.module.extensions.navi;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.module.extensions.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-09-29
|
||||
* <p>
|
||||
* 导航信息
|
||||
*/
|
||||
public class NaviInfoView extends BaseNaviInfoView {
|
||||
|
||||
private ImageView turnIcon;
|
||||
private TextView distance;
|
||||
private TextView distanceUnit;
|
||||
private TextView nextRoad;
|
||||
private TextView estimateInfo;
|
||||
|
||||
private StringBuilder mBuilder = new StringBuilder();
|
||||
|
||||
public NaviInfoView( Context context ) {
|
||||
this( context, null );
|
||||
}
|
||||
|
||||
public NaviInfoView( Context context, @Nullable AttributeSet attrs ) {
|
||||
this( context, attrs, 0 );
|
||||
}
|
||||
|
||||
public NaviInfoView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
View.inflate( context, R.layout.module_map_layout_navi_info_panel, this );
|
||||
turnIcon = findViewById( R.id.module_map_id_navi_next_info_road_turn_icon );
|
||||
distance = findViewById( R.id.module_map_id_navi_next_info_distance );
|
||||
distanceUnit = findViewById( R.id.module_map_id_navi_next_info_distance_unit );
|
||||
nextRoad = findViewById( R.id.module_map_id_navi_next_info_road );
|
||||
estimateInfo = findViewById( R.id.module_map_id_navi_arrive_destination_estimate_info );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyChanged( MogoNaviInfo naviInfo ) {
|
||||
super.notifyChanged( naviInfo );
|
||||
if ( naviInfo == null ) {
|
||||
return;
|
||||
}
|
||||
fillNextCrossDistance( distance, distanceUnit, naviInfo.getCurStepRetainDistance() );
|
||||
fillNextCrossIconType( turnIcon, naviInfo.getIconResId() );
|
||||
nextRoad.setText( naviInfo.getNextRoadName() );
|
||||
|
||||
try {
|
||||
mBuilder.delete( 0, mBuilder.length() );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mBuilder.append( "剩余" );
|
||||
fillFormatSurplusDistance( naviInfo.getPathRetainDistance(), mBuilder );
|
||||
mBuilder.append( " " );
|
||||
fillFormatTime( naviInfo.getPathRetainTime(), mBuilder );
|
||||
mBuilder.append( "\n" );
|
||||
fillArriveTime( naviInfo.getPathRetainTime(), mBuilder );
|
||||
|
||||
final String text = mBuilder.toString();
|
||||
estimateInfo.setText( text );
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当行信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getGuideInfo() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if ( getVisibility() == VISIBLE ) {
|
||||
builder.append( distance.getText() );
|
||||
builder.append( nextRoad.getText() );
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取剩余里程
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPathRetainDistance() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if ( getVisibility() == VISIBLE ) {
|
||||
builder.append( estimateInfo.getText() );
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.mogo.module.extensions.weather;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.module.extensions.R;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -9,68 +11,70 @@ import java.util.Map;
|
||||
* @author Lzq
|
||||
*/
|
||||
public enum Phenomena {
|
||||
Sunny( "00", "晴", "Sunny" ),
|
||||
Cloudy( "01", "多云", "Cloudy" ),
|
||||
Overcast( "02", "阴", "Overcast" ),
|
||||
Sunny( "00", "晴", "Sunny", R.drawable.ic_sunny ),
|
||||
Cloudy( "01", "多云", "Cloudy", R.drawable.ic_cloudy ),
|
||||
Overcast( "02", "阴", "Overcast", R.drawable.ic_overcast ),
|
||||
|
||||
Shower( "03", "阵雨", "Shower" ),
|
||||
Thundershower( "04", "雷阵雨", "Thundershower" ),
|
||||
ThundershowerWithHail( "05", "雷阵雨伴有冰雹", "Thundershower with hail" ),
|
||||
Sleet( "06", "雨夹雪", "Sleet" ),
|
||||
LightRain( "07", "小雨", "Light rain" ),
|
||||
ModerateRain( "08", "中雨", "Moderate rain" ),
|
||||
HeavyRain( "09", "大雨", "Heavy rain" ),
|
||||
Storm( "10", "暴雨", "Storm" ),
|
||||
HeavyStorm( "11", "大暴雨", "Heavy storm" ),
|
||||
SevereStorm( "12", "特大暴雨", "Severe storm" ),
|
||||
Shower( "03", "阵雨", "Shower", R.drawable.ic_shower ),
|
||||
Thundershower( "04", "雷阵雨", "Thundershower", R.drawable.ic_thundershower ),
|
||||
ThundershowerWithHail( "05", "雷阵雨伴有冰雹", "Thundershower with hail", R.drawable.ic_thundershower ),
|
||||
Sleet( "06", "雨夹雪", "Sleet", R.drawable.ic_snow ),
|
||||
LightRain( "07", "小雨", "Light rain", R.drawable.ic_light_rain ),
|
||||
ModerateRain( "08", "中雨", "Moderate rain", R.drawable.ic_light_rain ),
|
||||
HeavyRain( "09", "大雨", "Heavy rain", R.drawable.ic_heavy_rain ),
|
||||
Storm( "10", "暴雨", "Storm", R.drawable.ic_heavy_rain ),
|
||||
HeavyStorm( "11", "大暴雨", "Heavy storm", R.drawable.ic_heavy_rain ),
|
||||
SevereStorm( "12", "特大暴雨", "Severe storm", R.drawable.ic_severe_storm ),
|
||||
|
||||
SnowFlurry( "13", "阵雪", "Snow flurry" ),
|
||||
LightSnow( "14", "小雪", "Light snow" ),
|
||||
ModerateSnow( "15", "中雪", "Moderate snow" ),
|
||||
HeavySnow( "16", "大雪", "Heavy snow" ),
|
||||
Snowstorm( "17", "暴雪", "Snowstorm" ),
|
||||
SnowFlurry( "13", "阵雪", "Snow flurry", R.drawable.ic_snow ),
|
||||
LightSnow( "14", "小雪", "Light snow", R.drawable.ic_snow ),
|
||||
ModerateSnow( "15", "中雪", "Moderate snow", R.drawable.ic_snow ),
|
||||
HeavySnow( "16", "大雪", "Heavy snow", R.drawable.ic_snow ),
|
||||
Snowstorm( "17", "暴雪", "Snowstorm", R.drawable.ic_snow ),
|
||||
|
||||
Foggy( "18", "雾", "Foggy" ),
|
||||
IceRain( "19", "冻雨", "Ice rain" ),
|
||||
Duststorm( "20", "沙尘暴", "Duststorm" ),
|
||||
Foggy( "18", "雾", "Foggy", R.drawable.ic_fog ),
|
||||
IceRain( "19", "冻雨", "Ice rain", R.drawable.ic_heavy_rain ),
|
||||
Duststorm( "20", "沙尘暴", "Duststorm", R.drawable.ic_duststorm ),
|
||||
|
||||
LightToModerateRain( "21", "小到中雨", "Light to moderate rain" ),
|
||||
ModerateToHeavyRain( "22", "中到大雨", "Moderate to heavy rain" ),
|
||||
HeavyRainToStorm( "23", "大到大雨", "Heavy rain to storm" ),
|
||||
StormToHeavyStorm( "24", "暴雨到大暴雨", "Storm to heavy storm" ),
|
||||
HeavyToSevereStorm( "25", "大暴雨到特大暴雨", "Heavy to severe storm" ),
|
||||
LightToModerateRain( "21", "小到中雨", "Light to moderate rain", R.drawable.ic_moderate_rain ),
|
||||
ModerateToHeavyRain( "22", "中到大雨", "Moderate to heavy rain", R.drawable.ic_heavy_rain ),
|
||||
HeavyRainToStorm( "23", "大到大雨", "Heavy rain to storm", R.drawable.ic_heavy_rain ),
|
||||
StormToHeavyStorm( "24", "暴雨到大暴雨", "Storm to heavy storm", R.drawable.ic_severe_storm ),
|
||||
HeavyToSevereStorm( "25", "大暴雨到特大暴雨", "Heavy to severe storm", R.drawable.ic_severe_storm ),
|
||||
|
||||
LightToModerateSnow( "26", "小到中雪", "Light to moderate snow" ),
|
||||
ModerateToHeavySnow( "27", "中到大雪", "Moderate to heavy snow" ),
|
||||
HeavySnowToSnowStorm( "28", "大到暴雪", "Heavy snow to snowstorm" ),
|
||||
LightToModerateSnow( "26", "小到中雪", "Light to moderate snow", R.drawable.ic_snow ),
|
||||
ModerateToHeavySnow( "27", "中到大雪", "Moderate to heavy snow", R.drawable.ic_snow ),
|
||||
HeavySnowToSnowStorm( "28", "大到暴雪", "Heavy snow to snowstorm", R.drawable.ic_snow ),
|
||||
|
||||
Dust( "29", "浮尘", "Dust" ),
|
||||
Sand( "30", "扬沙", "Sand" ),
|
||||
SandStorm( "31", "强沙尘暴", "Sandstorm" ),
|
||||
Dust( "29", "浮尘", "Dust", R.drawable.ic_dust_sand ),
|
||||
Sand( "30", "扬沙", "Sand", R.drawable.ic_dust_sand ),
|
||||
SandStorm( "31", "强沙尘暴", "Sandstorm", R.drawable.ic_duststorm ),
|
||||
|
||||
Densefog( "32", "浓雾", "Dense fog" ),
|
||||
StrongFog( "49", "强浓雾", "Strong fog" ),
|
||||
DenseFog( "57", "大雾", "Dense fog" ),
|
||||
ExtraHeavyFog( "58", "特强浓雾", "Extra heavy fog" ),
|
||||
Densefog( "32", "浓雾", "Dense fog", R.drawable.ic_fog ),
|
||||
StrongFog( "49", "强浓雾", "Strong fog", R.drawable.ic_fog ),
|
||||
DenseFog( "57", "大雾", "Dense fog", R.drawable.ic_fog ),
|
||||
ExtraHeavyFog( "58", "特强浓雾", "Extra heavy fog", R.drawable.ic_fog ),
|
||||
|
||||
Haze( "53", "霾", "Haze" ),
|
||||
ModerateHaze( "54", "中度霾", "Moderate haze" ),
|
||||
Severehaze( "55", "重度霾", "Severe haze" ),
|
||||
SevereHaze( "56", "严重霾", "Severe haze" ),
|
||||
Haze( "53", "霾", "Haze", R.drawable.ic_haze ),
|
||||
ModerateHaze( "54", "中度霾", "Moderate haze", R.drawable.ic_haze ),
|
||||
Severehaze( "55", "重度霾", "Severe haze", R.drawable.ic_haze ),
|
||||
SevereHaze( "56", "严重霾", "Severe haze", R.drawable.ic_haze ),
|
||||
|
||||
Unknown( "99", "无", "Unknown" ),
|
||||
Unknown( "99", "无", "Unknown", R.drawable.ic_unknown ),
|
||||
|
||||
Rain( "301", "雨", "rain" ),
|
||||
Snow( "302", "雪", "snow" );
|
||||
Rain( "301", "雨", "rain", R.drawable.ic_heavy_rain ),
|
||||
Snow( "302", "雪", "snow", R.drawable.ic_snow );
|
||||
|
||||
public final String id;
|
||||
public final String nameCn;
|
||||
public final String nameEn;
|
||||
public final int resId;
|
||||
|
||||
Phenomena( String id, String nameCn, String nameEn ) {
|
||||
Phenomena( String id, String nameCn, String nameEn, int resId ) {
|
||||
this.id = id;
|
||||
this.nameCn = nameCn;
|
||||
this.nameEn = nameEn;
|
||||
this.resId = resId;
|
||||
}
|
||||
|
||||
static Map< String, Phenomena > mPhenomenas;
|
||||
|
||||
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_cloudy.png
Executable file
|
After Width: | Height: | Size: 988 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_dust_sand.png
Executable file
|
After Width: | Height: | Size: 551 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_duststorm.png
Executable file
|
After Width: | Height: | Size: 754 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_fog.png
Executable file
|
After Width: | Height: | Size: 449 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_haze.png
Executable file
|
After Width: | Height: | Size: 934 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_heavy_rain.png
Executable file
|
After Width: | Height: | Size: 801 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_light_rain.png
Executable file
|
After Width: | Height: | Size: 631 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_moderate_rain.png
Executable file
|
After Width: | Height: | Size: 631 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_overcast.png
Executable file
|
After Width: | Height: | Size: 929 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_severe_storm.png
Executable file
|
After Width: | Height: | Size: 987 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_shower.png
Executable file
|
After Width: | Height: | Size: 967 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_snow.png
Executable file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_sunny.png
Executable file
|
After Width: | Height: | Size: 913 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_thunder.png
Executable file
|
After Width: | Height: | Size: 772 B |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_thundershower.png
Executable file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
modules/mogo-module-extensions/src/main/res/drawable-xhdpi/ic_unknown.png
Executable file
|
After Width: | Height: | Size: 906 B |
|
Before Width: | Height: | Size: 737 B After Width: | Height: | Size: 737 B |
|
Before Width: | Height: | Size: 831 B After Width: | Height: | Size: 831 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<corners android:bottomLeftRadius="@dimen/dp_20" android:bottomRightRadius="@dimen/dp_20" />
|
||||
<solid android:color="#F1F1F1" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<corners android:radius="@dimen/dp_20" />
|
||||
<solid android:color="#FFFFFF" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:background="@drawable/module_map_dw_common_corner_bkg"
|
||||
android:drawableLeft="@drawable/module_map_ic_search"
|
||||
android:drawablePadding="@dimen/dp_16"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/dp_26"
|
||||
android:paddingRight="@dimen/dp_26"
|
||||
android:text="@string/module_map_str_search_hint"
|
||||
android:textColor="#99FFFFFF"
|
||||
android:textSize="@dimen/dp_32"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_map_id_common_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:background="@drawable/module_map_dw_common_corner_bkg"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/dp_22"
|
||||
android:paddingTop="@dimen/dp_17"
|
||||
android:paddingRight="@dimen/dp_22"
|
||||
android:paddingBottom="@dimen/dp_17"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_map_id_search"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_map_id_home"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_home" />
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/dp_2"
|
||||
android:layout_height="@dimen/dp_54"
|
||||
android:layout_marginLeft="@dimen/dp_21"
|
||||
android:layout_marginRight="@dimen/dp_21"
|
||||
android:background="#1ED8D8D8" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_map_id_company"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_company" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.mogo.module.extensions.navi.NaviInfoView
|
||||
android:id="@+id/module_map_id_navi_info_panel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_map_id_operation_panel"
|
||||
android:layout_width="@dimen/dp_90"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/dp_32"
|
||||
android:layout_marginBottom="@dimen/dp_60"
|
||||
android:background="@drawable/module_map_dw_common_corner_bkg"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/module_map_id_vr_mode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_92"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/module_map_ic_move2_current_location"
|
||||
android:text="实景"
|
||||
android:textColor="#CCFFFFFF"
|
||||
android:textSize="@dimen/dp_24" />
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/dp_48"
|
||||
android:layout_height="@dimen/dp_2"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="#1ED8D8D8" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_map_id_move2_current_location"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_move2_current_location" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_upload_road_condition"
|
||||
android:layout_width="@dimen/dp_90"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginBottom="@dimen/dp_40"
|
||||
android:background="@drawable/module_map_dw_upload_road_condition_bkg"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_map_str_upload_road_condition"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/dp_24"
|
||||
app:layout_constraintBottom_toTopOf="@+id/module_map_id_operation_panel"
|
||||
app:layout_constraintRight_toRightOf="@+id/module_map_id_operation_panel"
|
||||
app:layout_goneMarginBottom="@dimen/dp_32"
|
||||
app:layout_goneMarginRight="@dimen/dp_32" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_exit_navi"
|
||||
android:layout_width="@dimen/dp_200"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
android:layout_marginBottom="@dimen/dp_60"
|
||||
android:background="@drawable/module_map_dw_common_corner_bkg"
|
||||
android:gravity="center"
|
||||
android:text="退出导航"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/dp_32"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:background="#0C0C0C "
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/dp_70"
|
||||
android:paddingRight="@dimen/dp_70">
|
||||
@@ -13,6 +14,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_ext_ic_voice"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -24,9 +26,9 @@
|
||||
android:text="@string/module_ext_str_voice_msg"
|
||||
android:textColor="@color/module_ext_color_voice_text"
|
||||
android:textSize="@dimen/dp_32"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_ext_id_voice"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_ext_id_voice"
|
||||
app:layout_constraintTop_toTopOf="@+id/module_ext_id_voice" />
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_ext_id_time"
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="@dimen/dp_458"
|
||||
android:layout_height="@dimen/dp_318"
|
||||
android:background="@drawable/module_map_dw_navi_info_panel_bkg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_map_id_navi_next_info_road_turn_icon"
|
||||
android:layout_width="@dimen/dp_159"
|
||||
android:layout_height="@dimen/dp_159"
|
||||
android:layout_marginLeft="@dimen/dp_24"
|
||||
android:layout_marginTop="@dimen/dp_24"
|
||||
android:scaleType="fitCenter"
|
||||
tools:src="@drawable/ic_11" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_navi_next_info_distance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/module_map_id_navi_next_info_road_turn_icon"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_toRightOf="@+id/module_map_id_navi_next_info_road_turn_icon"
|
||||
android:textColor="#282828"
|
||||
android:textSize="@dimen/dp_60"
|
||||
tools:text="53" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_navi_next_info_distance_unit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/module_map_id_navi_next_info_distance"
|
||||
android:layout_marginLeft="@dimen/dp_12"
|
||||
android:layout_marginBottom="@dimen/dp_16"
|
||||
android:layout_toRightOf="@+id/module_map_id_navi_next_info_distance"
|
||||
android:textColor="#282828"
|
||||
android:textSize="@dimen/dp_28"
|
||||
tools:text="米" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_navi_next_info_road"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/module_map_id_navi_next_info_distance"
|
||||
android:layout_alignLeft="@+id/module_map_id_navi_next_info_distance"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textColor="#282828"
|
||||
android:textSize="@dimen/dp_28"
|
||||
tools:text="北三环东路辅路" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_navi_arrive_destination_estimate_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/module_map_id_navi_next_info_road_turn_icon"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="@dimen/dp_24"
|
||||
android:background="@drawable/module_map_dw_navi_info_extras_bkg"
|
||||
android:gravity="center"
|
||||
android:maxLines="2"
|
||||
android:textColor="#282828"
|
||||
android:textSize="@dimen/dp_28"
|
||||
tools:text="剩余2000.8公里 1000小时59分钟59秒 \n1天后达到达到达到达到" />
|
||||
</RelativeLayout>
|
||||
@@ -14,4 +14,7 @@
|
||||
<item>周六</item>
|
||||
</string-array>
|
||||
<string name="module_ext_str_dots">···</string>
|
||||
|
||||
<string name="module_map_str_search_hint">搜索目的地</string>
|
||||
<string name="module_map_str_upload_road_condition">上报\n路况</string>
|
||||
</resources>
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpActivity;
|
||||
@@ -19,6 +18,7 @@ import com.mogo.module.extensions.ExtensionsModuleConst;
|
||||
import com.mogo.module.main.cards.CardModulesAdapter;
|
||||
import com.mogo.module.main.cards.MogoModulesHandler;
|
||||
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.service.ServiceConst;
|
||||
@@ -34,7 +34,7 @@ import java.util.List;
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 描述
|
||||
* 描述:加载各个模块
|
||||
*/
|
||||
public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView,
|
||||
IMogoLocationListener,
|
||||
@@ -67,13 +67,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mCardsContainer = findViewById( R.id.module_main_id_cards_container );
|
||||
mCardsContainer.setOrientation( OrientedViewPager.Orientation.VERTICAL );
|
||||
|
||||
mCardsContainer.setOnPageChangeListener( new ViewPager.OnPageChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
||||
Logger.i( TAG, "position = " + position );
|
||||
}
|
||||
|
||||
mCardsContainer.setOnPageChangeListener( new OnPageChangeListenerAdapter() {
|
||||
@Override
|
||||
public void onPageSelected( int position ) {
|
||||
try {
|
||||
@@ -83,19 +77,6 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged( int state ) {
|
||||
if ( state == ViewPager.SCROLL_STATE_IDLE ) {
|
||||
// if ( mCurrentPosition == 0 ) {
|
||||
// mCurrentPosition = mCardModulesAdapter.getCount() - 3;
|
||||
// mCardsContainer.setCurrentItem( mCurrentPosition, false );
|
||||
// } else if ( mCurrentPosition == mCardModulesAdapter.getCount() - 2 ) {
|
||||
// mCurrentPosition = 1;
|
||||
// mCardsContainer.setCurrentItem( mCurrentPosition, false );
|
||||
// }
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -107,6 +88,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
MogoModulePaths.addModule( new MogoModule( MogoModulePaths.PATH_MODULE_MAP, MogoModulePaths.PATH_MODULE_MAP ) );
|
||||
MogoModulePaths.addModule( new MogoModule( ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY ) );
|
||||
MogoModulePaths.addModule( new MogoModule( ExtensionsModuleConst.PATH_EXTENSION, ExtensionsModuleConst.TYPE ) );
|
||||
MogoModulePaths.addModule( new MogoModule( ExtensionsModuleConst.PATH_ENTRANCE, ExtensionsModuleConst.TYPE_ENTRANCE ) );
|
||||
|
||||
mMogoModuleHandler = new MogoModulesManager( this );
|
||||
mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation();
|
||||
@@ -128,6 +110,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mMogoModuleHandler.loadMap( R.id.module_main_id_map_fragment_container );
|
||||
mMogoModuleHandler.loadAppsList( R.id.module_main_id_fragment_container );
|
||||
mMogoModuleHandler.loadExtensions( R.id.module_main_id_header_fragment_container );
|
||||
mMogoModuleHandler.loadEntrances( R.id.module_main_id_entrance_fragment_container );
|
||||
|
||||
mLocationClient = mMogoMapService.getSingletonLocationClient( getApplicationContext() );
|
||||
mLocationClient.addLocationListener( this );
|
||||
@@ -163,11 +146,22 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||
// int mappedCardPosition = mCardModulesAdapter.getNextCardPosition( marker.getOwner(), mCurrentPosition );
|
||||
// mCardsContainer.setCurrentItem( mappedCardPosition, true );
|
||||
switch2( marker.getOwner() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switch2( String cardType ) {
|
||||
if ( mCardModulesAdapter != null ) {
|
||||
int position = mCardModulesAdapter.getProviderPosition( cardType );
|
||||
if ( position != -1 ) {
|
||||
mCardsContainer.setCurrentItem( position, false );
|
||||
} else {
|
||||
Logger.e( TAG, "Can't find type of %s's position", cardType );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
package com.mogo.module.main;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.module.main.livedata.CardSwitchLiveData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -13,4 +20,18 @@ public class MainPresenter extends Presenter< MainView > {
|
||||
public MainPresenter( MainView view ) {
|
||||
super( view );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
CardSwitchLiveData.getInstance().observeForever( new Observer< String >() {
|
||||
@Override
|
||||
public void onChanged( String s ) {
|
||||
if ( TextUtils.isEmpty( s ) ) {
|
||||
return;
|
||||
}
|
||||
mView.switch2( s );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,6 @@ import com.mogo.commons.mvp.IView;
|
||||
* 主页 view 接口
|
||||
*/
|
||||
public interface MainView extends IView {
|
||||
|
||||
void switch2( String cardType );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.module.main;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.main.livedata.CardSwitchLiveData;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-06
|
||||
* <p>
|
||||
* 卡片控制
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_CARD_MANAGER )
|
||||
public class MogoCardManager implements IMogoCardManager {
|
||||
|
||||
@Override
|
||||
public void switch2( String cardType ) {
|
||||
CardSwitchLiveData.getInstance().postValue( cardType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -65,34 +65,23 @@ public class CardModulesAdapter extends FragmentStatePagerAdapter {
|
||||
}
|
||||
|
||||
/**
|
||||
* marker、卡片、语音等通过 launcher 切换到其他卡片。
|
||||
* 获取对应卡片类型在列表中的位置
|
||||
*
|
||||
* @param providerTag 卡片类型
|
||||
* @param currentPosition 当前卡片位置
|
||||
* @return 需要跳转到的卡片实际位置
|
||||
* @param tag 卡片类型
|
||||
* @return 列表中的位置
|
||||
*/
|
||||
public int getNextCardPosition( String providerTag, int currentPosition ) {
|
||||
int position = 0;
|
||||
int currentFactPosition = getFactPosition( currentPosition );
|
||||
for ( IMogoModuleProvider provider : mProviders ) {
|
||||
if ( TextUtils.equals( providerTag, provider.getModuleName() ) ) {
|
||||
break;
|
||||
public int getProviderPosition( String tag ) {
|
||||
if ( mProviders != null ) {
|
||||
for ( int i = 0; i < mProviders.size(); i++ ) {
|
||||
IMogoModuleProvider provider = mProviders.get( i );
|
||||
if ( provider != null ) {
|
||||
if ( TextUtils.equals( provider.getModuleName(), tag ) ) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
position++;
|
||||
}
|
||||
int offset = 0;
|
||||
if ( currentFactPosition > position ) {
|
||||
// 下一个卡片在当前卡片前面
|
||||
offset = position - mProviders.size();
|
||||
} else if ( currentFactPosition < position ) {
|
||||
// 下一个卡片在当前卡片后面
|
||||
offset = mProviders.size() - position;
|
||||
}
|
||||
return currentPosition + offset;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishUpdate( @NonNull ViewGroup container ) {
|
||||
super.finishUpdate( container );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,13 @@ public interface MogoModulesHandler extends IMogoMapListener,
|
||||
*/
|
||||
void loadExtensions( int containerId );
|
||||
|
||||
/**
|
||||
* 加载快捷操作
|
||||
*
|
||||
* @param containerId
|
||||
*/
|
||||
void loadEntrances( int containerId );
|
||||
|
||||
/**
|
||||
* 设置某一个module可用
|
||||
*
|
||||
|
||||
@@ -119,6 +119,11 @@ public class MogoModulesManager implements MogoModulesHandler,
|
||||
loadModuleByType( ModuleType.TYPE_EXTENSION, containerId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadEntrances( int containerId ) {
|
||||
loadModuleByType( ModuleType.TYPE_ENTRANCE, containerId );
|
||||
}
|
||||
|
||||
private void loadModuleByType( int type, int containerId ) {
|
||||
if ( mModuleProviders.isEmpty() ) {
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-06
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class OnPageChangeListenerAdapter implements ViewPager.OnPageChangeListener {
|
||||
|
||||
@Override
|
||||
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected( int position ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged( int state ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.main.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class PlaceholderFragment extends UnDestroyedViewFragment {
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_main_fragement_placeholder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||
super.onCreate( savedInstanceState );
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.main.R;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.module.ModuleType;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class PlaceholderFragmentProvider implements IMogoModuleProvider {
|
||||
|
||||
private Fragment mCopyTarget;
|
||||
private PlaceholderFragment mUi;
|
||||
|
||||
public void setCopyTarget( Fragment mUICopyTarget ) {
|
||||
this.mCopyTarget = mUICopyTarget;
|
||||
}
|
||||
|
||||
public void renderTargetUI() {
|
||||
if ( mCopyTarget == null ) {
|
||||
return;
|
||||
}
|
||||
final View target = mCopyTarget.getView();
|
||||
if ( target == null ) {
|
||||
return;
|
||||
}
|
||||
target.setDrawingCacheEnabled( true );
|
||||
Bitmap result = target.getDrawingCache();
|
||||
result = target.getDrawingCache() != null ? result.copy( Bitmap.Config.ARGB_8888, false ) : null;
|
||||
if ( mUi.getView() != null ) {
|
||||
mUi.getView().setBackgroundDrawable( new BitmapDrawable( result ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
mUi = new PlaceholderFragment();
|
||||
return mUi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView( Context context ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return "placeholder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoModuleLifecycle getCardLifecycle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapListener getMapListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return ModuleType.TYPE_CARD_FRAGMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoLocationListener getLocationListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.module.main.R;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-31
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public abstract class UnDestroyedViewFragment extends MvpFragment< IView, Presenter< IView > > implements IView {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView( @NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState ) {
|
||||
if ( mRootView == null ) {
|
||||
return super.onCreateView( inflater, container, savedInstanceState );
|
||||
}
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Presenter< IView > createPresenter() {
|
||||
return new Presenter< IView >( this ) {
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,10 @@ public class VerticalStackTransformer extends VerticalBaseTransformer {
|
||||
protected void onTransform( View page, float position ) {
|
||||
if ( position <= 0.0f ) {
|
||||
page.setAlpha( 1.0f );
|
||||
Log.e( "onTransform", "position <= 0.0f ==>" + position );
|
||||
page.setTranslationY( 0f );
|
||||
//控制停止滑动切换的时候,只有最上面的一张卡片可以点击
|
||||
page.setClickable( true );
|
||||
} else {
|
||||
Log.e( "onTransform", "position <= 3.0f ==>" + position );
|
||||
float scale = ( float ) ( page.getWidth() - WindowUtils.dip2px( context, spaceBetweenFirAndSecWith * position ) ) / ( float ) ( page.getWidth() );
|
||||
//控制下面卡片的可见度
|
||||
page.setAlpha( 1.0f );
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.mogo.module.main.cards;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
public class ZoomOutPageTransformer implements ViewPager.PageTransformer {
|
||||
private static final float MAX_SCALE = 1.0f;
|
||||
private static final float MIN_SCALE = 0.85f;//0.85f
|
||||
|
||||
@Override
|
||||
public void transformPage( View view, float position ) {
|
||||
// //setScaleY只支持api11以上
|
||||
if ( position < -1 ) {
|
||||
view.setScaleX( MIN_SCALE );
|
||||
view.setScaleY( MIN_SCALE );
|
||||
} else if ( position <= 1 ) //a页滑动至b页 ; a页从 0.0 -1 ;b页从1 ~ 0.0
|
||||
{ // [-1,1]
|
||||
// Log.e("TAG", view + " , " + position + "");
|
||||
float scaleFactor = MIN_SCALE + ( 1 - Math.abs( position ) ) * ( MAX_SCALE - MIN_SCALE );
|
||||
view.setScaleX( scaleFactor );
|
||||
//每次滑动后进行微小的移动目的是为了防止在三星的某些手机上出现两边的页面为显示的情况
|
||||
if ( position > 0 ) {
|
||||
view.setTranslationX( -scaleFactor * 2 );
|
||||
} else if ( position < 0 ) {
|
||||
view.setTranslationX( scaleFactor * 2 );
|
||||
}
|
||||
view.setScaleY( scaleFactor );
|
||||
|
||||
} else { // (1,+Infinity]
|
||||
|
||||
view.setScaleX( MIN_SCALE );
|
||||
view.setScaleY( MIN_SCALE );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.module.main.livedata;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-06
|
||||
* <p>
|
||||
* 切换卡片
|
||||
*/
|
||||
public class CardSwitchLiveData extends MutableLiveData< String > {
|
||||
|
||||
private CardSwitchLiveData() {
|
||||
// private constructor
|
||||
}
|
||||
|
||||
private static final class InstanceHolder {
|
||||
private static final CardSwitchLiveData INSTANCE = new CardSwitchLiveData();
|
||||
}
|
||||
|
||||
public static CardSwitchLiveData getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#0C0C0C"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- 小智语音-->
|
||||
<!-- 地图-->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_header_fragment_container"
|
||||
android:id="@+id/module_main_id_map_fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_main_id_fragment_container"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/dp_70"
|
||||
android:layout_marginTop="@dimen/dp_10">
|
||||
<!-- 卡片-->
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- 小智语音-->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_fragment_container"
|
||||
android:layout_width="@dimen/dp_660"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/module_main_id_header_fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.mogo.module.main.cards.OrientedViewPager
|
||||
android:id="@+id/module_main_id_cards_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="@dimen/dp_211"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/dp_20" />
|
||||
</FrameLayout>
|
||||
|
||||
<!-- 地图-->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_map_fragment_container"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_main_id_fragment_container"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
</LinearLayout>
|
||||
android:layout_marginTop="@dimen/dp_10">
|
||||
<!-- 卡片 & 应用入口-->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_fragment_container"
|
||||
android:layout_width="@dimen/dp_660"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/dp_70"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</LinearLayout>
|
||||
<com.mogo.module.main.cards.OrientedViewPager
|
||||
android:id="@+id/module_main_id_cards_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="@dimen/dp_211"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="@dimen/dp_20" />
|
||||
</FrameLayout>
|
||||
|
||||
<!--快捷操作浮层-->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_entrance_fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
@@ -6,17 +6,10 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.MogoMapView;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -31,20 +24,6 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
private MogoMapView mMogoMapView;
|
||||
private IMogoMap mMogoMap;
|
||||
|
||||
private View mSearch;
|
||||
private View mHome;
|
||||
|
||||
private View mCompany;
|
||||
|
||||
private View mUploadRoadCondition;
|
||||
|
||||
private View mVRMode;
|
||||
private View mMove2CurrentLocation;
|
||||
|
||||
private IMogoMapService mService;
|
||||
private IMogoMapUIController mMApUIController;
|
||||
private IMogoLocationClient mMogoLocationClient;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_map_fragment_map;
|
||||
@@ -55,39 +34,6 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
mMogoMapView = findViewById( R.id.module_map_id_map );
|
||||
mMogoMap = mMogoMapView.getMap();
|
||||
mMogoMap.getUIController().showMyLocation( true );
|
||||
findViewById(R.id.module_map_id_search).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
ARouter.getInstance().build(MogoModulePaths.PATH_MODULE_NAV_ACTIVITY).navigation(getActivity());
|
||||
}
|
||||
});
|
||||
|
||||
mSearch = findViewById( R.id.module_map_id_search );
|
||||
mSearch.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mHome = findViewById( R.id.module_map_id_home );
|
||||
mHome.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mCompany = findViewById( R.id.module_map_id_company );
|
||||
mCompany.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mUploadRoadCondition = findViewById( R.id.module_map_id_upload_road_condition );
|
||||
mUploadRoadCondition.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mVRMode = findViewById( R.id.module_map_id_vr_mode );
|
||||
mVRMode.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
mMove2CurrentLocation = findViewById( R.id.module_map_id_move2_current_location );
|
||||
mMove2CurrentLocation.setOnClickListener( view -> {
|
||||
final MogoLocation location = mMogoLocationClient.getLastKnowLocation();
|
||||
if ( location != null ) {
|
||||
mMApUIController.moveToCenter( new MogoLatLng( location.getLatitude(), location.getLongitude() ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -103,9 +49,6 @@ public class MapFragment extends MvpFragment< MapView, MapPresenter > implements
|
||||
mMogoMapView.onCreate( savedInstanceState );
|
||||
}
|
||||
initMapView();
|
||||
mService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
|
||||
mMApUIController = mService.getMapUIController();
|
||||
mMogoLocationClient = mService.getLocationClient( getContext() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,120 +9,4 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:background="@drawable/module_map_dw_common_corner_bkg"
|
||||
android:drawableLeft="@drawable/module_map_ic_search"
|
||||
android:drawablePadding="@dimen/dp_16"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/dp_26"
|
||||
android:paddingRight="@dimen/dp_26"
|
||||
android:text="@string/module_map_str_search_hint"
|
||||
android:textColor="#99FFFFFF"
|
||||
android:textSize="@dimen/dp_32"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_32"
|
||||
android:layout_marginTop="@dimen/dp_2"
|
||||
android:background="@drawable/module_map_dw_common_corner_bkg"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/dp_22"
|
||||
android:paddingTop="@dimen/dp_17"
|
||||
android:paddingRight="@dimen/dp_22"
|
||||
android:paddingBottom="@dimen/dp_17"
|
||||
app:layout_constraintLeft_toRightOf="@+id/module_map_id_search"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_map_id_home"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_home" />
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/dp_2"
|
||||
android:layout_height="@dimen/dp_54"
|
||||
android:layout_marginLeft="@dimen/dp_21"
|
||||
android:layout_marginRight="@dimen/dp_21"
|
||||
android:background="#1ED8D8D8" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_map_id_company"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_company" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_map_id_operation_panel"
|
||||
android:layout_width="@dimen/dp_90"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/dp_32"
|
||||
android:layout_marginBottom="@dimen/dp_33"
|
||||
android:background="@drawable/module_map_dw_common_corner_bkg"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/module_map_id_vr_mode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_92"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/module_map_ic_move2_current_location"
|
||||
android:text="实景"
|
||||
android:textColor="#CCFFFFFF"
|
||||
android:textSize="@dimen/dp_24" />
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/dp_48"
|
||||
android:layout_height="@dimen/dp_2"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="#1ED8D8D8" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_map_id_move2_current_location"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/module_map_ic_move2_current_location" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_map_id_upload_road_condition"
|
||||
android:layout_width="@dimen/dp_90"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:layout_marginBottom="@dimen/dp_40"
|
||||
android:background="@drawable/module_map_dw_upload_road_condition_bkg"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_map_str_upload_road_condition"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/dp_24"
|
||||
app:layout_constraintBottom_toTopOf="@+id/module_map_id_operation_panel"
|
||||
app:layout_constraintRight_toRightOf="@+id/module_map_id_operation_panel"
|
||||
app:layout_goneMarginBottom="@dimen/dp_32"
|
||||
app:layout_goneMarginRight="@dimen/dp_32" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,5 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">mogo-module-map</string>
|
||||
<string name="module_map_str_search_hint">搜索目的地</string>
|
||||
<string name="module_map_str_upload_road_condition">上报\n路况</string>
|
||||
</resources>
|
||||
|
||||
@@ -22,6 +22,6 @@ public interface RefreshApiService {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST( "/yycp-launcherSnapshot/launcherSnapshot/querySnapshotAsync" )
|
||||
Observable< BaseData > refreshData( @QueryMap Map< String, Object > params,
|
||||
Observable< BaseData > refreshData(
|
||||
@FieldMap Map< String, Object > parameters );
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
*/
|
||||
public class RefreshBody {
|
||||
|
||||
public List< String > dataType = new ArrayList<>();
|
||||
// public List< String > dataType = new ArrayList<>();
|
||||
public int limit = 50;// 请求数量
|
||||
public int radius = 2_000; // 地理围栏半径(米)
|
||||
public LatLon location;
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.network.ParamsProvider;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
@@ -28,13 +29,28 @@ import io.reactivex.schedulers.Schedulers;
|
||||
*/
|
||||
public class RefreshModel {
|
||||
|
||||
public static final String HOST_DEV = "http://dzt-test.zhidaohulian.com";
|
||||
public static final String HOST_TEST = "http://dzt-test.zhidaohulian.com";
|
||||
public static final String HOST_PRODUCT = "https://dzt.zhidaohulian.com";
|
||||
|
||||
private final Context mContext;
|
||||
private RefreshApiService mRefreshApiService;
|
||||
|
||||
public RefreshModel( Context context ) {
|
||||
this.mContext = context;
|
||||
IMogoNetwork network = ( IMogoNetwork ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_NETWORK ).navigation( context );
|
||||
this.mRefreshApiService = network.create( RefreshApiService.class, "http://www.baidu.com/" );
|
||||
this.mRefreshApiService = network.create( RefreshApiService.class, getNetHost() );
|
||||
}
|
||||
|
||||
private String getNetHost() {
|
||||
switch ( DebugConfig.getNetMode() ) {
|
||||
case DebugConfig.NET_MODE_DEV:
|
||||
return HOST_DEV;
|
||||
case DebugConfig.NET_MODE_QA:
|
||||
return HOST_TEST;
|
||||
default:
|
||||
return HOST_PRODUCT;
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshData( MogoLatLng latLng, int radius, final RefreshCallback callback ) {
|
||||
@@ -47,7 +63,7 @@ public class RefreshModel {
|
||||
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
|
||||
refreshBody.radius = radius;
|
||||
field.put( "data", GsonUtil.jsonFromObject( refreshBody ) );
|
||||
mRefreshApiService.refreshData( query, field )
|
||||
mRefreshApiService.refreshData( field )
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( new SubscribeImpl< BaseData >( RequestOptions.create( mContext ) ) {
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.zhidao.tanlu;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
assertEquals("com.zhidao.tanlu.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||