Android Open Source - dropdroid Util






From Project

Back to project page dropdroid.

License

The source code is released under:

GNU General Public License

If you think the Android project dropdroid 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.fjaviermo.Utils;
/*w w  w  . j ava2  s.c  om*/
import java.text.Collator;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.Locale;

public class Util {

  public enum SORT { NAME, DATE};

  /**
   * Devuelve el nombre de un archivo sin extension, si la extension
   * es la correcta
   */
  public static String getBaseName(String extension, String filename) {
    extension = "." + extension;
    if (filename.endsWith(extension)) {
      return filename.substring(0, filename.length() - extension.length());
    }
    return filename;
  }

  /**
   * Devuelve el tamao de una archivo en formato legible 
   */
  public static String readableFileSize(long size) {
    if(size <= 0) return "0";
    final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" };
    int digitGroups = (int) (Math.log10(size)/Math.log10(1024));
    return new DecimalFormat("#,##0.#").format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
  }

  /**
   * Devuelve un valor negativo si lname es menor que rname,
   * 0 si son iguales y un valor positivo si lname es mayor.
   */
  public static int compareNames(String lname, String rname) {
    Collator c = Collator.getInstance(Locale.getDefault());
    c.setStrength(Collator.SECONDARY); // Case-insensitive

    return c.compare(lname, rname);
  }

  /**
   * Un entero < 0 si ldate es mejor que rname, 0 son iguales, 
   * y un entero > 0 si ldate es mayor.
   */
  public static int compareDates(Date ldate, Date rdate) {
    return ldate.compareTo(rdate);
  }

  /**
   * Devuelve la diferencia entre lsize y rsize.
   */
  public static long compareSizes(long lsize, long rsize) {
    return lsize - rsize;
  }
}




Java Source Code List

com.fjaviermo.Utils.DropDroidConfig.java
com.fjaviermo.Utils.Util.java
com.fjaviermo.adapter.EpubAdapter.java
com.fjaviermo.comparator.EpubDateComparator.java
com.fjaviermo.comparator.EpubNameComparator.java
com.fjaviermo.dropdroid.CoverImageDialogFragment.java
com.fjaviermo.dropdroid.EpubListFragment.java
com.fjaviermo.dropdroid.EpubLoader.java
com.fjaviermo.dropdroid.MainActivity.java