Search in sources :

Example 1 with RealmModel

use of io.realm.RealmModel in project open-event-android by fossasia.

the class OSMapFragment method populateMap.

private void populateMap() {
    if (!mayRequestStorageForOfflineMap())
        return;
    final MapView mapView = (MapView) rootView.findViewById(R.id.mapview);
    final ZoomControls zoomControls = (ZoomControls) rootView.findViewById(R.id.zoomControls);
    Resources resources = getContext().getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        zoomControls.setPadding(0, 0, 0, resources.getDimensionPixelSize(resourceId) + 4);
    }
    mapView.setBuiltInZoomControls(false);
    mapView.setMultiTouchControls(true);
    event = realmRepo.getEvent();
    event.addChangeListener(new RealmChangeListener<RealmModel>() {

        @Override
        public void onChange(RealmModel realmModel) {
            showEvent();
        }
    });
    GeoPoint geoPoint = new GeoPoint(getDestinationLatitude(), getDestinationLongitude());
    mapView.getController().setCenter(geoPoint);
    mapView.getController().setZoom(17);
    mapView.setMaxZoomLevel(20);
    mapView.setMinZoomLevel(3);
    OverlayItem position = new OverlayItem(getDestinationName(), "Location", geoPoint);
    zoomControls.setOnZoomInClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mapView.getController().zoomIn();
        }
    });
    zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mapView.getController().zoomOut();
        }
    });
    ArrayList<OverlayItem> items = new ArrayList<>();
    items.add(position);
    mapView.getOverlays().add(new ItemizedIconOverlay<>(items, new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {

        @Override
        public boolean onItemSingleTapUp(int index, OverlayItem item) {
            return false;
        }

        @Override
        public boolean onItemLongPress(int index, OverlayItem item) {
            return false;
        }
    }, new DefaultResourceProxyImpl(getActivity())));
    mapView.invalidate();
}
Also used : ZoomControls(android.widget.ZoomControls) OverlayItem(org.osmdroid.views.overlay.OverlayItem) ArrayList(java.util.ArrayList) View(android.view.View) MapView(org.osmdroid.views.MapView) DefaultResourceProxyImpl(org.osmdroid.DefaultResourceProxyImpl) GeoPoint(org.osmdroid.util.GeoPoint) RealmModel(io.realm.RealmModel) GeoPoint(org.osmdroid.util.GeoPoint) MapView(org.osmdroid.views.MapView) Resources(android.content.res.Resources)

Example 2 with RealmModel

use of io.realm.RealmModel in project realm-java by realm.

the class NativeRealmAnyCollection method newRealmModelCollection.

public static NativeRealmAnyCollection newRealmModelCollection(Collection<? extends RealmModel> collection) {
    long[] objectValues = new long[collection.size()];
    boolean[] notNull = new boolean[collection.size()];
    int i = 0;
    for (RealmModel model : collection) {
        if (model != null) {
            RealmObjectProxy proxy = (RealmObjectProxy) model;
            objectValues[i] = ((UncheckedRow) proxy.realmGet$proxyState().getRow$realm()).getNativePtr();
            notNull[i] = true;
        }
        i++;
    }
    return new NativeRealmAnyCollection(nativeCreateObjectCollection(objectValues, notNull));
}
Also used : RealmModel(io.realm.RealmModel) RealmObjectProxy(io.realm.internal.RealmObjectProxy)

Aggregations

RealmModel (io.realm.RealmModel)2 Resources (android.content.res.Resources)1 View (android.view.View)1 ZoomControls (android.widget.ZoomControls)1 RealmObjectProxy (io.realm.internal.RealmObjectProxy)1 ArrayList (java.util.ArrayList)1 DefaultResourceProxyImpl (org.osmdroid.DefaultResourceProxyImpl)1 GeoPoint (org.osmdroid.util.GeoPoint)1 MapView (org.osmdroid.views.MapView)1 OverlayItem (org.osmdroid.views.overlay.OverlayItem)1