kopia lustrzana https://github.com/sh123/codec2_talkie
Overlay icons
rodzic
222f750ba6
commit
384be9fcc4
|
@ -2,7 +2,11 @@ package com.radio.codec2talkie.protocol.aprs.tools;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.radio.codec2talkie.R;
|
||||
|
@ -13,6 +17,7 @@ public class AprsSymbolTable {
|
|||
|
||||
private final ArrayList<Bitmap> _primaryTableIcons;
|
||||
private final ArrayList<Bitmap> _secondaryTableIcons;
|
||||
private final ArrayList<Bitmap> _overlayTableIcons;
|
||||
|
||||
private final int _cellWidth = 24;
|
||||
private final int _cellHeight = 24;
|
||||
|
@ -38,18 +43,33 @@ public class AprsSymbolTable {
|
|||
ImageView imageViewSecondary = new ImageView(context);
|
||||
imageViewSecondary.setImageResource(R.drawable.aprs_symbols_24_1);
|
||||
_secondaryTableIcons = Load(imageViewSecondary, _cellWidth, _cellHeight, _cntWidth, _cntHeight);
|
||||
|
||||
ImageView imageViewOverlay = new ImageView(context);
|
||||
imageViewOverlay.setImageResource(R.drawable.aprs_symbols_24_2);
|
||||
_overlayTableIcons = Load(imageViewOverlay, _cellWidth, _cellHeight, _cntWidth, _cntHeight);
|
||||
}
|
||||
|
||||
public Bitmap bitmapFromSymbol(String symbolCode) {
|
||||
if (symbolCode.length() != 2) return null;
|
||||
char table = symbolCode.charAt(0);
|
||||
char symbol = symbolCode.charAt(1);
|
||||
int index = (int)symbol - 33;
|
||||
if (index < 0 || index >= (_cntWidth * _cntHeight)) return null;
|
||||
int symbolIconIndex = (int)symbol - 33;
|
||||
int overlayIconIndex = (int)table - 33;
|
||||
if (symbolIconIndex < 0 || symbolIconIndex >= (_cntWidth * _cntHeight)) return null;
|
||||
if (table == '/') {
|
||||
return _primaryTableIcons.get(index);
|
||||
return _primaryTableIcons.get(symbolIconIndex);
|
||||
} else if (table == '\\') {
|
||||
return _secondaryTableIcons.get(symbolIconIndex);
|
||||
}
|
||||
return _secondaryTableIcons.get(index);
|
||||
if (overlayIconIndex < 0 || overlayIconIndex >= (_cntWidth * _cntHeight)) return null;
|
||||
Bitmap icon = _secondaryTableIcons.get(symbolIconIndex);
|
||||
Bitmap overlayIcon = _overlayTableIcons.get(overlayIconIndex);
|
||||
Bitmap bmOverlay = Bitmap.createBitmap(icon.getWidth() * 2, icon.getHeight() * 2, icon.getConfig());
|
||||
Canvas canvas = new Canvas(bmOverlay);
|
||||
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
|
||||
canvas.drawBitmap(icon, 0, 0, paint);
|
||||
canvas.drawBitmap(overlayIcon, 0, 0, paint);
|
||||
return bmOverlay;
|
||||
}
|
||||
|
||||
private ArrayList<Bitmap> Load(ImageView imageView, int cellWidth, int cellHeight, int cntWidth, int cntHeight) {
|
||||
|
|
|
@ -46,7 +46,7 @@ public class LogItemGroupHolder extends RecyclerView.ViewHolder {
|
|||
public void bind(LogItemGroup group) {
|
||||
@SuppressLint("MissingPermission") Location loc = _locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
if (loc == null) {
|
||||
_logItemViewDistance.setText(R.string.log_item_group_holder_unknown_km);
|
||||
_logItemViewDistance.setText("");
|
||||
} else {
|
||||
double distanceKm = Position.distanceTo(loc.getLatitude(), loc.getLongitude(), loc.getAltitude(),
|
||||
group.getLatitude(), group.getLongitude(), group.getAltitudeMeters()) / 1000.0;
|
||||
|
|
Ładowanie…
Reference in New Issue