本文整理汇总了Java中com.mapbox.mapboxsdk.offline.OfflineRegionStatus.isComplete方法的典型用法代码示例。如果您正苦于以下问题:Java OfflineRegionStatus.isComplete方法的具体用法?Java OfflineRegionStatus.isComplete怎么用?Java OfflineRegionStatus.isComplete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mapbox.mapboxsdk.offline.OfflineRegionStatus
的用法示例。
在下文中一共展示了OfflineRegionStatus.isComplete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStatusChanged
import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入方法依赖的package包/类
@Override
public void onStatusChanged(OfflineRegionStatus status) {
long currentMillis = System.currentTimeMillis();
long delta = currentMillis - lastUpdateMillis;
if (status.isComplete()) {
mLatch.countDown();
if (sOfflineRegionExecutor.getQueue().isEmpty()) {
notificationManager.cancel(R.id.download_notification);
}
} else {
switch (status.getDownloadState()) {
case OfflineRegion.STATE_INACTIVE:
mLatch.countDown();
break;
case OfflineRegion.STATE_ACTIVE:
if (status.isRequiredResourceCountPrecise() && delta > PROGRESS_UPDATE_DELTA_MS) {
lastUpdateMillis = currentMillis;
double percentage = status.getRequiredResourceCount() >= 0
? (100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
0.0;
notificationBuilder.setContentTitle(mContext.getString(R.string.offlinemap_title, getPendingAndActiveMapDownloads()));
notificationBuilder.setProgress(100, (int) percentage, false);
notificationManager.notify(R.id.download_notification, notificationBuilder.build());
}
break;
}
}
}
示例2: onBindViewHolder
import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
Context context = holder.itemView.getContext();
Pair<OfflineRegion, OfflineRegionStatus> pair = mRegionAndStatus.get(position);
String unknown = context.getString(R.string.offlineregion_unknown);
String regionName = context.getString(R.string.offlineregion_name, unknown);
String regionId = context.getString(R.string.offlineregion_regionid, unknown);
String placeId = context.getString(R.string.offlineregion_placeid, unknown);
String downloadState = context.getString(R.string.offlineregion_downloadState, unknown);
String downloadComplete = context.getString(R.string.offlineregion_downloadComplete, unknown);
String regionSize = context.getString(R.string.offlineregion_sizeMB, unknown);
OfflineRegion region = pair.first;
if (region != null) {
regionId = context.getString(R.string.offlineregion_regionid, Long.toString(region.getID()));
try {
OfflineRegionMetadata metadata = GsonSingleton.gson().fromJson(new String(region.getMetadata(), Charset.defaultCharset()), OfflineRegionMetadata.class);
regionName = context.getString(R.string.offlineregion_name, metadata.placeName);
placeId = context.getString(R.string.offlineregion_placeid, metadata.placeId);
} catch (JsonSyntaxException ignored) {
}
}
OfflineRegionStatus status = pair.second;
if (status != null) {
downloadState = status.getDownloadState() == OfflineRegion.STATE_ACTIVE ?
context.getString(R.string.offlineregion_downloadState, "Aktiv") :
context.getString(R.string.offlineregion_downloadState, "Inaktiv");
downloadComplete = status.isComplete() ?
context.getString(R.string.offlineregion_downloadComplete, "Ja") :
context.getString(R.string.offlineregion_downloadComplete, "Nei");
regionSize = context.getString(R.string.offlineregion_sizeMB, String.format(Locale.getDefault(), "%.2f", status.getCompletedResourceSize() / (1024.0 * 1024.0)));
}
holder.mRegionName.setText(regionName);
holder.mRegionId.setText(regionId);
holder.mPlaceId.setText(placeId);
holder.mDownloadState.setText(downloadState);
holder.mDownloadComplete.setText(downloadComplete);
holder.mRegionSize.setText(regionSize);
}
示例3: onStatus
import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入方法依赖的package包/类
@Override
public void onStatus(OfflineRegionStatus status) {
isDownloading = !status.isComplete();
updateFab();
}
示例4: getOfflineRegionObserver
import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入方法依赖的package包/类
private OfflineRegion.OfflineRegionObserver getOfflineRegionObserver(final String regionName) {
final NotificationCompat.Builder builder = notifications.get(regionName);
return new OfflineRegion.OfflineRegionObserver() {
int percentage;
@Override
public void onStatusChanged(OfflineRegionStatus status) {
if (deliverStatusUpdate) {
// Calculate the download percentage and update the progress bar
int newPercent = (int) Math.round(status.getRequiredResourceCount() >= 0 ?
(100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
0.0);
if (newPercent != percentage) {
percentage = newPercent;
builder.setContentText(percentage + "%");
builder.setProgress(100, percentage, false);
notificationManager.notify(regionName.hashCode(), builder.build());
}
}
if (status.isComplete()) {
// Download complete
// When the loop is finished, updates the notification
builder.setContentText("Region downloaded successfully")
.setProgress(0, 0, false)
.mActions
.clear();
notificationManager.notify(regionName.hashCode(), builder.build());
currentDownloadRegion = null;
checkNextDownload();
}
}
@Override
public void onError(OfflineRegionError error) {
// If an error occurs, print to logcat
Log.e(TAG, "onError reason: " + error.getReason());
Log.e(TAG, "onError message: " + error.getMessage());
}
@Override
public void mapboxTileCountLimitExceeded(long limit) {
// Notify if offline region exceeds maximum tile count
Log.e(TAG, "Mapbox tile count limit exceeded: " + limit);
}
};
}