Beispiel #1
0
 private void setCanGoBack() {
   ActivityDelegate a = getActivityDelegate();
   if (a == null) {
     Log.d("Activity is null");
     return;
   }
   setCanGoBack(a.getActionBar());
 }
Beispiel #2
0
  private void startDownload(Resource resource) {
    mConfirmationInProgress = false;

    ActivityDelegate ad = getActivityDelegate();
    if (ad == null) {
      return;
    }

    resource.setDownloadDirectory(VizUtils.getDownloadDir());

    // check download directory in case sd card or whatever has been
    // unmounted and we can no longer write to it.
    File directory = resource.getDownloadDirectory();
    if (!Utils.directoryCreate(directory)) {
      new AlertDialog.Builder(ad)
          .setIcon(R.drawable.ic_launcher)
          .setTitle(VizApp.getResString(R.string.download_failed))
          .setMessage(VizApp.getResString(R.string.storage_error))
          .setNeutralButton(R.string.ok, null)
          .create()
          .show();
      return;
    }

    Uri uri =
        VizApp.getResolver().insert(VizContract.Downloads.CONTENT_URI, resource.toContentValues());
    if (uri == null) {
      Log.e("Could not add download to database error");
      Toast.makeText(
              VizApp.getContext(),
              VizApp.getResString(R.string.database_access_error),
              Toast.LENGTH_LONG)
          .show();
      return;
    }

    Log.d("(uri=" + uri + ")");

    resource.setDownloadUri(uri);

    Downloads downloads = ad.getDownloadsFragment();
    downloads.queue(resource);
  }