Android Open Source - PDF2ImageForEP Choose P D F Activity






From Project

Back to project page PDF2ImageForEP.

License

The source code is released under:

GNU General Public License

If you think the Android project PDF2ImageForEP 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 com.artifex.mupdf;
/* w  w w.j  av a2  s.co  m*/
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;

import jp.co.muratec.pdf2image.R;

import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ChoosePDFActivity extends ListActivity {
  private File    mDirectory;
  private File [] mFiles;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String storageState = Environment.getExternalStorageState();

    if (!Environment.MEDIA_MOUNTED.equals(storageState)
        && !Environment.MEDIA_MOUNTED_READ_ONLY.equals(storageState))
    {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setTitle(R.string.no_media_warning);
      builder.setMessage(R.string.no_media_hint);
      AlertDialog alert = builder.create();
      alert.setButton(AlertDialog.BUTTON_POSITIVE,"Dismiss",
          new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              finish();
            }
          });
      alert.show();
      return;
    }

    mDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
    mFiles = mDirectory.listFiles(new FilenameFilter() {
      public boolean accept(File file, String name) {
        if (name.toLowerCase().endsWith(".pdf"))
          return true;
        if (name.toLowerCase().endsWith(".xps"))
          return true;
        if (name.toLowerCase().endsWith(".cbz"))
          return true;
        return false;
      }

    });
    List<String> fileNames = new ArrayList<String>();
    for (File f : mFiles)
      fileNames.add(f.getName());

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.picker_entry, fileNames);
    setListAdapter(adapter);
  }

  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    Uri uri = Uri.parse(mFiles[position].getAbsolutePath());
    Intent intent = new Intent(this,MuPDFActivity.class);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(uri);
    startActivity(intent);
  }
}




Java Source Code List

com.artifex.mupdf.ChoosePDFActivity.java
com.artifex.mupdf.LinkInfo.java
com.artifex.mupdf.MuPDFActivity.java
com.artifex.mupdf.MuPDFCore.java
com.artifex.mupdf.MuPDFPageAdapter.java
com.artifex.mupdf.MuPDFPageView.java
com.artifex.mupdf.OutlineActivityData.java
com.artifex.mupdf.OutlineActivity.java
com.artifex.mupdf.OutlineAdapter.java
com.artifex.mupdf.OutlineItem.java
com.artifex.mupdf.PageView.java
com.artifex.mupdf.ReaderView.java
com.artifex.mupdf.SafeAsyncTask.java
com.artifex.mupdf.SearchTaskResult.java
jp.co.muratec.pdf2image.DeepRadioGroup.java
jp.co.muratec.pdf2image.FilerActivity.java
jp.co.muratec.pdf2image.LoadLibrary.java
jp.co.muratec.pdf2image.PDF2ImageActivity.java
jp.co.muratec.pdf2image.PDF2ImageService.java