Back to project page DIYgenomics_Android.
The source code is released under:
/** * Copyright (C) 2010 DIYgenomics diygenomics.org * Copyright (C) 2010 Melanie Swan mxswan@gmail * Copyright (C) 2010 Michael Kolb * Copyright (C) 2010 Lawrence S. Wong * All rights reserved. * * M...
If you think the Android project DIYgenomics_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.
package org.diygenomics.pg; /* w w w. ja v a2 s .co m*/ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.view.ViewGroup.LayoutParams; import android.webkit.WebView; public class InfoHandler implements DialogInterface.OnClickListener { private static InfoHandler mInstance; private Dialog mDialog; private InfoHandler() {} public static InfoHandler getInstance() { if (mInstance == null) { mInstance = new InfoHandler(); } return mInstance; } public void showInfo(Context c, int filenameid) { if (mDialog != null) { mDialog.dismiss(); mDialog = null; } AlertDialog.Builder b = new AlertDialog.Builder(c); WebView html = new WebView(c); html.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); html.loadData(loadAssetFile(c, c.getString(filenameid)), "text/html", "UTF-8"); mDialog = b.setIcon(null) .setView(html) .setPositiveButton("OK", this) .show(); } private String loadAssetFile(Context c, String name) { try { BufferedReader r = new BufferedReader(new InputStreamReader(c.getAssets().open(name))); StringBuilder sb = new StringBuilder(); do { String line = r.readLine(); if (line != null) { sb.append(line); } else { break; } } while (true); r.close(); return sb.toString(); } catch (IOException e) { e.printStackTrace(); } return ""; } @Override public void onClick(DialogInterface arg0, int arg1) { if (mDialog != null) { mDialog.dismiss(); } } }