当前位置: 首页>>代码示例>>Java>>正文


Java LocusUtils类代码示例

本文整理汇总了Java中locus.api.android.utils.LocusUtils的典型用法代码示例。如果您正苦于以下问题:Java LocusUtils类的具体用法?Java LocusUtils怎么用?Java LocusUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocusUtils类属于locus.api.android.utils包,在下文中一共展示了LocusUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createControlStartScreen

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**************************************************/

    private ControlViewGroup createControlStartScreen() {
        // generate start screen layout
        View layout = mInflater.inflate(
                R.layout.screen_empty_with_button, null);
        ControlViewGroup cvStartScreen = parseLayout(layout);
        if (cvStartScreen == null) {
            return null;
        }

        // set click listener
        ControlView btnStartLocus =
                cvStartScreen.findViewById(R.id.button_start_locus);
        btnStartLocus.setOnClickListener(
                new ControlView.OnClickListener() {

                    @Override
                    public void onClick() {
                        LocusUtils.callStartLocusMap(mContext);
                    }
                });

        // return created controller
        return cvStartScreen;
    }
 
开发者ID:asamm,项目名称:locus-addon-smartwatch2,代码行数:27,代码来源:ControlSmartWatch2.java

示例2: onReceive

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
 * Major function that handle data received over intent. From this intent
 * are grabbed all information that Locus send and are redirected back
 * to your own handler.
 * @param ctx current context
 * @param intent received intent
 * @param handler handler for result
 */
