Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1.     public void get_Sync(View view){ // This is a button click
  2.        get_products(order, limit);
  3.     }
  4.    
  5.     public void get_products(final String order, final int limit){
  6.          ExecutorService mExec = Executors.newSingleThreadExecutor();
  7.          mExec.execute(new Runnable() {
  8.              @Override
  9.              public void run() {            
  10.                  try{
  11.                      SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
  12.    
  13.                      request.addProperty("order", order);
  14.                      request.addProperty("limit", limit);
  15.    
  16.                      SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
  17.                      envelope.setOutputSoapObject(request);
  18.                      HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
  19.                      androidHttpTransport.call(SOAP_ACTION, envelope);
  20.    
  21.                      SoapObject rep = (SoapObject) envelope.bodyIn;
  22.                      JSONArray jr = new JSONArray(rep.getPropertyAsString(0));
  23.    
  24.                      for(int i = 0; i <= jr.length() - 1; i++)
  25.                      {
  26.                          JSONObject jb = (JSONObject) jr.get(i);
  27.                          byte[] theImage = jb.getString("image").getBytes();
  28.                          db.add_oc_product(new oc_product(jb.getInt("product_id"), jb.getString("model"), jb.getInt("quantity"),
  29.                                                           theImage);
  30.                      }
  31.                  }catch (Exception e){
  32.                      Log.e("Error:", e.toString());
  33.                  }
  34.              }
  35.          });
  36.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement