private void sortDate() { if (sort == 5) { oldPref.setPreferences("displaySort", 4); } else { oldPref.setPreferences("displaySort", 5); } sort = (int) oldPref.getPreferences("displaySort"); generateAdapterView(tempItemList, sort); }
private void sortDuration() { if (sort == 3) { oldPref.setPreferences("displaySort", 2); } else { oldPref.setPreferences("displaySort", 3); } sort = (int) oldPref.getPreferences("displaySort"); generateAdapterView(tempItemList, sort); }
public void confirmDelete() { exportList = new ArrayList<String>(); for (int i = 0; i < adapter.checkBoxState.length; i++) { if (adapter.checkBoxState[i]) { exportList.add(currentDir + "/" + fileItemList.get(i).getName()); } } if (exportList.size() > 0) { deleteFiles(exportList); Toast.makeText(AudioFiles.this, "File has been deleted", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AudioFiles.this, "Select a file to delete", Toast.LENGTH_SHORT).show(); } sort = (int) oldPref.getPreferences("displaySort"); generateAdapterView(tempItemList, sort); hideFragment(R.id.file_actions); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.audio_list); // Hide the fragment to start with hideFragment(R.id.file_actions); // Pull file directory and sorting Preferences oldPref = new InternsPreferencesManager(this); currentDir = (String) oldPref.getPreferences("fileDirectory"); pref = PreferenceManager.getDefaultSharedPreferences(this); if (pref.getString("fileDirectory", null) == null) { pref.edit() .putString( "fileDirectory", Environment.getExternalStorageDirectory().getAbsolutePath().toString() + "/" + this.getString(R.string.folder_name)) .commit(); } currentDir = pref.getString("fileDirectory", currentDir); AudioInfo.fileDir = currentDir; sort = (int) oldPref.getPreferences("displaySort"); audioFileView = (ListView) findViewById(R.id.main_content); btnCheckAll = (CheckBox) findViewById(R.id.btnCheckAll); mPreviousDir = (ImageButton) findViewById(R.id.btnPreviousDir); mDirectoryPath = (TextView) findViewById(R.id.pathView); runOnUiThread( new Runnable() { @Override public void run() { mDirectoryPath.setText(currentDir); mDirectoryPath.invalidate(); } }); setButtonHandlers(); FragmentManager fm = getFragmentManager(); mExportTaskFragment = (ExportTaskFragment) fm.findFragmentByTag(TAG_EXPORT_TASK_FRAGMENT); if (savedInstanceState != null) { mZipping = savedInstanceState.getBoolean(STATE_ZIPPING, false); mExporting = savedInstanceState.getBoolean(STATE_EXPORTING, false); mProgress = savedInstanceState.getInt(STATE_PROGRESS, 0); } // check if fragment was retained from a screen rotation if (mExportTaskFragment == null) { mExportTaskFragment = new ExportTaskFragment(); fm.beginTransaction().add(mExportTaskFragment, TAG_EXPORT_TASK_FRAGMENT).commit(); fm.executePendingTransactions(); } else { if (mZipping) { zipProgress(mProgress); } else if (mExporting) { exportProgress(mProgress); } } }