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

📄 uicontroller.java

📁 The Funambol J2ME Mail Client aims to be a light, easy to use, free email client for J2ME devices.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    public static void showBackScreen() /*throws Exception*/ {
        try {
            Displayable screen = backStack.pop();
            // If the screen is the inbox, cleanup the other screens
            if(screen == inboxMessageList) {
                showInboxScreen();
            } else {
                display.setCurrent(screen);
            }
        } catch (Exception ex) {
            Log.error("ShowBackScreen: " + ex.toString());
            showInboxScreen();
        }
    }
    
    
    /**
     * show the current composeMessageScreen, performing no updates. <br />
     *
     * if you need to update the messagescreen use updateComposeMessageScreen
     * functions
     **/
    public static void showComposeMessageScreen(Displayable backScreen, Item item) {
        //backStack.push(backScreen);
        //display.setCurrent(getComposeMessageScreen());
        if (backScreen!=null) {
            backStack.push(backScreen);
        } else {
            backStack.push(inboxMessageList);
        }
        getComposeMessageScreen().setDefaultTitle();
        //display.setCurrent(getComposeMessageScreen());
        display.setCurrentItem(item);
    }
    
    /**
     * show the compose message screen ready for a new message to be composed
     */
    public static void composeNewMessage(Displayable backScreen) {
        
        // TODO: reset the contact list withoud reloading from rms, we can
        // use the contacts stored in memory!
        
        //threadPool.startThread(getContactListLoader(new Message()));
        //getComposeMessageScreen().get
        getContactListLoader(new Message()).load();
        getContactList().emptySearchString();
        showAddressList(display.getCurrent());
    }
    
    /**
     * update ComposeMessageScreen message.
     * the message remains unchanged
     **/
    public static void updateComposeMessageScreen(Message message) {
        getComposeMessageScreen().setMessage(message);
    }
    
    /**
     * update ComposeMessageScreen toAppend string.
     * the toAppend string remains unchanged
     **/
    public static void updateComposeMessageScreen(String toAppend) {
        getComposeMessageScreen().setToAppend(toAppend);
    }
    
    
    /**
     * update ComposeMessageScreen toAppend string and message
     **/
    public static void updateComposeMessageScreen(Message message, String toAppend) {
        updateComposeMessageScreen(message);
        updateComposeMessageScreen(toAppend);
    }
    
    /**
     * update ComposeMessageScreen message with the message referenced
     * by given messageinfo
     * the toAppend string remains unchanged
     **/
    public static void updateComposeMessageScreen(MessageInfo messageInfo) {
        Message toShow;
        try {
            toShow = messageInfo.getMessage();
            updateComposeMessageScreen(toShow);
        } catch (MailException ex) {
            ex.printStackTrace();
            Log.error("UIController: Unable to get message from messageInfo");
            //TODO: add alert here
        }
    }
    
    /**
     * update ComposeMessageScreen toAppend string and
     *  message (using the message referenced by given messageInfo)
     **/
    public static void updateComposeMessageScreen(MessageInfo messageInfo, String toAppend) {
        updateComposeMessageScreen(messageInfo);
        updateComposeMessageScreen(toAppend);
    }
    
    /**
     * return the composemessageform and create it if needed
     */
    public static ComposeMessageForm getComposeMessageScreen() {
        if (composeMessageScreen==null) {
            composeMessageScreen=new ComposeMessageForm();
        }
        return composeMessageScreen;
    }
    
    /**
     *  show the inbox screen, cleaning the stack and freeing not used objects
     * and memory
     */
    public static void showInboxScreen() {
        backStack.clear();
        outboxMessageList = null;
        sentMessageList = null;
        draftMessageList = null;
        composeMessageScreen = null;
        // contactList = null;
        if(!SyncClient.isBusy()) {
            getInboxMessageList().resetTitle();
        }
        display.setCurrent(getInboxMessageList());
        //#ifdef low_mem
//#         freeMemory();
        //#endif
    }
    
    /** If the freeMemory is low, try to collect some memory */
    public static long freeMemory() {
        
        long mem = Runtime.getRuntime().freeMemory();
        if(mem < 10000) {
            Log.info(">> freeMemory is low: " + Runtime.getRuntime().freeMemory());
            try {
                System.gc();
                Thread.sleep(1);
            } catch (InterruptedException ex) {
                // just ignore it
                Log.error("interrupted exception freeing memory");
                
            }
            mem = Runtime.getRuntime().freeMemory();
        }
        
        return mem;
    }
    
    /**
     * Display the outbox screen.
     */
    public static void showOutboxScreen(Displayable backScreen) {
        backStack.push(backScreen);
        //TODO: use lazy initInbox
        updateOutboxMessageList(null);
        display.setCurrent(getOutboxMessageList());
    }
    /**
     * push current screen in the backstack and display the sent message list
     *
     *@param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static void showSentScreen(Displayable backScreen) {
        backStack.push(backScreen);
        updateSentMessageList(null);
        UIController.display.setCurrent(getSentMessageList());
    }
    
    /**
     * push current screen in the backstack and display the draft message list
     *
     *@param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static void showDraftScreen(Displayable backScreen) {
        backStack.push(backScreen);
        updateDraftMessageList(null);
        UIController.display.setCurrent(getDraftMessageList());
    }
    
    /**
     *show the given messageInfo's Message
     *
     *@param backScreen the screen to be pushed in the stack
     *@param messageInfo the messageInfo pointing to the message to be shown
     *@param messageType one of UIController.OUTGOING_MESSAGE or
     *   UIController.INCOMING_MESSAGE
     */
    public static void showViewMessageScreen(Displayable backScreen,
            MessageInfo messageInfo) {
        try {
            //Log.info("showViewMessageScreen:" + System.currentTimeMillis());
            showViewMessageScreen(backScreen, messageInfo.getMessage());
        } catch (MailException ex) {
            ex.printStackTrace();
            Log.error("ViewMessage: "+ ex.toString());
            UIController.showErrorAlert(
                    Localization.getMessages().GENERIC_UNABLE_TO_OPEN_MESSAGE);
        }
    }
    
    /**
     * push current screen in the backstack and display the view message screen
     * with the given message.
     *<br>
     *the message read flag will be set to true if needed
     *
     *
     *
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     * @param message the message to be displayed
     */
    
    public static void showViewMessageScreen(Displayable backScreen, Message message) {
        backStack.push(backScreen);
        //   Log.debug("message flag opened = " + message.getFlags().isSet(MessageFlags.OPENED));
        if (!message.getFlags().isSet(MessageFlags.OPENED)) {
            changeReadFlag(message);
        }
        FunCanvasViewMessage viewMessageScreen = new FunCanvasViewMessage(message);
        FunCanvasMessageList fcml = (FunCanvasMessageList) backScreen;
        viewMessageScreen.setTitle("Message " + (fcml.getActiveElement()+1)
        + " of " + fcml.getNumMessages());
        display.setCurrent(viewMessageScreen);
    }
    
    /**
     * Create the folder list and display it
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static void showFolderList(Displayable displayable) {
        backStack.push(displayable);
        FolderInfo[] folders=messageManager.getRootFolders();
        display.setCurrent(new FolderList(folders));
    }
    
    /**
     * opens a list of links in the given message body
     * @param body the string to be searched for links
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     *
     */
    public static void showLinkList(Displayable displayable, String body) {
        backStack.push(displayable);
        display.setCurrent(new LinkList(body));
    }
    
    /*
    public static void showPhoneNumberList(Displayable displayable, String body) {
        backStack.push(displayable);
        display.setCurrent(new PhoneNumberList(body));
    }
     */
    /**
     * Methods to show settings screens
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     *
     */
    public static void showSettings(Displayable displayable) {
        backStack.push(displayable);
        display.setCurrent(new SettingsList());
    }
    
    
    /**
     *show account settings form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     *
     */
    public static void showAccountSettings(Displayable displayable) {
        display.setCurrent(getAccountSettingsForm(displayable));
    }
    
    /**
     * @return the account settings form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static Displayable getAccountSettingsForm(Displayable displayable) {
        backStack.push(displayable);
        return new AccountSettingsForm();
    }
    /**
     * show the mail sync settings form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static void showMailSyncSettings(Displayable displayable) {
        backStack.push(displayable);
        display.setCurrent(new GetMailSettingsForm());
    }
    
    
    /**
     * show the log settings form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    public static void showLogSettings(Displayable displayable) {
        backStack.push(displayable);
        display.setCurrent(new LogSettingsForm());
    }
    
    /**
     * show the log view form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    
    public static void showLogViewer(Displayable displayable) {
        backStack.push(displayable);
        display.setCurrent(new LogViewerForm());
    }
    
    /**
     * show the recipient list form
     * @param backscreen the displayable to be pushed in the stack,
     * often the current displayable
     */
    
    public static void showRecipientsList(Displayable displayable, Message message) {
        backStack.push(displayable);
        display.setCurrent(new FunCanvasRecipientList(message));
    }
    
    /**
     * show the contact list
     * @param backscreen the screen to be put in the stack for future back commands
     */
    public static void showAddressList(Displayable backScreen) {
        backStack.push(backScreen);
        getContactList().rewindList();
        display.setCurrent(getContactList());
    }
    
    
    public static void showAddContactScreen(Displayable displayable,
            FunCanvasContactList addressList) {
        backStack.push(displayable);
        display.setCurrent(new AddContactForm(addressList));
    }
    
    public static void showAddContactScreen(Displayable displayable) {
        showAddContactScreen(displayable,(FunCanvasContactList) null);
    }
    
    
    public static void showAddContactScreen(Displayable displayable, Contact contact) {
        backStack.push(displayable);
        UIController.display.setCurrent(new AddContactForm(contact,getContactList(), true));
    }

⌨️ 快捷键说明

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