Android Open Source - Android_OSM_offlinemap Marker Factory






From Project

Back to project page Android_OSM_offlinemap.

License

The source code is released under:

GNU General Public License

If you think the Android project Android_OSM_offlinemap listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.vellut.offlinemap;
/*from  w w w  .j  a  v a2s .co  m*/
import java.util.HashMap;
import java.util.Map;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;

public class MarkerFactory {
  private Map<Integer, Drawable> normalIcons;
  private Map<Integer, Drawable> starIcons;
  
  public int defaultSize;
  
  @SuppressLint("UseSparseArrays")
  public MarkerFactory(Context context) {
    normalIcons = new HashMap<Integer, Drawable>();
    starIcons = new HashMap<Integer, Drawable>();
    defaultSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
        Utils.DEFAULT_MARKER_SIZE_DP, context.getResources().getDisplayMetrics());
  }
  
  public Drawable getNormalMarker(int color) {
    Drawable icon = normalIcons.get(color);
    if(icon == null) {
      // divide size by 2: CricleDrawable takes radius as input
      icon = new CircleDrawable(color, defaultSize / 2);
      normalIcons.put(color, icon);
    }
    return icon;
  }
  
  public Drawable getStarMarker(int color) {
    Drawable icon = starIcons.get(color);
    if(icon == null) {
      icon = new StarDrawable(color, (int) (defaultSize * 1.25));
      starIcons.put(color, icon);
    }
    return icon;
  }
  
  public Drawable getMarker(MapAnnotation mapAnnotation) {
    if(mapAnnotation.isBookmarked) {
      return getStarMarker(mapAnnotation.color);
    } else {
      return getNormalMarker(mapAnnotation.color);
    }
  }
  
  
}




Java Source Code List

com.vellut.offlinemap.CircleDrawable.java
com.vellut.offlinemap.ColorPickerAdapter.java
com.vellut.offlinemap.CopyrightMapView.java
com.vellut.offlinemap.CurrentPositionDrawable.java
com.vellut.offlinemap.CurrentPosition.java
com.vellut.offlinemap.FileExplorerActivity.java
com.vellut.offlinemap.MainActivity.java
com.vellut.offlinemap.MapAnnotationEditActivity.java
com.vellut.offlinemap.MapAnnotation.java
com.vellut.offlinemap.MapData.java
com.vellut.offlinemap.MarkerFactory.java
com.vellut.offlinemap.StarDrawable.java
com.vellut.offlinemap.Utils.java