• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OfflineRegionError类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: launchDownload

import com.mapbox.mapboxsdk.offline.OfflineRegionError; //导入依赖的package包/类
private void launchDownload(final OfflineDownload offlineDownload, final OfflineRegion offlineRegion) {
  offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() {
    @Override
    public void onStatusChanged(OfflineRegionStatus status) {
      if (status.isComplete()) {
        finishDownload(offlineDownload, offlineRegion);
        return;
      }
      progressDownload(offlineDownload, status);
    }

    @Override
    public void onError(OfflineRegionError error) {
      OfflineDownloadStateReceiver.dispatchErrorBroadcast(getApplicationContext(), offlineDownload,
        error.getReason(), error.getMessage());
      stopSelf(offlineDownload.getServiceId());
    }

    @Override
    public void mapboxTileCountLimitExceeded(long limit) {
      OfflineDownloadStateReceiver.dispatchErrorBroadcast(getApplicationContext(), offlineDownload,
        "Mapbox tile count limit exceeded:" + limit);
    }
  });

  // Change the region state
  offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:29,代码来源:OfflineDownloadService.java


示例2: onError

import com.mapbox.mapboxsdk.offline.OfflineRegionError; //导入依赖的package包/类
@Override
public void onError(OfflineRegionError error) {
    mLatch.countDown();
    Timber.i("OfflineRegion error: %s message: %s", error.getReason(), error.getMessage());
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:6,代码来源:OfflineHelper.java


示例3: launchDownload

import com.mapbox.mapboxsdk.offline.OfflineRegionError; //导入依赖的package包/类
private void launchDownload() {
    // Set up an observer to handle download progress and
    // notify the user when the region is finished downloading
    offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() {
        @Override
        public void onStatusChanged(OfflineRegionStatus status) {
            try {
                // Compute a percentage
                double percentage = status.getRequiredResourceCount() >= 0
                        ? (100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
                        0.0;

                if (status.isComplete()) {
                    // Download complete
                    endProgress(getString(R.string.end_progress_success));
                    return;
                } else if (status.isRequiredResourceCountPrecise()) {
                    // Switch to determinate state
                    setPercentage((int) Math.round(percentage));
                }

                // Log what is being currently downloaded
                Crashlytics.log(String.format("%s%% of download is complete; %s bytes downloaded.",
                        String.valueOf(status.getCompletedResourceCount() / status.getRequiredResourceCount()),
                        String.valueOf(status.getCompletedResourceSize())));
            } catch (Exception ex) {
                Crashlytics.logException(ex);
            }
        }

        @Override
        public void onError(OfflineRegionError error) {
            // endProgress(getString(R.string.general_error_dialog_title));
            Crashlytics.log("onError message: " + error.getMessage());
            Crashlytics.logException(new Exception("onError reason: " + error.getReason()));
        }

        /*
         * Implement this method to be notified when the limit on the number of Mapbox
         * tiles stored for offline regions has been reached.
         *
         * Once the limit has been reached, the SDK will not download further offline
         * tiles from Mapbox APIs until existing tiles have been removed. Contact your
         * Mapbox sales representative to raise the limit.
         *
         * This limit does not apply to non-Mapbox tile sources.
         *
         * This method will be executed on the main thread.
         */
        @Override
        public void mapboxTileCountLimitExceeded(long limit) {
            endProgress(getString(R.string.tile_count_limit_exceed_error_message));
            Crashlytics.logException(new Exception("Mapbox tile count limit exceeded: " + limit + ". And error message should have been shown to the user saying '" + getString(R.string.tile_count_limit_exceed_error_message) + "'"));
        }
    });

    // Change the region state
    offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);
}
 
开发者ID:Hitchwiki,项目名称:MyHitchhikingSpots-for-Android,代码行数:60,代码来源:OfflineManagerActivity.java


示例4: getOfflineRegionObserver

import com.mapbox.mapboxsdk.offline.OfflineRegionError; //导入依赖的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


示例5: launchDownload

import com.mapbox.mapboxsdk.offline.OfflineRegionError; //导入依赖的package包/类
private void launchDownload() {
  // Set up an observer to handle download progress and
  // notify the user when the region is finished downloading
  offlineRegionDownloaded.setObserver(new OfflineRegion.OfflineRegionObserver() {
    @Override
    public void onStatusChanged(OfflineRegionStatus status) {
      // Compute a percentage
      double percentage = status.getRequiredResourceCount() >= 0
        ? (100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
        0.0;

      if (status.isComplete()) {
        // Download complete
        endProgress("Region downloaded successfully.");
        return;
      } else if (status.isRequiredResourceCountPrecise()) {
        // Switch to determinate state
        setPercentage((int) Math.round(percentage));
      }

      // Log what is being currently downloaded
      Log.d(TAG, String.format("%s/%s resources; %s bytes downloaded.",
        String.valueOf(status.getCompletedResourceCount()),
        String.valueOf(status.getRequiredResourceCount()),
        String.valueOf(status.getCompletedResourceSize())));
    }

    @Override
    public void onError(OfflineRegionError error) {
      Log.e(TAG, "onError reason: " + error.getReason());
      Log.e(TAG, "onError message: " + error.getMessage());
    }

    @Override
    public void mapboxTileCountLimitExceeded(long limit) {
      Log.e(TAG, "Mapbox tile count limit exceeded: " + limit);
    }
  });

  // Change the region state
  offlineRegionDownloaded.setDownloadState(OfflineRegion.STATE_ACTIVE);
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:43,代码来源:OfflineMapActivity.java


示例6: launchDownload

import com.mapbox.mapboxsdk.offline.OfflineRegionError; //导入依赖的package包/类
private void launchDownload() {
  // Set up an observer to handle download progress and
  // notify the user when the region is finished downloading
  offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() {
    @Override
    public void onStatusChanged(OfflineRegionStatus status) {
      // Compute a percentage
      double percentage = status.getRequiredResourceCount() >= 0
        ? (100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
        0.0;

      if (status.isComplete()) {
        // Download complete
        endProgress(getString(R.string.end_progress_success));
        return;
      } else if (status.isRequiredResourceCountPrecise()) {
        // Switch to determinate state
        setPercentage((int) Math.round(percentage));
      }

      // Log what is being currently downloaded
      Log.d(TAG, String.format("%s/%s resources; %s bytes downloaded.",
        String.valueOf(status.getCompletedResourceCount()),
        String.valueOf(status.getRequiredResourceCount()),
        String.valueOf(status.getCompletedResourceSize())));
    }

    @Override
    public void onError(OfflineRegionError error) {
      Log.e(TAG, "onError reason: " + error.getReason());
      Log.e(TAG, "onError message: " + error.getMessage());
    }

    @Override
    public void mapboxTileCountLimitExceeded(long limit) {
      Log.e(TAG, "Mapbox tile count limit exceeded: " + limit);
    }
  });

  // Change the region state
  offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:43,代码来源:OfflineManagerActivity.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Required类代码示例发布时间:2022-05-22
下一篇:
Java MultiSortedDocValues类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap