Android Open Source - android-furk-app A P I Utils






From Project

Back to project page android-furk-app.

License

The source code is released under:

Apache License

If you think the Android project android-furk-app 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.simple.furk;
//from ww w  .  j  a  va 2s.com
import android.content.Context;
import android.widget.Toast;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Nicolas on 4/15/2014.
 */
public class APIUtils {

    public static String formatSize(String strSize)
    {
        try {
            long size = Long.parseLong(strSize);
            String sizePref = "B";
            if (size >= 1073741824) {
                size = size / 1073741824;
                sizePref = "GB";
            } else if (size >= 1048576) {
                size = size / 1048576;
                sizePref = "MB";
            } else if (size >= 1024) {
                size = size / 1024;
                sizePref = "KB";
            }

            return "Size: "+size +" "+ sizePref;
        }
        catch (NumberFormatException e)
        {
            return "";
        }
    }
    public static String formatDate(String strDate)
    {
        try {
            // create SimpleDateFormat object with source string date format
            SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            // parse the string into Date object
            Date date = sdfSource.parse(strDate);
            Date now = new Date();

            SimpleDateFormat sdfDestination;
            if(date.getYear() == now.getYear())
                sdfDestination = new SimpleDateFormat("dd MMM");
            else
                sdfDestination = new SimpleDateFormat("dd/MM/yyyy");

            return "Added on: "+sdfDestination.format(date);

        } catch (ParseException pe) {
            return "";
        }

    }

    public static String formatBitRate(String bitRate)
    {
        return "Bitrate: "+ bitRate + " KB/s";
    }

}




Java Source Code List

com.simple.furk.APIClient.java
com.simple.furk.APIUtils.java
com.simple.furk.FileActivity.java
com.simple.furk.FurkServiceGuideExtension.java
com.simple.furk.Furk.java
com.simple.furk.LogExceptionHandler.java
com.simple.furk.LoginActivity.java
com.simple.furk.MainActivity.java
com.simple.furk.NavigationDrawerFragment.java
com.simple.furk.SearchActivity.java
com.simple.furk.SettingsActivity.java
com.simple.furk.adapter.ActiveFilesAdapter.java
com.simple.furk.adapter.FilesAdapter.java
com.simple.furk.adapter.MyFilesAdapter.java
com.simple.furk.adapter.SearchFilesAdapter.java
com.simple.furk.adapter.TFilesAdapter.java