骑猪闯天下

J2ME随笔,记录成长的脚步

统计

留言簿(3)

阅读排行榜

评论排行榜

[J2ME]触摸屏功能实现代码二

2. 实现触摸屏对象类

package com.xuudoo.ewl;

/**
 * ClipRegion.java
 * 
@author changfeng.du
 * Created on 2009.12.31
 * 控件的选择区域
 
*/

public class ClipRegion
{
    
public int i_clipX; //区域X
    public int i_clipY; //区域Y
    public int i_clipWidth; //区域宽
    public int i_clipHeight; //区域高
    
    
public ClipRegion(int a_x,int a_y,int a_width, int a_height)
    
{
        i_clipX 
= a_x;
        i_clipY 
= a_y;
        i_clipWidth 
= a_width;
        i_clipHeight 
= a_height;
    }

    
    
//判断选择是否在区域里面
    public boolean inClipRegion(int a_x,int a_y)
    
{
        
if(i_clipX <= a_x &&
           i_clipY 
<= a_y &&
           i_clipX 
+ i_clipWidth >= a_x &&
           i_clipY 
+ i_clipHeight >= a_y)
            
return true;
        
        
return false;
    }

}



3. 保存触摸控件的属性
在获取页面信息时,把要实现触摸功能的控件,以Vector的形势保存下来,这里主要是保存控件。

/**
 * UI控制类,本类也是该项目的一个亮点
 * Date:2010.02.25          
 
*/


package com.xuudoo.booking;

import java.io.IOException;
import java.util.*;

import javax.microedition.lcdui.*;
import javax.microedition.rms.InvalidRecordIDException;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStoreNotOpenException;

import com.xuudoo.ewl.*;

public class UIManager implements AsynchronismCommunication, CommandListener {

    
public static BookingMidlet _theMidlet;
    
public static Display _appDisplay;
    
public static UIManager _instance;
    
public int appWidth;
    
public int appHeight;
    
public int _containerX;
    
public int _containerY;
    
public int _containerHMargin;
    
public int _containerVMargin;
    
public static EWLCommandWindow _winCurrent;
    
public static short _flag = 10;

    
public static byte state = 0;// 当前的状态 
    public static byte STATE_LOGIN = 1;//登陆提示界面状态
    public static byte STATE_LOGIN_httpConnecting = 2;//确认登陆后的连接状态
    public static byte STATE_DEFAULE = 0;//其他正常界面状态
    public static final Font my_smallFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);//字体控制

    
public static String _promotoMsgs[] = "读取服务器信息……" };
    
public static EWLTicker _promoteMsgTicker;
    
public static boolean onProgramUpdate = false;
    
public static String programUpdateUrl = null;
    
public static String programUpdateInfo = null;
    
public static String firstRun = "0";
    
public static boolean orderIn = false;
    
public static Hashtable _rsvInfo;//存放所有获取到底信息
    public static Object _paramsAry[] = new Object[21];
    
public static short _reservationStep = 0;
    
public static boolean updateForm = false;
    
public static int helpPage = 0;
    
public static String[] httpConnectChoiceTip = {"CMWAP""CMNET,WLAN"};
    
private static final String helpIndex[] = //功能介绍 操作说明 客服信息
    "功能介绍""操作说明""客服信息" }
;
    
private static final String helpInfo[] = {
        
"功能介绍:",
        
"操作说明:",
        
"客服电邮:" }
;
    
public static boolean _showProgress = true;
    
public static EWLProgressBar _progressBar = new EWLProgressBar();
    
public static UserInfo user;
    
public static Vector _mgzList;
    
public static boolean roundFlight = false;
    
public static short roundFlightStep = 0;
    
public static int mgzClass = 0;
    
public static String msgTitle;
    
public static String msgInfo;
    
public static short msgNextFlag;
    
public static boolean needLoadSystemData = true;
    
public static boolean needChangeScreen = true;
    
public static boolean mainPageNeedShow = false;
    
public static Magazine _currMgz;
    
public static String _currBook;
    
public static Displayable _lastScr;
    
public static String _currMid;
    
public static String _currMnm;
    
public static String _nextPage;
    
public static String _searchKey = "71";
    
public static int _total;
    
public static int _curr = 1;
    
public static int _type;
    
private Vector dlBookID;//存放下载书的id
    private int dlbooknum;//下载书的数量
    public Vector dlist;
    
public int dlen;
    
public static MyRefreshTimer mRefreshTimer = null;
    
public static String _smscno = "";//短信服务中心号码
    public static String _platform = "";//手机平台型号
    public static String _appname = "xuudoo";//公司业务号
    public static String _session = "";
    
public static boolean agreeCharge;//是否同意收费
    public static boolean asking;//收费时的alert对话框标志位
    public String _percent;//显示百分比
    public int _FocusID;//当前选中项
    public boolean isResume = false;//续传标志位
    public static boolean isLoading = false;//正在下载标志位
    public DownloadTool downloadtool = null;//下载线程

    
public Vector downloadurl;//用以存放下载url列表
    public Vector downloaditem;//用以存放下载item列表
    public Vector downloadid;//用以存放下载id列表
    public Vector pausedlist;//用以存放下载url列表item列表id列表
    public static int pausedlen = 0;

    
public static int downloadpausednum = 0;//被暂停的下载数量
    public static Vector downloadpaused;//被暂停的下载的bookid

    
public int dlbookid = 0;
    
public static boolean isProgressbar = false;
    
public static BookCanvas bookcanvas;
    
    
public Vector i_clipArea=null;//触摸屏控件
    public static int browserLineX=5;//触摸屏坐标
    public static int browserLineY=28;
    
public static int browserLineWidth=349;
    
public static int browserLineHeight=17;

    
public int get_FocusID() {
        
return _FocusID;
    }


    
public void set_percent(String percent, int focusID) {
        _percent 
= percent;
        _FocusID 
= focusID;
    }


    
private UIManager() {
        _containerX 
= 5;
        _containerY 
= 28;
        _containerHMargin 
= 11;
        _containerVMargin 
= 55;
        EWLScreen.init(_theMidlet);
        appWidth 
= EWLScreen.SCREEN_WIDTH;
        appHeight 
= EWLScreen.SCREEN_HEIGHT;
        user 
= new UserInfo();
        String tmpVer 
= IOManager.getProtocolVer();
        
if (tmpVer != null && tmpVer.trim().length() == 0)
            ETInterface.ver 
= tmpVer;
        ETInterface.ver 
= ETInterface.ver.substring(0, ETInterface.ver.length() - 2+ ETInterface.pver;
        IOManager.setProtocolVer(ETInterface.ver);
        firstRun 
= IOManager.getFirstRun();
        mRefreshTimer 
= new MyRefreshTimer();

        
//返回SMS的服务中心号码
        _smscno = System.getProperty("wireless.messaging.sms.smsc");
        
if (_smscno == null || _smscno.equals(""|| _smscno.startsWith("+123"))
            _smscno 
= BookingMidlet.smsServerCenterNum;

        
//手机平台型号.
        _platform = BookingMidlet.phonePlatform;

        IOManager.log(
"platform=" + _platform);
        _session 
= Long.toString(System.currentTimeMillis());

    }


    
public static void loadAllSystemData() {
    }


    
public static UIManager getInstance(BookingMidlet midlet) {
        _theMidlet 
= midlet;
        _appDisplay 
= Display.getDisplay(_theMidlet);
        
if (_instance == null)
            _instance 
= new UIManager();
        
return _instance;
    }


    
/**
     * 流程控制
     
*/

    
public void doLoop() {
        
if (BookingMidlet.DEBUG)
            System.out.println(
"UIManger---------_flag code is:" + _flag);

        showMemory(
"IN DOLOOP()");
        
switch (_flag) {
        
case 10//启动系统,显示登录提示页面
            state = STATE_LOGIN;
            _appDisplay.setCurrent(EWLScreen.instance);
            FirstPage.iniFirstPagePic();
            
return;
        
case 20://展示系统首页面
            if (needLoadSystemData) {
                loadAllSystemData();
                needLoadSystemData 
= false;
            }

            resetReservInfo();
            doClean();
            
if (needChangeScreen) {
                EWLScreen.instance.clearScreen();
                needChangeScreen 
= false;
            }

            FirstPage tmp 
= new FirstPage();
            EWLScreen.setCurrent(tmp);
            
break;
        
case 30:
            doClean();
            _winCurrent 
= createFlightQueryNewWindow();
            
break/* Loop/switch isn't completed */
        
case 40:
            doClean();
            _winCurrent 
= createMgzSpecClassWindow();
            
break/* Loop/switch isn't completed */
        
case 470:
            _winCurrent 
= createSearchWindow();
            
break;
        
case 170:
            BusinessWindow.inOrder 
= false;
            doClean();
            _winCurrent 
= createBookDownloadedWindow();
            
break/* Loop/switch isn't completed */
        
case 60:
            doClean();
            _winCurrent 
= createSettingWindow();
            
break;
        
case 260:
            doClean();
            _winCurrent 
= createUserAddWindow();
            
break/* Loop/switch isn't completed */
        
case 270:
            doClean();
            _winCurrent 
= createUserChangePasswordWindow();
            
break/* Loop/switch isn't completed */
        
case 70:
            doClean();
            _winCurrent 
= createHelpWindow();
            
break;
        
case 370:
            doClean();
            _winCurrent 
= createHelpInfoWindow();
            
break;
        
case 80:
            doClean();
            _winCurrent 
= createBookMarkWindow(1);
            
break/* Loop/switch isn't completed */
        
case 310:
            _winCurrent 
= showMessage();
            
break;
        
case 330:
            _winCurrent 
= createMgzSpecClassWindow();
            
break;
        
case 350:
            _winCurrent 
= createComicsListWindow();
            
break;
        
case 360:
            _winCurrent 
= createHotMgzDetailQueryWindow();
            
break;
        
case 450:
            _winCurrent 
= createBookDownloadedWindow();
            
break;
        
case 460:
            _winCurrent 
= createDownloadingWindow();
            
break;
        
default// 找不到处理程序,退出
            IOManager.log("_flag = " + _flag + " 找不到处理程序,退出。");
            _theMidlet.notifyDestroyed();
        }
 // switch
        if (_flag != 20)
            EWLScreen.setCurrent(_winCurrent);
        System.gc();
        
try {
            Thread.sleep(
100L);
        }
 catch (InterruptedException interruptedexception) {
        }

    }


    
private void showMemory(String info) {
        System.gc();
        
try {
            Thread.sleep(
50L);
        }
 catch (InterruptedException ex) {
            ex.printStackTrace();
        }

    }


    
/**
     * 第一次登陆,画Logo登录 图片
     
*/

    
//    private void drawLogo() {
    
//        logoWin = new BusinessWindow();
    
//        for (byte i = 0; i < BusinessWindow.imgFileName.length; i++) {
    
//            logoWin.showLogo(i);
    
//            EWLScreen.setCurrent(logoWin);
    
//            
    
//            try {
    
//                Thread.sleep(3000L);
    
//            } catch (InterruptedException interruptedexception) {
    
//            }
    
//        }
    
//
    
//        logoWin = null;
    
//        System.gc();
    
//    }

    
private EWLCommandWindow createMgzSpecClassWindow() {
        String cmdStrings[] 
= "查询""返回" };
        
int cmdIDs[] = 12 };
        BusinessWindow winSellInfoMain 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short20);
        
