@Override protected Bitmap doInBackground(Object... params) { Bitmap bitmap = null; try { String url2 = url + type; if (destroyed && (imageViewReference.get() != findViewById(R.id.user_image))) { return null; } if (useDiskCache) { bitmap = CommonLib.getBitmapFromDisk(url2, getApplicationContext()); } if (bitmap == null) { try { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = true; BitmapFactory.decodeStream((InputStream) new URL(url).getContent(), null, opts); opts.inSampleSize = CommonLib.calculateInSampleSize(opts, width, height); opts.inJustDecodeBounds = false; bitmap = BitmapFactory.decodeStream((InputStream) new URL(url).getContent(), null, opts); if (useDiskCache) { CommonLib.writeBitmapToDisk( url2, bitmap, getApplicationContext(), Bitmap.CompressFormat.JPEG); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } catch (Error e) { } } if (bitmap != null) { bitmap = CommonLib.getRoundedCornerBitmap(bitmap, width); synchronized (zapp.cache) { zapp.cache.put(url2, bitmap); } } } catch (Exception e) { } return bitmap; }
@Override protected void onPostExecute(Object result) { if (destroyed) return; findViewById(R.id.wishbox_progress_container).setVisibility(View.GONE); if (result != null) { findViewById(R.id.content).setVisibility(View.VISIBLE); if (result instanceof Object[]) { Object[] arr = (Object[]) result; setWishes((ArrayList<Coupon>) arr[0]); } } else { if (CommonLib.isNetworkAvailable(mContext)) { Toast.makeText( mContext, mContext.getResources().getString(R.string.error_try_again), Toast.LENGTH_SHORT) .show(); } else { Toast.makeText( mContext, getResources().getString(R.string.no_internet_message), Toast.LENGTH_SHORT) .show(); findViewById(R.id.empty_view).setVisibility(View.VISIBLE); findViewById(R.id.content).setVisibility(View.GONE); } } }
// execute the api @Override protected Object doInBackground(Object... params) { try { CommonLib.ZLog("API RESPONSER", "CALLING GET WRAPPER"); String url = ""; url = CommonLib.SERVER + "redeem/get?"; Object info = RequestWrapper.RequestHttp(url, RequestWrapper.GET_REDEEM_COUPONS, RequestWrapper.FAV); CommonLib.ZLog("url", url); return info; } catch (Exception e) { e.printStackTrace(); } return null; }