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

📄 mmidlet.java

📁 飞信的j2me源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            s = "Amigo_J2ME_C11M20_CMCC_ANJIAN";
        String s1 = getAppProperty("build");
        if(s1 == null)
            s1 = "00";
        form.append(stringbuffer.toString() + s + "/" + s1);
        form.setCommandListener(this);
        form.addCommand(Setting.cmd_Back);
        pushBackScreen(display.getCurrent());
        display.setCurrent(form);
    }

    private void showConfirmShutDown(Displayable displayable)
    {
        Form form = new Form("关闭程序");
        form.setCommandListener(this);
        form.addCommand(Setting.cmd_Back);
        form.addCommand(Setting.cmd_OK);
        form.append("您真的要退出程序吗?");
        pushBackScreen(displayable);
        display.setCurrent(form);
    }

    public void closeChatSession(ChatSession chatsession)
    {
        String s = chatsession.getSessionName();
        if(s == null)
        {
            deleteChatSessionByKey(chatsession.key);
        } else
        {
            Transform.instance.byeChatSession(new String[] {
                chatsession.getSessionName()
            });
            deleteChatSessionByKey(chatsession.key);
        }
    }

    private void sendMessage()
    {
        String s = tb_WriteMessage.getString();
        if(s == null || s.length() == 0)
        {
            showAlert("发送内容不能为空,请重新输入。", tb_WriteMessage);
            return;
        }
        ChatSession chatsession = null;
        if(selectedItem == null)
            return;
        if(selectedItem.type == MListItem.BUDDY_ITEM)
        {
            String s1 = selectedBuddy.uri;
            chatsession = (ChatSession)ht_AllChatSession.get(s1);
            if(chatsession == null)
            {
                Vector vector = new Vector();
                vector.addElement(s1);
                chatsession = new ChatSession(null, vector);
                addNewChatSession(s1, chatsession);
            }
        } else
        {
            chatsession = selectedChatSession;
        }
        ChatMessage chatmessage = new ChatMessage(user.uri, s, (byte)1, new Date(), 0);
        chatsession.sendMessage(chatmessage);
    }

    public void showWriteMessage()
    {
        if(tb_WriteMessage == null)
        {
            tb_WriteMessage = new TextBox("写消息", "", 400, 0);
            tb_WriteMessage.setCommandListener(this);
            tb_WriteMessage.addCommand(Setting.cmd_Back);
            tb_WriteMessage.addCommand(cmd_Send);
            tb_WriteMessage.addCommand(cmd_CommonWords);
        } else
        {
            tb_WriteMessage.setString("");
        }
        pushBackScreen(display.getCurrent());
        display.setCurrent(tb_WriteMessage);
    }

    private void testSessionKeys()
    {
        Enumeration enumeration = ht_AllChatSession.keys();
        StringBuffer stringbuffer = new StringBuffer();
        boolean flag = false;
        while(enumeration.hasMoreElements()) 
        {
            String s = enumeration.nextElement().toString();
            ChatSession chatsession = (ChatSession)ht_AllChatSession.get(s);
            if(!s.equals(chatsession.key))
            {
                flag = true;
                stringbuffer.append('[');
                stringbuffer.append(s);
                stringbuffer.append("!=");
                stringbuffer.append(chatsession.key);
                stringbuffer.append("(ChatSession)]");
                stringbuffer.append("。\n");
            } else
            {
                stringbuffer.append('[');
                stringbuffer.append(s);
                stringbuffer.append("==");
                stringbuffer.append(chatsession.key);
                stringbuffer.append("(ChatSession)]");
                stringbuffer.append("。\n");
            }
        }
        if(flag)
            showAlert("错误:ChatSession的key与容器里的key不一致。\n" + stringbuffer.toString(), null);
        else
            showAlert("一切正常.\n" + stringbuffer, null);
    }

    private void clearBeforeLogin()
    {
        form_ServiceEntry = null;
        form_ServiceIntro = null;
        item_join = null;
        item_Dinggou = null;
        item_SoonLogin = null;
        tf_nickName = null;
    }

    private void initAll()
    {
        if(cmd_CommonWords == null)
        {
            cmd_CommonWords = new Command("常用短语", 4, 1);
            cmd_Send = new Command("发送", 4, 1);
            cmd_Edit = new Command("修改", 4, 1);
            cmd_Save = new Command("保存", 4, 1);
            cmd_Yes = new Command("是", 4, 1);
            cmd_No = new Command("否", 2, 1);
            readDataFromRMS();
        }
    }

    private StringItem newStringItem(String s, String s1)
    {
        StringItem stringitem = new StringItem(s, s1);
        return stringitem;
    }

    public void on_OpenService(String s)
    {
        if(isFirstRegedit)
            try
            {
                Thread.sleep(30000L);
            }
            catch(InterruptedException interruptedexception) { }
        Vector vector = StringParser.split(s, '\002');
        user.sid = vector.elementAt(0).toString();
        user.uri = vector.elementAt(1).toString();
        showRegInfScreen();
    }

    public void on_SetUserInf()
    {
        if(isFirstRegedit)
            try
            {
                Thread.sleep(30000L);
            }
            catch(InterruptedException interruptedexception) { }
        checkNewClient();
    }

    public void on_Error(String s)
    {
        if(!isLogin)
        {
            notifyAndExit(s);
            return;
        }
        int i = s.indexOf('\002');
        String s1 = s;
        if(i != -1)
            s1 = s.substring(0, i);
        switch(Integer.parseInt(s1))
        {
        case 901: 
            Transform.instance.autoPolling(false);
            showConfirmScreen("此帐户已在其他客户端登录!", null, new Command[] {
                Setting.cmd_ReLogin
            });
            break;

        case 900: 
            isLogin = false;
            Transform.instance.autoPolling(false);
            showConfirmScreen("会话过期,请重新登录。", null, new Command[] {
                Setting.cmd_ReLogin
            });
            break;

        case 903: 
            showAlert("该用户尚未开通Fetion", null);
            break;

        case 902: 
            String s2 = s.substring(i + 1);
            ChatSession chatsession = getChatSessionByName(s2);
            chatsession.on_SessionExpired();
            break;

        case 904: 
            String s3 = s.substring(i + 1);
            showAlert(s3, null);
            removeCurrentServiceAction();
            break;

        default:
            if(++errorTimer == 6)
                notifyAndExit(s);
            break;
        }
    }

    public void notifyAndExit(String s)
    {
        directlyExit = true;
        Transform.instance.killNetWorkThread();
        showConfirmScreen("发生异常,请重新启动应用程序。" + errorCode(s), null, new Command[] {
            Setting.cmd_Exit
        });
    }

    public void on_ByeChatSession(Vector vector)
    {
    }

    public void on_SetUserPresence(String s, String s1)
    {
        user.availability = s;
        user.activity = s1;
        canvas.repaint();
    }

    public void showSelectedLoginState()
    {
        if(form_LoginState == null)
        {
            Command command = new Command("登录", 4, 1);
            form_LoginState = new Form("提示");
            form_LoginState.addCommand(command);
            form_LoginState.setCommandListener(this);
            form_LoginState.append(ChineseString.HELP_MANIPULATE_CONTENT);
        }
        if(backScreens != null)
            backScreens.removeAllElements();
        display.setCurrent(form_LoginState);
    }

    private void showRegInfScreen()
    {
        Form form = new Form("注册资料");
        if(user.nickName.length() > 15)
            user.nickName = user.nickName.substring(0, 14);
        tf_nickName = new TextField("昵称", user.nickName, 15, 0);
        cg_SexSetting = new ChoiceGroup("性别", 4, new String[] {
            "保密", "女", "男"
        }, null);
        if(user.getGender(false).equals("保密"))
            cg_SexSetting.setSelectedIndex(0, true);
        else
        if(user.getGender(false).equals("女"))
            cg_SexSetting.setSelectedIndex(1, true);
        else
        if(user.getGender(false).equals("男"))
            cg_SexSetting.setSelectedIndex(2, true);
        df_BirthDay = new DateField("生日", 1);
        df_BirthDay.setDate(user.getBirthdayDate());
        form.append("您尚未登记您的个\n人资料,登记个人\n资料有助于您发展\n好友。\n");
        form.append("您的详细资料:\n");
        form.append(new StringItem("飞信号", user.sid));
        form.append(tf_nickName);
        form.append(cg_SexSetting);
        form.append(df_BirthDay);
        form.addCommand(cmd_Save);
        form.addCommand(Setting.cmd_Exit);
        form.setCommandListener(this);
        if(cancelOpenService)
        {
            form.append("\n");
            form.append("您的服务已经开通了,如果需要退订该业务,请选择业务退订。");
            form.addCommand(new Command("业务退订", 4, 1));
        }
        display.setCurrent(form);
    }

    public void on_Navigation(Vector vector)
    {
        user.setUri(vector.firstElement().toString());
        url_DownPhoto = String.valueOf(vector.elementAt(1));
        url_UpPhoto = String.valueOf(vector.elementAt(2));
        url_DownFile = String.valueOf(vector.elementAt(3));
        url_UpFile = String.valueOf(vector.elementAt(4));
        if(String.valueOf(vector.elementAt(5)).equals("1"))
        {
            url_NewVersion = String.valueOf(vector.elementAt(6));
            showUpdateQuery();
        } else
        if(String.valueOf(vector.elementAt(5)).equals("2"))
        {
            url_NewVersion = String.valueOf(vector.elementAt(6));
            isCompatible = false;
            showUpdateQuery();
        } else
        {
            Displayable displayable = display.getCurrent();
            if(displayable instanceof Form)
            {
                Form form = (Form)displayable;
                StringItem stringitem = (StringItem)form.get(0);
                stringitem.setText(ChineseString.loadingHit[3]);
            }
            startStepTimer = 9;
            user.activity = "400";
            user.availability = "300";
            currentPresenceIndex = 0;
            clearBeforeLogin();
            Transform.instance.login(user);
        }
    }

    private void showUpdateQuery()
    {
        Form form = new Form("升级程序");
        form.setCommandListener(this);
        form.addCommand(Setting.cmd_OK);
        form.addCommand(Setting.cmd_Cancel);
        if(isCompatible)
            form.append("Fetion有新版本了,要更新程序,请按“确定”;\n不更新也可以使用,请按“取消”,继续使用老版本。");
        else
            form.append("Fetion推出新版本了,您必须更新程序,否则无法继续使用。");
        display.setCurrent(form);
    }

    public void on_Login(Vector vector) throws Exception
    {
        ht_BlackList.clear();
        ht_BuddyList.clear();
        ChatSession.unReadQueue.removeAllElements();
        ChatSession.total_UnReadMessageCount = 0;
        if(cancelLogin)
        {
            logout();
            cancelLogin = false;
            return;
        }
        long l = System.currentTimeMillis();
        String s = vector.elementAt(0).toString();
        Vector vector1 = StringParser.split(s, '\002');
        setUserInf(vector1);
        buddyNum = Integer.parseInt(vector.elementAt(1).toString().trim());
        ml_BuddyList = new MList();
        ml_BlackList = new MList();
        if(buddyNum != 0)
        {
            Vector vector2 = new Vector(10, 10);
            Vector vector3 = new Vector(20, 20);
            for(int k = 0; k < buddyNum; k++)
            {
    

⌨️ 快捷键说明

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