Ejemplo n.º 1
0
  private void initView() {
    setContentView(R.layout.timeline);

    aq = new AQuery(this);

    mActionBar = (ActionBar) findViewById(R.id.actionbar);
    mActionBar.setHomeAction(new IntentAction(this, createIntent(this), R.drawable.logo_h));

    final Action composeAction =
        new IntentAction(this, createComposeIntent(), R.drawable.ic_action_compose);
    mActionBar.addAction(composeAction);

    mActionBar.addAction(
        new Action() {
          @Override
          public void performAction(View view) {
            refreshStatus(mSinceId);
          }

          @Override
          public int getDrawable() {
            return R.drawable.ic_action_refresh;
          }
        });

    mListView = ((PullAndLoadListView) findViewById(R.id.msg_list_item));

    // Set a listener to be invoked when the list should be refreshed.
    mListView.setOnRefreshListener(
        new PullAndLoadListView.OnRefreshListener() {
          @Override
          public void onRefresh() {
            // Do work to refresh the list here.
            refreshStatus(mSinceId);
          }
        });

    mListView.setOnLoadMoreListener(
        new PullAndLoadListView.OnLoadMoreListener() {

          public void onLoadMore() {
            loadMoreData(mMaxId);
          }
        });

    mListView.setLastUpdated(getLastSyncTime(Preferences.PREF_LAST_SYNC_TIME));

    mAdapter = new StatusItemAdapter(this);

    getFriendsTimeline(0, 0);

    mListView.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            // see: How to determine onItemClick for pulltorefreshlistview
            // http://stackoverflow.com/questions/10959030/how-to-determine-onitemclick-for-pulltorefreshlistview
            Statuses status = (Statuses) mListView.getItemAtPosition(position);

            if (status == null) {
              return;
            } else {
              Bundle bundle = new Bundle();
              bundle.putSerializable(Consts.STATUSES_KEY, status);

              Intent intent = new Intent(TimelineActivity.this, StatusDetailActivity.class);
              intent.putExtras(bundle);
              startActivity(intent);
            }
          }
        });
  }
Ejemplo n.º 2
0
  private void showContents() {
    aq.id(R.id.timelist_list).visible();

    // FIXME: put it here, else will pop up "Tap to Refresh"
    mListView.setAdapter(mAdapter);
  }