Upgrade to Pro — share decks privately, control downloads, hide ads and more …

お金🤑をかけずにフィードバックフォームを構築しちゃう💪お話

ayatk
March 31, 2018

 お金🤑をかけずにフィードバックフォームを構築しちゃう💪お話

Google Formsでフィードバックフォームを作っちゃおうってお話を2018年3月31日のLT会でやりました

ayatk

March 31, 2018
Tweet

More Decks by ayatk

Other Decks in Programming

Transcript

  1. URLղઆͷίʔφʔ • ΫΤϦύϥϝʔλ • entry.xxxxͱ͸ͳΜͳͷ͔ • ֤ೖྗϑΥʔϜΛද͢ID • ׂͱϥϯμϜͬΆ͍ •

    DevToolͰɺinputλάͷnameΛݟͯ΋֬ೝ͕Ͱ͖Δ • entry.xxxxʹೖΕ͍ͨจࣈྻ΍બ୒ࢶͷจࣈྻΛURLΤϯίʔυͯ͠ ϦΫΤετΛ౤͛Δͱ͍͍ײ͡ʹͰ͖Δ
  2. Service Interface interface FormService { @POST(“/forms/d/e/<Google-form-ID>/formResponse”) @FormUrlEncoded fun postForm( @Field("entry.2091053327")

    hoge: String, @Field("entry.682069554") huga: String, // ద౰ʹIDݟͳ͕Β૿΍ͯ͠ཉ͍͠ ..... ): Single<Response<Void>> }
  3. Form Client object FormClient { val service: FormService = Retrofit

    .Builder() .client(OkHttpClient.Builder().build()) .baseUrl("https://docs.google.com/") .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .build() .create(FormService::class.java) }
  4. Main Activity override fun onCreate() { RxTextView.textChanges(form) .map { it.isNotBlank()

    } .subscribe({ submit.isEnabled = it }) submit.setOnClickListener { FormClient.service .postForm(form.text.toString()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ /* ͳΜ͔৭ʑ͢Δ */}) .addTo(compositeDisposable) } }