Exemplo n.º 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);
   }
 }
Exemplo n.º 2
0
  private void setupTabs() {
    Resources res = getResources();
    tabHost = getTabHost();
    Intent homeIntent = new Intent().setClass(this, TweetListActivity.class);
    homeIntent.putExtra(LIST_ID, 0);
    homeIntent.putExtra("account", account);

    String tmp = getString(R.string.home_timeline);
    homeSpec =
        tabHost
            .newTabSpec("tmp")
            .setIndicator(tmp, res.getDrawable(R.drawable.ic_tab_home))
            .setContent(homeIntent);
    tabHost.addTab(homeSpec);

    Intent mentionsIntent = new Intent().setClass(this, TweetListActivity.class);
    mentionsIntent.putExtra(LIST_ID, -1);
    mentionsIntent.putExtra("account", account);

    tmp = getString(R.string.mentions);
    homeSpec =
        tabHost
            .newTabSpec("mentions")
            .setIndicator(tmp, res.getDrawable(R.drawable.ic_tab_mention))
            .setContent(mentionsIntent);
    tabHost.addTab(homeSpec);

    tmp = getString(R.string.direct);
    Intent directIntent = new Intent().setClass(this, TweetListActivity.class);
    directIntent.putExtra(LIST_ID, -2);
    directIntent.putExtra("account", account);
    homeSpec =
        tabHost
            .newTabSpec("directs")
            .setIndicator(tmp, res.getDrawable(R.drawable.ic_tab_direct))
            .setContent(directIntent);
    tabHost.addTab(homeSpec);

    if (account.getServerType().equalsIgnoreCase("twitter")) {
      tmp = getString(R.string.list);
      Intent listsIntent = new Intent().setClass(this, ListOfListsActivity.class);
      listsIntent.putExtra("list", 0);
      listsIntent.putExtra("account", account);
      homeSpec =
          tabHost
              .newTabSpec("lists")
              .setIndicator(tmp, res.getDrawable(R.drawable.ic_tab_list))
              .setContent(listsIntent);
      tabHost.addTab(homeSpec);

      Intent searchIntent = new Intent().setClass(this, ListOfListsActivity.class);
      searchIntent.putExtra("list", 1);
      searchIntent.putExtra("account", account);
      tmp = getString(R.string.searches);
      homeSpec =
          tabHost
              .newTabSpec("searches")
              .setIndicator(tmp, res.getDrawable(R.drawable.ic_tab_search))
              .setContent(searchIntent);
      tabHost.addTab(homeSpec);
    }
  }