本文整理汇总了Java中com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition类的典型用法代码示例。如果您正苦于以下问题:Java OfflineTilePyramidRegionDefinition类的具体用法?Java OfflineTilePyramidRegionDefinition怎么用?Java OfflineTilePyramidRegionDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OfflineTilePyramidRegionDefinition类属于com.mapbox.mapboxsdk.offline包,在下文中一共展示了OfflineTilePyramidRegionDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDownload
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的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);
}
});
}
示例2: getView
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(context).inflate(R.layout.item_feature, parent, false);
holder.text = convertView.findViewById(R.id.nameView);
holder.subText = convertView.findViewById(R.id.descriptionView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
currentRegion = getItem(position);
holder.text.setText(OfflineUtils.convertRegionName(currentRegion.getMetadata()));
holder.subText.setText(((OfflineTilePyramidRegionDefinition) currentRegion.getDefinition()).getStyleURL());
return convertView;
}
示例3: loadOfflineRegion
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的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);
}
});
}
示例4: selectOfflineRegion
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void selectOfflineRegion(int position) {
if (selectedRegionItem != null) {
selectedRegionItem.setSelected(false);
}
selectedRegionItem = adapter.getOfflineRegion(position);
selectedRegionItem.setSelected(true);
OfflineTilePyramidRegionDefinition definition =
(OfflineTilePyramidRegionDefinition) selectedRegionItem
.getOfflineRegion()
.getDefinition();
animateCameraToBounds(definition.getBounds());
if (selectedRegionItem.getStatus().isComplete()) {
switchMode(Mode.STATUS_COMPLETE);
} else {
switchMode(Mode.STATUS_INCOMPLETE);
}
closeEditMenu();
adapter.notifyDataSetChanged();
}
示例5: equals
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof OfflineRegionItem)) {
return false;
}
OfflineRegionItem that = (OfflineRegionItem) o;
if (that.offlineRegion == null || offlineRegion == null) {
return false;
}
OfflineTilePyramidRegionDefinition thatDefinition =
(OfflineTilePyramidRegionDefinition) that.offlineRegion.getDefinition();
OfflineTilePyramidRegionDefinition definition =
(OfflineTilePyramidRegionDefinition) offlineRegion.getDefinition();
return thatDefinition.getBounds().equals(definition.getBounds()) ||
(offlineRegion != null ? offlineRegion.equals(that.offlineRegion) : that.offlineRegion == null);
}
示例6: OfflineDownload
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private OfflineDownload(Parcel in) {
definition = in.readParcelable(OfflineTilePyramidRegionDefinition.class.getClassLoader());
serviceId = in.readInt();
regionId = in.readLong();
notificationOptions = in.readParcelable(NotificationOptions.class.getClassLoader());
progress = in.readInt();
metadata = new byte[in.readInt()];
in.readByteArray(metadata);
}
示例7: createMapSnapshot
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void createMapSnapshot(OfflineTilePyramidRegionDefinition definition,
MapSnapshotter.SnapshotReadyCallback callback) {
Resources resources = getResources();
int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
MapSnapshotter.Options options = new MapSnapshotter.Options(width, height);
options.withStyle(definition.getStyleURL());
options.withRegion(definition.getBounds());
mapSnapshotter = new MapSnapshotter(this, options);
mapSnapshotter.start(callback);
}
示例8: setupUI
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void setupUI(final OfflineTilePyramidRegionDefinition definition) {
// update map
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
// correct style
mapboxMap.setStyle(definition.getStyleURL());
// position map on top of offline region
CameraPosition cameraPosition = OfflineUtils.getCameraPosition(definition);
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
// restrict camera movement
mapboxMap.setMinZoomPreference(definition.getMinZoom());
mapboxMap.setMaxZoomPreference(definition.getMaxZoom());
mapboxMap.setLatLngBoundsForCameraTarget(definition.getBounds());
}
});
// update textview data
nameView.setText(OfflineUtils.convertRegionName(offlineRegion.getMetadata()));
styleView.setText(definition.getStyleURL());
latLngBoundsView.setText(definition.getBounds().toString());
minZoomView.setText(String.valueOf(definition.getMinZoom()));
maxZoomView.setText(String.valueOf(definition.getMaxZoom()));
offlineRegion.getStatus(offlineRegionStatusCallback);
}
示例9: offlinePlaceStartDownload
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的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);
}
});
}
示例10: containsInOfflineRegion
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
/**
* Check if a region is present in the list with the bounds parameter.
* @param regions
* @param bounds
* @return the OfflineRegion if it's present or null.
*/
private OfflineRegion containsInOfflineRegion(List<OfflineRegion> regions, LatLngBounds bounds) {
for (OfflineRegion offlineRegion : regions) {
if (((OfflineTilePyramidRegionDefinition) offlineRegion.getDefinition()).getBounds().equals(bounds)) {
return offlineRegion;
}
}
return null;
}
示例11: getCameraPosition
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
public static CameraPosition getCameraPosition(OfflineTilePyramidRegionDefinition definition) {
return new CameraPosition.Builder()
.target(definition.getBounds().getCenter())
.zoom(definition.getMinZoom())
.build();
}
示例12: withDefinition
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
public OfflineDownloadOptions withDefinition(OfflineTilePyramidRegionDefinition definition) {
this.definition = definition;
return this;
}
示例13: getRegionDefinition
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
OfflineTilePyramidRegionDefinition getRegionDefinition() {
return definition;
}
示例14: onDownloadRegion
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
@OnClick(R.id.fab)
public void onDownloadRegion() {
// get data from UI
String regionName = regionNameView.getText().toString();
double latitudeNorth = Double.parseDouble(latNorthView.getText().toString());
double longitudeEast = Double.parseDouble(lonEastView.getText().toString());
double latitudeSouth = Double.parseDouble(latSouthView.getText().toString());
double longitudeWest = Double.parseDouble(lonWestView.getText().toString());
String styleUrl = (String) styleUrlView.getSelectedItem();
float maxZoom = maxZoomView.getProgress();
float minZoom = minZoomView.getProgress();
if (!validCoordinates(latitudeNorth, longitudeEast, latitudeSouth, longitudeWest)) {
Toast.makeText(this, "coordinates need to be in valid range", Toast.LENGTH_LONG).show();
return;
}
// create offline definition from data
OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
styleUrl,
new LatLngBounds.Builder()
.include(new LatLng(latitudeNorth, longitudeEast))
.include(new LatLng(latitudeSouth, longitudeWest))
.build(),
minZoom,
maxZoom,
getResources().getDisplayMetrics().density
);
// customise notification appearance
NotificationOptions notificationOptions = new NotificationOptions()
.withSmallIconRes(R.drawable.mapbox_logo_icon)
.withReturnActivity(OfflineRegionDetailActivity.class.getName());
// start offline download
OfflinePlugin.getInstance().startDownload(this,
new OfflineDownloadOptions()
.withDefinition(definition)
.withMetadata(OfflineUtils.convertRegionName(regionName))
.withNotificationOptions(notificationOptions)
);
}
示例15: downloadRegion
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的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));
}
});
}