Search in sources :

Example 1 with IconsCache

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();
}
Also used : Drawable(android.graphics.drawable.Drawable) IconsCache(net.osmand.core.samples.android.sample1.IconsCache) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) QuadPoint(net.osmand.data.QuadPoint)

Example 2 with IconsCache

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));
}
Also used : Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) IconsCache(net.osmand.core.samples.android.sample1.IconsCache) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint)

Example 3 with IconsCache

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);
}
Also used : OsmandRegions(net.osmand.map.OsmandRegions) Handler(android.os.Handler) ResourceManager(net.osmand.core.samples.android.sample1.resources.ResourceManager) QuickSearchHelper(net.osmand.core.samples.android.sample1.search.QuickSearchHelper)

Example 4 with IconsCache

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));
    }
}
Also used : SampleApplication(net.osmand.core.samples.android.sample1.SampleApplication) IconsCache(net.osmand.core.samples.android.sample1.IconsCache)

Example 5 with IconsCache

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());
}
Also used : SampleApplication(net.osmand.core.samples.android.sample1.SampleApplication) IconsCache(net.osmand.core.samples.android.sample1.IconsCache)

Aggregations

IconsCache (net.osmand.core.samples.android.sample1.IconsCache)4 Drawable (android.graphics.drawable.Drawable)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 SampleApplication (net.osmand.core.samples.android.sample1.SampleApplication)2 SuppressLint (android.annotation.SuppressLint)1 Handler (android.os.Handler)1 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 ResourceManager (net.osmand.core.samples.android.sample1.resources.ResourceManager)1 QuickSearchHelper (net.osmand.core.samples.android.sample1.search.QuickSearchHelper)1 QuadPoint (net.osmand.data.QuadPoint)1 OsmandRegions (net.osmand.map.OsmandRegions)1