• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Utils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.estimote.sdk.Utils的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Utils类属于com.estimote.sdk包,在下文中一共展示了Utils类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handle

import com.estimote.sdk.Utils; //导入依赖的package包/类
/**
 * Calculate distance to Eddystone and calculate mean if enough values have been stored.
 *
 * @param eddystone The Eddystone to which to determine the distance.
 */
private void handle(Eddystone eddystone) {
    Log.d(TAG, "Found Eddystone "
            + eddystone.instance +
            " at distance "
            + Double.toString(Utils.computeAccuracy(eddystone)));

    mValues.add(Utils.computeAccuracy(eddystone));

    if (mValues.size() == NUM_SAMPLES) {
        Double mean = calculateArithmeticMean(mValues);
        mValues.clear();

        Log.d(TAG, "Mean calculated: " + Double.toString(mean));

        if (mean < mThresholdDistance && !mInRange) {
            Log.d(TAG, "Beacon in range, fire gesture.");
            mInRange = true;
            fireGestureDetected();
        } else if (mean > mThresholdDistance && mInRange){
            Log.d(TAG, "Beacon out of range");
            mInRange = false;
        }
    }
}
 
开发者ID:informatik-mannheim,项目名称:gesture-framework,代码行数:30,代码来源:ApproachDetector.java


示例2: calculateNearestBeacon

import com.estimote.sdk.Utils; //导入依赖的package包/类
/******** Helper methods ********/

    @Nullable
    private Beacon calculateNearestBeacon(Collection<Beacon> beacons) {
        Beacon nearestBeacon = null;
        Double shortestDistance = null;
        for (Beacon beacon : beacons) {
            double distance = Utils.computeAccuracy(beacon);
            if (nearestBeacon != null) {
                if (distance < shortestDistance) {
                    nearestBeacon = beacon;
                    shortestDistance = distance;
                }
            } else {
                nearestBeacon = beacon;
                shortestDistance = distance;
            }
        }
        return nearestBeacon;
    }
 
开发者ID:ribot,项目名称:ribot-app-android,代码行数:21,代码来源:AutoCheckInService.java


示例3: calculateDistance

