Android Open Source - android-simple-storage Order Type






From Project

Back to project page android-simple-storage.

License

The source code is released under:

Apache License

If you think the Android project android-simple-storage listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.sromku.simple.storage.helpers;
/*  ww  w.  j  a va 2 s  .  c  om*/
import java.io.File;
import java.util.Comparator;

public enum OrderType {

  NAME,
  /**
   * Last modified is the first
   */
  DATE,
  /**
   * Smaller size will be in the first place
   */
  SIZE;

  public Comparator<File> getComparator() {
    switch (ordinal()) {
    case 0: // name
      return new Comparator<File>() {
        @Override
        public int compare(File lhs, File rhs) {
          return lhs.getName().compareTo(rhs.getName());
        }
      }; 
    case 1: // date
      return new Comparator<File>() {
        @Override
        public int compare(File lhs, File rhs) {
          return (int) (rhs.lastModified() - lhs.lastModified());
        }
      }; 
    case 2: // size
      return new Comparator<File>() {
        @Override
        public int compare(File lhs, File rhs) {
          return (int) (lhs.length() - rhs.length());
        }
      }; 
    default:
      break;
    }
    return null;
  }
}




Java Source Code List

com.sromku.simple.storage.AbstractDiskStorage.java
com.sromku.simple.storage.ExternalStorage.java
com.sromku.simple.storage.InternalStorage.java
com.sromku.simple.storage.SimpleStorageConfiguration.java
com.sromku.simple.storage.SimpleStorage.java
com.sromku.simple.storage.Storable.java
com.sromku.simple.storage.StorageException.java
com.sromku.simple.storage.Storage.java
com.sromku.simple.storage.helpers.ImmutablePair.java
com.sromku.simple.storage.helpers.OrderType.java
com.sromku.simple.storage.helpers.SizeUnit.java
com.sromku.simple.storage.security.CipherAlgorithmType.java
com.sromku.simple.storage.security.CipherModeType.java
com.sromku.simple.storage.security.CipherPaddingType.java
com.sromku.simple.storage.security.CipherTransformationType.java
com.sromku.simple.storage.security.SecurityUtil.java