Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void get_Sync(View view){ // This is a button click
- get_products(order, limit);
- }
- public void get_products(final String order, final int limit){
- ExecutorService mExec = Executors.newSingleThreadExecutor();
- mExec.execute(new Runnable() {
- @Override
- public void run() {
- try{
- SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
- request.addProperty("order", order);
- request.addProperty("limit", limit);
- SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
- envelope.setOutputSoapObject(request);
- HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
- androidHttpTransport.call(SOAP_ACTION, envelope);
- SoapObject rep = (SoapObject) envelope.bodyIn;
- JSONArray jr = new JSONArray(rep.getPropertyAsString(0));
- for(int i = 0; i <= jr.length() - 1; i++)
- {
- JSONObject jb = (JSONObject) jr.get(i);
- byte[] theImage = jb.getString("image").getBytes();
- db.add_oc_product(new oc_product(jb.getInt("product_id"), jb.getString("model"), jb.getInt("quantity"),
- theImage);
- }
- }catch (Exception e){
- Log.e("Error:", e.toString());
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement