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

Java OfflineRegionStatus类代码示例

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

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



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

示例1: startDownload

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的package包/类
private static void startDownload(List<Place> places, Map<OfflineRegion, OfflineRegionStatus> regionStatusMap, @SuppressWarnings("UnusedParameters") int numberOfErrors) {
    for (Place place : places) {
        if (place != null && place.hasLocation()) {
            Map.Entry<OfflineRegion, OfflineRegionStatus> regionStatus = findRegionsStatusEntry(place.getId(), regionStatusMap);
            if (regionStatus == null) {
                offlinePlaceStartDownload(place);
                Timber.i("%s map download started", place.getName());
            } else if (regionStatus.getValue() != null && !regionStatus.getValue().isComplete() && regionStatus.getValue().getDownloadState() == OfflineRegion.STATE_INACTIVE) {
                offlinePlaceResumeDownload(place, regionStatus.getKey());
                Timber.i("%s map download resumed", place.getName());
            } else {
                Timber.i("%s map already offlined", place.getName());
            }
        }
    }
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:17,代码来源:OfflineHelper.java


示例2: setOfflineRegions

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的package包/类
public void setOfflineRegions(OfflineRegion[] offlineRegions) {
    mRegionAndStatus.clear();
    for (final OfflineRegion region : offlineRegions) {
        mRegionAndStatus.add(Pair.<OfflineRegion, OfflineRegionStatus>create(region, null));
        region.getStatus(new OfflineRegion.OfflineRegionStatusCallback() {
            @Override
            public void onStatus(OfflineRegionStatus status) {
                updateStatus(region, status);
            }

            @Override
            public void onError(String error) {
            }
        });
    }
    notifyDataSetChanged();
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:18,代码来源:OfflineRegionAdapter.java


示例3: refreshOfflineRegions

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的package包/类
private void refreshOfflineRegions() {
    offlineRegionManager.listOfflineRegions(new OfflineRegionManager.OnOfflineRegionsListedListener() {
        @Override
        public void onOfflineRegionsListed(List<OfflineRegion> offlineRegions) {
            for (final OfflineRegion region : offlineRegions) {
                region.getStatus(new OfflineRegion.OfflineRegionStatusCallback() {
                    @Override
                    public void onStatus(OfflineRegionStatus status) {
                        OfflineRegionItem regionItem = new OfflineRegionItem(region, status);
                        if (!adapter.getOfflineRegionItems().contains(regionItem)) {
                            adapter.addOfflineRegion(regionItem);
                            if (adapter.getItemCount() == 1) {
                                selectOfflineRegion(0);
                            }
                        }
                    }

                    @Override
                    public void onError(String error) {
                        Log.e(TAG, "Refresh Offline Regions error: " + error);
                    }
                });
            }
        }
    });
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:27,代码来源:OfflineRegionsActivity.java


示例4: launchDownload

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


示例5: progressDownload

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的package包/类
private void progressDownload(OfflineDownload offlineDownload, OfflineRegionStatus status) {
  int percentage = (int) (status.getRequiredResourceCount() >= 0
    ? (100.0 * status.getCompletedResourceCount() / status.getRequiredResourceCount()) :
    0.0);

  offlineDownload.setProgress(percentage);
  if (percentage % 5 == 0) {
    OfflineDownloadStateReceiver.dispatchProgressChanged(this, offlineDownload, percentage);
    if (notificationBuilder != null) {
      notificationBuilder.setProgress(100, percentage, false);
      notificationManager.notify(offlineDownload.getServiceId(), notificationBuilder.build());
    }
  }
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:15,代码来源:OfflineDownloadService.java


示例6: findRegionsStatusEntry

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的package包/类
private static Map.Entry<OfflineRegion, OfflineRegionStatus> findRegionsStatusEntry(String placeId, Map<OfflineRegion, OfflineRegionStatus> regionStatusMap) {
    for (Map.Entry<OfflineRegion, OfflineRegionStatus> entry : regionStatusMap.entrySet()) {
        if (entry.getKey() == null)
            continue;
        try {
            OfflineRegionMetadata metadata = GsonSingleton.gson().fromJson(new String(entry.getKey().getMetadata(), Charset.defaultCharset()), OfflineRegionMetadata.class);
            if (metadata.placeId != null && metadata.placeId.equals(placeId))
                return entry;
        } catch (JsonSyntaxException ignored) {
        }
    }
    return null;
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:14,代码来源:OfflineHelper.java


示例7: 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


示例8: 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


示例9: updateStatus

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的package包/类
private void updateStatus(OfflineRegion region, OfflineRegionStatus status) {
    boolean dirty = false;
    for (int i = 0; i < mRegionAndStatus.size(); ++i) {
        Pair<OfflineRegion, OfflineRegionStatus> pair = mRegionAndStatus.get(i);
        if (pair.first != null && pair.first.getID() == region.getID()) {
            mRegionAndStatus.set(i, Pair.create(region, status));
            dirty = true;
        }
    }
    if (dirty) {
        notifyDataSetChanged();
    }
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:14,代码来源:OfflineRegionAdapter.java


示例10: checkIfRegionDownloadIsCompleted

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的package包/类
private void checkIfRegionDownloadIsCompleted(final OfflineRegion offlineRegion) {
    offlineRegion.getStatus(new OfflineRegion.OfflineRegionStatusCallback() {
        @Override
        public void onStatus(OfflineRegionStatus status) {
            if (!status.isComplete() && status.getDownloadState() != OfflineRegion.STATE_ACTIVE) {
                resumeDownloadOfflineRegion(offlineRegion);
            }
        }

        @Override
        public void onError(String error) {
            Log.e(TAG, error);
        }
    });
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:16,代码来源:OfflineRegionDownloadService.java


示例11: 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


示例12: launchDownload

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


示例13: 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


示例14: OfflineRegionItem

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的package包/类
public OfflineRegionItem(OfflineRegion offlineRegion, OfflineRegionStatus status) {
    this.offlineRegion = offlineRegion;
    this.status = status;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:5,代码来源:OfflineRegionItem.java


示例15: getStatus

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的package包/类
public OfflineRegionStatus getStatus() {
    return status;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:4,代码来源:OfflineRegionItem.java


示例16: launchDownload

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


示例17: launchDownload

import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; //导入依赖的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.OfflineRegionStatus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java DataSmResult类代码示例发布时间:2022-05-22
下一篇:
Java DirectionsRoute类代码示例发布时间: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