本文整理汇总了Java中com.mapbox.mapboxsdk.offline.OfflineManager类的典型用法代码示例。如果您正苦于以下问题:Java OfflineManager类的具体用法?Java OfflineManager怎么用?Java OfflineManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OfflineManager类属于com.mapbox.mapboxsdk.offline包,在下文中一共展示了OfflineManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createDownload
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
private void createDownload(final OfflineDownload offlineDownload) {
final OfflineTilePyramidRegionDefinition definition = offlineDownload.getRegionDefinition();
final byte[] metadata = offlineDownload.getMetadata();
OfflineManager.getInstance(getApplicationContext())
.createOfflineRegion(
definition,
metadata,
new OfflineManager.CreateOfflineRegionCallback() {
@Override
public void onCreate(OfflineRegion offlineRegion) {
offlineDownload.setRegionId(offlineRegion.getID());
OfflineDownloadStateReceiver.dispatchStartBroadcast(getApplicationContext(), offlineDownload);
regionLongSparseArray.put(offlineDownload.getServiceId(), offlineRegion);
launchDownload(offlineDownload, offlineRegion);
showNotification(offlineDownload);
}
@Override
public void onError(String error) {
OfflineDownloadStateReceiver.dispatchErrorBroadcast(getApplicationContext(), offlineDownload, error);
}
});
}
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:25,代码来源:OfflineDownloadService.java
示例2: loadOfflineRegion
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
private void loadOfflineRegion(final long id) {
OfflineManager.getInstance(this)
.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() {
@Override
public void onList(OfflineRegion[] offlineRegions) {
for (OfflineRegion region : offlineRegions) {
if (region.getID() == id) {
offlineRegion = region;
OfflineTilePyramidRegionDefinition definition =
(OfflineTilePyramidRegionDefinition) region.getDefinition();
setupUI(definition);
return;
}
}
}
@Override
public void onError(String error) {
Timber.e(error);
}
});
}
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:24,代码来源:OfflineRegionDetailActivity.java
示例3: createOfflineRegion
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
public void createOfflineRegion(OfflineRegionDefinition definition,
final String regionName,
final OnOfflineRegionCreatedListener listener) {
offlineManager.createOfflineRegion(definition,
encodeRegionName(regionName),
new OfflineManager.CreateOfflineRegionCallback() {
@Override
public void onCreate(OfflineRegion offlineRegion) {
listener.onOfflineRegionCreated(offlineRegion, regionName);
}
@Override
public void onError(String error) {
Log.e(TAG, "Create offline region error: " + error);
}
});
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:18,代码来源:OfflineRegionManager.java
示例4: loadOfflineRegions
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
private void loadOfflineRegions() {
OfflineManager.getInstance(this).listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() {
@Override
public void onList(OfflineRegion[] offlineRegions) {
if (offlineRegions != null) {
adapter.setOfflineRegions(Arrays.asList(offlineRegions));
}
}
@Override
public void onError(String error) {
Toast.makeText(OfflineRegionListActivity.this, "Error loading regions " + error, Toast.LENGTH_LONG).show();
}
});
}
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:16,代码来源:OfflineRegionListActivity.java
示例5: offlinePlaceStartDownload
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
private static void offlinePlaceStartDownload(final Place place) {
final Context context = SjekkUTApplication.getContext();
// Set up the OfflineManager
OfflineManager offlineManager = OfflineManager.getInstance(context.getApplicationContext());
// Create a bounding box for the offline region
LatLngBounds latLngBounds = Utils.getLatLngBounds(place.getLocation(), MAP_OFFLINE_RADIUS);
// Define the offline region
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
context.getString(R.string.mapbox_style),
latLngBounds,
MAP_OFFLINE_MINZOOM,
MAP_OFFLINE_MAXZOOM,
context.getResources().getDisplayMetrics().density);
byte[] metaData = GsonSingleton.gson().toJson(new OfflineRegionMetadata(place)).getBytes(Charset.defaultCharset());
// Create the region asynchronously
offlineManager.createOfflineRegion(definition, metaData, new OfflineManager.CreateOfflineRegionCallback() {
@Override
public void onCreate(OfflineRegion offlineRegion) {
sOfflineRegionExecutor.schedule(new OfflineRegionTask(place, offlineRegion), OFFLINE_REGIONTASK_DELAY, TimeUnit.SECONDS);
}
@Override
public void onError(String error) {
Timber.e("Error: %s", error);
}
});
}
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:33,代码来源:OfflineHelper.java
示例6: onResume
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
Analytics.log(getActivity(), R.string.analytics_app_show_profilefragment);
OfflineManager.getInstance(getActivity()).listOfflineRegions(this);
mUserStats = realm.where(UserStats.class).equalTo("id", PreferenceUtils.getUserId(getContext())).findAll();
mPlaces = realm.where(Place.class).findAll();
setUserStats(mUserStats.isEmpty() ? null : mUserStats.first());
updatePlacesInAdapter(mPlaces);
mUserStats.addChangeListener(mUserStatsListener);
mPlaces.addChangeListener(mPlaceListener);
fetchUserStats();
fetchVisitedPlaces();
}
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:16,代码来源:ProfileFragment.java
示例7: listOfflineRegions
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
public void listOfflineRegions(final OnOfflineRegionsListedListener listener) {
offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() {
@Override
public void onList(OfflineRegion[] offlineRegions) {
listener.onOfflineRegionsListed(Arrays.asList(offlineRegions));
}
@Override
public void onError(String error) {
Log.e(TAG, "List offline regions error: " + error);
}
});
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:14,代码来源:OfflineRegionManager.java
示例8: downloadRegion
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
private void downloadRegion(final String regionName) {
// Define offline region parameters, including bounds,
// min/max zoom, and metadata
//Create a record to track usage of Download Map Region
Answers.getInstance().logCustom(new CustomEvent("Offline Map download click"));
// Start the progressBar
startProgress();
// Create offline definition using the current
// style and boundaries of visible map area
String styleUrl = mapboxMap.getStyleUrl();
LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
double minZoom = mapboxMap.getCameraPosition().zoom;
double maxZoom = mapboxMap.getMaxZoomLevel();
float pixelRatio = this.getResources().getDisplayMetrics().density;
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
styleUrl, bounds, minZoom, maxZoom, pixelRatio);
// Build a JSONObject using the user-defined offline region title,
// convert it into string, and use it to create a metadata variable.
// The metadata variable will later be passed to createOfflineRegion()
byte[] metadata;
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put(JSON_FIELD_REGION_NAME, regionName);
String json = jsonObject.toString();
metadata = json.getBytes(JSON_CHARSET);
} catch (Exception exception) {
Crashlytics.log("Failed to encode metadata.");
Crashlytics.logException(exception);
metadata = null;
}
// Create the offline region and launch the download
offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() {
@Override
public void onCreate(OfflineRegion offlineRegion) {
Crashlytics.log("Offline region created: " + regionName);
OfflineManagerActivity.this.offlineRegion = offlineRegion;
launchDownload();
}
@Override
public void onError(String error) {
Crashlytics.logException(new Exception("Error: " + error));
}
});
}
开发者ID:Hitchwiki,项目名称:MyHitchhikingSpots-for-Android,代码行数:51,代码来源:OfflineManagerActivity.java
示例9: provideOfflineManager
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
@Provides
public OfflineManager provideOfflineManager(Application application) {
return OfflineManager.getInstance(application);
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:5,代码来源:OfflineRegionModule.java
示例10: provideOfflineRegionManager
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
@Provides
public OfflineRegionManager provideOfflineRegionManager(OfflineManager offlineManager) {
return new OfflineRegionManager(offlineManager);
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:5,代码来源:OfflineRegionModule.java
示例11: OfflineRegionManager
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
@Inject
public OfflineRegionManager(OfflineManager offlineManager) {
this.offlineManager = offlineManager;
}
开发者ID:jawg,项目名称:osm-contributor,代码行数:5,代码来源:OfflineRegionManager.java
示例12: downloadRegion
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
private void downloadRegion(final String regionName) {
// Define offline region parameters, including bounds,
// min/max zoom, and metadata
// Start the progressBar
startProgress();
// Create offline definition using the current
// style and boundaries of visible map area
String styleUrl = map.getStyleUrl();
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
double minZoom = map.getCameraPosition().zoom;
double maxZoom = map.getMaxZoomLevel();
float pixelRatio = this.getResources().getDisplayMetrics().density;
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
styleUrl, bounds, minZoom, maxZoom, pixelRatio);
// Build a JSONObject using the user-defined offline region title,
// convert it into string, and use it to create a metadata variable.
// The metadata varaible will later be passed to createOfflineRegion()
byte[] metadata;
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put(JSON_FIELD_REGION_NAME, regionName);
String json = jsonObject.toString();
metadata = json.getBytes(JSON_CHARSET);
} catch (Exception exception) {
Log.e(TAG, "Failed to encode metadata: " + exception.getMessage());
metadata = null;
}
// Create the offline region and launch the download
offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() {
@Override
public void onCreate(OfflineRegion offlineRegion) {
Log.d(TAG, "Offline region created: " + regionName);
offlineRegionDownloaded = offlineRegion;
launchDownload();
}
@Override
public void onError(String error) {
Log.e(TAG, "Error: " + error);
}
});
}
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:47,代码来源:OfflineMapActivity.java
示例13: downloadRegion
import com.mapbox.mapboxsdk.offline.OfflineManager; //导入依赖的package包/类
private void downloadRegion(final String regionName) {
// Define offline region parameters, including bounds,
// min/max zoom, and metadata
// Start the progressBar
startProgress();
// Create offline definition using the current
// style and boundaries of visible map area
String styleUrl = map.getStyleUrl();
LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
double minZoom = map.getCameraPosition().zoom;
double maxZoom = map.getMaxZoomLevel();
float pixelRatio = this.getResources().getDisplayMetrics().density;
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
styleUrl, bounds, minZoom, maxZoom, pixelRatio);
// Build a JSONObject using the user-defined offline region title,
// convert it into string, and use it to create a metadata variable.
// The metadata variable will later be passed to createOfflineRegion()
byte[] metadata;
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put(JSON_FIELD_REGION_NAME, regionName);
String json = jsonObject.toString();
metadata = json.getBytes(JSON_CHARSET);
} catch (Exception exception) {
Log.e(TAG, "Failed to encode metadata: " + exception.getMessage());
metadata = null;
}
// Create the offline region and launch the download
offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() {
@Override
public void onCreate(OfflineRegion offlineRegion) {
Log.d(TAG, "Offline region created: " + regionName);
OfflineManagerActivity.this.offlineRegion = offlineRegion;
launchDownload();
}
@Override
public void onError(String error) {
Log.e(TAG, "Error: " + error);
}
});
}
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:47,代码来源:OfflineManagerActivity.java
注:本文中的com.mapbox.mapboxsdk.offline.OfflineManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论