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

📄 listmessages.java

📁 goText is a program for mobile phones that allows you to send text messages over GPRS/EDGE/UMTS. It
💻 JAVA
字号:
/**
 * Class : short description
 * @author Michele 'Miccar' Cardinale miccar@gmail.com
 * @author Natale Vinto ebballon@interfree.it
 * @version 1.0
 */

 /*
  *  goText : text messaging over GPRS
  *  Copyright (C) 2006  Natale Vinto <ebballon@interfree.it>
  *  OpenJLab Group www.openjlab.org
  *  Copyright (C) 2006  Michele Cardinale 'Miccar' <miccar@gmail.com>
  *  www.miccar.org
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *      GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */

import javax.microedition.lcdui.*;

public class ListMessages extends List implements CommandListener {
    
    protected goText gotext;
    protected Lang l;
    protected Service s;
    private Command command_back;
    
    public ListMessages(goText gotext, Service s) {
        super("",List.IMPLICIT);
        this.gotext=gotext;
        this.s=s;
        l=new Lang(gotext.lang);
        this.setTitle(l.LM_TITLE);
        this.start();
    }
    
    private void start(){
        String[] menu_string={l.COMMAND_NEW,l.LM_SAVED};
        Image[] menu_image=null;
        try {
            Image ico1 = Image.createImage("/img/nuovo.png");
            Image ico2 = Image.createImage("/img/salvati.png");
            menu_image= new Image[] {ico1,ico2};
        } catch (java.io.IOException err) {}
        for(int i=0;i<menu_string.length;i++){
            this.append(menu_string[i], menu_image[i]);
        }
        if(gotext.last_message!=null){
            Image ico_ultimo=null;
            try{
                ico_ultimo=Image.createImage("/img/ultimo.png");
            }catch(Exception e){}
            this.append(l.LM_LAST,ico_ultimo);
        }
        command_back=new Command(l.COMMAND_BACK,Command.BACK,1);
        this.addCommand(command_back);
        this.setCommandListener(this);
        this.show();
    }
    
    public void show(){
        gotext.display.setCurrent(this);
    }
    
    public void commandAction(Command c, Displayable d){
        if (c==List.SELECT_COMMAND){
            switch (this.getSelectedIndex()) {
                case 0:
                    new ListComposeMsg(gotext,new Message(),s);
                    break;
                case 1:
                    new ListSavedMessages();
                    break;
                case 2:
                    new ListComposeMsg(gotext,new Message(gotext.last_message),s);
                    break;
            }
        }else if (c==command_back){
            new ListSelectService(gotext);
        }
    }
    
    
    
    public class ListSavedMessages extends List implements CommandListener{
        
        private Command command_back,command_del,command_sel;
        
        public ListSavedMessages() {
            super(l.LM_SAVED,List.IMPLICIT);
            this.start();
        }
        
        private void start(){
            this.setTitle(l.LM_SAVED+" "+gotext.messages.length);
            if(gotext.messages.length==0){
                this.setTicker(new Ticker(l.LM_NOMESSAGE));
            } else {
                for(int i=0;i<gotext.messages.length;i++){
                    if(gotext.messages[i].getText().length()>30)
                        this.append(gotext.messages[i].getText().substring(0,28)+"..", null);
                    else
                        this.append(gotext.messages[i].getText(), null);
                }
            }
            command_sel=new Command(l.COMMAND_SEL,Command.SCREEN,1);
            command_del=new Command(l.COMMAND_DEL,Command.SCREEN,2);
            command_back=new Command(l.COMMAND_BACK,Command.BACK,3);
            this.addCommand(command_sel);
            this.addCommand(command_del);
            this.addCommand(command_back);
            this.setCommandListener(this);
            this.show();
        }
        
        public void show(){
            gotext.display.setCurrent(this);
        }
        
        public void commandAction(Command c, Displayable d){
            if (c==List.SELECT_COMMAND||c==command_sel){
                if (this.getSelectedIndex()>=0) {
                    new ListComposeMsg(gotext,new Message(gotext.messages[this.getSelectedIndex()]),s);
                }
            } else if (c==command_back){
                ListMessages.this.show();
            } else if (c==command_del){
                if(this.getSelectedIndex()>=0){
                    Message.delMessage(gotext.messages[this.getSelectedIndex()].getRmsId());
                    new ListSavedMessages();
                }
            }
        }
    }
    
}

⌨️ 快捷键说明

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