Android Open Source - egotrip Metadata Manager






From Project

Back to project page egotrip.

License

The source code is released under:

Apache License

If you think the Android project egotrip 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 net.myegotrip.egotrip.metadata;
//w w w .  j av a 2 s. c  om
import java.util.ArrayList;

import net.myegotrip.egotrip.DbTools;
import net.myegotrip.egotrip.LocationUpdate;
import android.content.Context;

public class MetadataManager {

  private static MetadataManager instance = null;

  private DbTools db;


  private MetadataManager(Context context) {
    db = DbTools.getDbTools(context);
  }

  public static MetadataManager getMetadataManager(Context context) {
    if (instance == null) {
      instance = new MetadataManager(context);
    }
    return instance;
  }

  /**
   * attach new metadata to a location
   * 
   * @param l
   *            LocationUpdate, must be in the database or an exception will
   *            be thrown
   * @param m
   *            new Metadata Object, should not be in the database yet
   */
  public void attachMetadata(LocationUpdate l, EgotripMetadata m) {
    db.insertMetadata(l,m);
  }

  
  public void deleteMetadata(EgotripMetadata m){
    db.markDeleted(m);
  }
  
  
  /**
   * returns all metadata of this LocationUpdate
   * 
   * @param l
   * @return
   */
  public ArrayList<EgotripMetadata> getMetadata(LocationUpdate l) {
    return getMetadata(l, null);
  }

  /**
   * return metadata of certain type
   * 
   * @param l
   * @param type
   * @return
   */
  public ArrayList<EgotripMetadata> getMetadata(LocationUpdate l, String type) {
    String and="";
    if(type!=null){
      and=" AND metadatatype='"+type+"'";
    }
    return db.getMetadata("locationid = "+l.getLocalID()+and);
  }

  // helper functions for known metadata types

  /**
   * return the first text attachment (since we probably only have one)
   * returns null if there is no Text attached
   */
  public Text getTextMetadata(LocationUpdate l) {
    ArrayList<EgotripMetadata> meta = getMetadata(l, EgotripMetadata.TEXT);
    if (meta.size() > 0) {
      return (Text) meta.get(0);
    }
    return null;
  }

  /**
   * return first image metadata (since we probably only have one)
   * 
   * @param l
   * @return Image or null
   */
  public Image getImageMetadata(LocationUpdate l) {
    ArrayList<EgotripMetadata> meta = getMetadata(l, EgotripMetadata.IMAGE);
    if (meta.size() > 0) {
      return (Image) meta.get(0);
    }
    return null;
  }

  /**
   * return first image metadata (since we probably only have one)
   * 
   * @param l
   * @return Image or null
   */
  public Icon getIconMetadata(LocationUpdate l) {
    ArrayList<EgotripMetadata> meta = getMetadata(l, EgotripMetadata.ICON);
    if (meta.size() > 0) {
      if (meta.get(0) instanceof Icon)return (Icon) meta.get(0);
    }
    return null;
  }

}




Java Source Code List

net.myegotrip.egotrip.CommonGPSServiceFunctions.java
net.myegotrip.egotrip.ControlHandler.java
net.myegotrip.egotrip.ControlWindow.java
net.myegotrip.egotrip.DbListener.java
net.myegotrip.egotrip.DbTools.java
net.myegotrip.egotrip.DownloadProgressHandler.java
net.myegotrip.egotrip.FallbackDefaults.java
net.myegotrip.egotrip.GPSService.java
net.myegotrip.egotrip.Installation.java
net.myegotrip.egotrip.LocationUpdate.java
net.myegotrip.egotrip.MapViewActivity.java
net.myegotrip.egotrip.PrefActivity.java
net.myegotrip.egotrip.ReleaseConfig.java
net.myegotrip.egotrip.StartupActivity.java
net.myegotrip.egotrip.TaskDoneListener.java
net.myegotrip.egotrip.Tools.java
net.myegotrip.egotrip.TripManager.java
net.myegotrip.egotrip.help.HelpActivity.java
net.myegotrip.egotrip.help.TopicActivity.java
net.myegotrip.egotrip.image.ImageHandler.java
net.myegotrip.egotrip.map.MockLocationProvider.java
net.myegotrip.egotrip.map.PlacemarkOverlay.java
net.myegotrip.egotrip.map.Placemark.java
net.myegotrip.egotrip.map.RouteOverlay.java
net.myegotrip.egotrip.map.RoutePoint.java
net.myegotrip.egotrip.map.Trip.java
net.myegotrip.egotrip.metadata.EgotripMetadata.java
net.myegotrip.egotrip.metadata.GenericMetadata.java
net.myegotrip.egotrip.metadata.Icon.java
net.myegotrip.egotrip.metadata.Image.java
net.myegotrip.egotrip.metadata.MetadataManager.java
net.myegotrip.egotrip.metadata.Text.java
net.myegotrip.egotrip.net.BetaUpdateManager.java
net.myegotrip.egotrip.net.ProtocolConstants.java
net.myegotrip.egotrip.net.ServerReply.java
net.myegotrip.egotrip.net.Uploader.java
net.myegotrip.egotrip.profile.ProfileActivity.java
net.myegotrip.egotrip.profile.ProfilePrefActivity.java
net.myegotrip.egotrip.profile.ProfileView.java
net.myegotrip.egotrip.utils.DebugActivity.java
net.myegotrip.egotrip.utils.Debug.java
net.myegotrip.egotrip.utils.GuiUtils.java
net.myegotrip.egotrip.utils.IconItem.java
net.myegotrip.egotrip.utils.TwoDScrollView.java
net.myegotrip.egotrip.utils.XYScaleGestureDetector.java