完成了Marker样式跟随卡片的切换整体高亮
This commit is contained in:
@@ -13,6 +13,8 @@ public class MarkerShowEntity {
|
||||
|
||||
// false - 没选中,true - 选中
|
||||
private boolean isChecked;
|
||||
// false - 非高亮,true - 高亮
|
||||
private boolean isHighlighted;
|
||||
// icon 地址,例如:头像,唱片图片,探路缩略,可能为空展示默认图
|
||||
private String iconUrl;
|
||||
// 要展示的文本
|
||||
@@ -32,6 +34,14 @@ public class MarkerShowEntity {
|
||||
isChecked = checked;
|
||||
}
|
||||
|
||||
public boolean isHighlighted() {
|
||||
return isHighlighted;
|
||||
}
|
||||
|
||||
public void setHighlighted(boolean highlighted) {
|
||||
isHighlighted = highlighted;
|
||||
}
|
||||
|
||||
public String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
@@ -78,6 +88,7 @@ public class MarkerShowEntity {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MarkerShowEntity that = (MarkerShowEntity) o;
|
||||
return isChecked == that.isChecked &&
|
||||
isHighlighted == that.isHighlighted &&
|
||||
Objects.equals(iconUrl, that.iconUrl) &&
|
||||
Objects.equals(textContent, that.textContent) &&
|
||||
Objects.equals(markerType, that.markerType) &&
|
||||
@@ -87,13 +98,14 @@ public class MarkerShowEntity {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(isChecked, iconUrl, textContent, markerType, bindObj, markerLocation);
|
||||
return Objects.hash(isChecked, isHighlighted, iconUrl, textContent, markerType, bindObj, markerLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MarkerShowEntity{" +
|
||||
"isChecked=" + isChecked +
|
||||
", isHighlighted=" + isHighlighted +
|
||||
", iconUrl='" + iconUrl + '\'' +
|
||||
", textContent='" + textContent + '\'' +
|
||||
", markerType='" + markerType + '\'' +
|
||||
|
||||
@@ -72,6 +72,9 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
|
||||
private int mCurrentPosition = 0;
|
||||
|
||||
// 是否是点击Marker进行的页面切换,false-不是,true-是
|
||||
private boolean isClickMarker;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_main_activity_main;
|
||||
@@ -87,8 +90,10 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
public void onPageSelected( int position ) {
|
||||
try {
|
||||
mCurrentPosition = position;
|
||||
mMogoModuleHandler.setEnable( mCardModulesAdapter.getProvider( position ).getModuleName() );
|
||||
mMogoCardManager.invoke( position, mMogoModuleHandler.getCurrentModuleName() );
|
||||
mMogoModuleHandler.setEnable(mCardModulesAdapter.getProvider(position).getModuleName());
|
||||
if (!isClickMarker) {
|
||||
mMogoCardManager.invoke(position, mMogoModuleHandler.getCurrentModuleName());
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -203,10 +208,12 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||
isClickMarker = true;
|
||||
switch2( marker.getOwner() );
|
||||
if ( mMogoModuleHandler != null ) {
|
||||
mMogoModuleHandler.onMarkerReceive( marker );
|
||||
}
|
||||
isClickMarker = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -216,7 +223,9 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
int position = mCardModulesAdapter.getProviderPosition( cardType );
|
||||
if ( position != -1 ) {
|
||||
mCardsContainer.setCurrentItem( position, Math.abs( mCurrentPosition - position ) == 1 );
|
||||
mMogoCardManager.invoke( position, mMogoModuleHandler.getCurrentModuleName() );
|
||||
if (!isClickMarker) {
|
||||
mMogoCardManager.invoke(position, mMogoModuleHandler.getCurrentModuleName());
|
||||
}
|
||||
} else {
|
||||
Logger.e( TAG, "Can't find type of %s's position", cardType );
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.mogo.module.common.entity.MarkerShareMusic;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.marker.MapMarkerAdapter;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
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;
|
||||
@@ -27,6 +29,7 @@ import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -49,6 +52,7 @@ public class MarkerServiceHandler {
|
||||
private static IMogoStatusManager mMogoStatusManager;
|
||||
private static IMogoImageloader mImageloader;
|
||||
private static IMogoSocketManager mMogoSocketManager;
|
||||
private static IMogoCardManager mMogoCardManager;
|
||||
|
||||
private static Context mContext;
|
||||
|
||||
@@ -57,14 +61,16 @@ public class MarkerServiceHandler {
|
||||
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();
|
||||
|
||||
mMarkerManager = mMapService.getMarkerManager(context);
|
||||
mNavi = mMapService.getNavi(context);
|
||||
mMapUIController = mMapService.getMapUIController();
|
||||
|
||||
mogoMarkerClickListener = new MoGoMarkerClickListener();
|
||||
|
||||
// 长连接
|
||||
mMogoSocketManager = (IMogoSocketManager) ARouter.getInstance().build(MogoServicePaths.PATH_SOCKET_MANAGER).navigation();
|
||||
mMogoSocketManager.registerOnMessageListener(401001, new IMogoOnMessageListener<MarkerResponse>() {
|
||||
|
||||
@Override
|
||||
@@ -80,6 +86,15 @@ public class MarkerServiceHandler {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getMogoCardManager().registerCardChangedListener("LAUNCHER_MARKER_MODULE", new IMogoCardChangedListener() {
|
||||
|
||||
@Override
|
||||
public void onSwitched(int position, String moduleName) {
|
||||
Logger.e(TAG, "======moduleName:" + moduleName);
|
||||
highlightedMarker(moduleName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static IMogoMapService getMapService() {
|
||||
@@ -110,6 +125,9 @@ public class MarkerServiceHandler {
|
||||
return mMogoStatusManager;
|
||||
}
|
||||
|
||||
public static IMogoCardManager getMogoCardManager() {
|
||||
return mMogoCardManager;
|
||||
}
|
||||
|
||||
private static IMogoMarker lastMarker;
|
||||
|
||||
@@ -134,7 +152,7 @@ public class MarkerServiceHandler {
|
||||
Logger.e(TAG, "onMarkerClicked 点击了大而全中的Marker lastMarkerShowEntity:" + lastMarkerShowEntity);
|
||||
|
||||
lastMarkerShowEntity.setChecked(false);
|
||||
drawMapMarker(lastMarkerShowEntity);
|
||||
drawMapMarkerItem(lastMarkerShowEntity);
|
||||
|
||||
lastMarker.remove();
|
||||
}
|
||||
@@ -145,13 +163,38 @@ public class MarkerServiceHandler {
|
||||
|
||||
markerShowEntity.setChecked(true);
|
||||
|
||||
lastMarker = drawMapMarker(markerShowEntity);
|
||||
lastMarker = drawMapMarkerItem(markerShowEntity);
|
||||
|
||||
marker.remove();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 记录所有的Marker
|
||||
private static List<MarkerShowEntity> markerShowEntities;
|
||||
|
||||
// 对指定类型高亮处理
|
||||
public static void highlightedMarker(String typeTag) {
|
||||
if (markerShowEntities != null) {
|
||||
if (lastMarker != null) {
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) lastMarker.getObject();
|
||||
lastMarkerShowEntity.setChecked(false);
|
||||
drawMapMarkerItem(lastMarkerShowEntity);
|
||||
}
|
||||
lastMarker = null;
|
||||
getMarkerManager().removeMarkers();
|
||||
|
||||
for (MarkerShowEntity markerShowEntity : markerShowEntities) {
|
||||
if (markerShowEntity.getMarkerType().equals(typeTag)) {
|
||||
markerShowEntity.setHighlighted(true);
|
||||
} else {
|
||||
markerShowEntity.setHighlighted(false);
|
||||
}
|
||||
drawMapMarkerItem(markerShowEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Marker
|
||||
@@ -238,7 +281,7 @@ public class MarkerServiceHandler {
|
||||
* 绘制Marker
|
||||
*/
|
||||
public static IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity) {
|
||||
Logger.e(TAG, "绘制Marker====markerTag:" + markerShowEntity);
|
||||
Logger.e(TAG, "绘制Marker====drawMapMarker:" + markerShowEntity);
|
||||
try {
|
||||
if (markerShowEntity.getMarkerLocation() != null) {
|
||||
View markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity);
|
||||
@@ -252,6 +295,40 @@ public class MarkerServiceHandler {
|
||||
IMogoMarker marker = getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
||||
marker.setOnMarkerClickListener(mogoMarkerClickListener);
|
||||
marker.setObject(markerShowEntity);
|
||||
|
||||
if (markerShowEntities == null) {
|
||||
markerShowEntities = new ArrayList<>();
|
||||
}
|
||||
markerShowEntities.add(markerShowEntity);
|
||||
return marker;
|
||||
} else {
|
||||
Logger.e(TAG, "Location 必须进行初始化!!!!!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Marker
|
||||
*/
|
||||
public static IMogoMarker drawMapMarkerItem(MarkerShowEntity markerShowEntity) {
|
||||
Logger.e(TAG, "绘制Marker====drawMapMarkerItem:" + markerShowEntity);
|
||||
try {
|
||||
if (markerShowEntity.getMarkerLocation() != null) {
|
||||
View markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity);
|
||||
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(markerShowEntity.getMarkerType())
|
||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||
.longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||
options.icon(markerView);
|
||||
|
||||
IMogoMarker marker = getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
||||
marker.setOnMarkerClickListener(mogoMarkerClickListener);
|
||||
marker.setObject(markerShowEntity);
|
||||
|
||||
return marker;
|
||||
} else {
|
||||
Logger.e(TAG, "Location 必须进行初始化!!!!!");
|
||||
|
||||
@@ -57,6 +57,12 @@ public class MapMarkerView extends MapMarkerBaseView {
|
||||
try {
|
||||
Object bindObj = markerShowEntity.getBindObj();
|
||||
|
||||
if (markerShowEntity.isHighlighted()) {
|
||||
ivBg.setAlpha(1f);
|
||||
} else {
|
||||
ivBg.setAlpha(0.7f);
|
||||
}
|
||||
|
||||
switch (markerShowEntity.getMarkerType()) {
|
||||
case ServiceConst.CARD_TYPE_CARS_CHATTING:
|
||||
case ServiceConst.CARD_TYPE_USER_DATA:
|
||||
|
||||
@@ -57,7 +57,7 @@ public class RefreshModel {
|
||||
if ( mRefreshApiService != null ) {
|
||||
final Map< String, Object > query = new ParamsProvider.Builder( mContext ).build();
|
||||
final RefreshBody refreshBody = new RefreshBody();
|
||||
refreshBody.limit = 20;
|
||||
refreshBody.limit = 5;
|
||||
refreshBody.location = new RefreshBody.LatLon( latLng.lat, latLng.lng );
|
||||
refreshBody.radius = radius;
|
||||
query.put( "data", GsonUtil.jsonFromObject( refreshBody ) );
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
android:layout_height="@dimen/dp_85"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/bg_map_marker_blue"
|
||||
android:alpha="0.8"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -69,7 +69,6 @@
|
||||
tools:text="诗一样的女子诗诗一样的女子诗诗一样的女子诗" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout >
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivReverseTriangle"
|
||||
android:layout_width="10dp"
|
||||
@@ -79,4 +78,5 @@
|
||||
app:layout_constraintStart_toStartOf="@+id/clMarkerContent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/clMarkerContent" />
|
||||
|
||||
|
||||
</merge >
|
||||
Reference in New Issue
Block a user