Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/map/CustomInfoWindow.java
package it.reyboz.bustorino.map; | package it.reyboz.bustorino.map; | ||||
import android.annotation.SuppressLint; | import android.annotation.SuppressLint; | ||||
import android.content.Context; | |||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.util.Log; | |||||
import android.view.MotionEvent; | import android.view.MotionEvent; | ||||
import android.view.View; | import android.view.View; | ||||
import android.widget.TextView; | |||||
import org.osmdroid.api.IMapView; | |||||
import org.osmdroid.views.MapView; | import org.osmdroid.views.MapView; | ||||
import org.osmdroid.views.overlay.infowindow.BasicInfoWindow; | import org.osmdroid.views.overlay.infowindow.BasicInfoWindow; | ||||
import it.reyboz.bustorino.ActivityMain; | import it.reyboz.bustorino.ActivityMain; | ||||
import it.reyboz.bustorino.R; | import it.reyboz.bustorino.R; | ||||
public class CustomInfoWindow extends BasicInfoWindow { | public class CustomInfoWindow extends BasicInfoWindow { | ||||
@Override | |||||
public void onOpen(Object item) { | |||||
super.onOpen(item); | |||||
TextView descr_textView = (TextView) mView.findViewById(R.id.bubble_description); | |||||
CharSequence text = descr_textView.getText(); | |||||
if (text==null || !text.toString().isEmpty()){ | |||||
descr_textView.setVisibility(View.VISIBLE); | |||||
} else | |||||
descr_textView.setVisibility(View.GONE); | |||||
mView.setElevation(3.2f); | |||||
} | |||||
@SuppressLint("ClickableViewAccessibility") | @SuppressLint("ClickableViewAccessibility") | ||||
public CustomInfoWindow(MapView mapView, String ID, String stopName) { | public CustomInfoWindow(MapView mapView, String ID, String stopName) { | ||||
// get the personalized layout | // get the personalized layout | ||||
super(R.layout.map_popup, mapView); | super(R.layout.map_popup, mapView); | ||||
// make clickable | // make clickable | ||||
mView.setOnTouchListener((View v, MotionEvent e) -> { | mView.setOnTouchListener((View v, MotionEvent e) -> { | ||||
if (e.getAction() == MotionEvent.ACTION_UP) { | if (e.getAction() == MotionEvent.ACTION_UP) { | ||||
Show All 18 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register