Android Toast Create showElapsed(long start, long end, Context ctx)

Here you can find the source of showElapsed(long start, long end, Context ctx)

Description

show Elapsed

Declaration

public static void showElapsed(long start, long end, Context ctx) 

Method Source Code

//package com.java2s;
import java.math.BigDecimal;
import android.content.Context;
import android.util.Log;

public class Main {
    public static void showElapsed(long start, long end, Context ctx) {
        /*if (end - start < 1000) {
           return;//from   w  ww .j a  v  a2 s.  co  m
        }
        Toast.makeText(ctx, "Request took " + getElapsedSeconds(start, end) + " seconds to execute", Toast.LENGTH_SHORT).show();*/
        Log.i("ElapsedTimeUtil",
                "Request took " + getElapsedSeconds(start, end)
                        + " seconds to execute");
    }

    public static double getElapsedSeconds(long start, long end) {
        BigDecimal seconds = new BigDecimal(end - start)
                .divide(new BigDecimal(1000));
        return seconds.doubleValue();
    }
}

Related

  1. showToastShort(Activity ctx, String text)
  2. showToastLong(Activity ctx, String text)
  3. showMessage(Context ctx, String msg)
  4. showMessage(final Activity context, final String message)
  5. showFailure(Activity activity, int id)
  6. formatToastDist(String message, int value, String unit)
  7. formatToastTemp(String message, int value, String unit)
  8. showMessage(final Activity activity, final String message)
  9. showToast(Activity activity, String message)