1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package com.epson.iprint.storage;
- import android.content.Context;
- import java.io.File;
- import java.util.Comparator;
- import epson.common.ExternalFileUtils;
- public class StorageItem {
- static final int LOGGERINFO_MYPOCKET_FILE = 2;
- static final int LOGGERINFO_MYPOCKET_PHOTO = 1;
- private static final int LOGGERINFO_NO_INFO = 0;
- int mLoggerInfo = 0;
- public String name;
- public String path;
- public ItemType type;
- public Object userInfo;
- public enum ItemType {
- DIRECTORY,
- FILE,
- PHOTO,
- LOADMORE
- }
- public static boolean endsWith(String str, String str2) {
- if (str2.length() > str.length()) {
- return false;
- }
- return str.regionMatches(true, str.length() - str2.length(), str2, 0, str2.length());
- }
- public StorageItem() {
- }
- public StorageItem(String str) {
- this.name = str;
- }
- public StorageItem(String str, String str2, ItemType itemType) {
- this.name = str;
- this.path = str2;
- this.type = itemType;
- }
- public StorageItem(String str, String str2, ItemType itemType, Object obj) {
- this.name = str;
- this.path = str2;
- this.type = itemType;
- this.userInfo = obj;
- }
- private String getDownloadLocalPath(Context context) {
- File file = new File(ExternalFileUtils.getInstance(context).getDownloadDir());
- if (!file.exists()) {
- file.mkdirs();
- }
- return new File(file.getAbsolutePath(), this.name).getPath();
- }
- public static class NameComparator implements Comparator<StorageItem> {
- public int compare(StorageItem storageItem, StorageItem storageItem2) {
- if (storageItem.name == null || storageItem2.name == null) {
- return -1;
- }
- int compareToIgnoreCase = storageItem.name.compareToIgnoreCase(storageItem2.name);
- if (compareToIgnoreCase != 0) {
- return compareToIgnoreCase;
- }
- if (storageItem.type == null || storageItem2.name == null) {
- return -1;
- }
- return storageItem.type.compareTo(storageItem2.type);
- }
- }
- }
|