Esempio n. 1
0
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   String name = platform.getName();
   if ("FacebookMessenger".equals(name)) {
     if (lastPosition >= 0) {
       Following lastFollwing = adapter.getItem(lastPosition);
       lastFollwing.checked = false;
     }
     lastPosition = position;
   }
   Following following = adapter.getItem(position);
   following.checked = !following.checked;
   adapter.notifyDataSetChanged();
 }
 public synchronized void follow(int id, int frame, int oid, Coord off, int szo) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   if (oid == -1) {
     g.delattr(Following.class);
   } else {
     Following flw = g.getattr(Following.class);
     if (flw == null) {
       flw = new Following(g, oid, off, szo);
       g.setattr(flw);
     } else {
       flw.tgt = oid;
       flw.doff = off;
       flw.szo = szo;
     }
   }
 }
Esempio n. 3
0
    private ArrayList<Following> parseList(HashMap<String, Object> res) {
      if (res == null || res.size() <= 0) {
        return null;
      }

      ArrayList<Following> data = new ArrayList<Following>();
      if ("SinaWeibo".equals(platform.getName())) {
        // users[id, name, description]
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> users =
            (ArrayList<HashMap<String, Object>>) res.get("users");
        for (HashMap<String, Object> user : users) {
          String uid = String.valueOf(user.get("id"));
          if (!map.containsKey(uid)) {
            Following following = new Following();
            following.uid = uid;
            following.screeName = String.valueOf(user.get("name"));
            following.description = String.valueOf(user.get("description"));
            following.icon = String.valueOf(user.get("profile_image_url"));
            map.put(following.uid, following);
            data.add(following);
          }
        }
        hasNext = (Integer) res.get("total_number") > map.size();
      } else if ("TencentWeibo".equals(platform.getName())) {
        hasNext = ((Integer) res.get("hasnext") == 0);
        // info[nick, name, tweet[text]]
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> infos =
            (ArrayList<HashMap<String, Object>>) res.get("info");
        for (HashMap<String, Object> info : infos) {
          String uid = String.valueOf(info.get("name"));
          if (!map.containsKey(uid)) {
            Following following = new Following();
            following.screeName = String.valueOf(info.get("nick"));
            following.uid = uid;
            @SuppressWarnings("unchecked")
            ArrayList<HashMap<String, Object>> tweets =
                (ArrayList<HashMap<String, Object>>) info.get("tweet");
            for (int i = 0; i < tweets.size(); ) {
              HashMap<String, Object> tweet = tweets.get(i);
              following.description = String.valueOf(tweet.get("text"));
              break;
            }
            following.icon = String.valueOf(info.get("head")) + "/100";
            map.put(following.uid, following);
            data.add(following);
          }
        }
      } else if ("Facebook".equals(platform.getName())) {
        // data[id, name]
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> datas =
            (ArrayList<HashMap<String, Object>>) res.get("data");
        for (HashMap<String, Object> d : datas) {
          String uid = String.valueOf(d.get("id"));
          if (!map.containsKey(uid)) {
            Following following = new Following();
            following.uid = uid;
            following.screeName = String.valueOf(d.get("name"));
            @SuppressWarnings("unchecked")
            HashMap<String, Object> picture = (HashMap<String, Object>) d.get("picture");
            if (picture != null) {
              @SuppressWarnings("unchecked")
              HashMap<String, Object> pData = (HashMap<String, Object>) picture.get("data");
              if (d != null) {
                following.icon = String.valueOf(pData.get("url"));
              }
            }
            map.put(following.uid, following);
            data.add(following);
          }
        }
        @SuppressWarnings("unchecked")
        HashMap<String, Object> paging = (HashMap<String, Object>) res.get("paging");
        hasNext = paging.containsKey("next");
      } else if ("Twitter".equals(platform.getName())) {
        // users[screen_name, name, description]
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> users =
            (ArrayList<HashMap<String, Object>>) res.get("users");
        for (HashMap<String, Object> user : users) {
          String uid = String.valueOf(user.get("screen_name"));
          if (!map.containsKey(uid)) {
            Following following = new Following();
            following.uid = uid;
            following.screeName = String.valueOf(user.get("name"));
            following.description = String.valueOf(user.get("description"));
            following.icon = String.valueOf(user.get("profile_image_url"));
            map.put(following.uid, following);
            data.add(following);
          }
        }
      } else if ("FacebookMessenger".equals(platform.getName())) {
        @SuppressWarnings("unchecked")
        ArrayList<HashMap<String, Object>> users =
            (ArrayList<HashMap<String, Object>>) res.get("users");
        for (HashMap<String, Object> user : users) {
          String userAddr = String.valueOf(user.get("jid"));
          if (!map.containsKey(userAddr)) {
            Following following = new Following();
            following.uid = userAddr;
            following.screeName = String.valueOf(user.get("name"));
            map.put(following.uid, following);
            data.add(following);
          }
        }
        hasNext = false;
      }
      return data;
    }