opt
This commit is contained in:
@@ -24,7 +24,7 @@ SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
|
||||
USERNAME=xintai
|
||||
PASSWORD=xintai2018
|
||||
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
|
||||
RELEASE=true
|
||||
RELEASE=false
|
||||
# 模块版本
|
||||
## 工程内模块
|
||||
MOGO_COMMONS_VERSION=1.1.0.7
|
||||
|
||||
@@ -82,8 +82,8 @@ public class MapCenterPointStrategy {
|
||||
{
|
||||
// 分类搜索,定位视图右边
|
||||
Map< Integer, MapCenterPoint > categorySearch = new HashMap<>();
|
||||
categorySearch.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.610833D ) );
|
||||
categorySearch.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.733594D, 0.596759D ) );
|
||||
categorySearch.put( CarSeries.CAR_SERIES_D80X, new MapCenterPoint( 0.733398D, 0.5D ) );
|
||||
categorySearch.put( CarSeries.CAR_SERIES_F80X, new MapCenterPoint( 0.733594D, 0.5D ) );
|
||||
sStrategies.put( Scene.CATEGORY_SEARCH, categorySearch );
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class WindowManagerView {
|
||||
}
|
||||
mLayoutParams.format = PixelFormat.TRANSLUCENT;
|
||||
mLayoutParams.gravity = Gravity.CENTER;
|
||||
mLayoutParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
||||
mLayoutParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
|
||||
if ( CarSeries.getSeries() == CarSeries.CAR_SERIES_F80X ) {
|
||||
mLayoutParams.width = 1920;
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
package com.mogo.module.navi.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 通用分享dialog
|
||||
* @since 2020-01-10
|
||||
*/
|
||||
public class NoticeDialog extends Dialog implements View.OnClickListener {
|
||||
private final String content;
|
||||
private final String positive;
|
||||
private TextView txtOk;
|
||||
private Context mContext;
|
||||
private View tvCancel;
|
||||
private View.OnClickListener onClickListener;
|
||||
private TextView tvContent;
|
||||
|
||||
public NoticeDialog(@NonNull Context context,String content,String positive) {
|
||||
super(context, R.style.Theme_AppCompat_Dialog);
|
||||
this.mContext = context;
|
||||
|
||||
this.content=content;
|
||||
this.positive=positive;
|
||||
|
||||
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
}
|
||||
|
||||
//public NoticeDialog(@NonNull Context context, int themeResId) {
|
||||
// super(context, R.style.Theme_AppCompat_Dialog);
|
||||
//}
|
||||
|
||||
public void setOnClickListener(View.OnClickListener onClickListener) {
|
||||
this.onClickListener = onClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initView();
|
||||
setContent(content);
|
||||
setPositiveButton(positive);
|
||||
initListener();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
setContentView(R.layout.dialog_common_notice);
|
||||
txtOk = findViewById(R.id.tv_dialog_ok);
|
||||
tvCancel = findViewById(R.id.tv_dialog_cancel);
|
||||
tvContent = findViewById(R.id.tv_dialog_content);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initListener() {
|
||||
txtOk.setOnClickListener(this);
|
||||
tvCancel.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
|
||||
if (onClickListener != null) {
|
||||
onClickListener.onClick(view);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public void setContent(String s) {
|
||||
if (tvContent != null) {
|
||||
tvContent.setText(s);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPositiveButton(String str) {
|
||||
if (txtOk != null) {
|
||||
txtOk.setText(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,11 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
)
|
||||
|
||||
var createWaterMask = BitmapUtils.createWaterMask(
|
||||
context, decodeResource, (index + 1).toString(), R.color.white, 18
|
||||
context,
|
||||
decodeResource,
|
||||
(index + 1).toString(),
|
||||
R.color.white,
|
||||
resources.getDimensionPixelSize(R.dimen.module_search_marker_number_textSize)
|
||||
)
|
||||
val options = MogoMarkerOptions()
|
||||
.icon(createWaterMask)
|
||||
@@ -74,7 +78,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
// .anchor(0.5f, 1f)
|
||||
.longitude(datums[index].point?.lng ?: 0.0)
|
||||
arrayList.add(options)
|
||||
if( locationList.size < 3 ){
|
||||
if (locationList.size < 3) {
|
||||
locationList.add(datums[index].point)
|
||||
}
|
||||
|
||||
@@ -178,7 +182,7 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateMarker(moveToCenter:Boolean = true) {
|
||||
private fun updateMarker(moveToCenter: Boolean = true) {
|
||||
|
||||
addMarkers?.get(mAdapter.lastPosition)?.setIcon(getMarkerIcon(mAdapter.lastPosition))
|
||||
var current = addMarkers?.get(mAdapter.current)
|
||||
@@ -198,10 +202,13 @@ class CategorySearchFragment : BaseFragment(), CategoryView, IMogoVoiceCmdCallBa
|
||||
if (mAdapter.current == index) R.mipmap.icon_search_category_checked else R.mipmap.icon_search_category_unchecked
|
||||
)
|
||||
|
||||
var createWaterMask = BitmapUtils.createWaterMask(
|
||||
context, decodeResource, (index + 1).toString(), R.color.white, 18
|
||||
return BitmapUtils.createWaterMask(
|
||||
context,
|
||||
decodeResource,
|
||||
(index + 1).toString(),
|
||||
R.color.white,
|
||||
resources.getDimensionPixelSize(R.dimen.module_search_marker_number_textSize)
|
||||
)
|
||||
return createWaterMask
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.module.navi.ui.search;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -16,13 +15,12 @@ import com.mogo.map.search.inputtips.IMogoInputtipsSearch;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
|
||||
import com.mogo.module.common.TextWatcherAdapter;
|
||||
import com.mogo.module.navi.R;
|
||||
import com.mogo.module.common.dialog.WMDialog;
|
||||
import com.mogo.module.navi.bean.EntityConvertUtils;
|
||||
import com.mogo.module.navi.bean.SearchPoi;
|
||||
import com.mogo.module.navi.constants.DataConstants;
|
||||
import com.mogo.module.navi.constants.SearchApisHolder;
|
||||
import com.mogo.module.navi.database.AppDataBase;
|
||||
import com.mogo.module.navi.dialog.NoticeDialog;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
|
||||
@@ -45,94 +43,95 @@ import io.reactivex.schedulers.Schedulers;
|
||||
* <p>
|
||||
* 搜搜页逻辑处理
|
||||
*/
|
||||
public class SearchPresenter extends Presenter<SearchView> {
|
||||
public class SearchPresenter extends Presenter< SearchView > {
|
||||
|
||||
private CompositeDisposable mCompositeDisposable;
|
||||
private IMogoMapService mMapService;
|
||||
|
||||
public SearchPresenter(SearchView view) {
|
||||
super(view);
|
||||
public SearchPresenter( SearchView view ) {
|
||||
super( view );
|
||||
mCompositeDisposable = new CompositeDisposable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NonNull LifecycleOwner owner) {
|
||||
super.onCreate(owner);
|
||||
attachSearchBoxTextWatcher(mView.getSearchBox());
|
||||
mMapService = (IMogoMapService) ARouter.getInstance()
|
||||
.build(MogoServicePaths.PATH_SERVICES_MAP)
|
||||
.navigation(getContext());
|
||||
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||
super.onCreate( owner );
|
||||
attachSearchBoxTextWatcher( mView.getSearchBox() );
|
||||
mMapService = ( IMogoMapService ) ARouter.getInstance()
|
||||
.build( MogoServicePaths.PATH_SERVICES_MAP )
|
||||
.navigation( getContext() );
|
||||
loadHistories();
|
||||
}
|
||||
|
||||
private void loadHistories() {
|
||||
Disposable subscribe =
|
||||
AppDataBase.getDatabase(getContext())
|
||||
.poiDao()
|
||||
.getAll()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<List<SearchPoi>>() {
|
||||
@Override public void accept(List<SearchPoi> searchPois) throws Exception {
|
||||
mView.showHistory(searchPois);
|
||||
}
|
||||
});
|
||||
AppDataBase.getDatabase( getContext() )
|
||||
.poiDao()
|
||||
.getAll()
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( new Consumer< List< SearchPoi > >() {
|
||||
@Override
|
||||
public void accept( List< SearchPoi > searchPois ) throws Exception {
|
||||
mView.showHistory( searchPois );
|
||||
}
|
||||
} );
|
||||
|
||||
addDisposable(subscribe);
|
||||
addDisposable( subscribe );
|
||||
}
|
||||
|
||||
private void attachSearchBoxTextWatcher(EditText editText) {
|
||||
if (editText == null) {
|
||||
private void attachSearchBoxTextWatcher( EditText editText ) {
|
||||
if ( editText == null ) {
|
||||
return;
|
||||
}
|
||||
editText.addTextChangedListener(watcherAdapter);
|
||||
editText.addTextChangedListener( watcherAdapter );
|
||||
}
|
||||
|
||||
private final TextWatcherAdapter watcherAdapter = new TextWatcherAdapter() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
public void afterTextChanged( Editable s ) {
|
||||
// 避免 disable 设置内容时触发
|
||||
final String input = s.toString();
|
||||
startSearchPoiByInput(input);
|
||||
startSearchPoiByInput( input );
|
||||
}
|
||||
};
|
||||
|
||||
public void startSearchPoiByInput(String keyword) {
|
||||
public void startSearchPoiByInput( String keyword ) {
|
||||
MogoInputtipsQuery mogoInputtipsQuery = new MogoInputtipsQuery();
|
||||
mogoInputtipsQuery.setKeyword(keyword);
|
||||
mogoInputtipsQuery.setKeyword( keyword );
|
||||
|
||||
MogoLocation lastKnowLocation = SearchApisHolder.getLocationClientApis().getLastKnowLocation();
|
||||
mogoInputtipsQuery.setCity(lastKnowLocation.getCityName());
|
||||
mogoInputtipsQuery.setCityLimit(true);
|
||||
mogoInputtipsQuery.setCity( lastKnowLocation.getCityName() );
|
||||
mogoInputtipsQuery.setCityLimit( true );
|
||||
IMogoInputtipsSearch inputtipsSearch =
|
||||
mMapService.getInputtipsSearch(getContext(), mogoInputtipsQuery);
|
||||
mMapService.getInputtipsSearch( getContext(), mogoInputtipsQuery );
|
||||
|
||||
inputtipsSearch.setInputtipsListener(new IMogoInputtipsListener() {
|
||||
@Override public void onGetInputtips(List<MogoTip> result) {
|
||||
mView.renderSearchPoiResult(result, false);
|
||||
inputtipsSearch.setInputtipsListener( new IMogoInputtipsListener() {
|
||||
@Override
|
||||
public void onGetInputtips( List< MogoTip > result ) {
|
||||
mView.renderSearchPoiResult( result, false );
|
||||
}
|
||||
});
|
||||
} );
|
||||
inputtipsSearch.requestInputtipsAsyn();
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存搜索到的导航地址
|
||||
*/
|
||||
public Single cacheSelectPoiItem(MogoTip tip) {
|
||||
return Single.create(emitter -> {
|
||||
SearchPoi poi = EntityConvertUtils.tipToPoi(tip);
|
||||
public Single cacheSelectPoiItem( MogoTip tip ) {
|
||||
return Single.create( emitter -> {
|
||||
SearchPoi poi = EntityConvertUtils.tipToPoi( tip );
|
||||
//ignore insert result
|
||||
final List<Long> output = AppDataBase.getDatabase(getContext()).poiDao().insert(poi);
|
||||
emitter.onSuccess(output);
|
||||
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||
final List< Long > output = AppDataBase.getDatabase( getContext() ).poiDao().insert( poi );
|
||||
emitter.onSuccess( output );
|
||||
} ).subscribeOn( Schedulers.io() ).observeOn( AndroidSchedulers.mainThread() );
|
||||
}
|
||||
|
||||
public void addDisposable(Disposable disposable) {
|
||||
mCompositeDisposable.add(disposable);
|
||||
public void addDisposable( Disposable disposable ) {
|
||||
mCompositeDisposable.add( disposable );
|
||||
}
|
||||
|
||||
private NoticeDialog noticeDialog;
|
||||
|
||||
private WMDialog dlg;
|
||||
public void deleteAllCachedPoi() {
|
||||
|
||||
//new AlertDialog.Builder( getContext() )
|
||||
@@ -147,40 +146,39 @@ public class SearchPresenter extends Presenter<SearchView> {
|
||||
// .create()
|
||||
// .show();
|
||||
|
||||
noticeDialog = new NoticeDialog(getContext(),"清空历史记录?","立即清空");
|
||||
|
||||
//noticeDialog.setContent("清空历史记录?");
|
||||
//noticeDialog.setPositiveButton("立即清空");
|
||||
|
||||
noticeDialog.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
if (v.getId() == R.id.tv_dialog_ok) {
|
||||
dlg = new WMDialog.Builder( getContext() )
|
||||
.setContent( "清空历史记录?" )
|
||||
.setCancelButton( "取消", ( ( dialog, which ) -> {
|
||||
dialog.dismiss();
|
||||
} ) )
|
||||
.setOkButton( "立即清空", ( ( dialog, which ) -> {
|
||||
deleteAllCachedPoiImpl();
|
||||
}
|
||||
}
|
||||
});
|
||||
noticeDialog.show();
|
||||
dialog.dismiss();
|
||||
} ) )
|
||||
.build();
|
||||
dlg.show();
|
||||
}
|
||||
|
||||
public void hideDialog(){
|
||||
if (noticeDialog != null) {
|
||||
noticeDialog.dismiss();
|
||||
public void hideDialog() {
|
||||
if ( dlg != null ) {
|
||||
dlg.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteAllCachedPoiImpl() {
|
||||
final Disposable disposable = AppDataBase.getDatabase(getContext())
|
||||
.poiDao()
|
||||
.getAll()
|
||||
.map(input -> {
|
||||
return AppDataBase.getDatabase(getContext()).poiDao().deleteAll(input);
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(count -> {
|
||||
mView.showHistory(null);
|
||||
});
|
||||
mCompositeDisposable.add(disposable);
|
||||
final Disposable disposable = AppDataBase.getDatabase( getContext() )
|
||||
.poiDao()
|
||||
.getAll()
|
||||
.map( input -> {
|
||||
return AppDataBase.getDatabase( getContext() ).poiDao().deleteAll( input );
|
||||
} )
|
||||
.subscribeOn( Schedulers.io() )
|
||||
.observeOn( AndroidSchedulers.mainThread() )
|
||||
.subscribe( count -> {
|
||||
mView.showHistory( null );
|
||||
} );
|
||||
mCompositeDisposable.add( disposable );
|
||||
}
|
||||
//
|
||||
///**
|
||||
@@ -214,9 +212,9 @@ public class SearchPresenter extends Presenter<SearchView> {
|
||||
//
|
||||
//
|
||||
|
||||
private void emitterCommonAddress(SingleEmitter<List<Long>> emitter, SearchPoi poi) {
|
||||
private void emitterCommonAddress( SingleEmitter< List< Long > > emitter, SearchPoi poi ) {
|
||||
String poiId = null;
|
||||
switch (mView.getSearchType()) {
|
||||
switch ( mView.getSearchType() ) {
|
||||
case SearchConstants.SEARCH_TYPE_MULTI_HOME:
|
||||
poiId = DataConstants.POI_ID_HOME;
|
||||
break;
|
||||
@@ -224,20 +222,20 @@ public class SearchPresenter extends Presenter<SearchView> {
|
||||
poiId = DataConstants.POI_ID_COMPANY;
|
||||
break;
|
||||
}
|
||||
if (TextUtils.isEmpty(poiId)) {
|
||||
emitter.onError(new IllegalArgumentException("设置类型错误,请重试"));
|
||||
if ( TextUtils.isEmpty( poiId ) ) {
|
||||
emitter.onError( new IllegalArgumentException( "设置类型错误,请重试" ) );
|
||||
return;
|
||||
}
|
||||
if (poi == null) {
|
||||
emitter.onError(new IllegalArgumentException("位置类型转换错误,请重试"));
|
||||
if ( poi == null ) {
|
||||
emitter.onError( new IllegalArgumentException( "位置类型转换错误,请重试" ) );
|
||||
return;
|
||||
}
|
||||
poi.setpId(poiId);
|
||||
poi.setType(mView.getSearchType());
|
||||
poi.setpId( poiId );
|
||||
poi.setType( mView.getSearchType() );
|
||||
//ignore insert result
|
||||
final List<Long> output = AppDataBase.getDatabase(getContext()).poiDao().insert(poi);
|
||||
final List< Long > output = AppDataBase.getDatabase( getContext() ).poiDao().insert( poi );
|
||||
notifyAIAssistCommonAddressChanged();
|
||||
emitter.onSuccess(output);
|
||||
emitter.onSuccess( output );
|
||||
}
|
||||
|
||||
private void notifyAIAssistCommonAddressChanged() {
|
||||
@@ -253,29 +251,31 @@ public class SearchPresenter extends Presenter<SearchView> {
|
||||
//mMapService.getNavi(getContext()).naviTo();
|
||||
}
|
||||
|
||||
public void insert(SearchPoi searchPoi) {
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
AppDataBase.getDatabase(getContext()).poiDao().insert(searchPoi);
|
||||
public void insert( SearchPoi searchPoi ) {
|
||||
Observable.create( new ObservableOnSubscribe< String >() {
|
||||
@Override
|
||||
public void subscribe( ObservableEmitter< String > emitter ) throws Exception {
|
||||
AppDataBase.getDatabase( getContext() ).poiDao().insert( searchPoi );
|
||||
}
|
||||
}).subscribeOn(Schedulers.io()).subscribe();
|
||||
} ).subscribeOn( Schedulers.io() ).subscribe();
|
||||
}
|
||||
|
||||
public void clearHistory(List<SearchPoi> list) {
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
AppDataBase.getDatabase(getContext()).poiDao().deleteAll(list);
|
||||
public void clearHistory( List< SearchPoi > list ) {
|
||||
Observable.create( new ObservableOnSubscribe< String >() {
|
||||
@Override
|
||||
public void subscribe( ObservableEmitter< String > emitter ) throws Exception {
|
||||
AppDataBase.getDatabase( getContext() ).poiDao().deleteAll( list );
|
||||
}
|
||||
}).subscribeOn(Schedulers.io()).subscribe();
|
||||
} ).subscribeOn( Schedulers.io() ).subscribe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NonNull LifecycleOwner owner) {
|
||||
super.onDestroy(owner);
|
||||
if (mView.getSearchBox() != null) {
|
||||
mView.getSearchBox().removeTextChangedListener(watcherAdapter);
|
||||
public void onDestroy( @NonNull LifecycleOwner owner ) {
|
||||
super.onDestroy( owner );
|
||||
if ( mView.getSearchBox() != null ) {
|
||||
mView.getSearchBox().removeTextChangedListener( watcherAdapter );
|
||||
}
|
||||
if (mCompositeDisposable != null && !mCompositeDisposable.isDisposed()) {
|
||||
if ( mCompositeDisposable != null && !mCompositeDisposable.isDisposed() ) {
|
||||
mCompositeDisposable.dispose();
|
||||
mCompositeDisposable = null;
|
||||
}
|
||||
|
||||
@@ -5,27 +5,31 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
|
||||
/**
|
||||
* @author zyz
|
||||
* 2020-01-13.
|
||||
*/
|
||||
public class BitmapUtils {
|
||||
public static Bitmap createWaterMask(Context context, Bitmap src, String text, int textColor,
|
||||
int textSize) {
|
||||
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paint.setColor(ContextCompat.getColor(context, textColor));
|
||||
paint.setTextSize(dp2px(context, textSize));
|
||||
|
||||
paint.setDither(true); // 获取跟清晰的图像采样
|
||||
paint.setFilterBitmap(true);// 过滤一些
|
||||
public static Bitmap createWaterMask( Context context, Bitmap src, String text, int textColor,
|
||||
int textSize ) {
|
||||
Paint paint = new Paint( Paint.ANTI_ALIAS_FLAG );
|
||||
paint.setColor( ContextCompat.getColor( context, textColor ) );
|
||||
paint.setTextSize( textSize );
|
||||
|
||||
paint.setDither( true ); // 获取跟清晰的图像采样
|
||||
paint.setFilterBitmap( true );// 过滤一些
|
||||
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
//创建一个bitmap
|
||||
Rect bounds = new Rect();
|
||||
paint.getTextBounds(text, 0, text.length(), bounds);
|
||||
paint.getTextBounds( text, 0, text.length(), bounds );
|
||||
//// 创建一个新的和SRC长度宽度一样的位图
|
||||
//Bitmap newb = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
////将该图片作为画布
|
||||
@@ -33,38 +37,30 @@ public class BitmapUtils {
|
||||
////在画布 0,0坐标上开始绘制原始图片
|
||||
Bitmap.Config config = src.getConfig();
|
||||
|
||||
if (config == null) {
|
||||
if ( config == null ) {
|
||||
config = android.graphics.Bitmap.Config.ARGB_8888;
|
||||
}
|
||||
// 绘制文字
|
||||
Bitmap ret = src.copy(config, true);
|
||||
Bitmap ret = src.copy( config, true );
|
||||
//Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
Canvas canvas = new Canvas(ret);
|
||||
Canvas canvas = new Canvas( ret );
|
||||
|
||||
int i = Integer.parseInt(text);
|
||||
int i = Integer.parseInt( text );
|
||||
|
||||
if (isLow(context)) {
|
||||
if (i == 1) {
|
||||
canvas.drawText(text, (width - bounds.width() * 2) / 2.0F,
|
||||
(float) (bounds.height() * 2.4),
|
||||
paint);
|
||||
} else {
|
||||
canvas.drawText(text, (width - bounds.width()) / 2.0F,
|
||||
(float) (bounds.height() * 1.9),
|
||||
paint);
|
||||
}
|
||||
float x, y;
|
||||
|
||||
if ( i == 1 ) {
|
||||
// "1" 有点偏右
|
||||
x = ( width - bounds.width() ) / 2 - bounds.width() / 2;
|
||||
} else {
|
||||
if (i == 1) {
|
||||
canvas.drawText(text, (width - bounds.width()*1.8F) / 2.0F,
|
||||
(float) (bounds.height() * 1.9),
|
||||
paint);
|
||||
}else {
|
||||
|
||||
canvas.drawText(text, (width - bounds.width()*1.2F) / 2.0F,
|
||||
(float) (bounds.height() * 1.9),
|
||||
paint);
|
||||
}
|
||||
x = ( width - bounds.width() ) / 2;
|
||||
}
|
||||
if ( CarSeries.CAR_SERIES_F80X == CarSeries.getSeries() ) {
|
||||
y = ( height - bounds.height() ) / 2 + bounds.height() - 5.5f;
|
||||
} else {
|
||||
y = ( height - bounds.height() ) / 2 + bounds.height() - 2.5f;
|
||||
}
|
||||
canvas.drawText( text, x, y, paint );
|
||||
|
||||
// 保存
|
||||
//canvas.save();
|
||||
@@ -72,13 +68,4 @@ public class BitmapUtils {
|
||||
// 存储
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int dp2px(Context context, float dp) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dp * scale + 0.5f);
|
||||
}
|
||||
|
||||
public static boolean isLow(Context context) {
|
||||
return context.getResources().getDisplayMetrics().density < 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/dp_790"
|
||||
android:layout_height="@dimen/dp_440"
|
||||
app:cardPreventCornerOverlap="false"
|
||||
|
||||
android:orientation="vertical"
|
||||
app:cardBackgroundColor="#3F4057"
|
||||
app:cardCornerRadius="@dimen/dp_20"
|
||||
>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dialog_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_56"
|
||||
android:layout_marginTop="@dimen/dp_134"
|
||||
android:text="是否退出导航?"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_40"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dialog_ok"
|
||||
android:layout_width="@dimen/dp_395"
|
||||
android:layout_height="@dimen/dp_128"
|
||||
android:background="@drawable/shape_react_blue_grident"
|
||||
android:gravity="center"
|
||||
android:text="确认"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/dp_40"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dialog_cancel"
|
||||
android:layout_width="@dimen/dp_395"
|
||||
android:layout_height="@dimen/dp_128"
|
||||
android:background="@drawable/shape_react_gray_grident"
|
||||
android:gravity="center"
|
||||
android:text="取消"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/dp_40"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -4,10 +4,10 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/moudle_search_fragment_padding"
|
||||
android:paddingLeft="@dimen/moudle_search_fragment_padding"
|
||||
android:paddingRight="@dimen/moudle_search_fragment_padding"
|
||||
android:paddingTop="@dimen/moudle_search_fragment_padding_top"
|
||||
android:paddingBottom="@dimen/module_search_fragment_padding"
|
||||
android:paddingLeft="@dimen/module_search_fragment_padding"
|
||||
android:paddingRight="@dimen/module_search_fragment_padding"
|
||||
android:paddingTop="@dimen/module_search_fragment_padding_top"
|
||||
android:clickable="true"
|
||||
tools:context=".ui.search.SearchFragment"
|
||||
style="@style/amap_fragment_container_padding_style"
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/ll_navi_search"
|
||||
android:layout_width="@dimen/module_search_dp_838"
|
||||
android:layout_height="@dimen/moudle_search_et_hight"
|
||||
android:layout_height="@dimen/module_search_et_hight"
|
||||
android:background="@drawable/shape_round_gray"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
@@ -109,11 +109,11 @@
|
||||
tools:showIn="@layout/fragment_search"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="@dimen/moudle_search_iv_back_hight"
|
||||
android:layout_width="@dimen/module_search_iv_back_hight"
|
||||
android:id="@+id/iv_navi_back"
|
||||
android:layout_height="@dimen/moudle_search_iv_back_hight"
|
||||
android:layout_marginLeft="@dimen/moudle_search_iv_back_margin_left"
|
||||
android:layout_marginRight="@dimen/moudle_search_iv_back_margin_right"
|
||||
android:layout_height="@dimen/module_search_iv_back_hight"
|
||||
android:layout_marginLeft="@dimen/module_search_iv_back_margin_left"
|
||||
android:layout_marginRight="@dimen/module_search_iv_back_margin_right"
|
||||
android:src="@mipmap/icon_back"
|
||||
/>
|
||||
<EditText
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<LinearLayout
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/ll_navi_search"
|
||||
android:layout_width="@dimen/moudle_search_et_width"
|
||||
android:layout_height="@dimen/moudle_search_et_hight"
|
||||
android:layout_width="@dimen/module_search_et_width"
|
||||
android:layout_height="@dimen/module_search_et_hight"
|
||||
android:background="@drawable/shape_round_gray"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
@@ -22,11 +22,11 @@
|
||||
tools:showIn="@layout/fragment_search"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="@dimen/moudle_search_iv_back_hight"
|
||||
android:layout_width="@dimen/module_search_iv_back_hight"
|
||||
android:id="@+id/iv_navi_back"
|
||||
android:layout_height="@dimen/moudle_search_iv_back_hight"
|
||||
android:layout_marginLeft="@dimen/moudle_search_iv_back_margin_left"
|
||||
android:layout_marginRight="@dimen/moudle_search_iv_back_margin_right"
|
||||
android:layout_height="@dimen/module_search_iv_back_hight"
|
||||
android:layout_marginLeft="@dimen/module_search_iv_back_margin_left"
|
||||
android:layout_marginRight="@dimen/module_search_iv_back_margin_right"
|
||||
android:src="@mipmap/icon_back"
|
||||
/>
|
||||
<TextView
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/ll_navi_search"
|
||||
android:layout_width="@dimen/moudle_search_et_width"
|
||||
android:layout_height="@dimen/moudle_search_et_hight"
|
||||
android:layout_width="@dimen/module_search_et_width"
|
||||
android:layout_height="@dimen/module_search_et_hight"
|
||||
android:background="@drawable/shape_round_gray"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
@@ -13,11 +13,11 @@
|
||||
tools:showIn="@layout/fragment_search"
|
||||
>
|
||||
<ImageView
|
||||
android:layout_width="@dimen/moudle_search_iv_back_hight"
|
||||
android:layout_width="@dimen/module_search_iv_back_hight"
|
||||
android:id="@+id/iv_navi_back"
|
||||
android:layout_height="@dimen/moudle_search_iv_back_hight"
|
||||
android:layout_marginLeft="@dimen/moudle_search_iv_back_margin_left"
|
||||
android:layout_marginRight="@dimen/moudle_search_iv_back_margin_right"
|
||||
android:layout_height="@dimen/module_search_iv_back_hight"
|
||||
android:layout_marginLeft="@dimen/module_search_iv_back_margin_left"
|
||||
android:layout_marginRight="@dimen/module_search_iv_back_margin_right"
|
||||
android:src="@mipmap/icon_back"
|
||||
/>
|
||||
<EditText
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
<resources>
|
||||
<!-- module_main_activity_main.xml-->
|
||||
|
||||
<dimen name="moudle_search_fragment_padding" >32px</dimen>
|
||||
<dimen name="moudle_search_fragment_padding_top">32px</dimen>
|
||||
<dimen name="moudle_search_et_width">640px</dimen>
|
||||
<dimen name="moudle_search_et_hight">64px</dimen>
|
||||
<dimen name="moudle_search_iv_back_hight">42px</dimen>
|
||||
<dimen name="moudle_search_iv_back_margin_left">12px</dimen>
|
||||
<dimen name="moudle_search_iv_back_margin_right">10px</dimen>
|
||||
<dimen name="module_search_fragment_padding" >32px</dimen>
|
||||
<dimen name="module_search_fragment_padding_top">32px</dimen>
|
||||
<dimen name="module_search_et_width">640px</dimen>
|
||||
<dimen name="module_search_et_hight">64px</dimen>
|
||||
<dimen name="module_search_iv_back_hight">42px</dimen>
|
||||
<dimen name="module_search_iv_back_margin_left">12px</dimen>
|
||||
<dimen name="module_search_iv_back_margin_right">10px</dimen>
|
||||
<dimen name="module_search_et_margin_right">30px</dimen>
|
||||
<dimen name="module_search_et_text_size">22px</dimen>
|
||||
<dimen name="module_search_btn_width">142px</dimen>
|
||||
@@ -45,5 +45,6 @@
|
||||
<dimen name="module_search_category_margin_bottom">96px</dimen>
|
||||
<dimen name="module_search_dp_104">56px</dimen>
|
||||
<dimen name="module_search_strategy_name_width" >100px</dimen>
|
||||
<dimen name="module_search_marker_number_textSize">18dp</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<dimen name="moudle_search_fragment_padding">@dimen/dp_60</dimen>
|
||||
<dimen name="moudle_search_fragment_padding_top">@dimen/dp_40</dimen>
|
||||
<dimen name="moudle_search_et_width">600dp</dimen>
|
||||
<dimen name="moudle_search_et_hight">@dimen/dp_120</dimen>
|
||||
<dimen name="moudle_search_iv_back_hight">@dimen/dp_80</dimen>
|
||||
<dimen name="moudle_search_iv_back_margin_left">@dimen/dp_24</dimen>
|
||||
<dimen name="moudle_search_iv_back_margin_right">@dimen/dp_20</dimen>
|
||||
<dimen name="module_search_et_margin_right">@dimen/dp_50</dimen>
|
||||
<dimen name="module_search_et_text_size">40px</dimen>
|
||||
<dimen name="module_search_btn_width">266px</dimen>
|
||||
<dimen name="module_search_btn_right_margin">8px</dimen>
|
||||
<dimen name="module_search_txt_big">40px</dimen>
|
||||
<dimen name="module_search_btn_height">104px</dimen>
|
||||
<dimen name="module_search_navi_home_width">568px</dimen>
|
||||
<dimen name="module_search_navi_home_height">120px</dimen>
|
||||
<dimen name="module_search_navi_home_margin_left">32px</dimen>
|
||||
<dimen name="module_search_navi_home_padding_left">75px</dimen>
|
||||
<dimen name="module_search_dp_72">72px</dimen>
|
||||
<dimen name="module_search_dp_75">75px</dimen>
|
||||
<dimen name="module_search_dp_778">778px</dimen>
|
||||
<dimen name="module_search_dp_1200">1200px</dimen>
|
||||
<dimen name="module_search_dp_32">32px</dimen>
|
||||
<dimen name="module_search_dp_40">40px</dimen>
|
||||
<dimen name="module_search_dp_60">60px</dimen>
|
||||
<dimen name="module_search_dp_37">37px</dimen>
|
||||
<dimen name="module_search_dp_268">268px</dimen>
|
||||
<dimen name="module_search_dp_236">236px</dimen>
|
||||
<dimen name="module_search_dp_180">180px</dimen>
|
||||
<dimen name="module_search_dp_80">80px</dimen>
|
||||
<dimen name="module_search_dp_70">70px</dimen>
|
||||
<dimen name="module_search_25sp">25sp</dimen>
|
||||
<dimen name="module_search_dp_42">42px</dimen>
|
||||
<dimen name="module_search_dp_160">160px</dimen>
|
||||
<dimen name="module_search_dp_150">150px</dimen>
|
||||
<dimen name="module_search_180dp">180dp</dimen>
|
||||
<dimen name="module_search_dp_120">120px</dimen>
|
||||
<dimen name="module_search_txt_setting_width">45px</dimen>
|
||||
<dimen name="module_search_dp_838">838px</dimen>
|
||||
<dimen name="module_search_category_margin_bottom">184px</dimen>
|
||||
<dimen name="module_search_dp_104">104px</dimen>
|
||||
<dimen name="module_search_strategy_name_width">154px</dimen>
|
||||
<dimen name="module_search_marker_number_textSize">32dp</dimen>
|
||||
|
||||
</resources>
|
||||
@@ -4,13 +4,13 @@
|
||||
<dimen name="fragment_left_margin">@dimen/dp_60</dimen>
|
||||
<dimen name="txt_title">@dimen/sp_40</dimen>
|
||||
<dimen name="txt_large">25sp</dimen>
|
||||
<dimen name="moudle_search_fragment_padding" >@dimen/dp_60</dimen>
|
||||
<dimen name="moudle_search_fragment_padding_top">@dimen/dp_40</dimen>
|
||||
<dimen name="moudle_search_et_width">600dp</dimen>
|
||||
<dimen name="moudle_search_et_hight">@dimen/dp_120</dimen>
|
||||
<dimen name="moudle_search_iv_back_hight">@dimen/dp_80</dimen>
|
||||
<dimen name="moudle_search_iv_back_margin_left">@dimen/dp_24</dimen>
|
||||
<dimen name="moudle_search_iv_back_margin_right">@dimen/dp_20</dimen>
|
||||
<dimen name="module_search_fragment_padding">@dimen/dp_60</dimen>
|
||||
<dimen name="module_search_fragment_padding_top">@dimen/dp_40</dimen>
|
||||
<dimen name="module_search_et_width">600dp</dimen>
|
||||
<dimen name="module_search_et_hight">@dimen/dp_120</dimen>
|
||||
<dimen name="module_search_iv_back_hight">@dimen/dp_80</dimen>
|
||||
<dimen name="module_search_iv_back_margin_left">@dimen/dp_24</dimen>
|
||||
<dimen name="module_search_iv_back_margin_right">@dimen/dp_20</dimen>
|
||||
<dimen name="module_search_et_margin_right">@dimen/dp_50</dimen>
|
||||
<dimen name="module_search_et_text_size">40px</dimen>
|
||||
<dimen name="module_search_btn_width">266px</dimen>
|
||||
@@ -45,6 +45,7 @@
|
||||
<dimen name="module_search_category_margin_bottom">184px</dimen>
|
||||
<dimen name="module_search_dp_104">104px</dimen>
|
||||
<dimen name="module_search_strategy_name_width" >154px</dimen>
|
||||
<dimen name="module_search_marker_number_textSize">32dp</dimen>
|
||||
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user