3Yʹ͍ͭͯ w ͱͱʹ/FUքͰੜ·ΕͨϥΠϒϥϦɻʢ$ͷ-*/2͕ݯྲྀʣ w /FUqJY͕͜ͷϥΠϒϥϦΛ+BWBʹҠ২ͨ͠3Y+BWBΛ࢝Ίɺ3Y+4ɺ3Y4XJGUɺ 3Y"OESPJEͳͲ༷ʑͳݴޠɺϓϥοτϑΥʔϜʹ͕͍ͬͯΔɻ w 3FBDUͱ͔3FEVYͱ໊͔લ͕ࣅͯΔ͚Ͳ͋Μ·ؔͳ͍ɻ3FBDUJWF 1SPHSBNJOHͱ͍͏͘͘Γʹ͓͍ͯؒɻ
3FBDUJWF1SPHSBNJOHͱ͍͏ύϥμΠϜ w "ͷηϧΛΠϯΫϦϝϯτ͢Δͱ#ɺ$ɺ"ͷมԽ͢Δ w ී௨ʹखଓ͖తʹίʔυΛॻ͍ͯ࠶ݱͰ͖ͳ͍ɻ0CTFSWFSύλʔϯΛͬͯ"ͷΛࢹ͢Δ Α͏ͳίʔυΛॻ͘ඞཁ͕͋Δɻ w 3FBDUJWF1SPHSBNJOHʮมԽ͢Δঢ়ଶʯͷؔੑΛॻ͍͍ͯ͘͜ͱͰঢ়ଶΛίϯτϩʔϧ͢Δ
ͬͯ3Y w 3Yঢ়ଶͷมԽΛ4USFBNͱͯ͠දݱ͢Δ w ొ͢Δͷ0CTFSWBCMFͱ0CTFSWFSΠϯλʔϑΣʔεɻ0CTFSWBCMFྲྀΕͯ ͘Δσʔλɺ0CTFSWFSྲྀΕͯ͘Δσʔλͷ؍ଌऀ w Ұ൪؆୯ͳϦετͷதΛ4USFBNʹมͯ͠දࣔ͢Δྫʢ+BWBʣ -JTU*OUFHFSMJTU"SSBZTBT-JTU
Ұ୴ͬͯ0CTFSWFSΠϯλʔϑΣʔεΛோΊΔ w 4USFBN͕ऴʹୡ͢ΔͱPO$PNQMFUFE͕ͬͯߪಡVOTVCTDSJCF͞ΕΔ w 7JFXͷ߹ৗʹࢹ͞Ε͍ͯΔɺͭ·Γ4USFBNແݶͰPO$PNQMFUFE͕Βͳ͍ͷͰࣗͰVOTVCTDSJCF͠ͳ͍ͱϦʔ Ϋ͢Δɻ public interface Observer {
/** * Notifies the Observer that the {@link Observable} has finished sending push-based notifications. * * The {@link Observable} will not call this method if it calls {@link #onError}. */ void onCompleted();
/** * Notifies the Observer that the {@link Observable} has experienced an error condition. * * If the {@link Observable} calls this method, it will not thereafter call {@link #onNext} or * {@link #onCompleted}. * * @param e * the exception encountered by the Observable */ void onError(Throwable e);
/** * Provides the Observer with a new item to observe. * * The {@link Observable} may call this method 0 or more times. * * The {@code Observable} will not call this method again after it calls either {@link #onCompleted} or * {@link #onError}. * * @param t * the item emitted by the Observable */ void onNext(T t);
private val subscriptions = CompositeSubscription() override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
val view = inflater.inflate(R.layout.fragment_rx_sample, container, false)
// ֤ೖྗཝͷObservableΛऔಘ val observableName = RxTextView.textChanges(view.findViewById(R.id.edit_order_name) as AppCompatEditText) val observablePostalCode = RxTextView.textChanges(view.findViewById(R.id.edit_order_postal_code) as AppCompatEditText) val observableAddressFirst = RxTextView.textChanges(view.findViewById(R.id.edit_order_address_first) as AppCompatEditText) val observableAddressSecond = RxTextView.textChanges(view.findViewById(R.id.edit_order_address_second) as AppCompatEditText)
// ButtonΛऔಘ val submitButton = view.findViewById(R.id.button_rx_submit) as AppCompatButton submitButton.isEnabled = false