Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;

public class Main {
    private static float distance(Context context, float diff) {
        float distanceInPx = (float) Math.sqrt(diff * diff);
        return pxToDp(context, distanceInPx);
    }

    private static float pxToDp(Context context, float px) {
        return px / context.getResources().getDisplayMetrics().density;
    }
}