整理资源
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
package com.mogo.module.common.drawer.marker;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
import com.mogo.module.common.constants.CarModelType;
|
||||
import com.mogo.module.common.constants.SafeType;
|
||||
import com.mogo.module.common.constants.VisionMode;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/29
|
||||
* <p>
|
||||
* 描述 按照命名规则,用字符串拼接成资源名称的方式拿到图片的id,避免枚举
|
||||
*/
|
||||
class MarkerResourceManager {
|
||||
|
||||
private static final String TAG = "MarkerResourceManager";
|
||||
|
||||
/**
|
||||
* @param mode
|
||||
* @param adasRecognizedType
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static int getMarkerDrawableResId( VisionMode mode,
|
||||
AdasRecognizedType adasRecognizedType,
|
||||
CarModelType type,
|
||||
SafeType safeType ) {
|
||||
if ( mode == null ) {
|
||||
mode = VisionMode.User;
|
||||
}
|
||||
if ( adasRecognizedType == null ) {
|
||||
adasRecognizedType = AdasRecognizedType.classIdCar;
|
||||
}
|
||||
if ( type == null ) {
|
||||
type = CarModelType.Other;
|
||||
}
|
||||
|
||||
if ( safeType == null ) {
|
||||
safeType = SafeType.Normal;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append( "module_commons" )
|
||||
.append( "_" ).append( mode.getRes() )
|
||||
.append( "_" ).append( adasRecognizedType.getRes() )
|
||||
.append( "_" ).append( type.getRes() )
|
||||
.append( "_" ).append( safeType.getRes() );
|
||||
|
||||
Logger.d( TAG, "res name = %s", builder.toString() );
|
||||
|
||||
int id = AbsMogoApplication.getApp().getResources().getIdentifier(
|
||||
builder.toString(),
|
||||
"drawable",
|
||||
AbsMogoApplication.getApp().getPackageName() );
|
||||
|
||||
if ( id == 0 ) {
|
||||
if ( mode == VisionMode.User ) {
|
||||
return R.drawable.module_commons_user_car_other_normal;
|
||||
} else {
|
||||
return R.drawable.module_commons_machine_car_other_normal;
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user