[26523] | 1 | package org.mapsforge.android.maps;
|
---|
| 2 |
|
---|
| 3 | import org.tipple.mapDisplay.R;
|
---|
| 4 |
|
---|
| 5 | import android.content.Context;
|
---|
| 6 | import android.text.method.ScrollingMovementMethod;
|
---|
| 7 | import android.view.Gravity;
|
---|
| 8 | import android.view.LayoutInflater;
|
---|
| 9 | import android.view.View;
|
---|
| 10 | import android.view.ViewGroup;
|
---|
| 11 | import android.widget.ImageView;
|
---|
| 12 | import android.widget.LinearLayout;
|
---|
| 13 | import android.widget.TextView;
|
---|
| 14 |
|
---|
| 15 | public class MarkerPopup extends LinearLayout {
|
---|
| 16 |
|
---|
| 17 | private TextView title;
|
---|
| 18 | private TextView snippet;
|
---|
| 19 | private ImageView image;
|
---|
| 20 |
|
---|
| 21 | public MarkerPopup(MapView mapView) {
|
---|
| 22 | super(mapView.getContext());
|
---|
| 23 | setupPopup(mapView);
|
---|
| 24 | this.setPadding(20, 10, 20, 10);
|
---|
| 25 | this.setVisibility(View.GONE);
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | private void setupPopup(ViewGroup mapView) {
|
---|
| 29 | LayoutInflater inflater = (LayoutInflater) mapView.getContext()
|
---|
| 30 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
---|
| 31 | View view = inflater.inflate(R.layout.markerpopup, this);
|
---|
| 32 | title = (TextView) view.findViewById(R.id.tTitle);
|
---|
| 33 | title.setGravity(Gravity.BOTTOM | Gravity.FILL_HORIZONTAL);
|
---|
| 34 | title.setTextColor(0xffffffff);
|
---|
| 35 | title.setBackgroundColor(0xCC000000);
|
---|
| 36 | title.setTextSize(14.0f);
|
---|
| 37 | title.setVerticalScrollBarEnabled(true);
|
---|
| 38 | title.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
|
---|
| 39 | title.setMovementMethod(new ScrollingMovementMethod());
|
---|
| 40 | image = (ImageView) view.findViewById(R.id.iPopupImage);
|
---|
| 41 | image.setImageDrawable(null);
|
---|
| 42 |
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | public void setData(OverlayMarkerItem item) {
|
---|
| 46 | this.setVisibility(VISIBLE);
|
---|
| 47 | setObjects(item);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | private void setObjects(OverlayMarkerItem item) {
|
---|
| 51 | if (item.getTitle() != null) {
|
---|
| 52 | title.setVisibility(VISIBLE);
|
---|
| 53 | String text_desc = item.getDescription();
|
---|
| 54 | text_desc += "\n" + item.getContent();
|
---|
| 55 | title.setText(text_desc);
|
---|
| 56 | title.setSelected(true);
|
---|
| 57 | } else {
|
---|
| 58 | title.setText("");
|
---|
| 59 | title.setVisibility(INVISIBLE);
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 | }
|
---|