예제 #1
0
 public void updateAdapter(List<FileInformation> hogFiles) {
   this.hogFiles = hogFiles;
   if (fileInformationAdapter == null) {
     fileInformationAdapter =
         new FileInformationAdapter(context, android.R.layout.simple_list_item_1, hogFiles);
     setListAdapter(fileInformationAdapter);
   } else {
     fileInformationAdapter.setFileInformations(hogFiles);
   }
 }
예제 #2
0
        @Override
        public void onClick(DialogInterface dialog, int which) {
          switch (which) {
            case DialogInterface.BUTTON_POSITIVE:

              /*
               * Pair[] aryHogFiles = (isBiggestFiles ? biggestHogFiles
               * .getHogFiles().toArray( new
               * Pair[biggestHogFiles.getHogFiles().size()]) :
               * smallestHogFiles.getHogFiles() .toArray( new
               * Pair[smallestHogFiles.getHogFiles() .size()]));
               */
              FileInformation[] fileInformations =
                  hogFiles.toArray(new FileInformation[hogFiles.size()]);
              File removingFile =
                  new File(
                      fileInformations[position].getFolder()
                          + File.separator
                          + fileInformations[position].getName());

              Log.d(TAG, "removingFile: " + removingFile);

              boolean isRemoved = removingFile.delete();
              // boolean isRemoved = hogFiles.remove(removingFile);
              String result;
              if (isRemoved) {
                result = "File removed";
                fileInformationAdapter.remove(position);
              } else {
                result = "File not removed";
              }
              Toast.makeText(getActivity(), result, Toast.LENGTH_SHORT).show();

              // boolean isDeleted = clickedFile.delete();
              clickedFile = null;
              // String strOutput = "IsDeleted: " + isDeleted;

              // if (Constants.debugOn)
              // FileIO.writeFile(strOutput, "FileHog_Output.txt");

              /*  switch (settings.getSelectedSearchDirectory()) {
                  case Settings.EXTERNAL_DIRECTORY:
                      if (isBiggestFiles
                              && hogFiles.size() - settings.getBiggestExternalExcludedHogFiles().size() < settings
                              .getIntFileCount()) {

                          startFileSearch();
                      } else if (!isBiggestFiles
                              && hogFiles.size() - settings.getSmallestExternalExcludedHogFiles().size() < settings
                              .getIntFileCount()) {

                          startFileSearch();
                      } else {
                          startFileSearch();
                      }
                      break;
                  case Settings.ROOT_DIRECTORY:
                      if (isBiggestFiles
                              && hogFiles.size() - settings.getBiggestRootExcludedHogFiles().size() < settings
                              .getIntFileCount()) {

                          startFileSearch();
                      } else if (!isBiggestFiles
                              && hogFiles.size() - settings.getSmallestRootExcludedHogFiles().size() < settings
                              .getIntFileCount()) {

                          startFileSearch();

                      } else {
                          startFileSearch();
                      }
                      break;
              }*/
              break;
            case DialogInterface.BUTTON_NEGATIVE:
              break;
          }
          dialog.dismiss();
        }
예제 #3
0
        @Override
        public void onClick(DialogInterface dialog, int which) {

          switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
              // Delete
              AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
              builder.setIcon(android.R.drawable.ic_dialog_alert);
              builder.setTitle("Delete File");
              builder.setMessage("Are you sure?");
              builder.setPositiveButton("Yes", dialogClickListener_YesOrNo);
              builder.setNegativeButton("No", dialogClickListener_YesOrNo).show();
              break;
            case DialogInterface.BUTTON_NEGATIVE:
              // Copy
              builder = null;
              ClipboardManager clipboard =
                  (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
              File file =
                  new File(clickedFile.getFolder() + File.separator + clickedFile.getName());
              Uri uri = Uri.fromFile(file);
              ClipData clip = ClipData.newUri(context.getContentResolver(), "URI", uri);
              clipboard.setPrimaryClip(clip);
              Toast.makeText(
                      context.getApplicationContext(),
                      "File copied to clipboard",
                      Toast.LENGTH_SHORT)
                  .show();
              break;
            case DialogInterface.BUTTON_NEUTRAL:
              // Exclude File
              Log.i(TAG, clickedFile.getFolder() + " added to excludedHogFiles");
              switch (settings.getSelectedSearchDirectory()) {
                case Settings.EXTERNAL_DIRECTORY:
                  if (isBiggestFiles) {
                    settings.getBiggestExternalExcludedHogFiles().add(clickedFile);
                    List<FileInformation> updatedHogFiles =
                        removeExcludedFromHogFiles(settings.getBiggestExternalExcludedHogFiles());
                    fileInformationAdapter.setFileInformations(updatedHogFiles);
                  } else {
                    settings.getSmallestExternalExcludedHogFiles().add(clickedFile);
                    List<FileInformation> updatedHogFiles =
                        removeExcludedFromHogFiles(settings.getSmallestExternalExcludedHogFiles());
                    fileInformationAdapter.setFileInformations(updatedHogFiles);
                  }
                  break;
                case Settings.ROOT_DIRECTORY:
                  if (isBiggestFiles) {
                    settings.getBiggestRootExcludedHogFiles().add(clickedFile);
                    List<FileInformation> updatedHogFiles =
                        removeExcludedFromHogFiles(settings.getBiggestRootExcludedHogFiles());
                    fileInformationAdapter.setFileInformations(updatedHogFiles);
                  } else {
                    settings.getSmallestRootExcludedHogFiles().add(clickedFile);
                    List<FileInformation> updatedHogFiles =
                        removeExcludedFromHogFiles(settings.getSmallestRootExcludedHogFiles());
                    fileInformationAdapter.setFileInformations(updatedHogFiles);
                  }
                  break;
              }
              break;
          }
        }