Android Open Source - WeatherMate Website View Activity






From Project

Back to project page WeatherMate.

License

The source code is released under:

Apache License

If you think the Android project WeatherMate 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 com.brightr.weathermate.activities;
// w ww.j a  v  a  2s  . c om
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

import com.brightr.weathermate.R;

public class WebsiteViewActivity extends Activity {
  
  
  ProgressDialog pd;
  
  
  //Url passed in from news activity
  String url;
  
  
  //WebView
  WebView browser;
  
  //ProgressBar
  ProgressBar pBar;

  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview_layout);
    
    url = getIntent().getStringExtra("key");
    
    browser = (WebView) findViewById(R.id.wvNewsWebview);
    
    browser.getSettings().setJavaScriptEnabled(true);
    browser.getSettings().setLoadWithOverviewMode(true);
    browser.getSettings().setUseWideViewPort(true);
    browser.setWebViewClient(new BrowserClient());
    browser.getSettings().setBuiltInZoomControls(true);
    browser.getSettings().setRenderPriority(RenderPriority.HIGH);
    
    try{
    browser.loadUrl(url);
    }
    catch(Exception e){
      e.printStackTrace();
    }
    
    
    
    
  //new LoadWebpage().execute();
    
    
  
    
    
  
    
    
  }
  
  private class BrowserClient extends WebViewClient{

  
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      
      view.loadUrl(url);
      return true;
    }
    
    
    
    
  }
  
  private class LoadWebpage extends AsyncTask<String, String, String>{

    @Override
    protected String doInBackground(String... arg0) {
      
      
      browser.getSettings().setJavaScriptEnabled(true);
      browser.getSettings().setLoadWithOverviewMode(true);
      browser.getSettings().setUseWideViewPort(true);
      browser.setWebViewClient(new BrowserClient());
      browser.getSettings().setBuiltInZoomControls(true);
      browser.getSettings().setRenderPriority(RenderPriority.HIGH);
      
      try{
      browser.loadUrl(url);
      }
      catch(Exception e){
        e.printStackTrace();
      }
      
      
      return null;
    }

  
    @Override
    protected void onPostExecute(String result) {
      
      pd.dismiss();
    }

    
    @Override
    protected void onPreExecute() {
      
      pd = new ProgressDialog(WebsiteViewActivity.this);
      pd.setTitle("Loading Webpage");
      pd.setMessage("Loading " + url);
      
      pd.show();
    }
    
    
    
    
  }
  
  

}




Java Source Code List

.PullToRefreshListView.java
com.brightr.listeners.FlingGestureListener.java
com.brightr.listeners.OnFlingGestureListener.java
com.brightr.listeners.SimpleGestureFilter.java
com.brightr.weathermate.activities.LocationMapview.java
com.brightr.weathermate.activities.MainActivity.java
com.brightr.weathermate.activities.MyFlightsActivity.java
com.brightr.weathermate.activities.NewsViewerActivity.java
com.brightr.weathermate.activities.SearchLocationsActivity.java
com.brightr.weathermate.activities.SettingsActivity.java
com.brightr.weathermate.activities.SocialMediaActivity.java
com.brightr.weathermate.activities.WebsiteViewActivity.java
com.brightr.weathermate.adapters.FlightListAdapter.java
com.brightr.weathermate.adapters.LocationListAdapter.java
com.brightr.weathermate.adapters.MenuAdapter.java
com.brightr.weathermate.adapters.MyPagerAdapter.java
com.brightr.weathermate.adapters.NewsPagerAdapter.java
com.brightr.weathermate.adapters.SavedFlightsAdapter.java
com.brightr.weathermate.adapters.SearchListAdapter.java
com.brightr.weathermate.adapters.TweetAdapter.java
com.brightr.weathermate.adapters.WeatherAdapter.java
com.brightr.weathermate.databases.FlightStorage.java
com.brightr.weathermate.databases.LocationStorage.java
com.brightr.weathermate.databases.NewsStorage.java
com.brightr.weathermate.fragments.EntertainmentNewsFragment.java
com.brightr.weathermate.fragments.GeneralNewsFragment.java
com.brightr.weathermate.fragments.MainWeatherFragment.java
com.brightr.weathermate.fragments.MenuFragment.java
com.brightr.weathermate.fragments.PoliticalNewsFragment.java
com.brightr.weathermate.fragments.SidePanelFragment.java
com.brightr.weathermate.fragments.SportsNewsFragment.java
com.brightr.weathermate.parsers.FlightTrackingParser.java
com.brightr.weathermate.parsers.JSONParser.java
com.brightr.weathermate.parsers.JSONTrafficParser.java
com.brightr.weathermate.parsers.TwitterFeedParser.java
com.brightr.weathermate.providers.FlightTrackingProvider.java
com.brightr.weathermate.providers.LocationSearchProvider.java
com.brightr.weathermate.providers.TrafficIncidentProvider.java
com.brightr.weathermate.providers.WeatherProvider.java
com.brightr.weathermate.utils.AirlineNamesCollection.java
com.brightr.weathermate.views.CustomDialogPreference.java
com.brightr.weathermate.views.CustomPreferenceCategory.java