コード例 #1
0
  private void initForm() {
    if (parentNode != null) {
      Uri fileUri = getContract().getFileToExport();

      mFileType.setText("." + FilesUtils.getFileExtension(getActivity(), fileUri));
      String filename = FPFile.contentUriToFilename(fileUri);

      etFilename.setText(Utils.filenameWithoutExtension(filename));
      showSaveButton(filename);
    }

    etFilename.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void afterTextChanged(Editable text) {
            showSaveButton(text.toString() + "." + typeOfExportFile());
          }

          // Not used
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          // Not used
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}
        });

    mBtnSave.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (etFilename.getText().length() > 0) {
              currentView.setEnabled(false);
              currentView.setAlpha(Constants.ALPHA_FADED);
              etFilename.setEnabled(false);
              mBtnSave.setEnabled(false);
              mBtnSave.setText("Saving file...");
              mProgressBar.setVisibility(View.VISIBLE);

              String filename = etFilename.getText().toString();
              getContract().exportFile(filename);
            }
          }
        });
  }
コード例 #2
0
 private String typeOfExportFile() {
   return FilesUtils.getFileExtension(getActivity(), getContract().getFileToExport());
 }