import com.estimote.sdk.Utils; //导入依赖的package包/类
private double calculateDistance(Beacon beacon)
{
	double calculatedDistance = Math.pow(10d, ((double) beacon.getMeasuredPower() - beacon.getRssi()) / (10 * 4));
	double estimoteDistance = Utils.computeAccuracy(beacon);

	return (calculatedDistance + estimoteDistance) / 2.0;
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:8,代码来源:BeaconListener.java


示例4: findNearestBeacon

import com.estimote.sdk.Utils; //导入依赖的package包/类
private static Beacon findNearestBeacon(List<Beacon> beacons) {
    Beacon nearestBeacon = null;
    double nearestBeaconsDistance = -1;
    for (Beacon beacon : beacons) {
        double distance = Utils.computeAccuracy(beacon);
        if (distance > -1 &&
                (distance < nearestBeaconsDistance || nearestBeacon == null)) {
            nearestBeacon = beacon;
            nearestBeaconsDistance = distance;
        }
    }

    Log.d(TAG, "Nearest beacon: " + nearestBeacon + ", distance: " + nearestBeaconsDistance);
    return nearestBeacon;
}
 
开发者ID:rominirani,项目名称:Estimote-Slack,代码行数:16,代码来源:NearestBeaconManager.java


示例5: bind

import com.estimote.sdk.Utils; //导入依赖的package包/类
private void bind(Beacon beacon, View view) {
    ViewHolder holder = (ViewHolder) view.getTag();
    holder.macTextView.setText(String.format("MAC: %s (%.2fm)", beacon.getMacAddress().toStandardString(), Utils.computeAccuracy(beacon)));
    holder.majorTextView.setText("Major: " + beacon.getMajor());
    holder.minorTextView.setText("Minor: " + beacon.getMinor());
    holder.measuredPowerTextView.setText("MPower: " + beacon.getMeasuredPower());
    holder.rssiTextView.setText("RSSI: " + beacon.getRssi());
}
 
开发者ID:donniepropst,项目名称:note.cntxt,代码行数:9,代码来源:BeaconListAdapter.java


示例6: bind

import com.estimote.sdk.Utils; //导入依赖的package包/类
private void bind(Beacon beacon, View view) {
  ViewHolder holder = (ViewHolder) view.getTag();
  holder.macTextView.setText(String.format("MAC: %s (%.2fm)", beacon.getMacAddress(), Utils.computeAccuracy(beacon)));
  holder.majorTextView.setText("Major: " + beacon.getMajor());
  holder.minorTextView.setText("Minor: " + beacon.getMinor());
  holder.measuredPowerTextView.setText("MPower: " + beacon.getMeasuredPower());
  holder.rssiTextView.setText("RSSI: " + beacon.getRssi());
}
 
开发者ID:travelbird,项目名称:hackathon-estimote-demo,代码行数:9,代码来源:BeaconListAdapter.java


示例7: bind

import com.estimote.sdk.Utils; //导入依赖的package包/类
private void bind(Nearable nearable, View view) {
  ViewHolder holder = (ViewHolder) view.getTag();
  holder.macTextView.setText(String.format("ID: %s (%s)", nearable.identifier, Utils.computeProximity(nearable).toString()));
  holder.majorTextView.setText("Major: " + nearable.region.getMajor());
  holder.minorTextView.setText("Minor: " + nearable.region.getMinor());
  holder.measuredPowerTextView.setText("MPower: " + nearable.power.powerInDbm);
  holder.rssiTextView.setText("RSSI: " + nearable.rssi);
}
 
开发者ID:travelbird,项目名称:hackathon-estimote-demo,代码行数:9,代码来源:NearableListAdapter.java


示例8: replaceWith

import com.estimote.sdk.Utils; //导入依赖的package包/类
public void replaceWith(Collection<Beacon> newBeacons) {
  this.beacons.clear();
  this.beacons.addAll(newBeacons);
  Collections.sort(beacons, new Comparator<Beacon>() {
    @Override
    public int compare(Beacon lhs, Beacon rhs) {
      return (int) Math.signum(Utils.computeAccuracy(lhs) - Utils.computeAccuracy(rhs));
    }
  });
  notifyDataSetChanged();
}
 
开发者ID:simkimsia,项目名称:play-ibeacon,代码行数:12,代码来源:LeDeviceListAdapter.java


示例9: bind

import com.estimote.sdk.Utils; //导入依赖的package包/类
private void bind(Beacon beacon, View view) {
  ViewHolder holder = (ViewHolder) view.getTag();
  holder.macTextView.setText(String.format("MAC: %s (%.2fm)", beacon.macAddress, Utils.computeAccuracy(beacon)));
  holder.majorTextView.setText("Major: " + beacon.major);
  holder.minorTextView.setText("Minor: " + beacon.minor);
  holder.measuredPowerTextView.setText("MPower: " + beacon.measuredPower);
  holder.rssiTextView.setText("RSSI: " + beacon.rssi);
}
 
开发者ID:simkimsia,项目名称:play-ibeacon,代码行数:9,代码来源:LeDeviceListAdapter.java


示例10: onCreate

import com.estimote.sdk.Utils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_proximizer);

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    initFromPreferences();

    View contentView = findViewById(R.id.baseview);
    contentView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setBackground(v);
            updateValueFields(v);
        }
    });

    beaconManager = new BeaconManager(this);
    beaconManager.setBackgroundScanPeriod(scanInterval, scanPause);

    beaconManager.setRangingListener(new BeaconManager.RangingListener() {

        @Override
        public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {

            for (Beacon beacon : beacons) {
                double acc = Utils.computeAccuracy(beacon);
                int colorValue = scaleToColorValue(acc);

                if (region.getIdentifier().equals(RED)) {
                    r = colorValue;
                } else if (region.getIdentifier().equals(GREEN)) {
                    g = colorValue;
                } else if (region.getIdentifier().equals(BLUE)) {
                    b = colorValue;
                }

                updateBackground();
            }
        }
    });

}
 
