åæ Retrofit + RxJavaã使ã£ãAPIéä¿¡æã«ãããã©ã«ãã§ã¯HTTP 200çªå°ä»¥å¤ã®ã¹ãã¼ã¿ã¹ã³ã¼ãã¯ã¨ã©ã¼ã¨ã㦠onError(throwable) ã«æ¸¡ã£ã¦ããã ãã®å ´å㯠retrofit2.HttpException åã«ãªã£ã¦ãããããonError å 㧠if (throwable instanceof HttpException) ããã°åå¥ã«ãã³ããªã³ã°å¯è½ã§ããããããã使ãããããã©ããã¯è°è«ã®ä½å°ãããããã«æãã å人çã«ã¯ããªã«ããªä¸è½ãªã¨ã©ã¼ï¼ãã¨ãã°ãµã¼ããã¦ã³ããããã¯ã¼ã¯ä¸éï¼ä»¥å¤ã¯ onNext ã§åãåãããã 1 çç±ã¯2ã¤ãã£ã¦ã onErrorã«ããã¨ãã®Observableã¯çµäºããã®ã§ RxBinding + REST ã®çµã¿åããã®ãããªObservableã¨ç¸æ§ãè¯ããªãã ã¨ã©ã¼çç±ãJSONã§è¿ãAPIã¯ãã§ã
å®ç¨çãªã©ã¤ãã©ãªãKotlin交ãã¦ç´¹ä»ãããããã¸ã§ã¯ãï¼ ä»åã¯APIã³ã¼ã«ãç°¡åã«æ¸ããã¨ãã§ããRetrofit2ãç´¹ä»ãã¾ãã ã¡ãªã¿ã«ä»åã¯Jsonãèªåçã«ã¯ã©ã¹ã¸å¤æãã¦ãããã©ã¤ãã©ãªã¨ãã¦Gsonãå©ç¨ãã¾ãã ã¾ããä»åã®å®è£ ä¾ã¯ãã¡ãã«PRãä½ã£ã¦ããã®ã§ããããããã°åèã«ã©ãã https://github.com/HoNKoT/KotlinAndroidDatabindingSample/pull/3 Retrofit2 "A type-safe HTTP client for Android and Java" ã¨å ¬å¼ãµã¤ãã«è¬³ããã¦ããã¨ãããç°¡åã«APIã³ã¼ã«ããããã®ã©ã¤ãã©ãªã§ãã ã¾ããããã¯ã°ã©ã¦ã³ãã§è¡ãªã£ã¦ã³ã¼ã«ããã¯ãæå®ãããã¨ãç°¡åã«ã§ãã¾ãã å ¬å¼ãµã¤ã 使ãæ¹ ä½¿ãæ¹ã¯è³ã£ã¦ã·ã³ãã« gradle interfaceå®è£ Http
All slide content and descriptions are owned by their creators.
I want to fetch XML data from API and map it to Kotlin model object by using Retrofit2 + SimpleXML in Kotlin. However, I got such as the following error message from SimpleXML. org.simpleframework.xml.core.MethodException: Annotation @org.simpleframework.xml.Element(data=false, name=, required=true, type=void) must mark a set or get method This is fetched XML data <?xml version="1.0" encoding="UTF
åæ ãã¾åå ãã¦ããããã¸ã§ã¯ãã®ãããã¯ã¼ã¯éä¿¡é¨åãå¤§å¹ ã«æ¸ãæããå¿ è¦ãããã次ã®ãããªçç±ããRxJavaã®æ¡ç¨ãæ¤è¨ããã è¤æ°ã®APIå¼ã³åºãã並è¡ã§ãã£ããå¾ ã¡åããã¦é次å¦çããã使ãåããå¿ è¦ããã è¤éãªä¸é£ã®å¼ã³åºãããªãã©ã¤ãã¨ã©ã¼ãã³ããªã³ã°ãèæ ®ãã¦æ¸ããã¨ãç°¡åã«ã§ããã å社ã®æ¡ç¨å®ç¸¾ããæãã¨ã©ã¾ãçç±ããªã çè ã¯RxJava(1)ãæ¥åã§ä½¿ã£ããã¨ããã RxJavaã§æ¸ãç´ããçµæãããã®è¦æ±ãé常ã«ç°¡åã«æºãããã¨ãã§ããããä¸æ £ããªã¡ã³ãã¼ã«ã¯ããã¤éåæå¦çãéå§ãããã®ãåããã«ããããã¨ãå¤æããã æ¬ããã¥ã¡ã³ãã¯å ã 社å Qiita Teamã«æ¸ãå§ãããã®ã§ããããä¸ã®ä¸ã®åããããªãã¼ã ã«ãçãããããç¥ããªãã¨èãå ¬éãããã¨ã«ããã ãªããç¾å¨RxJavaã¯ãã¼ã¸ã§ã³2ãªã®ã§ã¨ãã«æããªãRxJava2ï¼2017å¹´6ææç¹ã®ææ°
ã¾ããã Kotlinã§Andridéçºã¯æ§ããã«ãã£ã¦ã æé« ã§ãã Androidã§APIãå©ãæã«ã¯ãOkHttp + Retrofit + RxJavaãå®çªã«ãªã£ã¦ããã¨æãã¾ãã Koltinã®åãæã£ã¦ããã°ãRxJavaã使ãããCoroutinesã使ããã¨ã§ã幸ããªéçºãå¾ ã£ã¦ããããããã¾ããã 注æï¼Kotlin 1.1.xã§ã¯ãCoroutinesã¯ãexperimentalæ©è½ã§ããå®é¨çãªæ©è½ã§ãã®ã§ããªãªã¼ã¹ãããã¾ã§ã¯ããããã¯ãã«ãããªãã»ããç¡é£ã§ã RxJavaçã¨Coroutinesçã®æ¯è¼ ãã£ã¨ã·ã³ãã«ãªå ·ä½ä¾ã®ã»ããããã£ããã©ãããã¾ãããMVPæ§æã§ã®å ·ä½ä¾ã«ãªãã¾ããããã RxJavaç interface GithubApi { @GET("users/{user}") fun user(@Path("user") user: S
class Response{ @SerializedName("val") val val<Val>? = null } ã£ã¦ããã¢ãã«ã ã¨ãã¾ããããªããå½¢å¼ãç°ãªãã®ã§ã¨ã©ã¼ã«ãªãã ããã§JsonDeserializerã使ãã 以ä¸ã®ããã«jsonMappingã®ã¿ã¤ãã³ã°ã§ãªãããããã class ValRequestDeserializer:JsonDeserializer<Response>{ override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): Response { // ããã§jsonãé åããªãã¸ã§ã¯ããå¤å®ãã¦é åã«ãªããããã return context!!.deserialize(json, Response::c
Itâs been more than two years since I wrote this post about MVVM, RxJava and Retrofit. It seems a bit old-fashioned to me right now. Itâs surprising how much you can learn in one year! You take a look back and you might be embarrassed by your own code. Not only the code itself but also the process of how you get there. All that seems legacy code to me. In this article, Iâm going to try to improve
ã©ããï¼ã¹ãã¼ããã©ã³ã¢ããªãã¼ã ã®å²©ç°ã§ãï¼ IoTLT Advent Calendar 2016ã®15æ¥ç®ã®è¨äºã§ãã æè¿ã社å ã«å°å ¥ããã¦ããSlackã®çµµæåã追å ãããã¨ãå°ããªæ¥½ãã¿ã«ãªã£ã¦ãã¾ããååã®è¨äºã§æ¸å¿µãã¦ããå¥åº·è¨ºæã¯è¡å§ãé«ãã«ãªãããã ã¨ãããã¨ããã®å ´ãåãã¦ãå ±åããã¦ããã ãã¾ãã ä»åã¯å°ãæ¥åããé¢ãã¦ã社å LT大ä¼ãIoTLTã§çºè¡¨ãããMinecraft x IoTãã®è£è¶³è¨äºãæ¸ãã¦ããã¾ãã çºè¡¨ãè¦ã¦ããªãæ¹ã¯SlideShareã«ã¦è³æãå ±æãã¦ãã¾ãã®ã§ä¸èªãã¦ããã ããã¨å¹¸ãã§ãã IoTãé§ä½¿ãã¦ã²ã¼ã ã®ä¸çã¨ç¾å®ã®ä¸çãçµã¿åãããæ°ããMinecraftã®éã³æ¹ãç´¹ä»ãã¦ããããã¨æãã¾ãã 使ããã® ãã£ããæ°ããéã³æ¹ãå®ç¾ããããã«å¿ è¦ãªãã®ãã¡ãç´¹ä»ãã¾ãã Minecraft PCç Wio Node ãã¿ã³ LED
I'm trying to get the exact JSON that is being sent in the request. Here is my code: OkHttpClient client = new OkHttpClient(); client.interceptors().add(new Interceptor(){ @Override public com.squareup.okhttp.Response intercept(Chain chain) throws IOException { Request request = chain.request(); Log.e(String.format("\nrequest:\n%s\nheaders:\n%s", request.body().toString(), request.headers())); com
2018/11/29 è¿½è¨ UTF-8 以å¤ã®æåã³ã¼ã㧠POST / PUT ãè¡ãæ¹æ³ã追è¨ãã¾ããã RxJava 2.x ç¨ã® CallAdapter ã追è¨ãã¾ããã åæ¸ã æè¿Retrofitã使ããã¨ããã£ããã§ãããã¤ã³ãããã¯ã·ã§ã³ãã¡ããã£ã¨èªãã ãããã ã¨ããããã¼ãªã®ï¼ãã¨æããããªäºè±¡ã«ä½åº¦ãè¦èãããã®ã§ãã¡ã¢ãã¦ããã¾ãã API ã®è¨å® HTTP ã¡ã½ããããã¹ãã¯ã¨ãªããã©ã¡ã¼ã¿ãªã©ãé©å½ã«ä½ã£ãã¤ã³ã¿ã¼ãã§ã¼ã¹ã¨ã¢ããã¼ã·ã§ã³ã§è¡¨ç¾ãã¾ãã public interface GitHubService { @GET("users/{user}/repos") Call<List<Repo>> listRepos(@Path("user") String user); } ãã¼ã¹ã¨ãªã URL ã¯Retrofit.Builder#baseUrlã§æ¸¡ãã®
class HatenaOAuthManager(private val consumerKey: String, private val consumerSecret: String) { companion object { private val REQUEST_TOKEN_ENDPOINT_URL = "https://www.hatena.com/oauth/initiate" private val ACCESS_TOKEN_ENDPOINT_URL = "https://www.hatena.com/oauth/token" private val AUTHORIZATION_WEBSITE_URL = "https://www.hatena.ne.jp/touch/oauth/authorize" val AUTHORIZATION_DENY_URL = "$AUTHORI
Retrofit2 ç¾æç¹ã§ã¯2.0.0-beta1ãææ°ã§ãã Callã¢ããã¿ã¨ãããã®ã追å ããã¦ãã¾ãã以ä¸ã®ãããªç¹å¾´ãããããã§ãã ãã以å¤ã«Dynamic URL,Dynamic Query Paramã便å©ããã§ãã Simple HTTP with Retrofit 2 (Droidcon NYC 2015) by Jake Wharton Call encapsulates single request/response interaction Models a single request/response pair Separates request creation from response handling Each instance can only be used once.. ...instances can be cloned Supports bo
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}