anyview下载java_anyview.java 源代码在线查看 - anyview手机小说阅览器的开源代码 资源下载 虫虫电子下载站...

package com.ismyway.anyview;import javax.microedition.midlet.MIDlet;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Image;import javax.microedition.lcdui.Graphics;import javax.microedition.lcdui.Form;import java.io.DataOutputStream;import java.io.ByteArrayInputStream;import java.io.ByteArrayOutputStream;import javax.microedition.rms.RecordStore;import java.io.DataInputStream;import javax.microedition.rms.RecordStoreException;/** * Title: AnyView * * Description: E680(I) Reader * * Copyright: Copyright (c) 2005 * * Company: www.ismyway.com * * @author ZhangJian * @version 1.0 */public class AnyView extends MIDlet { public static CustomFont cf = null; public static Image UpArrow = null, DownArrow = null; public static AnyView av = null; public static String Root = ""; public static long StartTime = -1l; public final static int ScreenWidth = 240; public final static int ScreenHeight = 320; private SplashCanvas sc = null; private IAVReaderCanvas iav = null; private TXTReaderCanvas txt = null; public Display display; private StringBuffer error = new StringBuffer(""); public static int fontSize = 0; public static int lineSpace = 0; public static int readType = 0; //0纵向,1横向 public static String rootPath = ""; //阅读文档的根目录 public static int frontColor = 51; public static int backColor = 0; public static int delay = 125; public static int background = 0x3272AE; public static int bordorcolor = 0xC5C4C0; public static int fontcolor = 0xFFFFFF; public static int titlecolor = 0; public static boolean showhiddenfiles = false; public static boolean openlastfile = false; public static int guageheight = 1; public static int foldercolor = 0xffffff; public AnyView() { usedMemory(); av = this; init(); usedMemory(); if (!checkSystem()) { Form f = new Form("系统环境错误!"); f.append(error.toString()); display.setCurrent(f); return; } loadProperty(); if (!openlastfile) { switchSplash(); } else { Record r = new Record("avbookmark"); r.open(); int num = r.getNumRecords(); if (num < 1) { //没有任何记录 r.close(); switchSplash(); return; } String[] f = new String[num]; //寻找符合当前文件的书签 for (int i = 0; i < num; i++) { byte[] b = r.getRecord(1 + i); //RecordStore的RecordID总是从1开始 BookMark ibm = new BookMark(); if (!ibm.decodeBookMark(b)) { continue; } f[i] = ibm.getFilename(); } r.close(); int len = f.length - 1; FileSystemReader fsr = new FileSystemReader(f[len]); if (fsr.isDirectory() || !fsr.exists()) { switchSplash(); return; } else { switchTxt(f[len]); return; } } //switchTxt("/mmc/anyview/1.txt"); //display.setCurrent(new Search("Search")); //System.out.println(AnyView.usedMemory()); } void init() { StartTime = System.currentTimeMillis(); display = Display.getDisplay(this); openRec(); cf = new CustomFont(fontSize); int[] arrow = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0, 0, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0, 0, 0, 0, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFFFFFFFF, 0, 0, 0, 0, 0}; DownArrow = Image.createRGBImage(arrow, 11, 6, true); arrow = null; arrow = new int[] {0, 0, 0, 0, 0, 0xFFFFFFFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0, 0, 0, 0, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0, 0, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; UpArrow = Image.createRGBImage(arrow, 11, 6, true); arrow = null; } boolean checkSystem() { String[] lists = FileSystemReader.listRoots(); if (null == lists || lists.length < 2) { return false; } Root = lists[1]; lists = null; FileSystemReader fsa = new FileSystemReader(Root + "anyview/"); if (!fsa.isDirectory()) { error.append("MMS/SD卡下无anyview目录!\n"); fsa.close(); return false; } fsa.close(); fsa = new FileSystemReader(Root + "anyview/uc2gb"); if (!fsa.exists()) { error.append("anyview目录下缺少文件uc2gb!\n"); fsa.close(); return false; } fsa = new FileSystemReader(Root + "anyview/df16"); if (!fsa.exists()) { error.append("anyview目录下缺少文件df16!\n"); fsa.close(); return false; } fsa = new FileSystemReader(Root + "anyview/df12"); if (!fsa.exists()) { error.append("anyview目录下缺少文件df12!\n"); fsa.close(); return false; } fsa = null; /*fsa = new FileSystemReader(Root + "anyview/uc2gb"); if (!fsa.exists()) { fsa.close(); return false; }*/ return true; } /** * 获得用户定义的系统参数 */ private void loadProperty() { FileSystemReader fsa = new FileSystemReader(Root + "anyview/anyview.ini"); if (fsa.exists() && !fsa.isDirectory()) { int len = (int) fsa.fileSize(); byte b[] = fsa.read(len); if (null != b && b.length > 0) { //解析配置文件 String str = new String(b); int offset = 0; int end = 0; String temp; //showhiddenfiles try { offset = str.indexOf("showhiddenfiles="); end = str.indexOf(";", offset); temp = str.substring(offset + 16, end); int fps = Integer.parseInt(temp); showhiddenfiles = (fps == 1); } catch (Exception ex) { showhiddenfiles = false; } //openlastfile try { offset = str.indexOf("openlastfile="); end = str.indexOf(";", offset); temp = str.substring(offset + 13, end); int fps = Integer.parseInt(temp); openlastfile = (fps == 1); } catch (Exception ex) { openlastfile = false; } //background try {

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值