当前位置: 首页>>代码示例>>Java>>正文


Java IconFactory.fromDrawable方法代码示例

本文整理汇总了Java中com.mapbox.mapboxsdk.annotations.IconFactory.fromDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java IconFactory.fromDrawable方法的具体用法?Java IconFactory.fromDrawable怎么用?Java IconFactory.fromDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mapbox.mapboxsdk.annotations.IconFactory的用法示例。


在下文中一共展示了IconFactory.fromDrawable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resetStillMarkers

import com.mapbox.mapboxsdk.annotations.IconFactory; //导入方法依赖的package包/类
private void resetStillMarkers()
{

    Log.i(TAG, "Resetting markers.");

    runOnUiThread(new Runnable() {
        @SuppressLint("PrivateResource")
        @Override
        public void run() {
            mapView.removeAllAnnotations();
            listOfMarkers.clear();
            msg.setText(R.string.no_event);
            msg.setTextColor(getResources().getColor(R.color.black));
            msgbox.setBackgroundColor(getResources().getColor(R.color.safe));
        }
    });
    
    IconFactory mIconFactory = IconFactory.getInstance(this);
    Drawable mIconDrawableDisabled = ContextCompat.getDrawable(this, R.drawable.map_grey);
    Icon disabled_icon = mIconFactory.fromDrawable(mIconDrawableDisabled);

    Drawable mIconDrawableActive = ContextCompat.getDrawable(this, R.drawable.map_green);
    Icon active_icon = mIconFactory.fromDrawable(mIconDrawableActive);

    for (int i = 0; i < sensors.size(); i++)
    {
        listOfMarkers.add(
            mapView.addMarker(new MarkerOptions()
                    .position(sensors.get(i).getLatLng())
                    .title(sensors.get(i).getName())
                    .icon(sensors.get(i).hasUid() ? active_icon : disabled_icon)
                    .snippet(sensors.get(i).getUid())));
    }

}
 
开发者ID:caribewave,项目名称:android-app,代码行数:36,代码来源:MainActivity.java

示例2: dialogClose

import com.mapbox.mapboxsdk.annotations.IconFactory; //导入方法依赖的package包/类
public void dialogClose() {
  IconFactory mIconFactory = IconFactory.getInstance(this);
  Drawable mboundry = ContextCompat.getDrawable(this, R.drawable.boundary);
  final Icon Iboundry = mIconFactory.fromDrawable(mboundry);
  Drawable mboat = ContextCompat.getDrawable(this, R.drawable.pointarrow);
  Icon Iboat = mIconFactory.fromDrawable(mboat);

  //if (getBoatType() == true)
  {

    networkThread = new NetworkAsync().execute(); //launch networking asnyc task

  }
  //        else if (getBoatType() == false) {
  //            log.append("Simulated Boat");
  //            ipAddressBox.setText("Simulated Phone");
  //            simulatedBoat();
  //        } else {
  //            log.append("fail");
  //        }

  try {
    //boat2 = new Marker(currentBoat.getIpAddress().toString(), "Boat", new LatLng(pHollowStartingPoint.getLatitude(), pHollowStartingPoint.getLongitude()));


  } catch (Exception e) {

  }
}
 
开发者ID:platypusllc,项目名称:tablet,代码行数:30,代码来源:TeleOpPanel.java

示例3: updateMap

import com.mapbox.mapboxsdk.annotations.IconFactory; //导入方法依赖的package包/类
private void updateMap(String uid, JSONArray measurement)
{
    if (alert_in_progress) {
        // We don't want to interfere with a general alert
        return;
    }

    // A new event is coming
    resetMarkerTimer.cancel();

    updateLastActive();

    final ArrayList<String> places = new ArrayList<>();

    IconFactory mIconFactory = IconFactory.getInstance(this);
    Drawable mIconDrawableDanger = ContextCompat.getDrawable(this, R.drawable.map_yellow);
    Icon warning_icon = mIconFactory.fromDrawable(mIconDrawableDanger);

    for (final Marker marker : listOfMarkers) {
        if (marker.getSnippet().equals(uid)) {
            places.add(marker.getTitle());
            marker.setIcon(warning_icon);

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mapView.removeMarker(marker);
                    mapView.addMarker(new MarkerOptions()
                            .position(marker.getPosition())
                            .title(marker.getTitle())
                            .icon(marker.getIcon())
                            .snippet(marker.getSnippet()));
                }
            });

        }
    }

    // Update msg box
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            msg.setText(String.format(getString(R.string.measurement_event), TextUtils.join(", ", places)));
            msgbox.setBackgroundColor(getResources().getColor(R.color.warning));
        }
    });

    // Run for 2 seconds
    resetMarkerTimer = new Timer();
    resetMarkerTimer.schedule(new TimerTask() {
        @Override
        public void run() {
            if (!alert_in_progress) {
                resetStillMarkers();
            }
            resetMarkerTimer.cancel();
        }
    }, WARNING_DISPLAY_TIME_IN_S*1000);

}
 
开发者ID:caribewave,项目名称:android-app,代码行数:61,代码来源:MainActivity.java

示例4: showAlert

import com.mapbox.mapboxsdk.annotations.IconFactory; //导入方法依赖的package包/类
private void showAlert(JSONObject alert)
{
    // A new event is coming
    resetMarkerTimer.cancel();
    alert_in_progress = true;

    String tmp;
    JSONArray sensor_uids;
    List<String> uids_list = new ArrayList<>();
    updateLastActive();

    try {
        tmp = alert.get("message").toString();
    } catch(Exception e) {
        tmp = getString(R.string.general_alert);
    }

    try {
        sensor_uids = (JSONArray) alert.get("sensors_uids");
        //noinspection StatementWithEmptyBody
        for (int i = 0; i < sensor_uids.length();uids_list.add(sensor_uids.get(i++).toString()));
    } catch(Exception ignored) {
    }

    IconFactory mIconFactory = IconFactory.getInstance(this);
    Drawable mIconDrawableDanger = ContextCompat.getDrawable(this, R.drawable.map_red);
    Icon danger_icon = mIconFactory.fromDrawable(mIconDrawableDanger);

    for (final Marker marker : listOfMarkers) {
        if (uids_list.contains(marker.getSnippet())) {
            marker.setIcon(danger_icon);
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mapView.removeMarker(marker);
                    mapView.addMarker(new MarkerOptions()
                            .position(marker.getPosition())
                            .title(marker.getTitle())
                            .icon(marker.getIcon())
                            .snippet(marker.getSnippet()));
                        }
            });
        }
    }

    final String message = tmp;
    // Update msg box with alert
    runOnUiThread(new Runnable() {
        @SuppressLint("PrivateResource")
        @Override
        public void run() {
            msg.setText(message);
            msg.setTextColor(getResources().getColor(R.color.white));
            msgbox.setBackgroundColor(getResources().getColor(R.color.danger));
        }
    });

    // Run for 2 seconds
    resetAlertTimer = new Timer();
    resetAlertTimer.schedule(new TimerTask() {
        @Override
        public void run() {
            resetStillMarkers();
            resetAlertTimer.cancel();
            alert_in_progress = false;
        }
    }, ALERT_DISPLAY_TIME_IN_S*1000);
}
 
开发者ID:caribewave,项目名称:android-app,代码行数:69,代码来源:MainActivity.java


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