예제 #1
0
 /** Synchronize lists between what is available in the db and on twitter. */
 private void syncLists() {
   TwitterHelper th = new TwitterHelper(this, account);
   TweetDB tdb = new TweetDB(this, accountId);
   if (account.getServerType().equalsIgnoreCase("twitter")) {
     List<UserList> userLists = th.getUserLists();
     Map<String, Integer> storedLists = tdb.getLists();
     // Check for lists to add
     for (UserList userList : userLists) {
       if (!storedLists.containsValue(userList.getId())) {
         tdb.addList(userList.getName(), userList.getId(), DataObjectFactory.getRawJSON(userList));
       }
     }
     // check for outdated lists and remove them
     for (Entry<String, Integer> entry : storedLists.entrySet()) {
       Integer id = entry.getValue();
       boolean found = false;
       for (UserList userList2 : userLists) {
         if (userList2.getId() == id) {
           found = true;
           break;
         }
       }
       if (!found) {
         tdb.removeList(id);
       }
     }
     syncSearches(th, tdb);
   }
 }
예제 #2
0
    @Override
    protected Void doInBackground(Integer... params) {
      int accountId = params[0];

      TweetDB tdb = new TweetDB(context, accountId);
      if (tdb.getLists().size() == 0 && tdb.getSavedSearches().size() == 0) syncLists();

      return null;
    }