Package org.lexev.bestwisethoughts.client.data

Examples of org.lexev.bestwisethoughts.client.data.Thought


      final RequestAction requestAction) {
   
    SwingWorker<Thought, Void> swingWorker = new SwingWorker<Thought, Void>() {
            @Override
            public Thought doInBackground() throws IOException{
              Thought thoughtToShow = null;
        if (cachedReceivedThoughts.size() == 0){ 
          ThoughtList thoughtsFromServer = webServiceREST.getRandomThoughts();           
          cachedReceivedThoughts.addAll(thoughtsFromServer.getThoughtsList());       
        }
        thoughtToShow = cachedReceivedThoughts.poll();
        cachedLastThoughts.addAndSaveToFile(thoughtToShow.getID(), new Thought(thoughtToShow));
                return thoughtToShow;
            }

            @Override
            public void done() {       
                try {
                  Thought thoughtAcquired = get();
                  if (actionRequester == null){
                toaster.showToaster(thoughtAcquired);
                  } else {
                    actionRequester.completeBackgroundAction(
                        Status.OK,
View Full Code Here


            public Long doInBackground() throws NotRegisteredException, IOException{
              String resultString = null;
              if (webServiceREST.isUserRegistered()){
              //sending request to server
              resultString = webServiceREST.sendFavoriteRequest(thought);
                Thought modifiedThought = new Thought(thought);
                modifiedThought.setFavorite(!thought.isFavorite());
                //update cached last thoughts
                if (cachedLastThoughts.getMap().containsKey(thought.getID())){
                  cachedLastThoughts.getMap().get(thought.getID()).setFavorite(modifiedThought.isFavorite());
                    cachedLastThoughts.saveToFile()
                } else {
                  //Nothing to do
                }
                //update cached favorite thoughts
                if (modifiedThought.isFavorite()){
                  cachedFavoriteThought.addAndSaveToFile(modifiedThought.getID(), modifiedThought);
                } else {
                  cachedFavoriteThought.getMap().remove(thought.getID());
                }
                 
              } else {
View Full Code Here

TOP

Related Classes of org.lexev.bestwisethoughts.client.data.Thought

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.