public void onReceive(final Context ctx, Intent intent, OnUpdate handler) {
       // check handler
       if (handler == null) {
           throw new IllegalArgumentException("Incorrect arguments");
       }

	// check parameters and notify if any problem happen
	if (ctx == null || intent == null) {
		handler.onIncorrectData();
		return;
	}
	
	// prepare data container
	UpdateContainer update = PeriodicUpdatesFiller.intentToUpdate(intent, this);
	
	// send update back by handler (together with LocusVersion object)
	handler.onUpdate(LocusUtils.createLocusVersion(ctx, intent), update);
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:27,代码来源:PeriodicUpdatesHandler.java

示例3: getCount

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
 * Compute count of existing field notes.
 * @param ctx existing context
 * @param lv active Locus version
 * @return number of existing field notes
 */
public static int getCount(Context ctx, LocusUtils.LocusVersion lv)
        throws RequiredVersionMissingException {
    // get parameters for query
    Uri cpUri = getUriFieldNoteTable(lv);

    // execute request
    Cursor c = null;
    try {
        c = ctx.getContentResolver().query(cpUri,
                new String[] {ColFieldNote.ID},
                null, null, null);
        if (c == null) {
            return 0;
        } else {
            return c.getCount();
        }
    } finally {
        Utils.closeQuietly(c);
    }
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:27,代码来源:FieldNotesHelper.java

示例4: delete

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
 * Delete field note specified by it's ID
 * @param ctx existing context
 * @param lv active Locus version
 * @param fieldNoteId ID of field note to delete
 * @return <code>true</code> if deleted successfully, otherwise <code>false</code>
 */
public static boolean delete(Context ctx, LocusUtils.LocusVersion lv, long fieldNoteId)
        throws RequiredVersionMissingException {
    // get parameters for query
    Uri cpUri = getUriFieldNoteTable(lv);

    // execute request
    int res = ctx.getContentResolver().delete(cpUri,
            ColFieldNote.ID + "=?",
            new String[] {Long.toString(fieldNoteId)}
    );

    // delete images
    deleteImages(ctx, lv, fieldNoteId);

    // return result
    return res == 1;
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:25,代码来源:FieldNotesHelper.java

示例5: insert

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
  * Simple insert of one field note
  * @param ctx existing context
  * @param lv active Locus version
  * @param gcFn field note that should be inserted.
  * @return <code>true</code> if insert was successful, otherwise false
  */
 public static boolean insert(Context ctx, LocusUtils.LocusVersion lv,
FieldNote gcFn) throws RequiredVersionMissingException {
     // get parameters for query
     Uri cpUri = getUriFieldNoteTable(lv);

     // create data container
     ContentValues cv = createContentValues(gcFn);

     // execute request
     Uri newRow = ctx.getContentResolver().insert(cpUri, cv);
     if (newRow != null) {
         // set new ID to field note
         gcFn.setId(Utils.parseLong(newRow.getLastPathSegment()));

         // insert also images
         storeAllImages(ctx, lv, gcFn);

         // return result
         return true;
     }
     return false;
 }
 
开发者ID:asamm,项目名称:locus-api,代码行数:30,代码来源:FieldNotesHelper.java

示例6: storeAllImages

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**************************************************/

    private static void storeAllImages(Context ctx, LocusUtils.LocusVersion lv, FieldNote fn)
            throws RequiredVersionMissingException {
        Iterator<FieldNoteImage> images = fn.getImages();
        while (images.hasNext()) {
            FieldNoteImage img = images.next();
            img.setFieldNoteId(fn.getId());

            // update or insert image
            if (img.getId() >= 0) {
                updateImage(ctx, lv, img);
            } else {
                insertImage(ctx, lv, img);
            }
        }
    }
 
开发者ID:asamm,项目名称:locus-api,代码行数:18,代码来源:FieldNotesHelper.java

示例7: getImage

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
public static FieldNoteImage getImage(Context ctx, LocusUtils.LocusVersion lv, long imgId)
        throws RequiredVersionMissingException {
    // get parameters for query
    Uri cpUri = getUriFieldNoteImagesTable(lv);
    cpUri = ContentUris.withAppendedId(cpUri, imgId);

    // execute request
    Cursor c = null;
    try {
        c = ctx.getContentResolver().query(cpUri,
                null, null, null, null);
        if (c == null || c.getCount() != 1) {
            return null;
        }

        // get 'all' notes and return first
        return createFieldNoteImages(c).get(0);
    } finally {
        Utils.closeQuietly(c);
    }
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:22,代码来源:FieldNotesHelper.java

示例8: logOnline

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
   * Log list of defined field notes online on Geocaching server.
   *
* @param ctx existing context
* @param lv active Locus version
* @param ids list of FieldNote id's that should be logged
* @param createLog <code>true</code> if we wants to create a log directly, or
*                  <code>false</code> if note should be posted into FieldNotes section
* @throws RequiredVersionMissingException error in case, LocusVersion is not valid
*/
  public static void logOnline(Context ctx, LocusUtils.LocusVersion lv,
          long[] ids, boolean createLog) throws RequiredVersionMissingException {
      // check parameters
      if (ctx == null || lv == null || ids == null || ids.length == 0) {
          throw new IllegalArgumentException("logOnline(" + ctx + ", " + lv + ", " + ids + "), " +
                  "invalid parameters");
      }

      // check version
      if (!lv.isVersionValid(LocusUtils.VersionCode.UPDATE_05)) {
          throw new RequiredVersionMissingException(LocusUtils.VersionCode.UPDATE_05);
      }

      // execute request
      Intent intent = new Intent(LocusConst.ACTION_LOG_FIELD_NOTES);
      intent.putExtra(LocusConst.INTENT_EXTRA_FIELD_NOTES_IDS, ids);
intent.putExtra(LocusConst.INTENT_EXTRA_FIELD_NOTES_CREATE_LOG, createLog);
      ctx.startActivity(intent);
  }
 
开发者ID:asamm,项目名称:locus-api,代码行数:30,代码来源:FieldNotesHelper.java

示例9: actionStartNavigation

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
    * Intent that starts navigation in Locus app based on defined target.
    * @param act current activity
    * @param name name of target
    * @param latitude latitude of target
    * @param longitude longitude of target
    * @throws RequiredVersionMissingException if Locus in required version is missing
    */
public static void actionStartNavigation(Activity act, 
		String name, double latitude, double longitude) 
		throws RequiredVersionMissingException {
       // check required version
       if (!LocusUtils.isLocusAvailable(act, VersionCode.UPDATE_01)) {
           throw new RequiredVersionMissingException(VersionCode.UPDATE_01);
       }

       // call Locus
   	Intent intent = new Intent(LocusConst.ACTION_NAVIGATION_START);
	if (name != null) {
           intent.putExtra(LocusConst.INTENT_EXTRA_NAME, name);
       }
	intent.putExtra(LocusConst.INTENT_EXTRA_LATITUDE, latitude);
	intent.putExtra(LocusConst.INTENT_EXTRA_LONGITUDE, longitude);
	act.startActivity(intent);
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:26,代码来源:ActionTools.java

示例10: actionStartGuiding

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**************************************************/

public static void actionStartGuiding(Activity act, 
		String name, double latitude, double longitude) 
		throws RequiredVersionMissingException {
	if (LocusUtils.isLocusAvailable(act, 243, 243, 0)) {
		Intent intent = new Intent(LocusConst.ACTION_GUIDING_START);
		if (name != null) {
			intent.putExtra(LocusConst.INTENT_EXTRA_NAME, name);
		}
		intent.putExtra(LocusConst.INTENT_EXTRA_LATITUDE, latitude);
		intent.putExtra(LocusConst.INTENT_EXTRA_LONGITUDE, longitude);
		act.startActivity(intent);			
	} else {
		throw new RequiredVersionMissingException(243);
	}
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:18,代码来源:ActionTools.java

示例11: updateLocusWaypoint

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
 * Update waypoint in Locus
 * @param ctx current context
 * @param wpt waypoint to update. Do not modify waypoint's ID value, because it's key to update
 * @param forceOverwrite if set to <code>true</code>, new waypoint will completely rewrite all
 *  user's data (do not use if necessary). If set to <code>false</code>, Locus will handle update based on user's 
 *  settings (if user have defined "keep values", it will keep it)
 * @param loadAllGcWaypoints allow to force Locus to load all GeocacheWaypoints (of course
 * if point is Geocache and is visible on map)
 * @return number of affected waypoints
 * @throws RequiredVersionMissingException if Locus in required version is missing
 */
public static int updateLocusWaypoint(Context ctx, LocusVersion lv,
		Waypoint wpt, boolean forceOverwrite, boolean loadAllGcWaypoints) 
		throws RequiredVersionMissingException {
	// check version (available only in Free/Pro)
	int minVersion = VersionCode.UPDATE_01.vcFree;
	if (!LocusUtils.isLocusFreePro(lv, minVersion)) {
		throw new RequiredVersionMissingException(minVersion);
	}
	
	// generate cursor
       Uri scheme = getProviderUriData(lv, VersionCode.UPDATE_01,
               LocusConst.CONTENT_PROVIDER_PATH_WAYPOINT);

	// define empty cursor
	ContentValues cv = new ContentValues();
	cv.put("waypoint", wpt.getAsBytes());
	cv.put("forceOverwrite", forceOverwrite);
	cv.put("loadAllGcWaypoints", loadAllGcWaypoints);
	return ctx.getContentResolver().update(scheme, cv, null, null);
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:33,代码来源:ActionTools.java

示例12: displayWaypointScreen

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
 * Allows to display whole detail screen of certain waypoint.
 * @param ctx current context
 * @param lv LocusVersion we call
 * @param wptId ID of waypoints we wants to display
 * @param callback generated callback (optional)
 * @throws RequiredVersionMissingException if Locus in required version is missing
 */
private static void displayWaypointScreen(Context ctx, LocusVersion lv, long wptId, String callback)
        throws RequiredVersionMissingException {
    // check version (available only in Free/Pro)
    if (!LocusUtils.isLocusFreePro(lv, VersionCode.UPDATE_07.vcFree)) {
        throw new RequiredVersionMissingException(VersionCode.UPDATE_07);
    }

    // call intent
    Intent intent = new Intent(LocusConst.ACTION_DISPLAY_POINT_SCREEN);
    intent.putExtra(LocusConst.INTENT_EXTRA_ITEM_ID, wptId);
    if (callback != null && callback.length() > 0) {
        intent.putExtra(Waypoint.TAG_EXTRA_CALLBACK, callback);
    }
    ctx.startActivity(intent);
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:24,代码来源:ActionTools.java

示例13: actionTrackRecordAddWpt

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
   * Send broadcast to Locus to add a new waypoint to current track record.
   * @param ctx current context
   * @param lv version of Locus used for track record
   * @param wptName nameof waypoint
   * @param actionAfter action that may happen after (defined in LocusConst class)
   * @throws RequiredVersionMissingException if Locus in required version is missing
   */
  public static void actionTrackRecordAddWpt(Context ctx, LocusVersion lv,
          String wptName, String actionAfter) throws RequiredVersionMissingException {
      // generate basic intent
      Intent intent = actionTrackRecord(
              LocusConst.ACTION_TRACK_RECORD_ADD_WPT, lv);
      if (wptName != null && wptName.length() > 0) {
          intent.putExtra(LocusConst.INTENT_EXTRA_NAME, wptName);
      }

      // autosave is always disabled
      intent.putExtra(LocusConst.INTENT_EXTRA_TRACK_REC_AUTO_SAVE, false);

      // extra parameter
      intent.putExtra(LocusConst.INTENT_EXTRA_TRACK_REC_ACTION_AFTER, actionAfter);

// sent intent
LocusUtils.sendBroadcast(ctx, intent, lv);
  }
 
开发者ID:asamm,项目名称:locus-api,代码行数:27,代码来源:ActionTools.java

示例14: callAddNewWmsMap

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**************************************************/

/*
  Add own WMS map
  ------------------------------------
  - this feature allow 3rd party application, add web address directly to list of WMS services in
  Map Manager screen / WMS tab
 */

public static void callAddNewWmsMap(Context context, String wmsUrl)
		throws RequiredVersionMissingException, InvalidObjectException {
	// check availability and start action
	if (!LocusUtils.isLocusAvailable(context, VersionCode.UPDATE_01)) {
		throw new RequiredVersionMissingException(VersionCode.UPDATE_01);
	}
	if (TextUtils.isEmpty(wmsUrl)) {
		throw new InvalidObjectException("WMS Url address \'" + wmsUrl + "\', is not valid!");
	}
	
	// call intent with WMS url
	Intent intent = new Intent(LocusConst.ACTION_ADD_NEW_WMS_MAP);
	intent.putExtra(LocusConst.INTENT_EXTRA_ADD_NEW_WMS_MAP_URL, wmsUrl);
	context.startActivity(intent);
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:25,代码来源:ActionTools.java

示例15: removeSpecialDataSilently

import locus.api.android.utils.LocusUtils; //导入依赖的package包/类
/**
 * Method used for removing special objects from Locus map. Currently this method
 * is used only for removing circles. If you want to remove any visible points or
 * tracks you already send by this API, send simply new same intent (as the one
 * with your data), but with empty list of data. So for example send again
 * {@link PackWaypoints} that has same name!, but contain no data
 * @param ctx current context
 * @param extraName name of items to remove
 * @param itemsId ID of item
 * @return <code>true</code> if item was correctly send
 * @throws RequiredVersionMissingException exception in case of missing required app version
 */
static boolean removeSpecialDataSilently(Context ctx, LocusVersion lv,
		String extraName, long[] itemsId) throws RequiredVersionMissingException {
	// check Locus version
	if (!lv.isVersionValid(VersionCode.UPDATE_02)) {
		throw new RequiredVersionMissingException(VersionCode.UPDATE_02);
	}
	
	// check intent firstly
	if (itemsId == null || itemsId.length == 0) {
		Logger.logW(TAG, "Intent 'null' or not contain any data");
		return false;
	}
	
	// create intent with right calling method
	Intent intent = new Intent(LocusConst.ACTION_REMOVE_DATA_SILENTLY);
	intent.setPackage(lv.getPackageName());
	intent.putExtra(extraName, itemsId);
	
	// set import tag
	LocusUtils.sendBroadcast(ctx, intent, lv);
	return true;
}
 
开发者ID:asamm,项目名称:locus-api,代码行数:35,代码来源:ActionDisplay.java


注:本文中的locus.api.android.utils.LocusUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。