📄 bloglines.java
字号:
// Copyright (c) 2005 Sony Ericsson Mobile Communications AB
//
// This software is provided "AS IS," without a warranty of any kind.
// ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
// INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
//
// THIS SOFTWARE IS COMPLEMENTARY OF JAYWAY AB (www.jayway.se)
/*///////////////////////////////////////////////////////////////////////////////
//bloglinesMobileBuddy文档生成日期:2005.12.24
//
//(1)概述:
//类名称:Bloglines
//类说明:
// 初始化界面,监听各种消息并转发给相应负责人等各项工作。
//所在子系统:bloglinesMobileBuddy
//
//系统总描述:
我们提供的bloglines Mobile Buddy J2ME版本 就是这么一种概念:
一个可以下载到手机(例如Nokia7610已经确实可以下载安装并运行)的Java应用程序。
子系统描述:
下面介绍bloglines Mobile Buddy的功能列表:
配置Bloglines帐户信息
My Feeds
系统设置
关于
退出
//(2)历史记录:
//创建人: 郑昀(2005.12.24)
//联系我: Google Talk >> zhengyun@gmail.com
//Blogs: http://blog.csdn.net/zhengyun_ustc/以及http://www.cnblogs.com/zhengyun_ustc
//(3)版权声明:
//我这个版本的j2me客户端代码受GPL协议保护,允许您自由修改,但不得用于商业用途,除非得到本人的授权。
//(4)相关资源:
1:《[J2ME]Bloglines手机伴侣 开源说明》
2: 下载手机客户端:
3:下载源代码:
////////////////////////////////////////////////////////////////////*/
package com.ultrapower;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import com.ultrapower.gui.MenuCanvas;
import com.ultrapower.gui.PopupCanvas;
import com.ultrapower.gui.StringInputHandler;
import com.ultrapower.gui.popup.Popup;
import com.ultrapower.gui.popup.PopupListener;
import com.ultrapower.gui.popup.TextFieldPopup;
/**
* <p>
* The <code>Bloglines</code> class represents the Bloglines MIDlet
* game altogether. It coordinates the macro state of the application.
* </p><p>
* This class collects common functionality as starting and stopping a
* backgammon game, showing a popup, or getting string input from user. It is
* invoked statically since it mainly is a mediator.
* </p>
*
* @author Peter Andersson
*/
public class Bloglines implements PopupListener, CommandListener
{
/** Current canvas that is displayed */
protected static PopupCanvas m_currentCanvas;
/** Current listener to popups */
protected static PopupListener m_popupListener;
/** Popup instance cache */
protected static Popup m_popupCache;
/** TextFieldPopup instance cache */
protected static TextFieldPopup m_popupTextFieldCache;
/** Text box used for collecting user string input */
protected static TextBox m_textBox;
/** Handler when user has entered string input */
protected static StringInputHandler m_inputHandler;
/** Instance of this class, used as PopupListener or CommandListener */
protected static Bloglines m_inst;
/** Key for device id (int)*/
public static final int DEVICE_ID = 0;
/** Key for 用户登录bloglines的电子邮件地址名 (char[])*/
public static final int BLOGLINES_USER_MAILNAME = 1;
/** Key for 用户登录bloglines的密码 */
public static final int BLOGLINES_USER_PASSWORD = 2;
/** Key for saved game data (byte[])*/
public static final int SAVED_GAME_DATA = 3;
/** Key for preferred color (boolean)*/
public static final int BLACK_PREFERRED = 4;
/** Key for 连接互联网时走不走代理,默认是走cmwap代理, (boolean)*/ // Negative flag because default boolean = false
public static final int PROXY_CMWAP = 5;
/** Nbr of keys */
protected static final int NBR_OF_KEYS = 12;
/** Command used during user string input */
protected static final Command OK =
new Command(Resources.getString(Resources.TXT_C_OK), Command.OK, 1);
/** Command used during user string input */
protected static final Command CANCEL =
new Command(Resources.getString(Resources.TXT_C_CANCEL), Command.CANCEL, 1);
/**
* 将用户的电子邮件地址名保存入RMS中.
* @param usermail 电子邮件地址名,用于登录bloglines.
* zhengyun added 20051227
*/
protected static void setUserMail(String usermail)
{
RmsFacade.setChars(BLOGLINES_USER_MAILNAME, usermail.toCharArray());
}
/**
* 将用户的登录密码保存入RMS中.
* @param password 登录密码,用于登录bloglines.
* zhengyun added 20051227
*/
protected static void setUserPassword(String password)
{
RmsFacade.setChars(BLOGLINES_USER_PASSWORD, password.toCharArray());
}
/**
* 如果在RMS中找到了用户的登录电子邮件地址名,就返回它
* zhengyun added 20051227
*/
public static String hasSavedUserMail()
{
char[] mail = RmsFacade.getChars(BLOGLINES_USER_MAILNAME);
if(mail == null)
return "";
else
return String.valueOf(mail);
}
/**
* 如果在RMS中找到了用户的登录密码,就返回它
* zhengyun added 20051227
*/
public static String hasSavedUserPassword()
{
char[] pass = RmsFacade.getChars(BLOGLINES_USER_PASSWORD);
if(pass == null)
return "";
else
return String.valueOf(pass);
}
/**
* Shuts down the MIDlet.
*/
public synchronized static void shutdown()
{
System.out.println("shutdown Enter");
RmsFacade.shutdown();
if (m_popupCache != null)
{
m_popupCache.dispose();
m_popupCache = null;
}
// zhengyun 20051221 added
if (m_popupTextFieldCache != null)
{
m_popupTextFieldCache.dispose();
m_popupTextFieldCache = null;
}
m_inst = null;
System.gc();
Device.getMidlet().notifyDestroyed();
}
/**
* Gets input from the user. Runs asynchronously, i.e. this method does not
* lock. User input is reported to specified <code>InputHandler</code>.
*
* @param title The title of the input dialog.
* @param defaultText The default text presented in the input dialog.
* @param length The maximum length of the input.
* @param constraints The constraints of the text as defined in <code>TextField</code>.
* @param ih The input handler, which handles the input when the user
* commits the text.
*/
public static void getStringInput(String title, char[] defaultText,
int length, int constraints, StringInputHandler ih)
{
m_textBox.setString("");
m_textBox.setMaxSize(length);
m_textBox.setTitle(title);
if (defaultText != null)
{
try
{
m_textBox.insert(defaultText, 0, defaultText.length, 0);
m_textBox.setConstraints(constraints);
} catch (Throwable t)
{
// Failed setting default text, may happen
// due to constraints. Set to null text.
try
{
m_textBox.setChars(null, 0, 0);
m_textBox.setConstraints(constraints);
} catch (Throwable t2) {}
}
}
Device.getDisplay().setCurrent(m_textBox);
m_inputHandler = ih;
}
/**
* Returns the locking object of the user input mechanism
*
* @return The input monitor
*/
protected static Object getInputLock()
{
return m_textBox;
}
/**
* Sets specified canvas as current
*
* @param c The canvas to set
*/
public synchronized static void setCanvas(PopupCanvas c)
{
m_currentCanvas = c;
Device.getDisplay().setCurrent(c);
c.repaint();
}
/**
* Returns current canvas
*
* @return Current canvas
*/
public synchronized static PopupCanvas getCanvas()
{
return m_currentCanvas;
}
/**
* Returns true if a popup is currently displayed to the user
*
* @return true if a popup is displayed
*/
public synchronized static boolean isShowingPopup()
{
if (getCanvas() != null &&
getCanvas().getPopup() != null &&
getCanvas().getPopup().isActive())
{
return true;
}
else
{
return false;
}
}
/**
* Returns current displayed popup
*
* @return Current popup or null if no popup is displayed
*/
public synchronized static Popup getCurrentPopup()
{
if (!isShowingPopup())
return null;
else
return getCanvas().getPopup();
}
/**
* Shows a popup on the device display, enabling the user to make a choice
* amongst specified alternatives. Selected alternative is reported to
* specified listener. The popup has a timeout - if this timeout is reached
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -