Android Open Source - LCFR-Mobile-Android Protocol Detail Fragment






From Project

Back to project page LCFR-Mobile-Android.

License

The source code is released under:

Apache License

If you think the Android project LCFR-Mobile-Android 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.dizon.lcfrmobile;
// w ww  .  jav  a 2  s .  c om
import java.io.File;

import android.content.Context;
import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.TextView;

import org.dizon.lcfr.Protocol;
import org.dizon.lcfr.ProtocolContent;

/**
 * A fragment representing a single Protocol detail screen. This fragment is
 * either contained in a {@link ProtocolListActivity} in two-pane mode (on
 * tablets) or a {@link ProtocolDetailActivity} on handsets.
 */
public class ProtocolDetailFragment extends Fragment {
  /**
   * The fragment argument representing the item ID that this fragment
   * represents.
   */
  public static final String ARG_ITEM_ID = "item_id";
  
  private WebView wv;

  /**
   * The dummy content this fragment is presenting.
   */
  private Protocol mItem;

  /**
   * Mandatory empty constructor for the fragment manager to instantiate the
   * fragment (e.g. upon screen orientation changes).
   */
  public ProtocolDetailFragment() {
  }

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);    
    if (getArguments().containsKey(ARG_ITEM_ID)) {
      // Load the dummy content specified by the fragment
      // arguments. In a real-world scenario, use a Loader
      // to load content from a content provider.
      for(int i=0; i<ProtocolContent.ITEMS.size(); i++){
        if(ProtocolContent.ITEMS.get(i).getName().equals(getArguments().getString(ARG_ITEM_ID))){
          mItem=ProtocolContent.ITEMS.get(i);
          i=ProtocolContent.ITEMS.size();
        }
      }
    }
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_protocol_detail,
        container, false);
    wv=(WebView) rootView.findViewById(R.id.webView1);
    // Show the dummy content as text in a TextView.
    if (mItem != null) {
      StringBuilder sb = new StringBuilder();
      //iv.
      for(int i=0; i<mItem.getFiles().size(); i++){
        sb.append(mItem.getFiles().get(i).getFileName());
        sb.append("\n");
      }
      ((TextView) rootView.findViewById(R.id.protocol_detail))
          .setText(sb.toString());
      File file;
      
            file = getActivity().getApplicationContext().getFileStreamPath(mItem.getFiles().get(0).getFileName());
      Uri fileuri = Uri.fromFile(file);
      //wv.setInitialScale(30);
      wv.setPadding(0, 0, 0, 0);
      wv.setInitialScale(getScale());
      wv.getSettings().setBuiltInZoomControls(true);
      wv.getSettings().setLoadWithOverviewMode(true);
      wv.getSettings().setUseWideViewPort(true);
      //wv.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
      wv.loadUrl(fileuri.toString());
    }

    return rootView;
  }
  
  @Override
  public void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    wv.loadUrl("about:blank");
  }
  
  private int getScale(){
      Display display = ((WindowManager) getActivity().getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
      Point size = new Point();
      display.getSize(size);
      int width = size.x;
      //int width = display.getWidth(); 
      Double val = Double.valueOf(width)/Double.valueOf(2550);
      val = val * 100d;
      return val.intValue();
  }
}




Java Source Code List

org.dizon.LCFRCAD.CADData.java
org.dizon.LCFRCAD.Calls.java
org.dizon.LCFRCAD.Pcalls.java
org.dizon.lcfr.ProtocolContent.java
org.dizon.lcfr.ProtocolFile.java
org.dizon.lcfr.ProtocolXmlParser.java
org.dizon.lcfr.Protocol.java
org.dizon.lcfrmobile.GetS3File.java
org.dizon.lcfrmobile.HttpTeste.java
org.dizon.lcfrmobile.IncidentDetailActivity.java
org.dizon.lcfrmobile.IncidentDetailFragment.java
org.dizon.lcfrmobile.IncidentListActivity.java
org.dizon.lcfrmobile.IncidentListFragment.java
org.dizon.lcfrmobile.MainActivity.java
org.dizon.lcfrmobile.MainDisplayFragment.java
org.dizon.lcfrmobile.OnDownloadNotify.java
org.dizon.lcfrmobile.ProtocolDetailActivity.java
org.dizon.lcfrmobile.ProtocolDetailFragment.java
org.dizon.lcfrmobile.ProtocolListActivity.java
org.dizon.lcfrmobile.ProtocolListFragment.java
org.dizon.lcfrmobile.S3IndexChecker.java
org.dizon.lcfrmobile.SettingsActivity.java
org.dizon.lcfrmobile.dummy.DummyContent.java