Android Open Source - DIYgenomics_Android Info Handler






From Project

Back to project page DIYgenomics_Android.

License

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.

Java Source Code

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();
    }
  }

  
}




Java Source Code List

android.widget.BasicExpandableList.java
android.widget.BasicListView.java
org.diygenomics.pg.CategoriesActivity.java
org.diygenomics.pg.CategoryItemActivity.java
org.diygenomics.pg.Category.java
org.diygenomics.pg.Constants.java
org.diygenomics.pg.Data.java
org.diygenomics.pg.DotUtils.java
org.diygenomics.pg.Genome.java
org.diygenomics.pg.ImportActivity.java
org.diygenomics.pg.InfoHandler.java
org.diygenomics.pg.Main.java
org.diygenomics.pg.MappingItem.java
org.diygenomics.pg.StudiesActivity.java
org.diygenomics.pg.Study.java
org.diygenomics.pg.Variant.java
org.diygenomics.pg.utils.CSVParser.java
org.diygenomics.pg.utils.ConditionVariantTableRowComparator.java
org.diygenomics.pg.utils.Flurry.java
org.diygenomics.pg.utils.MLog.java
org.diygenomics.pg.utils.Row.java