Android Open Source - disconnected-content-explorer-android Report Detail Fragment






From Project

Back to project page disconnected-content-explorer-android.

License

The source code is released under:

MIT License

If you think the Android project disconnected-content-explorer-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 mil.nga.dice.report;
/*w  w w  . j av a  2  s. co  m*/
import java.io.File;

import android.annotation.TargetApi;
import android.os.Build;
import mil.nga.dice.R;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

/**
 * A fragment representing a single Report detail screen. This fragment is
 * either contained in a {@link ReportDetailActivity}.
 */
public class ReportDetailFragment extends Fragment {
  /**
   * The fragment argument representing the item ID that this fragment
   * represents.
   */
  public static final String ARG_ITEM_ID = "item_id";
  public static final String ARG_REPORT = "report";
  private Report mReport;

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

  
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    if (getArguments().containsKey(ARG_REPORT)) {
      mReport = getArguments().getParcelable(ARG_REPORT);
    }
  }

  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_report_detail, container, false);
    if (mReport == null) {
      return rootView;
    }
    File reportFile = new File(mReport.getPath(), "index.html");
    if (reportFile.canRead() && reportFile.length() > 0) {
      WebView webView = (WebView) rootView.findViewById(R.id.report_detail);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.loadUrl(reportFile.toURI().toASCIIString());
      // TODO: block network?
      // webView.getSettings().getBlockNetworkLoads();
      enableFileAjax(webView);
    }
    return rootView;
  }

  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  private void enableFileAjax(WebView webView) {
    webView.getSettings().setAllowFileAccessFromFileURLs(true);
  }

}




Java Source Code List

mil.nga.dice.DICE.java
mil.nga.dice.gridview.CustomGrid.java
mil.nga.dice.gridview.ReportGridActivity.java
mil.nga.dice.gridview.ReportGridFragment.java
mil.nga.dice.jackson.deserializer.Deserializer.java
mil.nga.dice.jackson.deserializer.FeatureDeserializer.java
mil.nga.dice.jackson.deserializer.GeometryDeserializer.java
mil.nga.dice.listview.CustomList.java
mil.nga.dice.listview.ReportListActivity.java
mil.nga.dice.listview.ReportListFragment.java
mil.nga.dice.listview.ReportListItem.java
mil.nga.dice.map.BackgroundTileProvider.java
mil.nga.dice.map.OfflineMapLoader.java
mil.nga.dice.map.OfflineMap.java
mil.nga.dice.map.ReportMapActivity.java
mil.nga.dice.map.ReportMapFragment.java
mil.nga.dice.report.NoteActivity.java
mil.nga.dice.report.NoteFragment.java
mil.nga.dice.report.ReportDetailActivity.java
mil.nga.dice.report.ReportDetailFragment.java
mil.nga.dice.report.ReportDropbox.java
mil.nga.dice.report.ReportManager.java
mil.nga.dice.report.ReportUnzipRunnable.java
mil.nga.dice.report.Report.java