📄 twittering.java
字号:
// Do nothing
// Insert post-action code here
}
// Insert global post-action code here
}//GEN-LINE:MVDICAEnd
/** Called by the system to indicate that a command has been invoked on a particular displayable.//GEN-BEGIN:MVDCABegin
* @param command the Command that ws invoked
* @param displayable the Displayable on which the command was invoked
*/
public void commandAction(Command command, Displayable displayable)
{//GEN-END:MVDCABegin
// Insert global pre-action code here
// main page
// tweet
// direct message
if (displayable == formMain)//GEN-BEGIN:MVDCABody
{
if (command == goToSettings)
{//GEN-END:MVDCABody
// Insert pre-action code here
getDisplay().setCurrent(get_formSettings());//GEN-LINE:MVDCAAction5
// Insert post-action code here
if (getData().getUser() != null)
settingsUser.setString(getData().getUser());
else
settingsUser.setString("");
if (getData().getPass() != null)
settingsPass.setString(getData().getPass());
else
settingsPass.setString("");
}//GEN-BEGIN:MVDCACase5
else if (command == exitApp)
{//GEN-END:MVDCACase5
// Insert pre-action code here
exitMIDlet();
// Do nothing//GEN-LINE:MVDCAAction11
// Insert post-action code here
}//GEN-BEGIN:MVDCACase11
else if (command == goToDirectMsgs)
{//GEN-END:MVDCACase11
// Insert pre-action code here
if (currCommand != null) currCommand.stop();
currCommand = new ClientCommandHandler(this, ClientCommandHandler.COMMAND_DIRECT_MSG_LIST, formMain);
currCommand.start();
formMain.deleteAll();
formMain.setTitle("Direct Messages");
formMain.append(new StringItem(null, "Loading..."));
// Do nothing//GEN-LINE:MVDCAAction9
// Insert post-action code here
}//GEN-BEGIN:MVDCACase9
else if (command == goToTweets)
{//GEN-END:MVDCACase9
// Insert pre-action code here
if (currCommand != null) currCommand.stop();
currCommand = new ClientCommandHandler(this, ClientCommandHandler.COMMAND_TWEET_LIST, formMain);
currCommand.start();
formMain.deleteAll();
formMain.setTitle("Tweets");
formMain.append(new StringItem(null, "Loading..."));
// Do nothing//GEN-LINE:MVDCAAction7
// Insert post-action code here
}//GEN-BEGIN:MVDCACase7
else if (command == goToMainPage)
{//GEN-END:MVDCACase7
// Insert pre-action code here
formMain = null;
getDisplay().setCurrent(get_formMain());//GEN-LINE:MVDCAAction33
// Insert post-action code here
}//GEN-BEGIN:MVDCACase33
}
else if (displayable == formSettings)
{
if (command == saveSettings)
{//GEN-END:MVDCACase33
// Insert pre-action code here
// save username and password
getData().setUser(get_settingsUser().getString());
getData().setPass(get_settingsPass().getString());
try
{
db.open();
db.write(DB_USER, getData().getUser(), false);
db.write(DB_PASS, getData().getPass(), false);
db.close();
}
catch(Exception e)
{
getDisplay().setCurrent(get_PopupPage("ERROR", "DB error: " + db.getError().getMessage(), null, AlertType.ERROR),getDisplay().getCurrent());
}
System.out.println("Details saved");
System.out.println(db.toString());
getDisplay().setCurrent(get_formMain());
// Do nothing//GEN-LINE:MVDCAAction13
// Insert post-action code here
}//GEN-BEGIN:MVDCACase13
else if (command == exitSettings)
{//GEN-END:MVDCACase13
// Insert pre-action code here
getDisplay().setCurrent(get_formMain());//GEN-LINE:MVDCAAction15
// Insert post-action code here
}//GEN-BEGIN:MVDCACase15
}
else if (displayable == formSelectUser)
{
if (command == backToMain)
{//GEN-END:MVDCACase15
// Insert pre-action code here
getDisplay().setCurrent(get_formMain());//GEN-LINE:MVDCAAction62
// Insert post-action code here
}//GEN-BEGIN:MVDCACase62
else if (command == refreshUserList)
{//GEN-END:MVDCACase62
// Insert pre-action code here
if (currCommand != null) currCommand.stop();
currCommand = new ClientCommandHandler(this, ClientCommandHandler.COMMAND_LIST_FRIENDS, formSelectUser);
formSelectUser.deleteAll();
formSelectUser.setTitle("Select Friend");
formSelectUser.append(new StringItem(null, "Loading friends..."));
currCommand.start();
//append_friendList(getData().getFriends(), formSelectUser);
// Do nothing//GEN-LINE:MVDCAAction58
// Insert post-action code here
}//GEN-BEGIN:MVDCACase58
}
else if (displayable == formInitError)
{
if (command == exit)
{//GEN-END:MVDCACase58
// Insert pre-action code here
exitMIDlet();
// Do nothing//GEN-LINE:MVDCAAction68
// Insert post-action code here
}//GEN-BEGIN:MVDCACase68
else if (command == clearSettings)
{//GEN-END:MVDCACase68
// Insert pre-action code here
formInitError.deleteAll();
try
{
db.close();
}
catch(Exception e)
{
}
try
{
db.delete();
formInitError.append(new StringItem("", "Settings cleared. Restart app"));
}
catch(Exception e)
{
formInitError.append(new StringItem("ERROR", e.getMessage() + "|" + e.toString()));
}
// Do nothing//GEN-LINE:MVDCAAction70
// Insert post-action code here
}//GEN-BEGIN:MVDCACase70
}//GEN-END:MVDCACase70
// Insert global post-action code here
}//GEN-LINE:MVDCAEnd
/** This method initializes UI of the application.//GEN-BEGIN:MVDInitBegin
*/
private void initialize()
{//GEN-END:MVDInitBegin
// Insert pre-init code here
// read rms and load variables
data = new Data();
db = new DB_RS(DB_STRING);
//System.out.println("Open: " + db.open());
//System.out.println("Init: " + db.initialise());
//System.out.println("Close: " + db.close());
//if (true)
//*
try
{
db.open();
db.initialise();
db.close();
Vector v;
String val;
data.setUser(db.getValueScalar(DB_USER));
data.setPass(db.getValueScalar(DB_PASS));
for(int i = 0; (db.getValueVector(DB_FRIENDS) != null) && i < db.getValueVector(DB_FRIENDS).size(); i++)
data.addFriend(db.getValueVector(DB_FRIENDS).elementAt(i).toString());
data.setTweetMsg(db.getValueScalar(DB_TWEET_MSG));
if (data.getTweetMsg() != null) get_whatAreYouDoing().setString(data.getTweetMsg());
data.setDirectMessageUser(db.getValueScalar(DB_DM_USER));
if (data.getDirectMessageUser() != null) get_dmUserText().setString(data.getDirectMessageUser());
data.setDirectMessageMsg(db.getValueScalar(DB_DM_MSG));
if (data.getDirectMessageMsg() != null) get_dmMsg().setString(data.getDirectMessageMsg());
System.out.println(data.toString());
exitApp = new Command("Exit", Command.SCREEN, 3);//GEN-BEGIN:MVDInitInit
getDisplay().setCurrent(get_formMain());//GEN-END:MVDInitInit
}
catch(Exception e)
{
getDisplay().setCurrent(get_formInitError());//, getDisplay().getCurrent());
get_formInitError().append(e.getMessage());
}
//*/
/*
popup = get_PopupPage("ERROR", "Cannot initialize database: " + db.getError().getMessage(), null, AlertType.ERROR);
getDisplay().setCurrent(popup);//, getDisplay().getCurrent());
//*/
//*
//popup = get_PopupPage("ERROR", "Cannot initialize database: " + db.getError().getMessage(), null, AlertType.ERROR);
//getDisplay().setCurrent(get_formMain());
//*/
// Insert post-init code here
}//GEN-LINE:MVDInitEnd
/**
* This method should return an instance of the display.
*/
public Display getDisplay() {//GEN-FIRST:MVDGetDisplay
return Display.getDisplay(this);
}//GEN-LAST:MVDGetDisplay
/**
* This method should exit the midlet.
*/
public void exitMIDlet() {//GEN-FIRST:MVDExitMidlet
getDisplay().setCurrent(null);
destroyApp(true);
notifyDestroyed();
}//GEN-LAST:MVDExitMidlet
/** This method returns instance for formMain component and should be called instead of accessing formMain field directly.//GEN-BEGIN:MVDGetBegin2
* @return Instance for formMain component
*/
public Form get_formMain()
{
if (formMain == null)
{//GEN-END:MVDGetBegin2
// Insert pre-init code here
formMain = new Form("Twittering", new Item[] {//GEN-BEGIN:MVDGetInit2
get_lblWAYD(),
get_whatAreYouDoing(),
get_sendTweetBtn(),
get_spacer1(),
get_lblDM(),
get_dmUserText(),
get_dmMsg(),
get_sendDirectMessageBtn(),
get_spacer2(),
get_strLicense()
});
formMain.addCommand(get_goToMainPage());
formMain.addCommand(get_goToTweets());
formMain.addCommand(get_goToDirectMsgs());
formMain.addCommand(get_goToSettings());
formMain.addCommand(exitApp);
formMain.setCommandListener(this);//GEN-END:MVDGetInit2
// Insert post-init code here
updateCharsAvailable(false);
updateCharsAvailable(true);
formMain.setItemStateListener(this);
}//GEN-BEGIN:MVDGetEnd2
return formMain;
}//GEN-END:MVDGetEnd2
/** This method returns instance for formSettings component and should be called instead of accessing formSettings field directly.//GEN-BEGIN:MVDGetBegin3
* @return Instance for formSettings component
*/
public Form get_formSettings()
{
if (formSettings == null)
{//GEN-END:MVDGetBegin3
// Insert pre-init code here
formSettings = new Form("Settings", new Item[] {//GEN-BEGIN:MVDGetInit3
get_settingsUser(),
get_settingsPass()
});
formSettings.addCommand(get_saveSettings());
formSettings.addCommand(get_exitSettings());
formSettings.setCommandListener(this);//GEN-END:MVDGetInit3
// Insert post-init code here
}//GEN-BEGIN:MVDGetEnd3
return formSettings;
}//GEN-END:MVDGetEnd3
/** This method returns instance for goToSettings component and should be called instead of accessing goToSettings field directly.//GEN-BEGIN:MVDGetBegin4
* @return Instance for goToSettings component
*/
public Command get_goToSettings()
{
if (goToSettings == null)
{//GEN-END:MVDGetBegin4
// Insert pre-init code here
goToSettings = new Command("Settings", Command.SCREEN, 2);//GEN-LINE:MVDGetInit4
// Insert post-init code here
}//GEN-BEGIN:MVDGetEnd4
return goToSettings;
}//GEN-END:MVDGetEnd4
/** This method returns instance for goToTweets component and should be called instead of accessing goToTweets field directly.//GEN-BEGIN:MVDGetBegin6
* @return Instance for goToTweets component
*/
public Command get_goToTweets()
{
if (goToTweets == null)
{//GEN-END:MVDGetBegin6
// Insert pre-init code here
goToTweets = new Command("Tweets", Command.SCREEN, 2);//GEN-LINE:MVDGetInit6
// Insert post-init code here
}//GEN-BEGIN:MVDGetEnd6
return goToTweets;
}//GEN-END:MVDGetEnd6
/** This method returns instance for goToDirectMsgs component and should be called instead of accessing goToDirectMsgs field directly.//GEN-BEGIN:MVDGetBegin8
* @return Instance for goToDirectMsgs component
*/
public Command get_goToDirectMsgs()
{
if (goToDirectMsgs == null)
{//GEN-END:MVDGetBegin8
// Insert pre-init code here
goToDirectMsgs = new Command("Direct Messages", Command.SCREEN, 2);//GEN-LINE:MVDGetInit8
// Insert post-init code here
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -