private static JSONObject generateMoveJson( String characterId, Item item, boolean transferToVault, int stackSize) { JSONObject json = new JSONObject(); try { json.put("characterId", characterId); json.put("itemId", item.getItemId()); json.put("itemReferenceHash", item.getItemHash()); json.put("membershipType", Data.getInstance().getMembership().getType()); json.put("stackSize", stackSize); json.put("transferToVault", transferToVault); } catch (JSONException e) { Log.e(LOG_TAG, "exception", e); e.printStackTrace(); } return json; }
public static Promise equip( final ClientWebView webView, final String owner, final Item item, final Promise p) { final Promise p_inner = new Promise(); JSONObject obj = new JSONObject(); try { obj.put("characterId", owner); obj.put("itemId", item.getItemId()); obj.put("membershipType", Data.getInstance().getMembership().getType()); } catch (JSONException e) { Log.e(LOG_TAG, "exception", e); e.printStackTrace(); } webView .call("destinyService.EquipItem", obj) .then( new ClientWebView.Callback() { @Override public void onAccept(String result) { for (Item tested_item : Items.getInstance().all()) { if (tested_item.getBucketTypeHash() == item.getBucketTypeHash() && item.getItemHash() != tested_item.getItemHash() && Items.getInstance().getItemOwner(tested_item).equals(owner) && tested_item.getCanEquip()) { tested_item.setIsEquipped(false); item.setIsEquipped(true); break; } } p_inner.onSuccess(); } @Override public void onError(String result) { p_inner.onError(result); } }); return p_inner; }