开发者ID:wwerner,项目名称:Proximizer,代码行数:44,代码来源:Proximizer.java


示例11: computeDotPosY

import com.estimote.sdk.Utils; //导入依赖的package包/类
private int computeDotPosY(Beacon beacon) {
  // Let's put dot at the end of the scale when it's further than 6m.
  double distance = Math.min(Utils.computeAccuracy(beacon), 6.0);
  return startY + (int) (segmentLength * (distance / 6.0));
}
 
开发者ID:travelbird,项目名称:hackathon-estimote-demo,代码行数:6,代码来源:DistanceBeaconActivity.java


示例12: onCreate

import com.estimote.sdk.Utils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_welcome_bird);
    background = (RelativeLayout) findViewById(R.id.background);
    accuracy = (TextView) findViewById(R.id.accuracy);
    title = (TextView) findViewById(R.id.info_text);
    bird = (ImageView) findViewById(R.id.bird);
    // Configure BeaconManager.
    beaconManager = new BeaconManager(this);
    beaconManager.setRangingListener(new BeaconManager.RangingListener() {
        @Override
        public void onBeaconsDiscovered(Region region, final List<Beacon> beacons) {
            // Note that results are not delivered on UI thread.
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    // Note that beacons reported here are already sorted by estimated
                    // distance between device and beacon.
                    getActionBar().setSubtitle("Found beacons: " + beacons.size());
                    // Check if our beacon is in range.
                    boolean found = false;
                    double distance = 10000;
                    bird.clearAnimation();
                    bird.setImageResource(R.drawable.palermo);

                    for ( int i = 0 ; i < beacons.size(); i++) {
                        Beacon beacon = beacons.get(i);
                        if (beacon.getMajor()==46235 && beacon.getMinor()==34332 ) {
                            // found!
                            distance = Utils.computeAccuracy(beacon);
                            String t = String.format(getString(R.string.antonio_close),distance );
                            accuracy.setText(t);
                            found = true;
                        }
                    }
                    if ( found) {
                        //background.setBackgroundColor(0xff369ecc);
                        title.setText(getString(R.string.antonio_in_range));
                        bird.setImageResource(R.drawable.antonio);

                        if (distance<2) {
                            AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
                            animation.getFillAfter();
                            animation.setDuration(1000);
                            animation.setRepeatCount(-1);
                            bird.startAnimation(animation);
                        }
                        else {
                        }
                    }
                    else {
                        //background.setBackgroundColor(0xffffffff);
                        accuracy.setText("");
                        title.setText(getString(R.string.welcome_jane));
                        bird.clearAnimation();
                        bird.setImageResource(R.drawable.palermo);
                    }
                }
            });
        }
    });
}
 
开发者ID:travelbird,项目名称:hackathon-estimote-demo,代码行数:64,代码来源:WelcomeBird.java


示例13: onCreate

import com.estimote.sdk.Utils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_receiver);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // Configure BeaconManager.
    beaconManager = new BeaconManager(this);
    beaconManager.setRangingListener(new BeaconManager.RangingListener() {
        @Override
        public void onBeaconsDiscovered(Region region, final List<Beacon> beacons) {
            // Note that results are not delivered on UI thread.
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    // Note that beacons reported here are already sorted by estimated
                    // distance between device and beacon.
                    // Check if our beacon is in range.
                    boolean found = false;
                    double distance = 10000;

                    for (int i = 0; i < beacons.size(); i++) {
                        Beacon beacon = beacons.get(i);
                        if (beacon.getMajor() == 46235 && beacon.getMinor() == 34332) {
                            // found!
                            distance = Utils.computeAccuracy(beacon);
                            String t = String.format(getString(R.string.antonio_close), distance);
                            found = true;
                            Log.i(TAG, "FOUND : "+t );
                        }
                    }
                    if (found) {
                        //background.setBackgroundColor(0xff369ecc);
                        if (distance < 10) {
                            mViewPager.setCurrentItem(1);
                        } else {
                            mViewPager.setCurrentItem(0);
                        }
                    } else {
                        mViewPager.setCurrentItem(0);
                        //background.setBackgroundColor(0xffffffff);
                    }
                }
            });
        }
    });

}
 
