Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine strategy for using string resources in presenters #14

Open
zinfin opened this issue May 4, 2017 · 1 comment
Open

Determine strategy for using string resources in presenters #14

zinfin opened this issue May 4, 2017 · 1 comment

Comments

@zinfin
Copy link
Contributor

zinfin commented May 4, 2017

  @Override final public void checkForMapbook() {

    mPath = mFileManager.fileExists();
    if (mPath != null){

      loadMapbook(new DataManagerCallbacks.MapbookCallback() {
        /**
         * If successfully loaded, populate view
         * @param mobileMapPackage - MobileMapPackage
         */
        @Override final public void onMapbookLoaded(final MobileMapPackage mobileMapPackage) {
          final List<ArcGISMap> maps = mobileMapPackage.getMaps();
          mView.setMaps(maps);
          final Item item = mobileMapPackage.getItem();
          mView.populateMapbookLayout(item);

          // Get the file size and date
          final long mapbookSize = mFileManager.getSize();
          final long mapbookModified = mFileManager.getModifiedDate();

          mView.setMapbookMetatdata(mapbookSize, mapbookModified, maps.size());

          final byte[] thumbnailData = item.getThumbnailData();
          if (thumbnailData != null && thumbnailData.length > 0) {
            mView.setThumbnailBitmap(thumbnailData);
          }else{
            final ListenableFuture<byte[]> futureThumbnail = item.fetchThumbnailAsync();
            futureThumbnail.addDoneListener(new Runnable() {
              @Override public void run() {
                try {
                  final byte[] itemThumbnailData = futureThumbnail.get();
                  mView.setThumbnailBitmap(itemThumbnailData);
                } catch (final Exception e) {
                  Log.e(TAG,e.getMessage());
                  mView.showMessage("There were problems obtaining thumbnail images for maps in mapbook.");
                }
              }
            });
          }
        }

        /**
         * If the mapbook fails to load, show a message
         * @param error - Throwable
         */
        @Override final public void onMapbookNotLoaded(final Throwable error) {
          Log.e(TAG, "Problem loading map book " + error.getMessage());
          mView.showMapbookNotFound();
          mView.showMessage("There was a problem loading the mapbook");
        }
      });

Was thinking the presenter can determine which string resource to provide and the view handles loading the resource. Have to think about this a bit more so we can handle this through a separate issue if we want to dig deeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant