opt
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user