开发者ID:travelbird,项目名称:hackathon-estimote-demo,代码行数:57,代码来源:ReceiverActivity.java


示例14: onCreate

import com.estimote.sdk.Utils; //导入依赖的package包/类
@Override
	public void onCreate() {
		super.onCreate();

		handler = new Handler();


		// TODO add sensor data to stop/start beacon scanning
		sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
		stepSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
		sensorManager.registerListener(this, stepSensor,SensorManager.SENSOR_DELAY_NORMAL);

		officeState = BeaconState.OUTSIDE;

		houseRegion = new Region("regionId", ESTIMOTE_PROXIMITY_UUID, null, null);
		beaconManager = new BeaconManager(getApplicationContext());

		// Default values are 5s of scanning and 25s of waiting time to save CPU cycles.
		// In order for this demo to be more responsive and immediate we lower down those values.
		//beaconManager.setBackgroundScanPeriod(TimeUnit.SECONDS.toMillis(5), TimeUnit.SECONDS.toMillis(25));
		//beaconManager.setForegroundScanPeriod(TimeUnit.SECONDS.toMillis(5), TimeUnit.SECONDS.toMillis(10));
		
		beaconManager.setRangingListener(new BeaconManager.RangingListener() {
			@Override
			public void onBeaconsDiscovered(Region region, final List<Beacon> beacons) {
				runOnUiThread(new Runnable() {
					@Override
					public void run() {
						for (Beacon beacon : beacons) {
							//Log.d(TAG, "MAC = " + beacon.getMacAddress() + ", RSSI = " + -beacon.getRssi());
//							if (beacon.getMajor() == specialMajor && beacon.getMinor() == specialMinor ){
//								specialBeacon = beacon;
//							}
							
							if(dismissIDs.indexOf(beacon.getMinor()) == -1 )
							{
								specialBeacon = beacon;
//								dismissIDs.add(specialBeacon.getMinor());
							}
						}
						
						if (specialBeacon != null){
							double officeDistance = Utils.computeAccuracy(specialBeacon);
							Log.d(TAG, "officeDistance: " + officeDistance);
							if (officeDistance < enterThreshold && officeState == BeaconState.OUTSIDE){
								officeState = BeaconState.INSIDE;
								if(dismissIDs.indexOf(specialBeacon.getMinor()) == -1)
								{
									String url = "https://api.mongolab.com/api/1/databases/impulse/collections/beacons?apiKey=4fe65986e4b0cb519caaa0a3&q=%7" +
											"Bmajor:"+specialBeacon.getMajor()+",minor:"+specialBeacon.getMinor()+"%7D";
									new RequestTask().execute(url);
									Log.d(TAG,"url: "+ url);
									dismissIDs.add(specialBeacon.getMinor());
								}
							}else if (officeDistance > exitThreshold && officeState == BeaconState.INSIDE){
								officeState = BeaconState.OUTSIDE;
								MainActivity.unPublish();
							}
						}
						else
						{
							Log.d(TAG,"no beacon");
						}
					}
				});
			}
		});
		//showNotification("hi");
		//stopScanning();
		startScanning();
	}
 
开发者ID:ankitg,项目名称:impulse,代码行数:72,代码来源:BeaconService.java



注:本文中的com.estimote.sdk.Utils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PutIndexTemplateResponse类代码示例发布时间:2022-05-22
下一篇:
Java YarnVersionInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap