Пример #1
0
 @Override
 public void run() {
   // TODO Auto-generated method stub
   int result;
   String target = myapplication.getlocalhost() + "adduserzaninfo.php";
   HttpPost httprequest = new HttpPost(target);
   List<NameValuePair> paramsList = new ArrayList<NameValuePair>();
   paramsList.add(new BasicNameValuePair("_userid", myapplication.getUserId())); // 本人
   paramsList.add(new BasicNameValuePair("_guid", guid)); // 本人
   paramsList.add(new BasicNameValuePair("_action", gzaction)); // 本人
   try {
     httprequest.setEntity(new UrlEncodedFormEntity(paramsList, "UTF-8"));
     HttpClient HttpClient1 = CustomerHttpClient.getHttpClient();
     HttpResponse httpResponse = HttpClient1.execute(httprequest);
     if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
       String json = EntityUtils.toString(httpResponse.getEntity());
       result = Integer.parseInt(json);
     } else {
       result = 0;
     }
   } catch (UnsupportedEncodingException e1) {
     e1.printStackTrace();
   } catch (ClientProtocolException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Пример #2
0
  public static XMPPTCPConnection getConnection() {

    if (connection != null) {
      return connection;
    }
    XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
    builder.setServiceName("bbxiaoqu");
    builder.setHost(DemoApplication.getInstance().xmpphost);
    builder.setPort(DemoApplication.getInstance().xmppport);
    builder.setCompressionEnabled(false);
    builder.setDebuggerEnabled(false);
    builder.setSendPresence(true);
    builder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

    connection = new XMPPTCPConnection(builder.build());
    connectionListener = new ViConnectionListener(mContext);
    connection.addConnectionListener(connectionListener);

    cm = ChatManager.getInstanceFor(connection);

    chatlistener = ChatListener.getInstance(mContext);
    cm.addChatListener(chatlistener);

    return connection;
  }
Пример #3
0
    private String getgz() {
      String target = DemoApplication.getInstance().getlocalhost() + "getgznum.php";
      HttpPost httprequest = new HttpPost(target);
      List<NameValuePair> paramsList = new ArrayList<NameValuePair>();

      System.out.println("gzpos:" + pos);
      System.out.println("gzpos:" + adapter.list.get(pos).get("guid").toString());

      paramsList.add(new BasicNameValuePair("_guid", adapter.list.get(pos).get("guid").toString()));
      String nums = "0";
      try {
        httprequest.setEntity(new UrlEncodedFormEntity(paramsList, "UTF-8"));
        HttpClient HttpClient1 = CustomerHttpClient.getHttpClient();
        HttpClient1.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000);
        HttpClient1.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 5000);
        HttpResponse httpResponse = HttpClient1.execute(httprequest);
        if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
          InputStream jsonStream = httpResponse.getEntity().getContent();
          byte[] data = null;
          try {
            data = StreamTool.read(jsonStream);
          } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
          String JsonContext = new String(data);
          if (JsonContext.length() > 0) {
            JSONArray arr = new JSONArray(JsonContext);
            JSONObject jsonobj = arr.getJSONObject(0);
            nums = jsonobj.getString("nums");
          }
        }
      } catch (ClientProtocolException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      return nums;
    }
