Exemplo n.º 1
0
 /**
  * Compare two OpenPath files, with sorting taken into account
  *
  * @param fa First OpenPath
  * @param fb Second OpenPath
  * @return an int determined by comparing the two paths. Possible values are described in the
  *     Comparable interface.
  * @see Comparable
  */
 public static int compare(OpenPath fa, OpenPath fb) {
   try {
     if (fa == null && fb != null) return 1;
     if (fb == null && fa != null) return 0;
     if (fb == null || fa == null) return 0;
     if (Sorting.foldersFirst()) {
       if (fb.isDirectory() && !fa.isDirectory()) return 1;
       if (fa.isDirectory() && !fb.isDirectory()) return -1;
     }
     String a = fa.getName();
     String b = fb.getName();
     Long sa = fa.length();
     Long sb = fb.length();
     Long ma = fa.lastModified();
     Long mb = fb.lastModified();
     if (a == null && b != null) return 1;
     if (a == null || b == null) return 0;
     switch (Sorting.getType()) {
       case ALPHA_DESC:
         return b.toLowerCase().compareTo(a.toLowerCase());
       case ALPHA:
         return a.toLowerCase().compareTo(b.toLowerCase());
       case SIZE_DESC:
         if (sa == null && sb != null) return 1;
         if (sa == null || sb == null) return 0;
         return sa.compareTo(sb);
       case SIZE:
         if (sb == null && sa != null) return 1;
         if (sa == null || sb == null) return 0;
         return sb.compareTo(sa);
       case DATE_DESC:
         if (ma == null && mb != null) return 1;
         if (ma == null || mb == null) return 0;
         return ma.compareTo(mb);
       case DATE:
         if (mb == null && ma != null) return 1;
         if (ma == null || mb == null) return 0;
         return mb.compareTo(ma);
       case TYPE:
         String ea = a.substring(a.lastIndexOf(".") + 1, a.length()).toLowerCase();
         String eb = b.substring(b.lastIndexOf(".") + 1, b.length()).toLowerCase();
         return ea.compareTo(eb);
       case NONE:
         return 0;
       default:
         return a.toLowerCase().compareTo(b.toLowerCase());
     }
   } catch (Exception e) {
     Logger.LogError("Unable to sort.", e);
     return 0;
   }
 }
Exemplo n.º 2
0
 @Override
 public Bitmap getDetailTexture(int n) {
   Bitmap bitmap =
       Bitmap.createBitmap(DETAIL_TEXTURE_WIDTH, DETAIL_TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);
   Canvas canvas = new Canvas(bitmap);
   canvas.drawARGB(32, 10, 10, 10);
   mPaint.setTextSize(15.0f);
   mPaint.setAntiAlias(true);
   OpenPath mPath = mPathItems[n];
   if (mPath == null)
     canvas.drawText("Detail text for card " + n, 0, DETAIL_TEXTURE_HEIGHT / 2, mPaint);
   else {
     Path p = new Path();
     RectF bounds = new RectF();
     String s = mPath.getName();
     int y = (int) mPaint.getTextSize() + 2;
     while (s != "") {
       mPaint.getTextPath(s, 0, s.length(), 0, 0, p);
       p.computeBounds(bounds, true);
       float lines = Math.max(1, bounds.right / DETAIL_TEXTURE_WIDTH);
       int chars = (int) (s.length() / lines);
       canvas.drawText(s, 0, chars, 0, y, mPaint);
       if (chars >= s.length()) break;
       y += bounds.height() + 2;
       s = s.substring(chars).trim();
     }
   }
   return bitmap;
 }
Exemplo n.º 3
0
 @Override
 public OpenPath getChild(String name) {
   try {
     for (OpenPath kid : list()) if (kid.getName().equals(name)) return kid;
   } catch (IOException e) {
   }
   return null;
 }
Exemplo n.º 4
0
 @Override
 public OpenPath getChild(String name) {
   try {
     OpenPath[] kids = list();
     for (OpenPath kid : kids) if (kid.getName().equals(name)) return kid;
   } catch (Exception e) {
   }
   return null;
 }
Exemplo n.º 5
0
 @Override
 public OpenPath getChild(String name) {
   try {
     for (OpenPath kid : list()) if (kid.getName().equals(name)) return kid;
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }
Exemplo n.º 6
0
    @Override
    public Bitmap getTexture(int n) {
      final int textw = TEXTURE_WIDTH;
      final int texth = TEXTURE_HEIGHT;
      final int px = PIXEL_BORDER;

      Bitmap bitmap = Bitmap.createBitmap(textw, texth, Bitmap.Config.ARGB_8888);
      Canvas canvas = new Canvas(bitmap);

      int w = textw;
      int h = texth;

      SoftReference<Bitmap> thumb = null;

      final OpenPath mPath = mPathItems[n];
      mPaint.setColor(0x40808080);

      canvas.drawARGB(0, 0, 0, 0);
      mPaint.setColor(0xffffffff);
      mPaint.setAntiAlias(true);

      if (mPathItems != null
          && (thumb = ThumbnailCreator.generateThumb(mPath, textw, texth, getApplicationContext()))
              != null
          && thumb.get() != null) {
        Bitmap b = thumb.get();
        w = b.getWidth();
        h = b.getHeight();
        // canvas.drawRect(2, 2, w - 2, h - 2, mPaint);
        // canvas.drawRect(px, px, textw - px, texth, mBlackPaint);
        Matrix matrix = canvas.getMatrix();
        matrix.setRectToRect(new RectF(0, 0, w, h), new RectF(0, 0, w, h), ScaleToFit.START);
        canvas.drawBitmap(b, matrix, null);
      } else {
        canvas.drawRect(2, 2, w - 2, h - 2, mPaint);
        mPaint.setTextSize(100.0f);
        if (mPath == null) canvas.drawText("" + n, 2, h - 10, mPaint);
        else {
          mPaint.setTextSize(30f);
          canvas.drawText(mPath.getName(), 2, h - 10, mPaint);
        }
        canvas.drawBitmap(mGlossyOverlay, null, new Rect(px, px, textw - px, texth - px), mPaint);
      }
      return bitmap;
    }
Exemplo n.º 7
0
 @Override
 public OpenPath getChild(String name) {
   for (OpenPath kid : mKids) if (kid.getName().equals(name)) return kid;
   return null;
 }
Exemplo n.º 8
0
 @Override
 public CharSequence getTitle() {
   return mPath.getName();
 }