Android Open Source - advanced-tourist-map Wiki Overlay Item






From Project

Back to project page advanced-tourist-map.

License

The source code is released under:

GNU General Public License

If you think the Android project advanced-tourist-map listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.muxe.advancedtouristmap.overlay;
/*from ww  w. jav  a2 s  .  com*/
import org.mapsforge.android.maps.GeoPoint;
import org.muxe.advancedtouristmap.PositionInfo;
import org.muxe.advancedtouristmap.R;
import org.muxe.advancedtouristmap.wikipedia.WikiArticleInterface;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

public class WikiOverlayItem extends GenericOverlayItem {
  
  private WikiArticleInterface article;
  
  public WikiOverlayItem(WikiArticleInterface article) {
    this.article = article;
  }
  
  public WikiOverlayItem(WikiArticleInterface article, String title, String snippet) {
    super(article.getGeoPoint(), title, snippet);
    this.article = article;
  }
  
  public WikiOverlayItem(WikiArticleInterface article, String title, String snippet, Drawable marker) {
    super(article.getGeoPoint(), title, snippet, marker);
    this.article = article;
  }
  
  public WikiArticleInterface getArticle() {
    return this.article;
  }

  public void setArticle(WikiArticleInterface article) {
    this.article = article;
  }

  @Override
  public void onTap(final Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    LayoutInflater factory = LayoutInflater
        .from(context);
    final View dialogView = factory.inflate(R.layout.webview_dialog,
        null);
    builder.setTitle(article.getTitle());
    // a progress bar to indicate loading
    final ProgressBar progressBar = (ProgressBar) dialogView
        .findViewById(R.id.webview_dialog_progress);
    WebView webView = (WebView) dialogView
        .findViewById(R.id.webview_dialog_webview);

    // handle link clicks internally (doesn't open new browser window)
    webView.setWebViewClient(new WebViewClient() {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
        progressBar.setVisibility(View.VISIBLE);
        view.loadUrl(url);
        return false;
      }
    });

    // show loading progress
    webView.setWebChromeClient(new WebChromeClient() {
      @Override
      public void onProgressChanged(WebView view, int progress) {
        if (progress == 100) {
          progressBar.setVisibility(View.GONE);
        } else {
          progressBar.setProgress(progress);
        }
      }

    });

    // let the article set what to render (load url or local data)
    article.setWebView(webView);

    builder.setView(dialogView);

    builder.setPositiveButton("Info",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            context.startActivity(new Intent(context,
                PositionInfo.class).putExtra(
                PositionInfo.LATITUDE_EXTRA,
                article.getLat()).putExtra(
                PositionInfo.LONGITUDE_EXTRA,
                article.getLng()));
          }
        });

    builder.setNegativeButton("Close", null);

    builder.show();
  }
}




Java Source Code List

org.mapsforge.geocoding.Unchecked.java
org.mapsforge.geocoding.widget.CityCompletionAdapter.java
org.mapsforge.geocoding.widget.PlaceCompletionAdapter.java
org.mapsforge.geocoding.widget.RoadCompletionAdapter.java
org.mapsforge.geocoding.widget.RoadListAdapter.java
org.mapsforge.geocoding.widget.SqliteCompletionAdapter.java
org.mapsforge.geocoding.widget.State.java
org.muxe.advancedtouristmap.AdvancedTouristMapApplication.java
org.muxe.advancedtouristmap.AdvancedTouristMap.java
org.muxe.advancedtouristmap.BaseActivity.java
org.muxe.advancedtouristmap.CacheSizePreference.java
org.muxe.advancedtouristmap.EditPreferences.java
org.muxe.advancedtouristmap.FilePickerIconAdapter.java
org.muxe.advancedtouristmap.FilePicker.java
org.muxe.advancedtouristmap.InfoView.java
org.muxe.advancedtouristmap.LocationPicker.java
org.muxe.advancedtouristmap.MoveSpeedPreference.java
org.muxe.advancedtouristmap.PositionInfo.java
org.muxe.advancedtouristmap.Search.java
org.muxe.advancedtouristmap.SeekBarPreference.java
org.muxe.advancedtouristmap.Utility.java
org.muxe.advancedtouristmap.overlay.GenericOverlayItem.java
org.muxe.advancedtouristmap.overlay.GenericOverlay.java
org.muxe.advancedtouristmap.overlay.PoiOverlayItem.java
org.muxe.advancedtouristmap.overlay.PositionOverlayItem.java
org.muxe.advancedtouristmap.overlay.WikiOverlayItem.java
org.muxe.advancedtouristmap.poi.PoiBrowserActivity.java
org.muxe.advancedtouristmap.poi.PoiOrCategory.java
org.muxe.advancedtouristmap.routing.AngleCalc.java
org.muxe.advancedtouristmap.routing.DecisionOverlay.java
org.muxe.advancedtouristmap.routing.DecisionPoint.java
org.muxe.advancedtouristmap.routing.RouteCalculator.java
org.muxe.advancedtouristmap.routing.RouteList.java
org.muxe.advancedtouristmap.routing.Route.java
org.muxe.advancedtouristmap.sourcefiles.AddressFile.java
org.muxe.advancedtouristmap.sourcefiles.FileManagerActivity.java
org.muxe.advancedtouristmap.sourcefiles.FileManager.java
org.muxe.advancedtouristmap.sourcefiles.MapBundle.java
org.muxe.advancedtouristmap.sourcefiles.MapFile.java
org.muxe.advancedtouristmap.sourcefiles.PoiFile.java
org.muxe.advancedtouristmap.sourcefiles.RoutingFile.java
org.muxe.advancedtouristmap.sourcefiles.SourceFile.java
org.muxe.advancedtouristmap.wikipedia.AbstractWikiArticle.java
org.muxe.advancedtouristmap.wikipedia.ArticleRetrieverFactory.java
org.muxe.advancedtouristmap.wikipedia.ArticleRetriever.java
org.muxe.advancedtouristmap.wikipedia.GeonamesRetriever.java
org.muxe.advancedtouristmap.wikipedia.OnlineWikiArticle.java
org.muxe.advancedtouristmap.wikipedia.WikiArticleInterface.java
org.muxe.advancedtouristmap.wikipedia.WikilocationRetriever.java