Android Open Source - DroidDesignGuide D D G View Fragment






From Project

Back to project page DroidDesignGuide.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project DroidDesignGuide 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

/**
 * Copyright (c) 2012 Acrylic Goat Software
 * /*from w  w w.j ava 2s  .  com*/
 * This software is subject to the provisions of the GNU Lesser General
 * Public License Version 3 (LGPL).  See LICENSE.txt for details.
 */
package com.acrylicgoat.droiddesign.fragments;

import com.acrylicgoat.droiddesign.R;
import com.acrylicgoat.droiddesign.util.ContentCache;
import com.actionbarsherlock.app.SherlockFragment;

import android.os.Bundle;
//import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebSettings.LayoutAlgorithm;

/**
 * @author ew2
 *
 */
public class DDGViewFragment extends SherlockFragment {
    private WebView viewer = null;
    //DDGViewActivity activity = null;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) 
    {
        viewer = (WebView) inflater.inflate(R.layout.web_view, container, false);
        viewer.getSettings().setUseWideViewPort(true);
        viewer.getSettings().setSupportZoom(true);
        viewer.getSettings().setJavaScriptEnabled(true);
        viewer.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
        //viewer.setInitialScale(90);
        viewer.getSettings().setDefaultFontSize(17);
        return viewer;
    }
    
    public void updateUrl(final String newUrl) 
    {
        if (viewer != null) 
        {
            ContentCache.setObject("url", newUrl);

            viewer.loadUrl(newUrl); 
        }
    }
    
    @Override
    public void onResume() 
    {
        super.onResume();
        String url = (String)ContentCache.getObject("url");
        if(url != null)
        {
            updateUrl(url);
              
        }
    }
    

}




Java Source Code List

com.acrylicgoat.droiddesign.activity.DDGViewActivity.java
com.acrylicgoat.droiddesign.activity.MainActivity.java
com.acrylicgoat.droiddesign.activity.SublistActivity.java
com.acrylicgoat.droiddesign.adapters.LandscapeListAdapter.java
com.acrylicgoat.droiddesign.adapters.ListAdapter.java
com.acrylicgoat.droiddesign.fragments.DDGListFragment.java
com.acrylicgoat.droiddesign.fragments.DDGViewFragment.java
com.acrylicgoat.droiddesign.util.ContentCache.java
com.acrylicgoat.droiddesign.util.DDGUtil.java