Ejemplo n.º 1
0
    public BackUpTask(FragmentActivity activity) {
      super(activity);
      String s = activity.getApplicationInfo().dataDir;
      app_internal = new File(s).listFiles(new FilesDirFilter());

      appFiles = new ArrayList<>(3);

      // Get the path of all the app files in both the sd card, the emulated memory, and the
      // internal memory
      appFiles.add(activity.getFilesDir());

      if (FileHandler.isExternalStorageWritable(activity)) {
        appFiles.add(FileHandler.getExternalFilesDir(activity));
      }

      if (FileHandler.isEmulatedFilesDirWritable()) {
        final File emulatedDir = FileHandler.getEmulatedFilesDir(activity);
        if (emulatedDir != null) appFiles.add(emulatedDir);
      }

      // Get the destination path
      if (isSdCardWritable(activity)) {
        // Only true if there is an sd card and android version is less than 5.0
        output = new File(FileHandler.getExternalStorageDirectory(activity), FILENAME);
      } else if (FileHandler.isEmulatedFilesDirWritable()) {
        output = new File(Environment.getExternalStorageDirectory(), FILENAME);
      } else {
        output = null;
        cancel(true);
      }
    }
Ejemplo n.º 2
0
  private void updateViews() {
    Log.e("", "Size: " + mMenu.size());
    isRunning = prefs.getBoolean(C.PREF_SATURATE_START, false);
    seek.setEnabled(!isRunning);
    if (isRunning) {
      final File file = new File(fa.getFilesDir(), C.CACHEIMG);

      Thread thread =
          new Thread() {
            @Override
            public void run() {
              final Bitmap myBitmap = BitmapFactory.decodeFile(file.toString());
              fa.runOnUiThread(
                  new Runnable() {
                    public void run() {
                      image.setImageBitmap(mUtils.toGrayscale(myBitmap, mUtils.h2F()));
                      seek.setProgress(hour);
                      if (mMenu.size() > 1) {
                        mMenu.getItem(0).setVisible(false);
                        mMenu.getItem(1).setVisible(true);
                      }
                    }
                  });
            }
          };

      thread.start();
    } else {
      seek.setProgress(hour);
      if (mMenu.size() > 1) {
        mMenu.getItem(0).setVisible(true);
        mMenu.getItem(1).setVisible(false);
      }
    }
  }