Android Open Source - trifork-ibeacon-demo Utils






From Project

Back to project page trifork-ibeacon-demo.

License

The source code is released under:

Apache License

If you think the Android project trifork-ibeacon-demo 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.trifork.ibeacon.util;
/*w w w.ja v a  2s  .  c  o  m*/
import org.altbeacon.beacon.Beacon;
import org.altbeacon.beacon.Region;

import java.text.DecimalFormat;

public class Utils {

    private static DecimalFormat rangeFormatter = new DecimalFormat("#,##0.0");

    public static String formatRange(double rangeInMeters) {
        return rangeFormatter.format(rangeInMeters);
    }

    public static boolean isSameBeacon(Beacon entry, Region selectedBeacon) {
        if (entry == null || selectedBeacon == null) return false;
        return (entry.getId1().equals(selectedBeacon.getId1())
                && entry.getId2().equals(selectedBeacon.getId2())
                && entry.getId3().equals(selectedBeacon.getId3()));
    }

    public static Proximity proximityFromDistance(double accuracy) {
        if (accuracy < 0.0D) {
            return Proximity.UNKNOWN;
        }
        if (accuracy < 0.5D) {
            return Proximity.IMMEDIATE;
        }
        if (accuracy <= 3.0D) {
            return Proximity.NEAR;
        }
        return Proximity.FAR;
    }

    private static double computeAccuracy(Beacon beacon) {
//            if (beacon.getRssi() == 0) {
//                return -1.0D;
//            }
//
//            double ratio = beacon.getRssi() / beacon.getTxPower();
//            double rssiCorrection = 0.96D + Math.pow(Math.abs(beacon.getRssi()), 3.0D) % 10.0D / 150.0D;
//
//            if (ratio <= 1.0D) {
//                return Math.pow(ratio, 9.98D) * rssiCorrection;
//            }
//            return (0.103D + 0.89978D * Math.pow(ratio, 7.71D)) * rssiCorrection;

        return 0;
    }


    public static enum Proximity {
        UNKNOWN,
        IMMEDIATE,
        NEAR,
        FAR;
    }
}




Java Source Code List

com.echo.holographlibrary.BarGraph.java
com.echo.holographlibrary.Bar.java
com.echo.holographlibrary.LineGraph.java
com.echo.holographlibrary.LinePoint.java
com.echo.holographlibrary.Line.java
com.echo.holographlibrary.PieGraph.java
com.echo.holographlibrary.PieSlice.java
com.echo.holographlibrary.Utils.java
com.trifork.ibeacon.ApplicationContext.java
com.trifork.ibeacon.ApplicationModule.java
com.trifork.ibeacon.BaseActivity.java
com.trifork.ibeacon.BaseApplication.java
com.trifork.ibeacon.BaseFragment.java
com.trifork.ibeacon.BootBroadcastReceiver.java
com.trifork.ibeacon.MainActivity.java
com.trifork.ibeacon.database.Dao.java
com.trifork.ibeacon.database.Database.java
com.trifork.ibeacon.database.RegionHistoryCursorLoader.java
com.trifork.ibeacon.database.RegionHistoryEntry.java
com.trifork.ibeacon.detectors.BeaconController.java
com.trifork.ibeacon.detectors.IBeaconParser.java
com.trifork.ibeacon.eventbus.FullScanCompleteEvent.java
com.trifork.ibeacon.eventbus.NewBeaconSelectedEvent.java
com.trifork.ibeacon.eventbus.OttoEvent.java
com.trifork.ibeacon.eventbus.RangeScanCompleteEvent.java
com.trifork.ibeacon.eventbus.RequestBeaconScanEvent.java
com.trifork.ibeacon.eventbus.RequestBeaconTransmit.java
com.trifork.ibeacon.eventbus.RequestFullScanEvent.java
com.trifork.ibeacon.eventbus.StopFullScanEvent.java
com.trifork.ibeacon.eventbus.StopScanEvent.java
com.trifork.ibeacon.eventbus.StopTransmitEvent.java
com.trifork.ibeacon.ui.BeaconDataFragment.java
com.trifork.ibeacon.ui.LocationFragment.java
com.trifork.ibeacon.ui.NotificationFragment.java
com.trifork.ibeacon.ui.RangingFragment.java
com.trifork.ibeacon.ui.RegionLogFragment.java
com.trifork.ibeacon.ui.ScanFragment.java
com.trifork.ibeacon.util.CircularBuffer.java
com.trifork.ibeacon.util.PersistentState.java
com.trifork.ibeacon.util.Utils.java
com.trifork.ibeacon.widgets.BeaconView.java
com.trifork.ibeacon.widgets.LocationTrackerView.java