Example usage for com.squareup.okhttp FormEncodingBuilder FormEncodingBuilder

List of usage examples for com.squareup.okhttp FormEncodingBuilder FormEncodingBuilder

Introduction

In this page you can find the example usage for com.squareup.okhttp FormEncodingBuilder FormEncodingBuilder.

Prototype

FormEncodingBuilder

Source Link

Usage

From source file:com.yingke.shengtai.adapter.ChatSaleAdapter.java

License:Open Source License

public void postRequest(final TextView text, final String userName, final Map<String, String> map) {
    FormEncodingBuilder builder = new FormEncodingBuilder();
    for (Map.Entry<String, String> entry : map.entrySet()) {
        builder.add(entry.getKey(), entry.getValue());
    }/*w w w.  jav  a2  s  . c  o  m*/
    RequestBody formBody = builder.build();
    Request request = new Request.Builder().url(IApi.URL_IMID_NAME).header("User-Agent", "OkHttp Headers.java")
            .addHeader("Accept", "application/json").addHeader("Content-Type", "application/json;charset=utf-8")
            .addHeader("Content-Length", "length").post(formBody).build();
    RequestManager.getOkHttpClient().newCall(request).enqueue(new Callback() {
        @Override
        public void onFailure(Request request, IOException e) {
        }

        @Override
        public void onResponse(Response response) throws IOException {
            if (response.isSuccessful()) {
                String json = response.body().string();
                ImidToNickNameData data = JosnUtil.gson.fromJson(json, new TypeToken<ImidToNickNameData>() {
                }.getType());
                if (data != null && TextUtils.equals("1", data.getResult() + "")) {
                    try {
                        User user = new User();
                        user.setNick(data.getDetaillist().get(0).getDisplayname());
                        user.setUsername(data.getDetaillist().get(0).getImid());
                        user.setSex(data.getDetaillist().get(0).getSex());
                        userDao.saveContactsss(user);
                        UIHandler.sendEmptyMessage(0);

                    } catch (Exception e) {

                    }
                }

            }

        }
    });
}

From source file:edd.practica2_201314448.Cola.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    RequestBody formBody = new FormEncodingBuilder().add("dato", jTextField1.getText()).build();
    String r = Ingresar("QueueCola", formBody);
    System.out.println(r);//from w ww  .j a va  2s.com
}

From source file:edd.practica2_201314448.Cola.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    RequestBody formBody = new FormEncodingBuilder().add("dato", "").build();
    String r = Ingresar("DeQueueCola", formBody);
    System.out.println(r);//from  ww w  .j a v a 2s  . c om
}

From source file:edd.practica2_201314448.Cola.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    RequestBody formBody = new FormEncodingBuilder().add("dato", "").build();
    String r = Ingresar("GrafCola", formBody);
    Graphivs g = new Graphivs();
    try {/*from w  w  w . ja  v a  2  s  .c  o m*/
        g.CargarDatosCola(r);
    } catch (IOException ex) {
        Logger.getLogger(Cola.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:edd.practica2_201314448.Lista.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    RequestBody formBody = new FormEncodingBuilder().add("dato", jTextField1.getText()).build();
    String r = Ingresar("AgregarSimple", formBody);
    System.out.println(r);/*  ww w.j a  v  a2s  . co  m*/
}

From source file:edd.practica2_201314448.Lista.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    RequestBody formBody = new FormEncodingBuilder().add("dato", jTextField2.getText()).build();
    String r = Ingresar("EliminarSimple", formBody);
    System.out.println(r);/*  w w  w .j  a v  a 2  s .  c  om*/
}

From source file:edd.practica2_201314448.Lista.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    RequestBody formBody = new FormEncodingBuilder().add("dato", jTextField3.getText()).build();
    String r = Ingresar("BuscarSimple", formBody);
    System.out.println(r);/*from   ww  w.j  a v  a2  s. c  om*/
}

From source file:edd.practica2_201314448.Lista.java

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    RequestBody formBody = new FormEncodingBuilder().add("dato", "").build();
    String r = Ingresar("GrafLista", formBody);
    Graphivs g = new Graphivs();
    try {//from   w  ww  . j av  a 2  s  .c om
        g.CargarDatosLista(r);
    } catch (IOException ex) {
        Logger.getLogger(Lista.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:edd.practica2_201314448.Pila.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    RequestBody formBody = new FormEncodingBuilder().add("dato", jTextField1.getText()).build();
    String r = Ingresar("Push", formBody);
    System.out.println(r);/*w  w w. ja  v  a  2s  .  c  om*/
}

From source file:edd.practica2_201314448.Pila.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    RequestBody formBody = new FormEncodingBuilder().add("dato", "").build();
    String r = Ingresar("Pop", formBody);
    System.out.println(r);//from   w  w  w .  j  av  a 2s.  com
}