⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmidlet.java

📁 飞信的j2me源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        datainputstream = null;
        dataoutputstream = null;
        abyte0 = (new byte[] {
            0
        });
        s = "http://nav.m161.com.cn/getadapteruri.aspx";
        serverUrl = s;
        if("0".equals(getAppProperty("is172")))
            setServerURL(false, s);
        else
            setServerURL(true, s);
        for(i =0 ; i<3 ; i++){
            try{
                ioError = false;
                responseError = false;
                httpconnection = (HttpConnection)Connector.open(serverUrl);
                position = 3;
                //if(isProxy)  修改
                    httpconnection.setRequestProperty("X-Online-Host", realHostIP);
                httpconnection.setRequestMethod("POST");
                httpconnection.setRequestProperty("Content-Length", "1");
                dataoutputstream = httpconnection.openDataOutputStream();
                dataoutputstream.write(abyte0);
                startStepTimer = 2;
                position = 2;
                output("# request URL:" + httpconnection.getURL());
                datainputstream = httpconnection.openDataInputStream();
                int j = (int)httpconnection.getLength();
                rpcode = httpconnection.getResponseCode();
                if(rpcode >= 200 && rpcode < 300)
                    setAdaperUrl(reading(datainputstream, j, (byte)2));
                else
                    responseError = true;
                if(datainputstream != null)
                    try
                    {
                        datainputstream.close();
                    }
                    catch(IOException ioexception) { }
                if(dataoutputstream != null)
                    try
                    {
                        dataoutputstream.close();
                    }
                    catch(IOException ioexception1) { }
                if(httpconnection != null)
                    try
                    {
                        httpconnection.close();
                    }
                    catch(IOException ioexception2) { }
            }
            catch(IOException ex) {
                ioError = true;
                if(datainputstream != null)
                    try
                    {
                        datainputstream.close();
                    }
                    catch(IOException ioexception3) { }
                if(dataoutputstream != null)
                    try
                    {
                        dataoutputstream.close();
                    }
                    catch(IOException ioexception4) { }
                if(httpconnection != null)
                    try
                    {
                        httpconnection.close();
                    }
                    catch(IOException ioexception5) { }

            }
            if(ioError)
            {
                setServerURL(!isProxy, s);
                continue; 
            }
            if(responseError)
            {
                setServerURL(!isProxy, s);
            } else
            {
                startStepTimer = 3;
                return true;
            }
        }
        return false;
    }

    private void setAdaperUrl(byte abyte0[])
        throws UnsupportedEncodingException
    {
        String s = new String(abyte0, "UTF-8");
        serverUrl = s.substring(s.indexOf("<Uri>") + 5, s.indexOf("</Uri>")).trim();
    }

    private void setServerURL(boolean flag, String s)
    {
        isProxy = flag;
        if(flag)
        {
            int i = s.indexOf('/', 8);
            if(i == -1)
                i = s.length();
            realHostIP = s.substring(7, i);
            serverUrl = "http://10.0.0.172:80" + s.substring(i);
            System.out.println("realHostIP:" + realHostIP + ",serverUrl:" + serverUrl);
        } else
        {
            serverUrl = s;
        }
    }

    private void showServiceEntry()
    {
        if(form_ServiceEntry == null)
        {
            form_ServiceEntry = new Form("Fetion");
            item_SoonLogin = newStringItem("", "马上登录");
            item_join = newStringItem("", "立即加入");
            item_Dinggou = newStringItem("", "我要定购");
            form_ServiceEntry.append(str_ServerEntry);
            form_ServiceEntry.addCommand(Setting.cmd_Exit);
            form_ServiceEntry.addCommand(Setting.cmd_OK);
            form_ServiceEntry.setCommandListener(this);
        }
        display.setCurrent(form_ServiceEntry);
    }

    protected void destroyApp(boolean flag) throws MIDletStateChangeException
    {
        if(isLogin)
            logout();
    }

    protected void pauseApp()
    {
    }

    protected void startApp()
        throws MIDletStateChangeException
    {
    }

    public void showWaitingScreen(String s, Displayable displayable)
    {
        Form form = new Form("请等待");
        form.setCommandListener(this);
        if(displayable != null)
            form.addCommand(Setting.cmd_Cancel);
        form.append(s);
        form.append(new Gauge("", false, -1, 2));
        pushBackScreen(displayable);
        display.setCurrent(form);
    }

    public void showConfirmScreen(String s, Displayable displayable, Command acommand[])
    {
        Form form = new Form("提示");
        form.setCommandListener(this);
        for(int i = 0; i < acommand.length; i++)
            form.addCommand(acommand[i]);

        form.append(new StringItem("", s));
        pushBackScreen(displayable);
        display.setCurrent(form);
    }

    public void showAlert(String s, Displayable displayable)
    {
        Form form = new Form("  ");
        form.addCommand(cmd_AlertOK);
        form.setCommandListener(this);
        form.append(s);
        if(displayable != null)
            pushBackScreen(displayable);
        else
            pushBackScreen(display.getCurrent());
        display.setCurrent(form);
    }

    public void commandAction(Command command, Displayable displayable)
    {
        if(command == cmd_AlertOK)
        {
            popAndBackScreen(displayable);
            return;
        }
        if(command == Setting.cmd_Exit)
        {
            if(directlyExit)
                notifyDestroyed();
            else
                showConfirmShutDown(displayable);
            return;
        }
        String s = command.getLabel();
        String s1 = "";
        if(command == List.SELECT_COMMAND || (displayable instanceof List) && command == Setting.cmd_Selected)
        {
            List list = (List)displayable;
            s1 = list.getString(list.getSelectedIndex());
        }
        String s2 = displayable.getTitle();
        if("业务退订".equals(s) || "业务退订".equals(s1))
        {
            showConfirmCancelService(displayable);
            return;
        }
        if(command == Setting.cmd_Back || command == Setting.cmd_Cancel)
        {
            if("确认添加好友".equals(s2))
                vec_CancelWpendingPair.addElement(removeWpendingANDBackNextScreen(displayable));
            else
            if("升级程序".equals(s2))
            {
                if(isCompatible)
                    showSelectedLoginState();
                else
                    notifyDestroyed();
            } else
            if("编辑常用语".equals(s2) && (displayable instanceof List))
            {
                commonWords = temp_CommonWords;
                temp_CommonWords = null;
                popAndBackScreen(displayable);
            } else
            if("请等待".equals(s2))
                notifyDestroyed();
            else
                popAndBackScreen(displayable);
            return;
        }
        if(command == Setting.cmd_WriteMessage)
        {
            showWriteMessage();
            return;
        }
        if(command == cmd_Send)
        {
            sendMessage();
            return;
        }
        if(command == cmd_CommonWords)
        {
            showInsertCommonWords();
            return;
        }
        if(command == cmd_Save)
        {
            if("本人资料".equals(s2))
            {
                Form form = (Form)displayable;
                String s4 = ((TextField)form.get(0)).getString().trim();
                String s11 = ((TextField)form.get(1)).getString();
                if(s4 == null || s4.length() == 0)
                {
                    showAlert("昵称不能为空。", displayable);
                    return;
                }
                user.email = ((TextField)form.get(4)).getString();
                user.setGender(cg_SexSetting.getString(cg_SexSetting.getSelectedIndex()));
                Date date1 = df_BirthDay.getDate();
                if(date1 != null)
                {
                    if(getAgeByBirthDay(date1) >= 99 || getAgeByBirthDay(date1) < 2)
                    {
                        Calendar calendar2 = Calendar.getInstance();
                        calendar2.get(5);
                        String s16 = "" + calendar2.get(1) + '\u5E74' + (calendar2.get(2) + 1) + '\u6708' + calendar2.get(5) + '\u65E5';
                        calendar2.setTime(date1);
                        String s17 = "" + calendar2.get(1) + '\u5E74' + (calendar2.get(2) + 1) + '\u6708' + calendar2.get(5) + '\u65E5';
                        showAlert("年龄区间应该在2-99之间。\n今天:" + s16 + ",\n" + "您输入:" + s17 + "。", null);
                        return;
                    }
                    Calendar calendar3 = Calendar.getInstance();
                    calendar3.setTime(date1);
                    user.birthDate = "" + calendar3.get(1) + '-' + (calendar3.get(2) + 1) + '-' + calendar3.get(5);
                }
                user.nickName = s4;
                user.impresa = s11;
                service_UpdateUserProfile(user);
                popAndBackScreen(displayable);
                return;
            }
            if("查看资料".equals(s2))
            {
                Form form1 = (Form)displayable;
                String s5 = ((TextField)form1.get(1)).getString().trim();
                if(selectedBuddy.nickNameReset != 1 || !selectedBuddy.screenName.equals(s5))
                {
                    service_ChangeBuddyNickName(s5, selectedBuddy);
                    selectedBuddy.screenName = s5;
                    if(s5 == null || s5.length() == 0)
                        selectedBuddy.nickNameReset = 0;
                    else
                        selectedBuddy.nickNameReset = 1;
                }
                popAndBackScreen(displayable);
                return;
            }
        }
        if(displayable == mainList)
        {
            if(s1.equals("注销"))
            {
                showLogoutScreen();
                isDestroy = false;
            } else
            if(s1.equals("帮助"))
                showHelpList();
            else
            if(s1.equals("选项"))
                showOptionList();
            else
            if(s1.equals("我的状态"))
                showMyPresenceList();
            else
            if(s1.equals("直接添加好友"))
                showAddBuddy();
            else
            if(s1.equals("本人资料"))
                showSomeBodyInf(user, "本人资料");
            else
            if(s1.equals("退出"))
                commandAction(Setting.cmd_Exit, ((Displayable) (mainList)));
        } else
        if(displayable == form_LoginState)
        {
            if(command.getCommandType() == 4)
            {
                user.activity = "400";
                user.availability = "300";
                currentPresenceIndex = 0;
                if(guid != null)
                {
                    clearBeforeLogin();
                    Transform.instance.login(user);
                }
            } else
            {
                user.activity = "0";
                user.availability = "0";
                currentPresenceIndex = 6;
            }
            showWaitingScreen("正在登录,请稍候...", form_LoginState);
            if(guid == null)
            {
                serverUrl = serverUrl.substring(0, serverUrl.indexOf("?guid"));
                Transform.instance.initRequest();
            }
        } else
        if(displayable == form_ServiceEntry)
        {
            if(command == Setting.cmd_OK)
            {
                form_ServiceIntro = new Form("服务介绍");
                form_ServiceIntro.append(FEE_README);
                form_ServiceIntro.addCommand(Setting.cmd_OK);
                form_ServiceIntro.addCommand(Setting.cmd_Exit);
                form_ServiceIntro.setCommandListener(this);
                pushBackScreen(display.getCurrent());
                display.setCurrent(form_ServiceIntro);
            }
        } else
        if(displayable == form_ServiceIntro)
        {
            if(command == Setting.cmd_OK)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -