StorageItem.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package com.epson.iprint.storage;
  2. import android.content.Context;
  3. import java.io.File;
  4. import java.util.Comparator;
  5. import epson.common.ExternalFileUtils;
  6. public class StorageItem {
  7. static final int LOGGERINFO_MYPOCKET_FILE = 2;
  8. static final int LOGGERINFO_MYPOCKET_PHOTO = 1;
  9. private static final int LOGGERINFO_NO_INFO = 0;
  10. int mLoggerInfo = 0;
  11. public String name;
  12. public String path;
  13. public ItemType type;
  14. public Object userInfo;
  15. public enum ItemType {
  16. DIRECTORY,
  17. FILE,
  18. PHOTO,
  19. LOADMORE
  20. }
  21. public static boolean endsWith(String str, String str2) {
  22. if (str2.length() > str.length()) {
  23. return false;
  24. }
  25. return str.regionMatches(true, str.length() - str2.length(), str2, 0, str2.length());
  26. }
  27. public StorageItem() {
  28. }
  29. public StorageItem(String str) {
  30. this.name = str;
  31. }
  32. public StorageItem(String str, String str2, ItemType itemType) {
  33. this.name = str;
  34. this.path = str2;
  35. this.type = itemType;
  36. }
  37. public StorageItem(String str, String str2, ItemType itemType, Object obj) {
  38. this.name = str;
  39. this.path = str2;
  40. this.type = itemType;
  41. this.userInfo = obj;
  42. }
  43. private String getDownloadLocalPath(Context context) {
  44. File file = new File(ExternalFileUtils.getInstance(context).getDownloadDir());
  45. if (!file.exists()) {
  46. file.mkdirs();
  47. }
  48. return new File(file.getAbsolutePath(), this.name).getPath();
  49. }
  50. public static class NameComparator implements Comparator<StorageItem> {
  51. public int compare(StorageItem storageItem, StorageItem storageItem2) {
  52. if (storageItem.name == null || storageItem2.name == null) {
  53. return -1;
  54. }
  55. int compareToIgnoreCase = storageItem.name.compareToIgnoreCase(storageItem2.name);
  56. if (compareToIgnoreCase != 0) {
  57. return compareToIgnoreCase;
  58. }
  59. if (storageItem.type == null || storageItem2.name == null) {
  60. return -1;
  61. }
  62. return storageItem.type.compareTo(storageItem2.type);
  63. }
  64. }
  65. }