Ejemplo n.º 1
0
 public String getGameValue(String name1, String name2, String name3) {
   StringBuffer sb = new StringBuffer();
   if (!StringUtils.isEmpty(name1)) {
     sb.append(name1);
   }
   if (!StringUtils.isEmpty(name2)) {
     sb.append(",").append(name2);
   }
   if (!StringUtils.isEmpty(name3)) {
     sb.append(",").append(name3);
   }
   return sb.toString();
 }
Ejemplo n.º 2
0
  private void initView() {
    // TODO Auto-generated method stub
    if (page == 0) {
      mTitleBar.setTitleText("最近玩的游戏");
    } else {
      mTitleBar.setTitleText("喜欢的游戏");
    }
    mTitleBar.setLogo(R.drawable.selector_back_btn);
    mTitleBar
        .addRightButtonView(R.drawable.selector_top_btn, "确定")
        .setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent intent = getIntent();
                name1 = et_game1.getEditableText().toString().trim();
                name2 = et_game2.getEditableText().toString().trim();
                name3 = et_game3.getEditableText().toString().trim();
                intent.putExtra("game", getGameValue(name1, name2, name3));
                setResult(Activity.RESULT_OK, intent);
                finish();
              }
            });

    name1 = getIntent().getStringExtra("name1");
    name2 = getIntent().getStringExtra("name2");
    name3 = getIntent().getStringExtra("name3");
    if (!StringUtils.isEmpty(name1)) {
      et_game1.setText(name1);
    }
    if (!StringUtils.isEmpty(name2)) {
      et_game2.setText(name2);
    }
    if (!StringUtils.isEmpty(name3)) {
      et_game3.setText(name3);
    }
  }
Ejemplo n.º 3
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();
  }
Ejemplo n.º 4
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();
  }
Ejemplo n.º 5
0
  private void getData(final boolean isRefresh) {

    if (isRefresh) {
      pageNum = 1;
    }

    Map<String, Object> params = new LinkedHashMap<String, Object>();
    // if (page == 2) {
    // params.put("uid", getMyApplication().userBean.data.profile.uid + "");
    // }
    params.put("page", pageNum++ + "");
    params.put("count", count + "");
    if (page == 4) {
      params.put("t", "feed");
    } else if (page == 5) {
      params.put("t", "comment");
    }
    if (!StringUtils.isEmpty(fromUid)) params.put("uid", fromUid);

    UIHelper.reqGetData(
        act,
        WeiboBean.class,
        params,
        3,
        new IResponseListener() {

          @Override
          public void onSuccess(Object o) {
            WeiboBean data = (WeiboBean) o;
            List<WeiboListItem> list = data.data.weibolist;
            if (list != null && list.size() > 0) {
              if (isRefresh) {
                if (list.size() < 10) {
                  listview.setIsLoadFull(true);
                } else {
                  listview.setIsLoadFull(false);
                }
                if (StringUtils.isEmpty(fromUid)) {
                  new Thread(
                          new Runnable() {

                            @Override
                            public void run() {
                              // TODO Auto-generated method stub
                              db.deleteByWhere(WeiboDao.class, "type=" + page + " and uid=" + uid);
                              WeiboDao dao = null;
                              for (WeiboListItem item : adapter.getList()) {
                                dao = new WeiboDao();
                                dao.setJson(gson.toJson(item));
                                dao.setType(page);
                                dao.setUid(uid);
                                db.save(dao);
                              }
                            }
                          })
                      .start();
                }
                adapter.clear();
                adapter.addAllFirst(list);

              } else {
                if (list.size() < 10) {
                  listview.setIsLoadFull(true);
                } else {
                  listview.setIsLoadFull(false);
                }
                adapter.addAll(list);
              }
              adapter.notifyDataSetChanged();
            }
          }

          @Override
          public void onReqStart() {}

          @Override
          public void onFinish() {
            listview.finishRefresh();
            listview.finishLoadMore();
          }

          @Override
          public void onFailure(Object arg0) {}
        });
  }
Ejemplo n.º 6
0
  private void requestContact() {

    if (isRefresh) {
      pageNum = 1;
    }

    Map<String, Object> params = new LinkedHashMap<String, Object>();
    params.put("page", pageNum++ + "");
    params.put("count", count + "");
    if (!StringUtils.isEmpty(fromUid)) {
      params.put("uid", fromUid);
    }

    RequestHelper.requestGetFans(
        this,
        params,
        page,
        new IResponseListener() {

          @Override
          public void onSuccess(Object o) {
            // TODO Auto-generated method stub
            fansBean = (FansBean) o;
            final LinkedList<FansData> list = fansBean.data.userlist;

            if (list != null && list.size() > 0) {
              if (isRefresh) {
                if (list.size() < 10) {
                  listview.setIsLoadFull(true);
                } else {
                  listview.setIsLoadFull(false);
                }

                adapter.clear();
                adapter.addAll(list);
                if (StringUtils.isEmpty(fromUid)) {

                  new Thread(
                          new Runnable() {

                            @Override
                            public void run() {
                              // TODO Auto-generated method stub
                              db.deleteByWhere(FansDao.class, "type=" + page + " and uid = " + uid);
                              FansDao dao = null;
                              for (FansData item : list) {
                                dao = new FansDao();
                                dao.setJson(gson.toJson(item));
                                dao.setType(page);
                                dao.setUid(uid);
                                db.save(dao);
                              }
                            }
                          })
                      .start();
                }
              } else {
                if (list.size() < 10) {
                  listview.setIsLoadFull(true);
                } else {
                  listview.setIsLoadFull(false);
                }
                adapter.addAll(list);
              }
              adapter.notifyDataSetChanged();
            }
          }

          @Override
          public void onReqStart() {
            // TODO Auto-generated method stub

          }

          @Override
          public void onFinish() {
            // TODO Auto-generated method stub
            listview.finishRefresh();
            listview.finishLoadMore();
          }

          @Override
          public void onFailure(Object o) {
            // TODO Auto-generated method stub

          }
        });
  }