Пример #4
0
  // ViewHolderimg holder_img = null;
  private View haveimg(int position, View convertView) {
    final ViewHolderimg holder_img;
    final DemoApplication myapplication = (DemoApplication) this.context.getApplicationContext();
    MessZanService messgzService = new MessZanService(this.context);
    if (convertView == null) {
      holder_img = new ViewHolderimg();
      // 可以理解为从vlist获取view  之后把view返回给ListView
      convertView = LayoutInflater.from(context).inflate(R.layout.listview_item_fw, null);
      holder_img.tag = (ImageView) convertView.findViewById(R.id.fwtag);
      holder_img.imageView = (ImageView) convertView.findViewById(R.id.imageView);
      holder_img.senduser = (TextView) convertView.findViewById(R.id.senduser);
      holder_img.sendcontent = (TextView) convertView.findViewById(R.id.sendcontent);
      holder_img.usertag = (TextView) convertView.findViewById(R.id.usertags);
      holder_img.zannum = (TextView) convertView.findViewById(R.id.zannum);
      holder_img.zan = (ImageView) convertView.findViewById(R.id.zan);
      holder_img.tel = (ImageView) convertView.findViewById(R.id.telphone);
      convertView.setTag(holder_img);
    } else {
      holder_img = (ViewHolderimg) convertView.getTag();
    }

    View.OnClickListener listener =
        new View.OnClickListener() {
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (v == holder_img.tel) {
              Intent intent = new Intent();
              intent.setAction(Intent.ACTION_CALL);
              intent.setData(Uri.parse("tel:" + v.getTag().toString()));
              intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              v.getContext().getApplicationContext().startActivity(intent);
            }
            if (v == holder_img.zan) {
              ImageView zanimg = (ImageView) v;
              String n_tag = v.getTag().toString();
              String[] arr = n_tag.split("_");
              int num = Integer.parseInt(arr[0]);
              int n1 = 0;
              int iszan = Integer.parseInt(arr[1]);
              String guidstr = arr[2];
              MessZanService messgzService =
                  new MessZanService(v.getContext().getApplicationContext());

              boolean ishavezhan1 = messgzService.isexit(guidstr, myapplication.getUserId());
              System.out.println(
                  guidstr + "____" + myapplication.getUserId() + "____" + ishavezhan1);
              if (ishavezhan1) {
                zanimg.setImageResource(R.mipmap.tab_sub_sos);
                n1 = num - 1;
                zanimg.setTag(n1 + "_0_" + guidstr);
                messgzService.removezan(guidstr, myapplication.getUserId());
                T.showShort(myapplication, "取消赞!");
                gzaction = "remove";
                guid = guidstr;
                new Thread(savegzThread).start();
              } else {
                zanimg.setImageResource(R.mipmap.tab_sub_sos_sel);
                n1 = num + 1;
                zanimg.setTag(n1 + "_1_" + guidstr);
                messgzService.addzan(guidstr, myapplication.getUserId());
                T.showShort(myapplication, "赞成功!");
                guid = guidstr;
                gzaction = "add";
                new Thread(savegzThread).start();
              }
              holder_img.zannum.setText(String.valueOf(n1));
            }
          }
        };

    holder_img.imageView.setTag(position); // 设置标签
    if (list.get(position).get("headface") != null
        && list.get(position).get("headface").toString().trim().length() > 0) {
      String fileName = "";
      if (list.get(position).get("headface").toString().trim().length() > 4) {
        String headface = list.get(position).get("headface").toString().trim();
        fileName = DemoApplication.getInstance().getlocalhost() + "uploads/" + headface;
      }
      ImageLoader.getInstance()
          .displayImage(
              fileName,
              holder_img.imageView,
              ImageOptions.getOptions(),
              new ImageLoadingListener() {
                @Override
                public void onLoadingCancelled(String arg0, View arg1) {
                  // TODO Auto-generated method stub
                }

                @Override
                public void onLoadingComplete(String arg0, View arg1, Bitmap bitmap) {
                  // TODO Auto-generated method stub
                  if (bitmap == null) {
                    holder_img.imageView.setImageResource(R.mipmap.t3);
                  }
                }

                @Override
                public void onLoadingFailed(String arg0, View arg1, FailReason bitmap) {
                  // TODO Auto-generated method stub
                  if (bitmap == null) {
                    holder_img.imageView.setImageResource(R.mipmap.t3);
                  }
                }

                @Override
                public void onLoadingStarted(String arg0, View arg1) {
                  // TODO Auto-generated method stub
                }
              });
    }
    // tab_sub_sos
    holder_img.senduser.setText(list.get(position).get("sendnickname").toString());
    // title
    if (list.get(position).get("title").toString().equals("帮帮忙")) {
      holder_img.sendcontent.setText(list.get(position).get("content").toString());
    } else {
      holder_img.sendcontent.setText(list.get(position).get("title").toString());
    }

    holder_img.zannum.setText(list.get(position).get("zannum").toString());
    holder_img.usertag.setText(list.get(position).get("tags").toString());
    holder_img.tel.setTag(list.get(position).get("telphone").toString());
    holder_img.tel.setOnClickListener(listener);
    holder_img.tag.setImageResource(R.mipmap.dynamic_join_left);
    boolean ishavezhan =
        messgzService.isexit(list.get(position).get("guid").toString(), myapplication.getUserId());
    Log.v(
        TAG,
        list.get(position).get("guid").toString()
            + "____"
            + myapplication.getUserId()
            + "____"
            + ishavezhan);
    if (ishavezhan) {
      holder_img.zan.setImageResource(R.mipmap.tab_sub_sos_sel);
      holder_img.zan.setTag(
          list.get(position).get("zannum").toString()
              + "_1_"
              + list.get(position).get("guid").toString());
      holder_img.zan.setOnClickListener(listener);

    } else {
      holder_img.zan.setImageResource(R.mipmap.tab_sub_sos);
      holder_img.zan.setTag(
          list.get(position).get("zannum").toString()
              + "_0_"
              + list.get(position).get("guid").toString());
      holder_img.zan.setOnClickListener(listener);
    }
    return convertView;
  }