Android Open Source - antigravity File Description Helper From Project Back to project page antigravity .
License The source code is released under:
GNU General Public License
If you think the Android project antigravity 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.floatboth.antigravity.ui;
/ / w w w . j a v a 2 s . c o m
import java.util.Map;
import java.util.HashMap;
import java.util.Date;
import android.content.Context;
import android.text.format.DateFormat;
import com.samskivert.mustache.*;
import com.floatboth.antigravity.*;
import com.floatboth.antigravity.data.File;
public class FileDescriptionHelper {
public static String shortDescription(Context context, File file) {
String dateS = dateTime(context, file.createdAt);
String sizeS = size(file.size, false);
return dateS + "\n" + sizeS + " " + file.kind;
}
public static String longDescription(Context context, File file) {
Map<String, String> desc = new HashMap<String, String>();
desc.put("name" , file.name);
desc.put("type" , file.type);
desc.put("date" , dateTime(context, file.createdAt));
desc.put("size" , size(file.size, false));
return Mustache.compiler().compile(context.getString(R.string.file_description_template)).execute(desc);
}
public static String dateTime(Context context, Date date) {
return DateFormat.getMediumDateFormat(context).format(date) +
" " + DateFormat.getTimeFormat(context).format(date);
}
// http://stackoverflow.com/a/3758880
public static String size(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B" ;
int exp = (int ) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE" ).charAt(exp-1) + (si ? "" : "i" );
return String.format("%.1f %sB" , bytes / Math.pow(unit, exp), pre);
}
}
Java Source Code List com.floatboth.antigravity.ADNPrefs.java com.floatboth.antigravity.AntigravityApplication.java com.floatboth.antigravity.CanHasCamera.java com.floatboth.antigravity.DataCache.java com.floatboth.antigravity.data.ADNAuthError.java com.floatboth.antigravity.data.ADNAuthResponse.java com.floatboth.antigravity.data.ADNMeta.java com.floatboth.antigravity.data.ADNResponse.java com.floatboth.antigravity.data.Annotation.java com.floatboth.antigravity.data.Configuration.java com.floatboth.antigravity.data.DerivedFiles.java com.floatboth.antigravity.data.Entities.java com.floatboth.antigravity.data.Entity.java com.floatboth.antigravity.data.FileAnnotationReplacementValueWrapper.java com.floatboth.antigravity.data.FileAnnotationReplacementValue.java com.floatboth.antigravity.data.File.java com.floatboth.antigravity.data.LinkEntity.java com.floatboth.antigravity.data.PostConfiguration.java com.floatboth.antigravity.data.Post.java com.floatboth.antigravity.data.SupportAnnotationValue.java com.floatboth.antigravity.data.Thumbnail.java com.floatboth.antigravity.data.TypedContent.java com.floatboth.antigravity.net.ADNClient.java com.floatboth.antigravity.net.ADNSpiceService.java com.floatboth.antigravity.net.ConfigurationRequest.java com.floatboth.antigravity.net.CreatePostRequest.java com.floatboth.antigravity.net.DeleteFileRequest.java com.floatboth.antigravity.net.LoginRequest.java com.floatboth.antigravity.net.MyFilesRequest.java com.floatboth.antigravity.net.UpdateFileRequest.java com.floatboth.antigravity.net.UploadFileRequest.java com.floatboth.antigravity.post.LinkPostFactory.java com.floatboth.antigravity.post.OembedPostFactory.java com.floatboth.antigravity.post.PlainPostFactory.java com.floatboth.antigravity.post.PostFactory.java com.floatboth.antigravity.post.SupportPostFactory.java com.floatboth.antigravity.ui.AboutActivity.java com.floatboth.antigravity.ui.BaseActivity.java com.floatboth.antigravity.ui.FileActivity.java com.floatboth.antigravity.ui.FileDescriptionHelper.java com.floatboth.antigravity.ui.FileListAdapter.java com.floatboth.antigravity.ui.FileListFragment.java com.floatboth.antigravity.ui.LicenseActivity.java com.floatboth.antigravity.ui.LoginActivity.java com.floatboth.antigravity.ui.MainActivity.java com.floatboth.antigravity.ui.PostActivity.java com.floatboth.antigravity.ui.UploadActivity.java net.app.adnlogin.ADNPassportUtility.java