//package com.retain;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.util.Date;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.widget.ImageView;
import android.widget.Toast;
/**
* @author Nazmul Idris
* @version 1.0
* @since Jul 8, 2008, 2:35:39 PM
*/
class AppUtils {
/**
* 127.0.0.1 in the emulator points back to itself. Use this if you want to
* access your host OS
*/
public static String EmulatorLocalhost = "10.0.2.2";
private static final String[] months = { "Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
static public String getDateStr(long milliseconds, Date currentDate) {
// seconds diff
long diff = (long) (currentDate.getTime() - milliseconds) / 1000;
if (diff < 3600) {
long minutesAgo = (long) diff / 60;
if (minutesAgo < 1)
return "seconds ago";
else if (minutesAgo == 1)
return "1 minute ago";
else
return (String.valueOf(minutesAgo) + " minutes ago");
} else if (diff < 7200)
return "1 hour ago";
else if (diff < 86400)
return (String.valueOf((int) diff / 3600) + " hours ago");
else {
Date d = new Date(milliseconds);
return months[d.getMonth()] + " " + d.getDate();
}
}
}// end class AppUtils