public void getVouchers() { Gson gson = new Gson(); VoucherList vouchres; String voucherListString = spref.getString(Constants.KEY_VOUCHERS, ""); if (voucherListString.equals("")) { vouchres = new VoucherList(); } else { vouchres = gson.fromJson(voucherListString, VoucherList.class); } voucherList = (ArrayList<Voucher>) vouchres.getVouchers(); // voucherListString = gson.toJson(vouchres); // spref.edit().putString(Constants.KEY_VOUCHERS, // voucherListString).commit(); // Voucher v = new Voucher(); // v.setMsg("http://appwizlive.com/uploads/retailer/11/pnimages/deviceimg/pn_14053468485.Eshop1.jpg"); // v.setType("Image"); // vouchres.getVouchers().add(v); // // Voucher v2 = new Voucher(); // v2.setMsg("http://appwizlive.com/uploads/retailer/10/bgupload/edn_promotional_video3.mp4"); // v2.setType("Video"); // vouchres.getVouchers().add(v2); // vouchres.getVouchers().add(v2); }
public void closePressed(int position) { int pos = position; // listViewVoucher.getPositionForView(v); if (voucherList.size() <= pos) { return; } voucherList.remove(pos); VoucherList vouchres = new VoucherList(); vouchres.setVouchers(voucherList); Gson gson = new Gson(); String voucherListString = gson.toJson(vouchres); spref.edit().putString(Constants.KEY_VOUCHERS, voucherListString).commit(); adapter.notifyDataSetChanged(); }