[tuxdroid-svn] r5956 - software_suite_v3/software/plugin/plugin-twitter/trunk/src
Status: Beta
Brought to you by:
ks156
From: jerome <c2m...@c2...> - 2009-12-08 14:50:09
|
Author: jerome Date: 2009-12-08 15:49:51 +0100 (Tue, 08 Dec 2009) New Revision: 5956 Modified: software_suite_v3/software/plugin/plugin-twitter/trunk/src/TwitterPlugin.java Log: * Changed the way to notify users fro messages, replies. Modified: software_suite_v3/software/plugin/plugin-twitter/trunk/src/TwitterPlugin.java =================================================================== --- software_suite_v3/software/plugin/plugin-twitter/trunk/src/TwitterPlugin.java 2009-12-08 14:17:40 UTC (rev 5955) +++ software_suite_v3/software/plugin/plugin-twitter/trunk/src/TwitterPlugin.java 2009-12-08 14:49:51 UTC (rev 5956) @@ -373,16 +373,23 @@ */ if (this.configuration().getCheckMessages()) { - if ( getPrivateMessagesCount(twitter) > 0 ) + int msCount = getPrivateMessagesCount(twitter); + if ( msCount > 0 ) { //First check insilent mode. if(this.getCommand().equalsIgnoreCase("run") || secondCycle) { if(!this.configuration().getReadTweets()) { - this.sort(this.messagesList); - //Counting by name and throwing messages. - this.getByNames(this.messagesList, MESSAGE); + this.throwRes(); + if(msCount == 1) + { + this.throwMessage("You have a new message"); + } + else + { + this.throwMessage("You have {0} messages", msCount); + } } else { @@ -407,18 +414,25 @@ throwMessage(pickSentence(noNewMessageSentences)); } } - + + int rpCount = getPublicMessagesCount(twitter); //Getting and sorting new user replies. - if ( getPublicMessagesCount(twitter) > 0 ) + if ( rpCount > 0 ) { //First check insilent mode. if(this.getCommand().equalsIgnoreCase("run") || secondCycle) { if(!this.configuration().getReadTweets()) { - this.sort(this.repliesList); - //Counting by name and throwing messages. - this.getByNames(this.repliesList, REPLY); + throwRes(); + if (rpCount == 1) + { + this.throwMessage("You have a new reply"); + } + else + { + this.throwMessage("You have {0} new replies", rpCount); + } } else { @@ -489,83 +503,7 @@ return list[rand.nextInt(list.length)]; } - /*** - * Sort a typ string list. - * @param list - */ - private void sort(List<String> list) - { - Collections.sort(list); - } - - /*** - * Throw messages by user names. - * @param list - */ - private void getByNames(List<String> list, byte type) - { - Vector<String> dtUsers = new Vector<String>(); - Vector<Integer> dtCount = new Vector<Integer>(); - int count = 1; - - //Handling no replies / no messages. - if (list.size() == 0) - { - return; - } - - //Counting by names. - for( int i = 0 ; i != list.size() ; i ++) - { - - if (dtUsers.contains(list.get(i))) - { - dtCount.set(dtUsers.indexOf(list.get(i)), dtCount.get(dtUsers.indexOf(list.get(i))) + 1); - } - else - { - dtUsers.add(list.get(i)); - dtCount.add(1); - } - - } - - if (dtUsers.size() > 0) - { - throwRes(); - } - - for(String it : dtUsers) - { - count = dtCount.get(dtUsers.indexOf(it)); - - if ( type == REPLY ) - { - if ( count == 1 ) - { - throwMessage("One reply from {0}", it); - } - else - { - throwMessage ("{0} replies from {1}", count, it); - } - } - else - { - if ( count == 1 ) - { - throwMessage("One message from {0}", it); - } - else - { - throwMessage("{0} messages from {1}", count, it); - } - } - } - } - - /** * Return true if the text value indicates that the message was sent from a user * to an other user , but not the TuxDroid owner. |