Android Open Source - RadaeePDF-B4A P D F Grid Adt






From Project

Back to project page RadaeePDF-B4A.

License

The source code is released under:

Apache License

If you think the Android project RadaeePDF-B4A 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.radaee.util;
/*from   w w w . ja v  a 2 s. c o  m*/
import java.io.File;
import java.util.Vector;


import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class PDFGridAdt extends BaseAdapter
{
  private Context m_context;
  private Handler m_hand_ui = new Handler()
  {
    public void handleMessage(Message msg)
    {
      PDFGridItem item = (PDFGridItem)msg.obj;
      item.page_set();
      notifyDataSetChanged();
      super.handleMessage(msg);
    }
  };
  private PDFGridThread m_thread;
  static protected int clr_back = 0xFFCCCCCC;
  static protected int clr_text = 0xFF000044;
  public class SnatchItem
  {
    public String m_path;
    public String m_name;
    public PDFGridItem m_item;
  }
  private Vector<SnatchItem> m_items = new Vector<SnatchItem>();
  private void insert_item( SnatchItem item )
  {
    int left = 0;
    int right = m_items.size() - 1;
    if( item.m_item.is_dir() )
    {
      while( left <= right )
      {
        int mid = (left + right)>>1;
        SnatchItem tmp = m_items.get(mid);
        if( !tmp.m_item.is_dir() )
          right = mid - 1;
        else
        {
          int ret = item.m_name.compareToIgnoreCase(tmp.m_name);
          if( ret == 0 )
          {
            left = mid;
            break;
          }
          if( ret > 0 ) left = mid + 1;
          else right = mid - 1;
        }
      }
    }
    else
    {
      while( left <= right )
      {
        int mid = (left + right)>>1;
        SnatchItem tmp = m_items.get(mid);
        if( tmp.m_item.is_dir() )
          left = mid + 1;
        else
        {
          int ret = item.m_name.compareToIgnoreCase(tmp.m_name);
          if( ret == 0 )
          {
            left = mid;
            break;
          }
          if( ret > 0 ) left = mid + 1;
          else right = mid - 1;
        }
      }
    }
    m_items.insertElementAt(item, left);
  }
  public void destroy()
  {
    int cur = 0;
    int cnt = m_items.size();
    while( cur < cnt )
    {
      m_items.get(cur).m_item.page_destroy();
      cur++;
    }
    m_thread.destroy();
    m_items.clear();
  }
  public void set_dir( File file, boolean need_up )
  {
    int cur = 0;
    int cnt = m_items.size();
    while( cur < cnt )
    {
      m_items.get(cur).m_item.page_destroy();
      cur++;
    }
    m_items.clear();
    if( need_up )
    {
      SnatchItem item = new SnatchItem();
      item.m_name = "..";
      item.m_path = null;
      item.m_item = new PDFGridItem(m_context, null);
      item.m_item.set_dir(item.m_name, item.m_path);
      insert_item( item );
    }

    File files[] = file.listFiles();
    if( files == null )
    {
      notifyDataSetChanged();
      return;
    }
    cur = 0;
    cnt = files.length;
    while( cur < cnt )
    {
      if( !files[cur].isHidden() )
      {
        if( files[cur].isFile() )
        {
          String name = files[cur].getName();
          int len = name.length();
          if( len > 4 )
          {
            String ext = name.substring(name.length() - 4);
            if( ext.compareToIgnoreCase(".pdf") == 0 )
            {
              SnatchItem item = new SnatchItem();
              item.m_name = files[cur].getName();
              item.m_path = files[cur].getPath();
              item.m_item = new PDFGridItem(m_context, null);
              item.m_item.set_file(m_thread, item.m_name, item.m_path);
              insert_item( item );
            }
          }
        }
        if( files[cur].isDirectory() )
        {
          SnatchItem item = new SnatchItem();
          item.m_name = files[cur].getName();
          item.m_path = files[cur].getPath();
          item.m_item = new PDFGridItem(m_context, null);
          item.m_item.set_dir(item.m_name, item.m_path);
          insert_item( item );
        }
      }
      cur++;
    }
    notifyDataSetChanged();
  }
  public PDFGridAdt( Context ctx )
  {
    m_context = ctx;
    m_thread = new PDFGridThread( m_hand_ui );
    m_thread.start();
  }
  public int getCount()
  {
    return m_items.size();
  }

  public Object getItem(int arg0)
  {
    return m_items.get(arg0);
  }

  public long getItemId(int position)
  {
    return 0;
  }

  public View getView(int position, View convertView, ViewGroup parent)
  {
    return m_items.get(position).m_item;
  }

}




Java Source Code List

com.example.pdfhttpdemo.MainActivity.java
com.example.pdfhttpdemo.ReaderController.java
com.radaee.pdf.BMDatabase.java
com.radaee.pdf.BMDatabase.java
com.radaee.pdf.BMDatabase.java
com.radaee.pdf.Document.java
com.radaee.pdf.Document.java
com.radaee.pdf.Document.java
com.radaee.pdf.Global.java
com.radaee.pdf.Global.java
com.radaee.pdf.Global.java
com.radaee.pdf.HWriting.java
com.radaee.pdf.HWriting.java
com.radaee.pdf.HWriting.java
com.radaee.pdf.Ink.java
com.radaee.pdf.Ink.java
com.radaee.pdf.Ink.java
com.radaee.pdf.Matrix.java
com.radaee.pdf.Matrix.java
com.radaee.pdf.Matrix.java
com.radaee.pdf.PDFHttpStream.java
com.radaee.pdf.PageContent.java
com.radaee.pdf.PageContent.java
com.radaee.pdf.PageContent.java
com.radaee.pdf.Page.java
com.radaee.pdf.Page.java
com.radaee.pdf.Page.java
com.radaee.pdf.Path.java
com.radaee.pdf.Path.java
com.radaee.pdf.Path.java
com.radaee.reader.PDFCropAct.java
com.radaee.reader.PDFCrop.java
com.radaee.reader.PDFEncAct.java
com.radaee.reader.PDFInkAct.java
com.radaee.reader.PDFInk.java
com.radaee.reader.PDFReaderAct.java
com.radaee.reader.PDFReaderOldAct.java
com.radaee.reader.PDFReaderOld.java
com.radaee.reader.PDFReader.java
com.radaee.reader.PDFSimpleAct.java
com.radaee.reader.PDFSimple.java
com.radaee.reader.PDFTestAct.java
com.radaee.reader.ReaderActivity.java
com.radaee.reader.ReaderController.java
com.radaee.reader.ReaderController.java
com.radaee.util.ComboListAdt.java
com.radaee.util.ComboList.java
com.radaee.util.PDFAESEnc.java
com.radaee.util.PDFAESEnc.java
com.radaee.util.PDFAESStream.java
com.radaee.util.PDFAESStream.java
com.radaee.util.PDFAssetStream.java
com.radaee.util.PDFAssetStream.java
com.radaee.util.PDFFileStream.java
com.radaee.util.PDFFileStream.java
com.radaee.util.PDFGridAdt.java
com.radaee.util.PDFGridItem.java
com.radaee.util.PDFGridThread.java
com.radaee.util.PDFGridView.java
com.radaee.util.PDFHttpStream.java
com.radaee.util.PDFHttpStream.java
com.radaee.util.PDFMemStream.java
com.radaee.util.PDFMemStream.java
com.radaee.util.PDFThumbView.java
com.radaee.util.SnatchAdt.java
com.radaee.util.SnatchView.java
com.rootsoft.pdfviewer.main.java
com.rootsoft.pdfviewer.readercontroller.java
com.rootsoft.rspdfviewer.pdf.RSPDFAnnotation.java
com.rootsoft.rspdfviewer.pdf.RSPDFBMDatabase.java
com.rootsoft.rspdfviewer.pdf.RSPDFDocument.java
com.rootsoft.rspdfviewer.pdf.RSPDFGlobal.java
com.rootsoft.rspdfviewer.pdf.RSPDFHWriting.java
com.rootsoft.rspdfviewer.pdf.RSPDFInk.java
com.rootsoft.rspdfviewer.pdf.RSPDFMatrix.java
com.rootsoft.rspdfviewer.pdf.RSPDFPageContent.java
com.rootsoft.rspdfviewer.pdf.RSPDFPage.java
com.rootsoft.rspdfviewer.pdf.RSPDFPath.java
com.rootsoft.rspdfviewer.pdf.RSPDFTemplate.java
com.rootsoft.rspdfviewer.pdf.RSPDFVPage.java
com.rootsoft.rspdfviewer.pdf.RSPDFViewCurl.java
com.rootsoft.rspdfviewer.pdf.RSPDFViewDual.java
com.rootsoft.rspdfviewer.pdf.RSPDFViewHorz.java
com.rootsoft.rspdfviewer.pdf.RSPDFViewThumb.java
com.rootsoft.rspdfviewer.pdf.RSPDFViewVert.java
com.rootsoft.rspdfviewer.pdf.RSPDFView.java
com.rootsoft.rspdfviewer.pdf.RSReaderView.java