Пример #1
0
  protected void onResume() {
    super.onResume();

    Log.i("TabWidget", "onResume");
    Account tmp = getIntent().getExtras().getParcelable("account");
    if (!tmp.equals(account)) {
      // New account, so re-setup tabs
      tabHost.clearAllTabs();
      account = tmp;
      setupTabs();
    }
    Log.i("TabWidget", "Account=" + account);
    titleTextBox.setText(account.getAccountIdentifier());
  }
Пример #2
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);
   }
 }
Пример #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.i("TabWidget", "onCreate");
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.tabs);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
    pg = (ProgressBar) findViewById(R.id.title_progress_bar);
    titleTextBox = (TextView) findViewById(R.id.title_msg_box);

    account = getIntent().getExtras().getParcelable("account");
    accountId = account.getId();
    Log.i("TabWidget", "Account=" + account);

    setupTabs();

    tabHost.setCurrentTab(0); // Home tab, tabs start at 0

    new InitialSyncTask(this).execute(accountId);
  }
Пример #4
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);
    }
  }