//winSellInfoMain.buttonType = 11;
        
//
        winSellInfoMain._strTitle = "书目列表";
        winSellInfoMain.setCommandListener(winSellInfoMain);
        winSellInfoMain.setContainer(
new EWLContainer());
        ((EWLWindow) (winSellInfoMain)).container.setBounds(_containerX, _containerY,
                ((EWLComponent) (winSellInfoMain)).width 
- _containerHMargin, ((EWLComponent) (winSellInfoMain)).height
                        
- _containerVMargin);
        
//commit get_spec_class
        Vector mgzBooks = null;
        mgzBooks 
= (Vector) _rsvInfo.get("ALL_HOT_BOOK");
        
if (mgzBooks == null)
            
return null;
        EWLMenuItem items[] 
= new EWLMenuItem[mgzBooks.size()];
        
for (int i = 0; i < mgzBooks.size(); i++{
            Book bk 
= (Book) mgzBooks.elementAt(i);
            items[i] 
= new EWLMenuItem(null, bk.bookName, Integer.parseInt(bk.bookId), true,0);
            items[i].isSingleLine 
= false;
            items[i].align 
= 1;
            items[i].width 
= ((EWLComponent) (((EWLWindow) (winSellInfoMain)).container)).width;
            ((EWLWindow) (winSellInfoMain)).container.addComponent(items[i], 
false);
        }

        ((EWLWindow) (winSellInfoMain)).container.layout();
        ((EWLWindow) (winSellInfoMain)).container.setFocusIndex(
0false);
        
return winSellInfoMain;
    }


    
/**
     * 清除所有的控件
     
*/

    
public void cleanArea()
    
{
        
if(i_clipArea==null)
            
return;
        i_clipArea.removeAllElements();
    }

    
/**
     * 增加新的控件
     * 
@param a_clipArea
     
*/

    
public void addClipArea(ClipRegion a_clipArea)
    
{
        
if(i_clipArea==null)
            i_clipArea 
= new Vector();
        i_clipArea.addElement(a_clipArea);
    }


    
/**
     * 漫画查询列表窗口
     * 
@return
     
*/

    
private EWLCommandWindow createComicsListWindow() {
        
//清除以前的触摸屏控件
        cleanArea();
        
        String cmdString[] 
= (String[]) null;
        cmdString 
= (new String[] "确定""返回" });
        
int cmdId[] = 12 };
        BusinessWindow hotLineListWindow 
