use of net.osmand.core.samples.android.sample1.IconsCache in project Osmand by osmandapp.
the class MapContextMenuFragment method buildHeader.
private void buildHeader() {
IconsCache iconsCache = getMyApplication().getIconsCache();
final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
Drawable icon = menu.getLeftIcon();
int iconId = menu.getLeftIconId();
if (icon != null) {
iconView.setImageDrawable(icon);
iconLayout.setVisibility(View.VISIBLE);
} else if (iconId != 0) {
iconView.setImageDrawable(iconsCache.getOsmandIcon(iconId, !nightMode ? R.color.osmand_orange : R.color.osmand_orange_dark));
iconLayout.setVisibility(View.VISIBLE);
} else {
iconLayout.setVisibility(View.GONE);
}
setAddressLocation();
}
use of net.osmand.core.samples.android.sample1.IconsCache in project Osmand by osmandapp.
the class MapMultiSelectionMenuFragment method buildHeader.
private void buildHeader(View view, MenuObject item, MainActivity mainActivity) {
AndroidUtils.setBackground(mainActivity, view, !menu.isLight(), R.drawable.expandable_list_item_background_light, 0);
IconsCache iconsCache = mainActivity.getMyApplication().getIconsCache();
final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
Drawable icon = item.getLeftIcon();
int iconId = item.getLeftIconId();
if (icon != null) {
iconView.setImageDrawable(icon);
iconLayout.setVisibility(View.VISIBLE);
} else if (iconId != 0) {
iconView.setImageDrawable(iconsCache.getOsmandIcon(iconId, menu.isLight() ? R.color.osmand_orange : R.color.osmand_orange_dark));
iconLayout.setVisibility(View.VISIBLE);
} else {
iconLayout.setVisibility(View.GONE);
}
// Text line 1
TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);
AndroidUtils.setTextPrimaryColor(mainActivity, line1, !menu.isLight());
line1.setText(item.getTitleStr());
// Text line 2
TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2);
AndroidUtils.setTextSecondaryColor(mainActivity, line2, !menu.isLight());
line2.setText(item.getTypeStr());
Drawable slIcon = item.getTypeIcon();
line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null);
line2.setCompoundDrawablePadding(dpToPx(5f));
}
use of net.osmand.core.samples.android.sample1.IconsCache in project Osmand by osmandapp.
the class SampleApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
OsmandResources.init(this);
locationProvider = new SampleLocationProvider(this);
searchUICore = new QuickSearchHelper(this);
geocodingLookupService = new GeocodingLookupService(this);
resourceManager = new ResourceManager(this);
regions = new OsmandRegions();
updateRegionVars();
indexRegionsBoundaries();
uiHandler = new Handler();
poiTypes = MapPoiTypes.getDefaultNoInit();
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
initPoiTypes();
}
// Initialize native core
if (NativeCore.isAvailable() && !NativeCore.isLoaded()) {
assetsCustom = CoreResourcesFromAndroidAssets.loadFromCurrentApplication(this);
NativeCore.load(assetsCustom);
}
Logger.get().setSeverityLevelThreshold(LogSeverityLevel.Debug);
iconsCache = new IconsCache(assetsCustom, this);
}
use of net.osmand.core.samples.android.sample1.IconsCache in project Osmand by osmandapp.
the class DirectionDrawable method setColorId.
public void setColorId(int clrId) {
// R.color.color_ok, R.color.color_unknown, R.color.color_warning
if (arrowImage != null) {
IconsCache iconsCache = ((SampleApplication) ctx.getApplicationContext()).getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, clrId);
} else {
paintRouteDirection.setColor(ctx.getResources().getColor(clrId));
}
}
use of net.osmand.core.samples.android.sample1.IconsCache in project Osmand by osmandapp.
the class DirectionDrawable method setImage.
public void setImage(int resourceId, int clrId) {
IconsCache iconsCache = ((SampleApplication) ctx.getApplicationContext()).getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, clrId);
this.resourceId = resourceId;
onBoundsChange(getBounds());
}
Aggregations