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


Java OfflineRegionStatus.isComplete方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:29,代码来源:OfflineHelper.java

示例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);
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:39,代码来源:OfflineRegionAdapter.java

示例3: onStatus

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入方法依赖的package包/类
@Override
public void onStatus(OfflineRegionStatus status) {
  isDownloading = !status.isComplete();
  updateFab();
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:6,代码来源:OfflineRegionDetailActivity.java

示例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);
        }
    };
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:47,代码来源:OfflineRegionDownloadService.java


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