= new BusinessWindow(cmdString, cmdId, 1, (short390);
        hotLineListWindow.setCommandListener(hotLineListWindow);
        hotLineListWindow.setContainer(
new EWLContainer());
        ((EWLWindow) (hotLineListWindow)).container.setBounds(_containerX, _containerY,
                ((EWLComponent) (hotLineListWindow)).width 
- _containerHMargin,
                ((EWLComponent) (hotLineListWindow)).height 
- _containerVMargin);

        Vector hotMgzs 
= _mgzList;
        EWLMenuItem cabItems[] 
= new EWLMenuItem[hotMgzs.size()];
        
//漫画查询结果 条
        hotLineListWindow._strTitle = "漫画查询结果 " + hotMgzs.size() + "";//;
        if (_total > 1{
            EWLMenuItem itemPrev 
= new EWLMenuItem(null"上一页           [" + Integer.toString(_curr) + "/"
                    
+ Integer.toString(_total) + "]          下一页" , -1true,2);
            
//添加触摸屏控件
            addClipArea(new ClipRegion(browserLineX, browserLineY, browserLineWidth, browserLineHeight));
            ((EWLWindow) (hotLineListWindow)).container.addComponent(itemPrev, 
false);
        }

        
//把rms操作放在循环语句之外,以少操作为标准
        if(dlbooknum==0)
            openDownloaded();
        String bookIDStr[]
= new String[dlbooknum];
        
for (int i=0; i < dlbooknum; i++{
            bookIDStr[i] 
= (String) dlBookID.elementAt(i * 2);
        }


        
for (int i = 0; i < hotMgzs.size(); i++{
            
//添加触摸屏控件
            int num =i;
            
if(_total > 1)//页码行
                num=i+1;
            addClipArea(
new ClipRegion(browserLineX, browserLineY+ num*browserLineHeight, browserLineWidth, browserLineHeight));
            
            Magazine ht 
= (Magazine) hotMgzs.elementAt(i);
            String s 
= ht.mgzName;
            
for (int j=0; j < dlbooknum; j++{
                
if(bookIDStr[j].equals(ht.mgzId)){
                    s 
= s + " (已下载)";
                    
break;
                }

            }

            
if (ht.mgzState == 11)
                s 
= s + " ";
            cabItems[i] 
= new EWLMenuItem(null, s, Integer.parseInt(ht.mgzId), true,0);
            cabItems[i].width 
= ((EWLComponent) (((EWLWindow) (hotLineListWindow)).container)).width;
            cabItems[i].isSingleLine 
= false;
            cabItems[i].align 
= 1;
            ((EWLWindow) (hotLineListWindow)).container.addComponent(cabItems[i], 
false);
            
            
//统一修改为每本书下都加横线
            EWLSeparator sep = new EWLSeparator();
            ((EWLWindow) (hotLineListWindow)).container.addComponent(sep, 
false);
            
//把高亮设置统一起来,分隔符加进去
            addClipArea(new ClipRegion(0000));
        }

        
if (_total > 1{
            EWLMenuItem itemNext 
= null;
            
if(_total <= 5){
                String pagestr 
= "";
                
for(int k = 1;k <= _total; k ++){
                    pagestr 
+= k + "    ";
                }

                itemNext 
= new EWLMenuItem(null,  pagestr + "  快速选页"-2,
                        
true6);
            }

            
else{
                
if (_curr < 4{
                    itemNext 
= new EWLMenuItem(null"1    " + "2    " + "3    " + "4    " + "5    " + "  快速选页"-2,
                            
true6);
                }
 else if (_curr >= 3 && _curr < (_total - 2)) {
                    itemNext 
= new EWLMenuItem(null, Integer.toString(_curr - 2+ "    " + Integer.toString(_curr - 1)
                            
+ "    " + Integer.toString(_curr) + "    " + Integer.toString(_curr + 1+ "    "
                            
+ Integer.toString(_curr + 2+ "    " + "  快速选页"-2true6);
                }
 else if (_curr >= (_total - 2)) {
                    itemNext 
= new EWLMenuItem(null, Integer.toString(_total - 4+ "    "
                            
+ Integer.toString(_total - 3+ "    " + Integer.toString(_total - 2+ "    "
                            
+ Integer.toString(_total - 1+ "    " + Integer.toString(_total) + "    " + "  快速选页"-2,
                            
true6);
                }

            }

            
//添加触摸屏控件
            addClipArea(new ClipRegion(browserLineX, browserLineY+ (hotMgzs.size()+1)*browserLineHeight, browserLineWidth, browserLineHeight));
            ((EWLWindow) (hotLineListWindow)).container.addComponent(itemNext, 
false);
        }


        ((EWLWindow) (hotLineListWindow)).container.layout();
        
if (_paramsAry[18!= null)
            
try {
                
int tmpIdx = Integer.parseInt(_paramsAry[18].toString());
                ((EWLWindow) (hotLineListWindow)).container.setFocusIndex(tmpIdx, 
false);
                focusHightlight(hotLineListWindow, tmpIdx);
            }
 catch (NumberFormatException e) {
            }

        
else {
            
if (_total > 1)
                ((EWLWindow) (hotLineListWindow)).container.setFocusIndex(
1false);
            
else
                ((EWLWindow) (hotLineListWindow)).container.setFocusIndex(
0false);
        }

        mRefreshTimer.setComponents(((EWLWindow) (hotLineListWindow)).container.components);
        
return hotLineListWindow;
    }


    
public static void showFeeInfo(String msg) {
        Alert alert 
= new Alert("提示", msg, null, AlertType.INFO);
//        alert.addCommand(new Command("返回", Command.CANCEL, 0));
        alert.setCommandListener(UIManager._instance);
        alert.setTimeout(
2000);
        Display.getDisplay(_theMidlet).setCurrent(alert);
    }


    
public static void showAlert(String msg) {
        Form _form 
= new Form("请注意");
        _form.append(msg);
        _form.addCommand(
new Command("确定"20));
        _form.addCommand(
new Command("返回"10));
        _form.setCommandListener(_instance);
        Display.getDisplay(_theMidlet).setCurrent(_form);
    }


    
public static void showError(String msg) {
        Form _form 
= new Form("错误");
        _form.append(msg);
        _form.addCommand(
new Command("返回"20));
        _form.setCommandListener(_instance);
        Display.getDisplay(_theMidlet).setCurrent(_form);
    }


    
public static void showProgramUpdate(CommandListener in, boolean canChoose) {
        updateForm 
= true;
        Form _form 
= new Form("程序更新");
        _form.append(programUpdateInfo);
        _form.addCommand(
new Command("确定", Command.OK, 0));
        
if(canChoose)
            _form.addCommand(
new Command("取消", Command.BACK, 0));
        _form.setCommandListener(in);
        Display.getDisplay(_theMidlet).setCurrent(_form);
    }


    
/**
     * alert 升级提示,还没有实现,待测试。
     * 
@param in
     
*/

    
public static void showProgramUpdate(String updateMsg, String OK_SoftKey, String BACK_SoftKey) {
        Alert alert 
= new Alert("程序更新", updateMsg, null, AlertType.INFO);
        alert.addCommand(
new Command(OK_SoftKey, Command.OK, 0));
        
if(BACK_SoftKey != null)
            alert.addCommand(
new Command(BACK_SoftKey, Command.BACK, 0));
        alert.setCommandListener(UIManager._instance);
        alert.setTimeout(
-2);
        Display.getDisplay(_theMidlet).setCurrent(alert, EWLScreen.instance);
    }

    
    
public static void showInfo(String msg) {
        Alert alert 
= new Alert("信息", msg, null, AlertType.INFO);
        alert.addCommand(
new Command("确定", Command.OK, 0));
        alert.addCommand(
new Command("取消", Command.BACK, 0));
        alert.setCommandListener(UIManager._instance);
        alert.setTimeout(
-2);
        Display.getDisplay(_theMidlet).setCurrent(alert, EWLScreen.instance);
    }


    
private void doClean() {
        
if (_winCurrent != null)
            ((EWLWindow) (_winCurrent)).container.removeAllComponents(
false);
        _winCurrent 
= null;
    }


    
/**
     * 已下载目录窗口
     * 
@return
     
*/

    
public EWLCommandWindow createBookDownloadedWindow() {
        String cmdStrings[] 
= //进入,删除,返回
        "进入""删除""返回" }
;
        
int cmdIDs[] = 123 };
        BusinessWindow winSeatSelect 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short220);
        winSeatSelect._strTitle 
= "已下载";
        winSeatSelect.setCommandListener(winSeatSelect);
        winSeatSelect.setContainer(
new EWLContainer());
        ((EWLWindow) (winSeatSelect)).container.setBounds(_containerX, _containerY,
                ((EWLComponent) (winSeatSelect)).width 
- _containerHMargin, ((EWLComponent) (winSeatSelect)).height
                        
- _containerVMargin);
        openDownloaded();
        EWLMenuItem items[] 
= new EWLMenuItem[dlbooknum];
        
for (int i = 0; i < items.length; i++{
            items[i] 
= new EWLMenuItem(null, (String) dlBookID.elementAt(i * 2 + 1), Integer.parseInt((String) dlBookID
                    .elementAt(i 
* 2)), true,0);
            items[i].isSingleLine 
= false;
            items[i].align 
= 1;
            items[i].width 
= ((EWLComponent) (((EWLWindow) (winSeatSelect)).container)).width;
            ((EWLWindow) (winSeatSelect)).container.addComponent(items[i], 
false);
        }


        ((EWLWindow) (winSeatSelect)).container.layout();
        ((EWLWindow) (winSeatSelect)).container.setFocusIndex(
0false);
        
return winSeatSelect;
    }


    
public static Image getImageByFile(String fileName) {
        Image img 
= null;
        
try {
            img 
= Image.createImage(fileName);
        }
 catch (IOException ex) {
            ex.printStackTrace();
        }

        
return img;
    }


    
private void focusHightlight(BusinessWindow win, int idx) {
        
if (idx < 0 || idx >= ((EWLWindow) (win)).container.componentCount)
            
return;
        
int tmpSelectedY = ((EWLWindow) (win)).container.components[idx].y;
        
int tmpAllY = ((EWLWindow) (win)).container.components[((EWLWindow) (win)).container.componentCount - 1].y
                
+ ((EWLWindow) (win)).container.components[((EWLWindow) (win)).container.componentCount - 1].height;
        
if (tmpAllY - tmpSelectedY < ((EWLComponent) (((EWLWindow) (win)).container)).height) {
            ((EWLWindow) (win)).container.scrollPos 
= tmpAllY - ((EWLComponent) (((EWLWindow) (win)).container)).height;
            
if (((EWLWindow) (win)).container.scrollPos < 0)
                ((EWLWindow) (win)).container.scrollPos 
= 0;
        }
 else {
            ((EWLWindow) (win)).container.scrollPos 
= tmpSelectedY;
        }

    }


    
public EWLCommandWindow createBookMarkWindow(int type) {
        String cmdStrings[] 
= "确定""返回" };
        
int cmdIDs[] = 12 };
        BusinessWindow winHelpAbout 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short210);
        winHelpAbout.buttonType 
= 1;
        String info[] 
= (String[]) null;
        winHelpAbout._strTitle 
= "书签管理器";
        String tmp 
= IOManager.getBookMark();
        
if (tmp.equals("0^0^0")) {
            info 
= (new String[] "您暂时没有书签!" });
        }
 else {
            
int idx = tmp.indexOf("^");
            String mgzId 
= tmp.substring(0, idx);
            tmp 
= tmp.substring(idx + 1);
            idx 
= tmp.indexOf("^");
            String mgzNm 
= tmp.substring(0, idx);
            tmp 
= tmp.substring(idx + 1);
            String pageId 
= tmp;
            UIManager._currMid 
= mgzId;
            UIManager._currMnm 
= mgzNm;
            UIManager._nextPage 
= pageId;
            info 
= (new String[] "书签1 " + mgzNm + ": 第" + pageId + "" });
        }

        winHelpAbout.setCommandListener(winHelpAbout);
        winHelpAbout.setContainer(
new EWLContainer());
        ((EWLWindow) (winHelpAbout)).container.setBounds(_containerX, _containerY,
                ((EWLComponent) (winHelpAbout)).width 
- _containerHMargin, ((EWLComponent) (winHelpAbout)).height
                        
- _containerVMargin);
        EWLMenuItem items[] 
= new EWLMenuItem[info.length];
        
for (int i = 0; i < items.length; i++{
            items[i] 
= new EWLMenuItem(null, info[i], i, true,0);
            items[i].isSingleLine 
= false;
            items[i].align 
= 1;
            items[i].width 
= ((EWLComponent) (((EWLWindow) (winHelpAbout)).container)).width;
            items[i].enabledChoose 
= false;
            ((EWLWindow) (winHelpAbout)).container.addComponent(items[i], 
false);
        }


        ((EWLWindow) (winHelpAbout)).container.layout();
        
return winHelpAbout;
    }


    
public EWLCommandWindow createHelpInfoWindow() {
        String cmdStrings[] 
= """返回" };
        
int cmdIDs[] = 21 };
        BusinessWindow winHelpInfo 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short207);
        winHelpInfo.buttonType 
= 1;
        String info[] 
= (String[]) null;
        winHelpInfo._strTitle 
= helpIndex[helpPage];
        info 
= (new String[] { helpInfo[helpPage] });
        winHelpInfo.setCommandListener(winHelpInfo);
        winHelpInfo.setContainer(
new EWLContainer());
        ((EWLWindow) (winHelpInfo)).container.setBounds(_containerX, _containerY, ((EWLComponent) (winHelpInfo)).width
                
- _containerHMargin, ((EWLComponent) (winHelpInfo)).height - _containerVMargin);
        EWLMenuItem items[] 
= new EWLMenuItem[info.length];
        
for (int i = 0; i < items.length; i++{
            items[i] 
= new EWLMenuItem(null, info[i], i, true,0);
            items[i].isSingleLine 
= false;
            items[i].align 
= 1;
            items[i].width 
= ((EWLComponent) (((EWLWindow) (winHelpInfo)).container)).width;
            items[i].enabledChoose 
= false;
            ((EWLWindow) (winHelpInfo)).container.addComponent(items[i], 
false);
        }


        ((EWLWindow) (winHelpInfo)).container.layout();
        
return winHelpInfo;
    }


    
public static void commitRequest(BusinessWindow win, String request, String requestInfo, boolean isUpdate)
            
throws Exception {
        IOManager.log(
"请求命令字符串:[" + request + "]");
        _showProgress 
= true;
        IOManager._strRequest 
= request;
        IOManager._isUpdate 
= isUpdate;
        IOManager._businessWindow 
= win;
        
if (IOManager.getInstance().isAlive()) {
            
throw new Exception("暂时没有可用连接,请稍后再进行操作。");
        }
 else {
            IOManager._interrupt 
= false;
            IOManager.getInstance().start();
            _progressBar.setPosition(
0);
            _instance.showProgressBar(requestInfo);
            
return;
        }

    }


    
//显示进度条
    public void showProgressBar(String info) {
        isProgressbar 
= true;
        String cmdString[] 
= "取消" };
        
int cmdId[] = 1 };
        BusinessWindow popup 
= new BusinessWindow(cmdString, cmdId, 1, (short180);
        popup.setCommandListener(popup);
        popup.setContainer(
new EWLContainer());
        ((EWLWindow) (popup)).container.setBounds(_containerX, _containerY, ((EWLComponent) (popup)).width
                
- _containerHMargin, ((EWLComponent) (popup)).height - _containerVMargin);
        popup._strTitle 
= "提交请求"//
        int y = (((EWLComponent) (((EWLWindow) (popup)).container)).height * 3/ 7;
        EWLMenuItem miLable 
= new EWLMenuItem(null, info, 7true,0);
        miLable.setFont(EWLConstants.SMALL_FONT, 
false);
        miLable.align 
= 2;
        miLable.enabledChoose 
= false;
        miLable.isSingleLine 
= false;
        miLable.width 
= ((EWLComponent) (((EWLWindow) (popup)).container)).width;
        miLable.setBounds(
0, y, ((EWLComponent) (((EWLWindow) (popup)).container)).width, miLable.getPreferredHeight());
        _progressBar.setBounds(
5, y += miLable.getPreferredHeight() + 1,
                ((EWLComponent) (((EWLWindow) (popup)).container)).width 
- 1010);
        EWLMenuItem lablePhone 
= new EWLMenuItem(null""9true,0);
        lablePhone.setFont(EWLConstants.SMALL_FONT, 
false);
        lablePhone.align 
= 2;
        lablePhone.enabledChoose 
= false;
        lablePhone.isSingleLine 
= false;
        lablePhone.width 
= ((EWLComponent) (((EWLWindow) (popup)).container)).width;
        lablePhone.setBounds(
0, y += 12, ((EWLComponent) (((EWLWindow) (popup)).container)).width, miLable
                .getPreferredHeight());
        ((EWLWindow) (popup)).container.addComponent(miLable, 
false);
        ((EWLWindow) (popup)).container.addComponent(_progressBar, 
false);
        ((EWLWindow) (popup)).container.addComponent(lablePhone, 
false);
        EWLScreen.popup(popup);
//        EWLScreen.addRefreshTarget(popup);
    }


    
public EWLCommandWindow showMessage() {
        String cmdString[] 
= "返回" };
        
int cmdId[] = 1 };
        BusinessWindow winMessage 
= new BusinessWindow(cmdString, cmdId, 3, (short185);
        winMessage.buttonType 
= 1;
        winMessage._strTitle 
= msgTitle;
        winMessage.setCommandListener(winMessage);
        winMessage.setContainer(
new EWLContainer());
        ((EWLWindow) (winMessage)).container.setBounds(_containerX, _containerY, ((EWLComponent) (winMessage)).width
                
- _containerHMargin, ((EWLComponent) (winMessage)).height - _containerVMargin);
        EWLMenuItem miLable 
= new EWLMenuItem(null, msgInfo, 0true,0);
        miLable.font 
= EWLConstants.MEDIUM_FONT;
        miLable.align 
= 1;
        miLable.enabledChoose 
= false;
        miLable.isSingleLine 
= false;
        miLable.width 
= ((EWLComponent) (((EWLWindow) (winMessage)).container)).width;
        ((EWLWindow) (winMessage)).container.addComponent(miLable, 
false);
        ((EWLWindow) (winMessage)).container.layout();
        
return winMessage;
    }


    
public EWLCommandWindow createUserAddWindow() {
        String cmdStrings[] 
= "确定""返回" };
        
int cmdIDs[] = 12 };
        BusinessWindow winUserAdd 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short310);
        winUserAdd._strTitle 
= "会员登录";
        winUserAdd.setCommandListener(winUserAdd);
        winUserAdd.setContainer(
new EWLContainer());
        ((EWLWindow) (winUserAdd)).container.setBounds(_containerX, _containerY, ((EWLComponent) (winUserAdd)).width
                
- _containerHMargin, ((EWLComponent) (winUserAdd)).height - _containerVMargin);
        EWLMenuItem miLable[] 
= new EWLMenuItem[3];
        miLable[
0= new EWLMenuItem(null"用户名*"11true,0);
        miLable[
1= new EWLMenuItem(null"口令*"12true,0);
        miLable[
2= new EWLMenuItem(null"*如果您已在网站注册,请直接使用网站注册时的用户名和口令"13true,0);
        
for (int i = 0; i < miLable.length; i++{
            miLable[i].setFont(EWLConstants.SMALL_FONT, 
false);
            miLable[i].align 
= 33;
            miLable[i].enabledChoose 
= false;
            miLable[i].isSingleLine 
= false;
            miLable[i].width 
= ((EWLComponent) (((EWLWindow) (winUserAdd)).container)).width;
        }


        EWLEdit edtUserName 
= new EWLEdit(EWLConstants.EDIT_ANY);
        edtUserName.width 
= ((EWLComponent) (((EWLWindow) (winUserAdd)).container)).width;
        EWLEdit edtPassWord 
= new EWLEdit(EWLConstants.EDIT_ANY);
        edtPassWord.width 
= ((EWLComponent) (((EWLWindow) (winUserAdd)).container)).width;
        ((EWLWindow) (winUserAdd)).container.addComponent(miLable[
0], false);
        ((EWLWindow) (winUserAdd)).container.addComponent(edtUserName, 
false);
        ((EWLWindow) (winUserAdd)).container.addComponent(miLable[
1], false);
        ((EWLWindow) (winUserAdd)).container.addComponent(edtPassWord, 
false);
        ((EWLWindow) (winUserAdd)).container.addComponent(miLable[
2], false);
        ((EWLWindow) (winUserAdd)).container.layout();
        ((EWLWindow) (winUserAdd)).container.setFocusIndex(
1false);
        
return winUserAdd;
    }


    
public EWLCommandWindow createUserChangePasswordWindow() {
        String cmdStrings[] 
= "确定""返回" };
        
int cmdIDs[] = 12 };
        BusinessWindow winUserChangePassword 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short320);
        winUserChangePassword._strTitle 
= "修改密码";
        winUserChangePassword.setCommandListener(winUserChangePassword);
        winUserChangePassword.setContainer(
new EWLContainer());
        ((EWLWindow) (winUserChangePassword)).container.setBounds(_containerX, _containerY,
                ((EWLComponent) (winUserChangePassword)).width 
- _containerHMargin,
                ((EWLComponent) (winUserChangePassword)).height 
- _containerVMargin);
        EWLMenuItem miLable[] 
= new EWLMenuItem[3];
        miLable[
0= new EWLMenuItem(null"原密码*"11true,0);
        miLable[
1= new EWLMenuItem(null"新密码(不能少于6位)*"12true,0);
        miLable[
2= new EWLMenuItem(null"重复新密码*"13true,0);
        
for (int i = 0; i < miLable.length; i++{
            miLable[i].setFont(EWLConstants.SMALL_FONT, 
false);
            miLable[i].align 
= 33;
            miLable[i].enabledChoose 
= false;
            miLable[i].width 
= ((EWLComponent) (((EWLWindow) (winUserChangePassword)).container)).width;
        }


        EWLEdit edtOldCode 
= new EWLEdit(EWLConstants.EDIT_ANY);
        edtOldCode.width 
= ((EWLComponent) (((EWLWindow) (winUserChangePassword)).container)).width;
        EWLEdit edtNewCode1 
= new EWLEdit(EWLConstants.EDIT_ANY);
        edtNewCode1.width 
= ((EWLComponent) (((EWLWindow) (winUserChangePassword)).container)).width;
        EWLEdit edtNewCode2 
= new EWLEdit(EWLConstants.EDIT_ANY);
        edtNewCode2.width 
= ((EWLComponent) (((EWLWindow) (winUserChangePassword)).container)).width;
        ((EWLWindow) (winUserChangePassword)).container.addComponent(miLable[
0], false);
        ((EWLWindow) (winUserChangePassword)).container.addComponent(edtOldCode, 
false);
        ((EWLWindow) (winUserChangePassword)).container.addComponent(miLable[
1], false);
        ((EWLWindow) (winUserChangePassword)).container.addComponent(edtNewCode1, 
false);
        ((EWLWindow) (winUserChangePassword)).container.addComponent(miLable[
2], false);
        ((EWLWindow) (winUserChangePassword)).container.addComponent(edtNewCode2, 
false);
        ((EWLWindow) (winUserChangePassword)).container.layout();
        ((EWLWindow) (winUserChangePassword)).container.setFocusIndex(
1false);
        
return winUserChangePassword;
    }


    
public int[] getDateNum(String strDate) {
        
int tmp[] = new int[3];
        Calendar now 
= Calendar.getInstance();
        tmp[
0= now.get(1);
        tmp[
1= now.get(2+ 1;
        tmp[
2= now.get(5);
        
try {
            
int idx = strDate.indexOf("-");
            String strY 
= strDate.substring(0, idx);
            strDate 
= strDate.substring(idx + 1);
            idx 
= strDate.indexOf("-");
            String strM 
= strDate.substring(0, idx);
            String strD 
= strDate.substring(idx + 1);
            tmp[
0= Integer.parseInt(strY);
            tmp[
1= Integer.parseInt(strM);
            tmp[
2= Integer.parseInt(strD);
        }
 catch (Throwable throwable) {
        }

        
return tmp;
    }


    
public EWLCommandWindow createFlightQueryNewWindow() {
        String cmdStrings[] 
= "进入""返回" };
        
int cmdIDs[] = 12 };
        BusinessWindow winFlightQueryNew 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short15);
        winFlightQueryNew._strTitle 
= "分类";
        winFlightQueryNew.setCommandListener(winFlightQueryNew);
        winFlightQueryNew.setContainer(
new EWLContainer());
        ((EWLWindow) (winFlightQueryNew)).container.setBounds(_containerX, _containerY,
                ((EWLComponent) (winFlightQueryNew)).width 
- _containerHMargin,
                ((EWLComponent) (winFlightQueryNew)).height 
- _containerVMargin);
        Vector hotLines 
= null;
        hotLines 
= (Vector) _rsvInfo.get("ALL_HOT_LINE");
        EWLMenuItem items[] 
= new EWLMenuItem[hotLines.size()];
        
for (int i = 0; i < items.length; i++{
            BookType ht 
= (BookType) hotLines.elementAt(i);
            items[i] 
= new EWLMenuItem(null, ht.bookName, Integer.parseInt(ht.bookId), true,0);
            items[i].isSingleLine 
= false;
            items[i].align 
= 1;
            items[i].width 
= ((EWLComponent) (((EWLWindow) (winFlightQueryNew)).container)).width;
            ((EWLWindow) (winFlightQueryNew)).container.addComponent(items[i], 
false);
        }


        ((EWLWindow) (winFlightQueryNew)).container.layout();
        ((EWLWindow) (winFlightQueryNew)).container.setFocusIndex(
0false);
        
if (_paramsAry[10!= null)
            
try {
                
int mtpIdx = Integer.parseInt(_paramsAry[10].toString());
                ((EWLWindow) (winFlightQueryNew)).container.setFocusIndex(mtpIdx, 
false);
                focusHightlight(winFlightQueryNew, mtpIdx);
            }
 catch (Exception ex) {
                IOManager.log(_paramsAry[
10+ "" + ex.toString());
            }

        roundFlight 
= false;
        roundFlightStep 
= 0;
        
return winFlightQueryNew;
    }


    
/**
     * 设置项九宫格
     * 
@return
     
*/

    
public EWLCommandWindow createSettingWindow() {
        String sUserType;
        String httpConMode;
        String cmdStrings[] 
= "确定""返回" };
        
int cmdIDs[] = 12 };
        BusinessWindow winSetting 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short200);
        winSetting._strTitle 
= "欢迎您  " + user.getPhoneNumber(); //我的控制面板
        winSetting.setCommandListener(winSetting);
        winSetting.setContainer(
new EWLContainer());
        ((EWLWindow) (winSetting)).container.setBounds(_containerX, _containerY, ((EWLComponent) (winSetting)).width
                
- _containerHMargin, ((EWLComponent) (winSetting)).height - _containerVMargin);
        
if (user.getPayed() == "true"{
            sUserType 
= "包月用户";
        }
 else
            sUserType 
= "普通用户";
        
if(BookingMidlet.useProxy)
            httpConMode
=httpConnectChoiceTip[0];
        
else
            httpConMode
=httpConnectChoiceTip[1];
        EWLMenuItem items[];
        
if(BookingMidlet.CMWAPSETTING)
            items 
= new EWLMenuItem[3];
        
else
            items 
= new EWLMenuItem[2];
        items[
0= new EWLMenuItem(null"您的用户编号:" + user.getUserID(), 0true,0);
        items[
1= new EWLMenuItem(null"当前状态:" + sUserType, 1true,0);
        
if(BookingMidlet.CMWAPSETTING)
            items[
2= new EWLMenuItem(null"联网方式: "+httpConMode, 2true,0);
        
for (int i = 0; i < items.length; i++{
            items[i].isSingleLine 
= false;
            items[i].align 
= 1;
            items[i].width 
= ((EWLComponent) (((EWLWindow) (winSetting)).container)).width;
            
//items[i].enabledChoose = false;
            ((EWLWindow) (winSetting)).container.addComponent(items[i], false);
        }


        ((EWLWindow) (winSetting)).container.layout();
        ((EWLWindow) (winSetting)).container.setFocusIndex(
0false);
        
if (_paramsAry[1!= null)
            
try {
                
int mtpIdx = Integer.parseInt(_paramsAry[1].toString());
                ((EWLWindow) (winSetting)).container.setFocusIndex(mtpIdx, 
false);
                focusHightlight(winSetting, mtpIdx);
            }
 catch (Exception ex) {
                IOManager.log(_paramsAry[
1+ "" + ex.toString());
            }

        
return winSetting;
    }


    
public EWLCommandWindow createHelpWindow() {
        String cmdStrings[] 
= "进入""返回" };
        
int cmdIDs[] = 12 };
        BusinessWindow winHelp 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short205);
        winHelp._strTitle 
= "系统帮助"//系统帮助
        winHelp.setCommandListener(winHelp);
        winHelp.setContainer(
new EWLContainer());
        ((EWLWindow) (winHelp)).container.setBounds(_containerX, _containerY, ((EWLComponent) (winHelp)).width
                
- _containerHMargin, ((EWLComponent) (winHelp)).height - _containerVMargin);
        EWLMenuItem items[] 
= new EWLMenuItem[3];
        items[
0= new EWLMenuItem(null, helpIndex[0], 0true,0);
        items[
1= new EWLMenuItem(null, helpIndex[1], 1true,0);
        items[
2= new EWLMenuItem(null, helpIndex[2], 2true,0);
        
for (int i = 0; i < items.length; i++{
            items[i].isSingleLine 
= false;
            items[i].align 
= 1;
            items[i].width 
= ((EWLComponent) (((EWLWindow) (winHelp)).container)).width;
            ((EWLWindow) (winHelp)).container.addComponent(items[i], 
false);
        }


        ((EWLWindow) (winHelp)).container.layout();
        ((EWLWindow) (winHelp)).container.setFocusIndex(
0false);
        
if (_paramsAry[20!= null)
            
try {
                
int mtpIdx = Integer.parseInt(_paramsAry[20].toString());
                ((EWLWindow) (winHelp)).container.setFocusIndex(mtpIdx, 
false);
                focusHightlight(winHelp, mtpIdx);
            }
 catch (Exception ex) {
                IOManager.log(_paramsAry[
20+ "" + ex.toString());
            }

        
return winHelp;
    }


    
//用户管理页面,现在该功能暂时不需要,考虑以后可能需要
    
//    public EWLCommandWindow createUserManageWindow() {
    
//        String cmdStrings[] = { "进入", "返回" };
    
//        int cmdIDs[] = { 1, 2 };
    
//        BusinessWindow winUserManage = new BusinessWindow(cmdStrings, cmdIDs, 1, (short) 300);
    
//        winUserManage._strTitle = "用户管理";
    
//        winUserManage.setCommandListener(winUserManage);
    
//        winUserManage.setContainer(new EWLContainer());
    
//        ((EWLWindow) (winUserManage)).container.setBounds(_containerX, _containerY,
    
//                ((EWLComponent) (winUserManage)).width - _containerHMargin, ((EWLComponent) (winUserManage)).height
    
//                        - _containerVMargin);
    
//        EWLMenuItem items[] = new EWLMenuItem[6];
    
//        items[0] = new EWLMenuItem(null, "注册会员", 0);
    
//        items[1] = new EWLMenuItem(null, "\u4FEE\u6539\u5BC6\u7801", 1);
    
//        items[2] = new EWLMenuItem(null, "\u4FEE\u6539\u624B\u673A\u53F7", 2);
    
//        items[3] = new EWLMenuItem(null, "\u4FEE\u6539\u4F1A\u5458\u4FE1\u606F", 3);
    
//        items[4] = new EWLMenuItem(null, "\u79EF\u5206\u67E5\u8BE2", 4);
    
//        items[5] = new EWLMenuItem(null, "\u77ED\u4FE1\u9A8C\u8BC1", 5);
    
//        for (int i = 0; i < items.length; i++) {
    
//            items[i].isSingleLine = false;
    
//            items[i].align = 1;
    
//            items[i].width = ((EWLComponent) (((EWLWindow) (winUserManage)).container)).width;
    
//            ((EWLWindow) (winUserManage)).container.addComponent(items[i], false);
    
//        }
    
//
    
//        ((EWLWindow) (winUserManage)).container.layout();
    
//        ((EWLWindow) (winUserManage)).container.setFocusIndex(0, false);
    
//        if (_paramsAry[16] != null)
    
//            try {
    
//                int mtpIdx = Integer.parseInt(_paramsAry[16].toString());
    
//                ((EWLWindow) (winUserManage)).container.setFocusIndex(mtpIdx, false);
    
//                focusHightlight(winUserManage, mtpIdx);
    
//            } catch (Exception ex) {
    
//                IOManager.log(_paramsAry[16] + ", " + ex.toString());
    
//            }
    
//        return winUserManage;
    
//    }

    
public void ACcreateProgressShow(int startPosition, String msg) {
        _showProgress 
= true;
        _instance.showProgressBar(msg);
        _progressBar.setPosition(startPosition);
    }


    
public void ACsetPosition(int position) {
        _progressBar.setPosition(position);
    }


    
public void ACcloseProgressShow() {
        _showProgress 
= false;
        EWLScreen.hidePopup();
    }


    
public void ACprocessResult(ETInterface interfaceData, boolean successful) {
        
if (successful) {
            
if (interfaceData.getResponseCommand().equals("830"))
                processUpdateRoll(interfaceData);
        }
 else if (interfaceData.getRequestCommand().equals("030"))
            setRollInfo(
new String[] { interfaceData.getErrorMessage() });
        
else
            showError(interfaceData.getErrorMessage());
    }


    
private static void processUpdateRoll(ETInterface interfaceData) {
        String info[] 
= new String[interfaceData.getResponseTableLoop()[0].length];
        
for (int i = 0; i < info.length; i++)
            info[i] 
= interfaceData.getResponseTableLoop()[0][i][0];

        setRollInfo(info);
    }


    
public static void setRollInfo(String info[]) {
        _promotoMsgs 
= info;
        
int idx = _promoteMsgTicker.getTitleCount();
        
for (int i = 0; i < idx; i++)
            _promoteMsgTicker.removeTitle(i);

        
for (int i = 0; i < info.length; i++)
            _promoteMsgTicker.addTitle(info[i]);

    }


    
public void commandAction(Command arg0, Displayable arg1) {
        Display.getDisplay(_theMidlet).setCurrent(EWLScreen.instance);
        
if (arg1 instanceof Alert) {
            
if (ETInterface.onUpdate)
                BusinessWindow.doUpdate();
            
if (arg0.getCommandType() == Command.OK) {
                agreeCharge 
= true;
                
if (BookingMidlet.DEBUG)
                    System.out.println(
"agreeCharge is true");
            }
else {
                agreeCharge 
= false;
                
if (BookingMidlet.DEBUG)
                    System.out.println(
"agreeCharge is false");
            }

            asking 
= false;
        }
 else if (arg1 instanceof Form) {
            
if (arg1.getTitle().equals("计费提示")) {
                
if (arg0.getCommandType() == Command.OK)
                    agreeCharge 
= true;
                
else
                    agreeCharge 
= false;
                asking 
= false;
            }
 else if (arg1.getTitle().equals("程序更新")) {
                
if (arg0.getCommandType() == Command.OK)
                    
try {
                        BookingMidlet.bookingMidlet.platformRequest(programUpdateUrl);
                        System.out.println(
"Updating");
                        _theMidlet.notifyDestroyed();
                    }
 catch (Exception e) {
                        e.printStackTrace();
                    }

            }

//            else if (arg1.getTitle().equals("提示")) {//用alert实现
//                if (arg0.getCommandType() == Command.BACK)
//                    BizWindow.nChargeNum = 0;
//                return;
//            }
            Display.getDisplay(BookingMidlet.bookingMidlet).setCurrent(EWLScreen.instance);
        }

    }


    
private EWLCommandWindow createHotMgzDetailQueryWindow() {
        String cmdStrings[] 
= "下载""返回" };
        
int cmdIDs[] = 12 };
        BusinessWindow winHotMgzDetailQuery 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short400);
        winHotMgzDetailQuery._strTitle 
= "热门漫画信息";
        winHotMgzDetailQuery.setCommandListener(winHotMgzDetailQuery);
        winHotMgzDetailQuery.setContainer(
new EWLContainer());
        ((EWLWindow) (winHotMgzDetailQuery)).container.setBounds(_containerX, _containerY,
                ((EWLComponent) (winHotMgzDetailQuery)).width 
- _containerHMargin,
                ((EWLComponent) (winHotMgzDetailQuery)).height 
- _containerVMargin);
        Magazine hotMgz 
= null;
        hotMgz 
= (Magazine) _rsvInfo.get("HOT_LINE");
        UIManager._currMgz 
= hotMgz;
        
int itemNum=2;
        
if(!hotMgz.mgzLocate.equals(""))
            itemNum
=3;
        EWLMenuItem miLable[] 
= new EWLMenuItem[itemNum];
        miLable[
0= new EWLMenuItem(null"漫画类别:" + hotMgz.mgzId, 11true,0);
        miLable[
1= new EWLMenuItem(null"漫画标题:" + hotMgz.mgzName, 12true,0);
        
if(itemNum==3)
            miLable[
2= new EWLMenuItem(null"漫画简介:" + hotMgz.mgzLocate, 13true,0);
        
for (int i = 0; i < miLable.length; i++{
            miLable[i].setFont(EWLConstants.SMALL_FONT, 
false);
            miLable[i].align 
= 33;
            miLable[i].enabledChoose 
= false;
            miLable[i].width 
= ((EWLComponent) (((EWLWindow) (winHotMgzDetailQuery)).container)).width;
            miLable[i].isSingleLine 
= false;
        }

        ((EWLWindow) (winHotMgzDetailQuery)).container.addComponent(miLable[
0], false);
        ((EWLWindow) (winHotMgzDetailQuery)).container.addComponent(miLable[
1], false);
        
if(itemNum==3)
            ((EWLWindow) (winHotMgzDetailQuery)).container.addComponent(miLable[
2], false);
        ((EWLWindow) (winHotMgzDetailQuery)).container.layout();
//        ((EWLWindow) (winHotMgzDetailQuery)).container.setFocusIndex(1, false);
        return winHotMgzDetailQuery;
    }


    
public void resetReservInfo() {
        _rsvInfo 
= new Hashtable();
    }


    
/**
     * 查看网络连接是否用cmwap
     * 
@return
     
*/

    
public boolean checkCmwapConnect() {
        
boolean cmwapConnect=true;
        String httpConMode
="";
        RMSRecorderIfno checkCmwapRMS 
= new RMSRecorderIfno();
        
try{
            checkCmwapRMS.open(
"cmwaprms"true);
            
if(checkCmwapRMS.size()>0){
                checkCmwapRMS.openReadStream(
1);
                httpConMode 
= checkCmwapRMS.readString().trim();
                
if(httpConMode.equals("CMWAP"))
                    cmwapConnect
=true;
                
else if(httpConMode.equals("CMNET"))
                    cmwapConnect
=false;
            }

        }
catch(Exception e){
            
if(BookingMidlet.DEBUG)
                e.printStackTrace();
        }

        checkCmwapRMS.close();
        
return cmwapConnect;
        
    }

    
    
/**
     * 设置网络连接方式
     
*/

    
public void changeCmwapConnect(boolean cmwapCon) {
        
//BookingMidlet.useProxy=cmwapCon;//在下次登录时生效,当时修改的不生效
        String httpConMode="";
        
if(cmwapCon)
            httpConMode 
="CMWAP";
        
else
            httpConMode 
="CMNET";
        
        RMSRecorderIfno ChangeCmwapRMS 
= new RMSRecorderIfno();
        ChangeCmwapRMS.open(
"cmwaprms"true);
        
if (ChangeCmwapRMS.size()== 0{
            ChangeCmwapRMS.openWriteStream();
            ChangeCmwapRMS.write(httpConMode);
            ChangeCmwapRMS.addRecord(ChangeCmwapRMS.saveStreamToByteArray());
        }
else{
            ChangeCmwapRMS.openWriteStream();
            ChangeCmwapRMS.write(httpConMode);
            ChangeCmwapRMS.setRecord(
1, ChangeCmwapRMS.saveStreamToByteArray());
        }

        ChangeCmwapRMS.close();
    }

    
    
/**
     * 打开已经下载的漫画
     
*/

    
public final void openDownloaded() {
        dlBookID 
= new Vector();
        RMSRecorderIfno bn1 
= new RMSRecorderIfno();
        bn1.open(
"002_" + "downloaded"true);
        
if (bn1.size() > 0{
            bn1.openReadStream(
1);
            dlbooknum 
= bn1.readInt();
            
if (dlbooknum > 0{
                bn1.openReadStream(
2);
                
int wrongNum=0;
                
for (int i = 0; i < dlbooknum; i++{
                    String bookId 
= bn1.readString().trim();
                    String bookName 
= bn1.readString().trim();
                    
//处理存储中出现name和id相同的异常
                    if(bookId.equals(bookName)){
                        wrongNum
++;
                        
continue;
                    }

                    
//处理存储中出现id是另一本书name的异常
                    try{
                        Integer.parseInt(bookId);
                    }
catch (Exception e){
                        
if(BookingMidlet.DEBUG)
                            e.printStackTrace();
                        wrongNum
++;
                        
continue;
                    }

                    dlBookID.addElement(bookId);
                    dlBookID.addElement(bookName);
                    
//在这里强制刷新,会出现异常。
                }

                
//清楚记录为空的数据
                if(wrongNum>0)
                    dlbooknum
=dlbooknum-wrongNum;
            }

        }
 else {
            bn1.openWriteStream();
            bn1.write(
0);
            bn1.addRecord(bn1.saveStreamToByteArray());
            bn1.openWriteStream();
            bn1.write(
"");
            bn1.write(
"");
            bn1.addRecord(bn1.saveStreamToByteArray());
        }

        bn1.close();
    }


    
public final boolean isHoldDownload(String id) {
        
boolean ret = false;
        
if (downloadid != null)
            
for (int i = 0; i < downloadid.size(); i++{
                String bookid 
= (String) downloadid.elementAt(i);
                
if (id.equals(bookid)) {
                    ret 
= true;
                    
break;
                }

            }

        
return ret;
    }


    
public final boolean isDownloaded(String id) {
        
boolean ret = false;
        
int i = 0;
        
for (; i < dlbooknum; i++{
            String str 
= (String) dlBookID.elementAt(i * 2);
            
if (id.equals(str)) {
                ret 
= true;
                
break;
            }

        }

        
if (i == dlbooknum)
            ret 
= false;
        
return ret;
    }


    
/**
     * 存储已下载的漫画
     
*/

    
private void writeDownloaded() {
        RMSRecorderIfno rms 
= new RMSRecorderIfno();
        rms.open(
"002_" + "downloaded"true);
        rms.openWriteStream();
        rms.write(dlbooknum);
        rms.setRecord(
1, rms.saveStreamToByteArray());
        rms.closeWriteStream();
        rms.openWriteStream();
        
int wrongNum=0;
        
for (int i = 0; i < dlbooknum; i++{
            String bookId 
= ((String) dlBookID.elementAt(i * 2)).trim();
            String bookName 
= ((String) dlBookID.elementAt(i * 2 + 1)).trim();
            
if(bookId.equals(bookName)){
                
//清除存储操作中出现异常的rms
                wrongNum++;
                
continue;
            }

            
//处理存储中出现id是另一本书name的异常
            try{
                Integer.parseInt(bookId);
            }
catch (Exception e){
                
if(BookingMidlet.DEBUG)
                    e.printStackTrace();
                wrongNum
++;
                
continue;
            }

            rms.write(bookId);
            rms.write(bookName);
        }

        rms.setRecord(
2, rms.saveStreamToByteArray());
        
//出现异常后对dlbooknum的rms处理
        if(wrongNum>0){
            dlbooknum
=dlbooknum-wrongNum;
            rms.closeWriteStream();
            rms.openWriteStream();
            rms.write(dlbooknum);
            rms.setRecord(
1, rms.saveStreamToByteArray());
        }

        rms.close();
    }



    
public final void insertDownloaded(XItem item) {
        String itmename 
= new String(item.itmename);
        String itemId 
= new String(item.itemId);
        dlBookID.insertElementAt(itmename, 
0);
        dlBookID.insertElementAt(itemId, 
0);
        dlbooknum
++;
//        n++;
        
//        EWLScreen.prompt2 = "---------------------第" + n + "进入------------------------";
        writeDownloaded();
    }


    
public final void removeDownloadedItem(XItem item) {
        
if (item.itmename == null || item.itemId == null || item.itmename.toLowerCase().endsWith("null")
                
|| item.itemId.toLowerCase().endsWith("null")) {
            
return;
        }

        String str 
= new String(item.itemId);
        
int i;
        
if ((i = dlBookID.indexOf(str)) > -1{
            dlBookID.removeElementAt(i);
            dlBookID.removeElementAt(i);
            dlbooknum
--;
            writeDownloaded();
        }

    }


    
public final void removeDownloadPaused(String bookid) {
        
if (downloadpaused == null || downloadpaused.size() < 1 || downloadpausednum <= 0)
            
return;
        
int i = 0;
        
if ((i = downloadpaused.indexOf(bookid)) > -1{
            downloadpaused.removeElementAt(i);
            downloadpausednum
--;
            writeDownloadPaused();
        }


    }


    
public final void insertDownloadPaused(String bookid) {
        
int i = downloadpaused.size();
        downloadpaused.insertElementAt(bookid, i);
        downloadpausednum
++;
        writeDownloadPaused();
    }


    
private final void writeDownloadPaused() {
        RMSRecorderIfno rms 
= new RMSRecorderIfno();
        rms.open(
"002_" + "downloadpause"true);
        rms.openWriteStream();
        rms.write(downloadpausednum);
        rms.setRecord(
1, rms.saveStreamToByteArray());
        rms.closeWriteStream();
        rms.openWriteStream();
        
for (int i = 0; i < downloadpausednum; i++{
            
int str = Integer.parseInt((String) downloadpaused.elementAt(i));
            rms.write(str);
        }

        rms.setRecord(
2, rms.saveStreamToByteArray());
        rms.close();
    }


    
public final boolean isDownloadPaused(String bookid) {
        
if (downloadpausednum <= 0 || downloadpaused.size() < 1)
            
return false;
        
boolean ret = false;
        
int i;
        
for (i = 0; i < downloadpausednum; i++{
            String str 
= (String) downloadpaused.elementAt(i);
            
if (bookid.equals(str)) {
                ret 
= true;
                
break;
            }

        }

        
if (i == downloadpausednum)
            ret 
= false;
        
return ret;
    }


    
// for downloadpaused
    public final void openDownloadPaused() {
        downloadpaused 
= new Vector();
        RMSRecorderIfno rms 
= new RMSRecorderIfno();
        rms.open(
"002_" + "downloadpause"true);
        
if (rms.size() > 0{
            rms.openReadStream(
1);
            downloadpausednum 
= rms.readInt();
            
if (downloadpausednum > 0{
                rms.openReadStream(
2);
                
for (int i = 0; i < downloadpausednum; i++{
                    
int num1 = rms.readInt();
                    downloadpaused.addElement(Integer.toString(num1));
                }

            }

        }
 else {
            rms.openWriteStream();
            rms.write(
0);
            rms.addRecord(rms.saveStreamToByteArray());
            rms.openWriteStream();
            rms.write(
"");
            rms.write(
"");
            rms.addRecord(rms.saveStreamToByteArray());
        }

        rms.close();
    }


    
// for downloading
    public final void openDownloading() {
        dlist 
= new Vector();
        RMSRecorderIfno rms 
= new RMSRecorderIfno();
        rms.open(
"002_" + "downloading"true);
        
if (rms.size() > 0{
            rms.openReadStream(
1);
            dlen 
= rms.readInt();
            
if (dlen > 0{
                rms.openReadStream(
2);
                
int rmsNullNum=0;
                
for (int i = 0; i < dlen; i++{
                    String s 
= rms.readString();
                    String s1 
= rms.readString();
                    String s2 
= rms.readString();
                    
if(s==null || s1==null ){
                        rmsNullNum
++;
                        
continue;
                    }

                    dlist.addElement(s);
                    dlist.addElement(s1);
                    dlist.addElement(s2);
                }

                
//清楚记录为空的数据
                if(rmsNullNum>0)
                    dlen
=dlen-rmsNullNum;
            }

        }
 else {
            rms.openWriteStream();
            rms.write(
0);
            rms.addRecord(rms.saveStreamToByteArray());
            rms.openWriteStream();
            rms.write(
"");
            rms.write(
"");
            rms.addRecord(rms.saveStreamToByteArray());
        }

        rms.close();
    }


    
public final boolean isDownloading(String id) {
        
boolean ret = false;
        
int j;
        
for (j = 0; j < dlen; j++{
            String s 
= (String) dlist.elementAt(j * 3);
            
if (id.equals(s)) {
                ret 
= true;
                
break;
            }

        }

        
if (j == dlen)
            ret 
= false;
        
return ret;
    }


    
private void writeDownloading() {
        RMSRecorderIfno rms 
= new RMSRecorderIfno();
        rms.open(
"002_" + "downloading"true);
        rms.openWriteStream();
        rms.write(dlen);
        rms.setRecord(
1, rms.saveStreamToByteArray());
        rms.openWriteStream();
        
for (int i = 0; i < dlen; i++{
            rms.write((String) dlist.elementAt(i 
* 3));
            rms.write((String) dlist.elementAt(i 
* 3 + 1));
            rms.write((String) dlist.elementAt(i 
* 3 + 2));
        }

        rms.setRecord(
2, rms.saveStreamToByteArray());
        rms.close();
    }


    
public final void insertDownloading(XItem item) {
        String itmename 
= item.itmename;
        String itemId 
= item.itemId;
        String state 
= Integer.toString(item.state);
        dlist.insertElementAt(state, 
0);
        dlist.insertElementAt(itmename, 
0);
        dlist.insertElementAt(itemId, 
0);
        dlen
++;
        writeDownloading();
    }


    
public final void removeDownloadingItem(XItem xitem) {
        
if (xitem.itmename == null || xitem.itemId == null || xitem.itmename.toLowerCase().endsWith("null")
                
|| xitem.itemId.toLowerCase().endsWith("null")) {
            
return;
        }

        String s 
= new String(xitem.itemId);
        
int i;
        
if ((i = dlist.indexOf(s)) > -1{
            dlist.removeElementAt(i);
            dlist.removeElementAt(i);
            dlist.removeElementAt(i);
            dlen
--;
            writeDownloading();
        }

    }


    
/**
     * 正在下载目录
     * 
@return
     
*/

    
public EWLCommandWindow createDownloadingWindow() {
        String cmdStrings[] 
= "暂停""续传""删除""返回" };
        
int cmdIDs[] = 1234 };
        BusinessWindow winSeatSelect 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short520);
        winSeatSelect._strTitle 
= "正在下载";
        winSeatSelect.setCommandListener(winSeatSelect);
        winSeatSelect.setContainer(
new EWLContainer());
        ((EWLWindow) (winSeatSelect)).container.setBounds(_containerX, _containerY,
                ((EWLComponent) (winSeatSelect)).width 
- _containerHMargin, ((EWLComponent) (winSeatSelect)).height
                        
- _containerVMargin);
        openDownloading();
        openDownloadPaused();
        
        EWLMenuItem items[] 
= new EWLMenuItem[dlen];
        
for (int i = 0; i < dlen; i++{
            
//TODO
            items[i] = new EWLMenuItem(null, (String) dlist.elementAt(i * 3 + 1), Integer.parseInt((String) dlist
                    .elementAt(i 
* 3)), true,0);
            items[i].isSingleLine 
= false;
            items[i].align 
= 1;
            items[i].width 
= ((EWLComponent) (((EWLWindow) (winSeatSelect)).container)).width;
            ((EWLWindow) (winSeatSelect)).container.addComponent(items[i], 
false);
        }


        ((EWLWindow) (winSeatSelect)).container.layout();
        ((EWLWindow) (winSeatSelect)).container.setFocusIndex(
0false);
        
return winSeatSelect;
    }


    
public EWLCommandWindow createSearchWindow() {
        String cmdStrings[] 
= "确定""返回" };
        
int cmdIDs[] = 12 };
        BusinessWindow winUserAdd 
= new BusinessWindow(cmdStrings, cmdIDs, 1, (short530);
        winUserAdd._strTitle 
= "搜索漫画";
        winUserAdd.setCommandListener(winUserAdd);
        winUserAdd.setContainer(
new EWLContainer());
        ((EWLWindow) (winUserAdd)).container.setBounds(_containerX, _containerY, ((EWLComponent) (winUserAdd)).width
                
- _containerHMargin, ((EWLComponent) (winUserAdd)).height - _containerVMargin);
        EWLMenuItem miLable[] 
= new EWLMenuItem[1];
        miLable[
0= new EWLMenuItem(null"请输入关键字*"11true,0);
        
for (int i = 0; i < miLable.length; i++{
            miLable[i].setFont(EWLConstants.SMALL_FONT, 
false);
            miLable[i].align 
= 33;
            miLable[i].enabledChoose 
= false;
            miLable[i].isSingleLine 
= false;
            miLable[i].width 
= ((EWLComponent) (((EWLWindow) (winUserAdd)).container)).width;
        }


        EWLEdit edtUserName 
= new EWLEdit(EWLConstants.EDIT_ANY);
        edtUserName.width 
= ((EWLComponent) (((EWLWindow) (winUserAdd)).container)).width;
        ((EWLWindow) (winUserAdd)).container.addComponent(miLable[
0], false);
        ((EWLWindow) (winUserAdd)).container.addComponent(edtUserName, 
false);
        ((EWLWindow) (winUserAdd)).container.layout();
        ((EWLWindow) (winUserAdd)).container.setFocusIndex(
1false);
        
return winUserAdd;
    }


    
public static String genFdata() {
        String s;
        s 
= user.getUserID();
        String version 
= BookingMidlet.bookingMidlet.getAppProperty("MIDlet-Version");
        
if (s.equals(""|| s == null)
            s 
= "0";
        s 
+= "_" + _smscno + "_" + _platform + "-" + version + "_" + _appname + "_" + BookingMidlet._distno;
        System.out.println(
"fdata=" + s);
        
return s;
    }


    
//续传时计算已下载部分内容百分比
    public String DownPercent(String bookname) {
        RMSRecorderIfno rms 
= new RMSRecorderIfno();
        rms.open(
"002_" + bookname + "_mgz"true);
        
int rec = UIManager.RMSPrecent(rms);
        
int num = 0;
        RMSRecorderIfno rms1 
= new RMSRecorderIfno();
        rms1.open(
"002_" + bookname + "_url"true);
        RecordEnumeration enu 
= null;
        
if (enu == null{
            
try {
                enu 
= rms1.rs.enumerateRecords(nullnullfalse);
            }
 catch (RecordStoreNotOpenException e) {
                e.printStackTrace();
            }

            
int j = 0;
            
while (enu.hasNextElement()) {
                
try {
                    j 
= enu.nextRecordId();
                    
if (j == 2{
                        num 
= DownloadTool.bytesToInt(rms1.getRecord(j));
                    }

                }
 catch (InvalidRecordIDException e) {
                    e.printStackTrace();
                }

            }

        }

        String percent 
= "" + 100 * (rec / (num + 0.01));
        percent 
= "(" + DownloadTool.forMatString(percent) + "%)";

        
return percent;
    }


    
public static int RMSPrecent(RMSRecorderIfno rms) {
        
int i = 0;
        
try {
            RecordEnumeration enu 
= null;
            
if (enu == null{
                enu 
= rms.rs.enumerateRecords(nullnullfalse);
            }

            
while (enu.hasNextElement()) {
                
try {
                    enu.nextRecordId();
                }
 catch (InvalidRecordIDException e) {
                    e.printStackTrace();
                }

                i
++;
            }

        }
 catch (RecordStoreNotOpenException e) {
            e.printStackTrace();
        }

        
return i;
    }

}


posted on 2010-02-25 15:38 骑猪闯天下 阅读(584) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: