예제 #1
0
  private void initView() {
    // TODO Auto-generated method stub
    if (page == 0) {
      mTitleBar.setTitleText(R.string.title_fans);
    } else {
      mTitleBar.setTitleText(R.string.title_attention);
    }
    mTitleBar.setLogo(R.drawable.selector_back_btn);

    adapter = new ListAdapter();
    listview.setAdapter(adapter);
    listview.setOnRefreshListener(
        new OnRefreshListener() {

          @Override
          public void onRefresh() {
            // TODO Auto-generated method stub
            isRefresh = true;
            requestGetContact();
          }
        });

    if (StringUtils.isEmpty(fromUid)) {
      List<FansDao> list = db.findAllByWhere(FansDao.class, "type=" + page + " and uid =" + uid);
      if (list != null && list.size() > 0) {
        for (FansDao item : list) {
          FansData data = gson.fromJson(item.getJson(), FansData.class);
          adapter.add(data);
        }
        if (list.size() < 10) {
          listview.setIsLoadFull(true);
        } else {
          listview.setIsLoadFull(false);
        }
        adapter.notifyDataSetChanged();
      }
    }
    listview.refresh();
  }
예제 #2
0
  private void initView() {

    db = FinalDb.create(act);
    gson = new Gson();

    page = getArguments().getInt("page");

    listview.setOnRefreshListener(
        new OnRefreshListener() {

          @Override
          public void onRefresh() {
            // TODO Auto-generated method stub
            getData(true);
          }
        });
    listview.setOnLoadMoreListener(
        new OnLoadMoreListener() {

          @Override
          public void onLoadMore() {
            // TODO Auto-generated method stub
            getData(false);
          }
        });

    adapter = new WeiboListAdapter(0);
    adapter.setmFragment(this);
    adapter.setOnPictureClickListener(new OnPictureClickListener());
    adapter.setOnMultiPictureClickListener(new OnMultiPictureClickListener());

    adapter.setOnAvatarClickListener(
        new OnAvatarClickListener() {

          @Override
          public void onAvatarClick(int position) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(act, FriendInfoActivity.class);
            intent.putExtra("uid", adapter.getItem(position).uid);
            startActivity(intent);
          }
        });
    adapter.setOnZanClickListener(
        new OnZanClickListener() {

          @Override
          public void OnZanClick(int position) {
            // TODO Auto-generated method stub
            if ("1".equals(adapter.getItem(position).is_digg)) {
              delDigg(position);
            } else {
              addDigg(position);
            }
          }
        });
    adapter.setOnShoucangClickListener(
        new OnShoucangClickListener() {

          @Override
          public void OnShoucangClick(int position) {
            // TODO Auto-generated method stub
            if ("1".equals(adapter.getItem(position).iscoll.colled)) {
              doUnFavorite(position);
            } else {
              doFavorite(position);
            }
          }
        });
    adapter.setOnPinglunClickListener(
        new OnPinglunClickListener() {

          @Override
          public void OnPinglunClick(int position) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(act, WriteCommentActivity.class);
            intent.putExtra("weiboListItem", adapter.getItem(position));
            startActivity(intent);
          }
        });
    adapter.setOnZhuanfaClickListener(
        new OnZhuanfaClickListener() {

          @Override
          public void OnZhuanfaClick(int position) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(act, WriteCommentActivity.class);
            intent.putExtra("weiboListItem", adapter.getItem(position));
            intent.putExtra("isZhuanfa", true);
            startActivity(intent);
          }
        });
    listview.setAdapter(adapter);
    listview.setOnScrollListener(new OnListScrollListener());
    listview.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(act, WeiboDetailActivity.class);
            intent.putExtra("weiboListItem", adapter.getItem(arg2 - 1));
            startActivity(intent);
          }
        });

    if (StringUtils.isEmpty(fromUid)) {
      List<WeiboDao> list = db.findAllByWhere(WeiboDao.class, "type=" + page + " and uid=" + uid);
      if (list != null && list.size() > 0) {
        for (WeiboDao item : list) {
          WeiboListItem data = gson.fromJson(item.getJson(), WeiboListItem.class);
          adapter.add(data);
        }
        if (list.size() < 10) {
          listview.setIsLoadFull(true);
        } else {
          listview.setIsLoadFull(false);
        }
        adapter.notifyDataSetChanged();
      }
    }
    listview.refresh();
  }