📄 mcanvas.java
字号:
import java.io.IOException;
import java.io.InputStream;
import java.util.Calendar;
import java.util.Date;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.Sprite;
class MCanvas extends Canvas implements Runnable, CommandListener
{
public static Image img_SmallIcon;
public static Image img_Tab;
public static Image img_BigIcon;
public static Image img_Bottom;
public static Image img_BackGround;
public static Image img_Commands;
public Image img_AppName;
Sprite sp_FirstAnimation;
public int animation;
public static final int ANIM_COVER = 1;
public static final int AUTO_PAGE_DOWN = 2;
public static final int AUTO_PAGE_UP = 4;
public int x;
public int y;
boolean isKeyPressed;
boolean isPointed;
boolean isshowSystemSetting;
private int keyCode;
private int pointedx;
private int pointedy;
private int tabNum;
MList currentList;
byte rightKeyAction;
static Calendar now = Calendar.getInstance();
static Date dateNow = new Date();
static StringBuffer sb_Time = new StringBuffer(5);
private MMIDlet midlet;
private Command cmd_MainMenu;
private Command cmd_Exit;
private boolean necError;
private boolean isloadImageError;
private boolean hasPainted;
GroupSection buddySec;
GroupSection strangerSec;
public static int WIDTH = 0;
public static int HEIGHT = 0;
public static MCanvas instance = null;
String errorPath;
Exception ee;
boolean bException;
MList lastList;
boolean isPaintFirstPage;
int frameTime;
long start;
long spend;
public MCanvas(MMIDlet mmidlet)
{
animation = 0;
isKeyPressed = false;
isPointed = false;
isshowSystemSetting = false;
tabNum = 0;
rightKeyAction = 0;
cmd_MainMenu = new Command("主菜单", 4, 0);
cmd_Exit = new Command("退出", 7, 0);
necError = false;
isloadImageError = false;
hasPainted = false;
errorPath = null;
ee = null;
bException = false;
isPaintFirstPage = true;
frameTime = 100;
start = 0L;
spend = 0L;
instance = this;
setFullScreenMode(true);
WIDTH = getWidth();
HEIGHT = getHeight();
midlet = mmidlet;
try
{
if(img_SmallIcon == null)
{
MMIDlet.out("line 89 in MCanvas ");
readImage();
MMIDlet.out("line 91 in MCanvas ");
}
}
catch(IOException ioexception)
{
isloadImageError = true;
}
buddySec = new GroupSection("好友");
strangerSec = new GroupSection("陌生人");
(new Thread(this)).start();
}
/*public void loginInit()
{
label0:
{
tabNum = 0;
MMIDlet _tmp = midlet;
currentList = MMIDlet.ml_BuddyList;
lastList = null;
int i = Setting.HEAD_HEIGHT + img_Tab.getHeight() / 3;
MMIDlet _tmp1 = midlet;
MMIDlet.ml_BuddyList.setY(Setting.ITEM_HEIGHT + i);
MMIDlet _tmp2 = midlet;
MMIDlet.ml_StrangerList.setY(Setting.ITEM_HEIGHT * 2 + i);
MMIDlet _tmp3 = midlet;
MMIDlet.ml_SessionList.setY(i);
MMIDlet _tmp4 = midlet;
MMIDlet.ml_BlackList.setY(i);
MMIDlet _tmp5 = midlet;
MMIDlet.ml_BuddyList.isPaint = false;
MMIDlet _tmp6 = midlet;
MMIDlet.ml_BuddyList.isSelected = false;
MMIDlet _tmp7 = midlet;
MMIDlet.ml_StrangerList.isPaint = false;
MMIDlet _tmp8 = midlet;
MMIDlet.ml_StrangerList.isSelected = false;
buddySec.isExpand = strangerSec.isExpand = false;
buddySec.isSelected = true;
strangerSec.isSelected = false;
buddySec.y = i;
strangerSec.y = Setting.ITEM_HEIGHT + i + 2;
MMIDlet _tmp9 = MMIDlet.instance;
if(-1 == MMIDlet.str_ClientVersion.indexOf("NEC_N850"))
{
MMIDlet _tmp10 = MMIDlet.instance;
if(-1 == MMIDlet.str_ClientVersion.indexOf("NEC_NQ"))
{
MMIDlet _tmp11 = MMIDlet.instance;
if(-1 == MMIDlet.str_ClientVersion.indexOf("NEC_AG"))
{
MMIDlet _tmp12 = MMIDlet.instance;
if(-1 == MMIDlet.str_ClientVersion.indexOf("NEC_NK"))
{
MMIDlet _tmp13 = MMIDlet.instance;
if(-1 == MMIDlet.str_ClientVersion.indexOf("SAM_I858"))
{
MMIDlet _tmp14 = MMIDlet.instance;
if(-1 == MMIDlet.str_ClientVersion.indexOf("PAN_VS6"))
break label0;
}
}
}
}
}
setCommandListener(this);
addCommand(cmd_MainMenu);
addCommand(cmd_Exit);
MMIDlet _tmp15 = MMIDlet.instance;
if(-1 == MMIDlet.str_ClientVersion.indexOf("SAM_I858"))
{
MMIDlet _tmp16 = MMIDlet.instance;
if(-1 == MMIDlet.str_ClientVersion.indexOf("PAN_VS6"))
necError = true;
}
}
img_AppName = null;
isPaintFirstPage = false;
isKeyPressed = false;
}*/
public void loginInit() {
int i;
tabNum = 0;
currentList = MMIDlet.ml_BuddyList;
lastList = null;
i = Setting.HEAD_HEIGHT + img_Tab.getHeight() / 3;
MMIDlet.ml_BuddyList.setY(Setting.ITEM_HEIGHT + i);
MMIDlet.ml_StrangerList.setY(Setting.ITEM_HEIGHT * 2 + i);
MMIDlet.ml_SessionList.setY(i);
MMIDlet.ml_BlackList.setY(i);
MMIDlet.ml_BuddyList.isPaint = false;
MMIDlet.ml_BuddyList.isSelected = false;
MMIDlet.ml_StrangerList.isPaint = false;
MMIDlet.ml_StrangerList.isSelected = false;
buddySec.isExpand = strangerSec.isExpand = false;
buddySec.isSelected = true;
strangerSec.isSelected = false;
buddySec.y = i;
strangerSec.y = Setting.ITEM_HEIGHT + i + 2;
setCommandListener(this);
addCommand(cmd_MainMenu);
addCommand(cmd_Exit);
necError = true;
img_AppName = null;
isPaintFirstPage = false;
isKeyPressed = false; //修改
}
public void readImage()
throws IOException
{
MMIDlet.out("line 167 in MCanvas ");
InputStream inputstream = getClass().getResourceAsStream("/res/" + Integer.toString(WIDTH) + "/i.png");
MMIDlet.out("line 169 in MCanvas ");
Image image = null;
byte abyte0[] = new byte[inputstream.available()];
inputstream.read(abyte0);
byte byte0 = abyte0[0];
boolean flag = false;
int j = 1;
MMIDlet.out("line 180 in MCanvas ");
for(int k = 0; k < byte0; k++)
{
int i = (abyte0[j] & 0xff) << 8 | abyte0[j + 1] & 0xff;
j += 2;
if(0 == k)
img_BigIcon = Image.createImage(abyte0, j, i);
else
if(1 == k)
img_SmallIcon = Image.createImage(abyte0, j, i);
else
if(2 == k)
img_Bottom = Image.createImage(abyte0, j, i);
else
if(3 == k)
img_Tab = Image.createImage(abyte0, j, i);
else
if(4 == k)
image = Image.createImage(abyte0, j, i);
else
if(5 == k)
img_AppName = Image.createImage(abyte0, j, i);
else
if(6 == k)
img_BackGround = Image.createImage(abyte0, j, i);
else
if(7 == k)
img_Commands = Image.createImage(abyte0, j, i);
j += i;
}
sp_FirstAnimation = new Sprite(image, image.getWidth() / 2, image.getHeight());
sp_FirstAnimation.setFrameSequence(new int[] {
0, 1
});
sp_FirstAnimation.setPosition(58, 28);
}
private void updateKeyState(int i)
{
if(isPaintFirstPage)
return;
if(i == MMIDlet.instance.leftKeyCode)
{
midlet.showMainList();
return;
}
if(i == MMIDlet.instance.rightKeyCode)
{
midlet.commandAction(Setting.cmd_Exit, this);
rightSoftAction();
return;
}
switch(i)
{
case 50: // '2'
if(currentList != null && currentList.isSelected)
currentList.pageUp();
return;
case 56: // '8'
if(currentList != null && currentList.isSelected)
currentList.pageDown();
return;
case 42: // '*'
if(currentList != null && currentList.isSelected)
currentList.home();
return;
case 35: // '#'
if(currentList != null && currentList.isSelected)
currentList.end();
return;
case 53: // '5'
ChatSession chatsession = midlet.getLastChatSession();
if(chatsession != null)
{
chatsession.show(MMIDlet.display);
}
return;
}
switch(getGameAction(i))
{
case 8: // '\b'
fire();
return;
case 1: // '\001'
up();
return;
case 6: // '\006'
down();
return;
case 2: // '\002'
left();
return;
case 5: // '\005'
right();
return;
case 3: // '\003'
case 4: // '\004'
case 7: // '\007'
default:
return;
}
}
public void Pass_Error_Info(String s, Exception exception)
{
errorPath = s;
ee = exception;
bException = true;
}
/*public void Paint_Error(Graphics g) throws Exception
{
String as[] = new String[3];
if(bException)
{
g.setColor(150, 0, 0);
Graphics _tmp = g;
Graphics _tmp1 = g;
g.drawString(errorPath, 5, 0, 0x10 | 4);
int i = 0;
int j = 5;
int k = 10;
do
{
if(i >= ee.toString().length())
break;
Graphics _tmp2 = g;
Graphics _tmp3 = g;
g.drawString("" + ee.toString().charAt(i), j, k, 0x10 | 4);
j += 5;
if(i % 18 == 0)
{
k += 10;
j = 5;
}
} while(true);
}
}*/
public void Paint_Error(Graphics g) throws Exception {
String[] s2;
int i;
int j;
int k;
s2 = new String[3];
if (bException) {
g.setColor(150, 0, 0);
g.drawString(errorPath, 5, 0, 0x10 | 4);
i = 0;
j = 5;
k = 10;
while (i < ee.toString().length()) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -