use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class CompressedExplorerFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
compressedFile = new File(Uri.parse(getArguments().getString(KEY_PATH)).getPath());
mToolbarContainer = mainActivity.getAppbar().getAppbarLayout();
mToolbarContainer.setOnTouchListener((view, motionEvent) -> {
if (stopAnims) {
if ((!compressedExplorerAdapter.stoppedAnimation)) {
stopAnim();
}
compressedExplorerAdapter.stoppedAnimation = true;
}
stopAnims = false;
return false;
});
listView.setVisibility(View.VISIBLE);
mLayoutManager = new LinearLayoutManager(getActivity());
listView.setLayoutManager(mLayoutManager);
if (utilsProvider.getAppTheme().equals(AppTheme.DARK)) {
rootView.setBackgroundColor(Utils.getColor(getContext(), R.color.holo_dark_background));
} else if (utilsProvider.getAppTheme().equals(AppTheme.BLACK)) {
listView.setBackgroundColor(Utils.getColor(getContext(), android.R.color.black));
} else {
listView.setBackgroundColor(Utils.getColor(getContext(), android.R.color.background_light));
}
gobackitem = sp.getBoolean(PreferencesConstants.PREFERENCE_SHOW_GOBACK_BUTTON, false);
coloriseIcons = sp.getBoolean(PreferencesConstants.PREFERENCE_COLORIZE_ICONS, true);
showSize = sp.getBoolean(PreferencesConstants.PREFERENCE_SHOW_FILE_SIZE, false);
showLastModified = sp.getBoolean(PreferencesConstants.PREFERENCE_SHOW_LAST_MODIFIED, true);
showDividers = sp.getBoolean(PreferencesConstants.PREFERENCE_SHOW_DIVIDERS, true);
year = ("" + Calendar.getInstance().get(Calendar.YEAR)).substring(2, 4);
skin = mainActivity.getColorPreference().getColorAsString(ColorUsage.PRIMARY);
accentColor = mainActivity.getColorPreference().getColorAsString(ColorUsage.ACCENT);
iconskin = mainActivity.getColorPreference().getColorAsString(ColorUsage.ICON_SKIN);
if (savedInstanceState == null && compressedFile != null) {
files = new ArrayList<>();
// adding a cache file to delete where any user interaction elements will be cached
String fileName = compressedFile.getName().substring(0, compressedFile.getName().lastIndexOf("."));
String path = getActivity().getExternalCacheDir().getPath() + SEPARATOR + fileName;
files.add(new HybridFileParcelable(path));
decompressor = CompressedHelper.getCompressorInstance(getContext(), compressedFile);
changePath("");
} else {
onRestoreInstanceState(savedInstanceState);
}
mainActivity.supportInvalidateOptionsMenu();
}
use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class FileUtils method otgFolderSize.
/**
* Helper method to get size of an otg folder
*/
public static long otgFolderSize(String path, final Context context) {
final AtomicLong totalBytes = new AtomicLong(0);
OTGUtil.getDocumentFiles(path, context, new OnFileFound() {
@Override
public void onFileFound(HybridFileParcelable file) {
totalBytes.addAndGet(getBaseFileSize(file, context));
}
});
return totalBytes.longValue();
}
use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class FileUtils method parseName.
/**
* We're parsing a line returned from a stdout of shell.
* @param line must be the line returned from a 'ls' command
*/
public static HybridFileParcelable parseName(String line) {
boolean linked = false;
StringBuilder name = new StringBuilder();
StringBuilder link = new StringBuilder();
String size = "-1";
String date = "";
String[] array = line.split(" ");
if (array.length < 6)
return null;
for (String anArray : array) {
if (anArray.contains("->") && array[0].startsWith("l")) {
linked = true;
}
}
int p = getColonPosition(array);
if (p != -1) {
date = array[p - 1] + " | " + array[p];
size = array[p - 2];
}
if (!linked) {
for (int i = p + 1; i < array.length; i++) {
name.append(" ").append(array[i]);
}
name = new StringBuilder(name.toString().trim());
} else {
int q = getLinkPosition(array);
for (int i = p + 1; i < q; i++) {
name.append(" ").append(array[i]);
}
name = new StringBuilder(name.toString().trim());
for (int i = q + 1; i < array.length; i++) {
link.append(" ").append(array[i]);
}
}
long Size = (size == null || size.trim().length() == 0) ? -1 : Long.parseLong(size);
if (date.trim().length() > 0) {
ParsePosition pos = new ParsePosition(0);
SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd | HH:mm");
Date stringDate = simpledateformat.parse(date, pos);
HybridFileParcelable baseFile = new HybridFileParcelable(name.toString(), array[0], stringDate.getTime(), Size, true);
baseFile.setLink(link.toString());
return baseFile;
} else {
HybridFileParcelable baseFile = new HybridFileParcelable(name.toString(), array[0], new File("/").lastModified(), Size, true);
baseFile.setLink(link.toString());
return baseFile;
}
}
use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class CloudUtil method listFiles.
/**
* @deprecated use getCloudFiles()
*/
public static ArrayList<HybridFileParcelable> listFiles(String path, CloudStorage cloudStorage, OpenMode openMode) throws CloudPluginException {
final ArrayList<HybridFileParcelable> baseFiles = new ArrayList<>();
getCloudFiles(path, cloudStorage, openMode, new OnFileFound() {
@Override
public void onFileFound(HybridFileParcelable file) {
baseFiles.add(file);
}
});
return baseFiles;
}
use of com.amaze.filemanager.filesystem.HybridFileParcelable in project AmazeFileManager by TeamAmaze.
the class MainActivityHelper method showFailedOperationDialog.
public void showFailedOperationDialog(ArrayList<HybridFileParcelable> failedOps, Context contextc) {
MaterialDialog.Builder mat = new MaterialDialog.Builder(contextc);
mat.title(contextc.getString(R.string.operationunsuccesful));
mat.theme(mainActivity.getAppTheme().getMaterialDialogTheme());
mat.positiveColor(accentColor);
mat.positiveText(R.string.cancel);
String content = contextc.getResources().getString(R.string.operation_fail_following);
int k = 1;
for (HybridFileParcelable s : failedOps) {
content = content + "\n" + (k) + ". " + s.getName();
k++;
}
mat.content(content);
mat.build().show();
}
Aggregations