public RoomBuilderFragment(ArrayList<RoomQueryGuestSO> childrenSOArrayList, int position) { this.childrenSOArrayList = new ArrayList<>(); for (RoomQueryGuestSO item : childrenSOArrayList) { if (item.isChild()) { this.childrenSOArrayList.add(item); } else { adultCount = item.getAge(); } } this.position = position; }
public void sendData() { boolean isAgeSetted = true; for (RoomQueryGuestSO item : childrenSOArrayList) { if (item.getAge() == 0) { isAgeSetted = false; } } if (isAgeSetted) { getActivity().dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK)); getActivity().dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK)); RoomQueryGuestSO guest = new RoomQueryGuestSO( false, Integer.valueOf(tvAdults.getText().toString().replaceAll("[^0-9]", ""))); childrenSOArrayList.add(0, guest); ((MainActivity) getActivity()).updateArrayListInFragment(childrenSOArrayList, position); } else { Toast.makeText( getActivity().getApplicationContext(), "Make sure you have entered children`s ages", Toast.LENGTH_SHORT) .show(); } }