Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] Re: Duvida chama retrofit

Legal Cabral vou olha ela também, obrigado.

2017-11-14 12:59 GMT-02:00 Duanniston Cardoso Cabral <duanniston@gmail.com>:
Essa lib também ajuda bastante no debug, https://github.com/jgilfelt/chuck

Mas você não deve usar mais de uma instancia do retrofit. 

Em 8 de novembro de 2017 21:27, Tiago Grillo <tijgrillo@gmail.com> escreveu:
Legal Pedro boa dica, também achei este app no github https://github.com/OBrunoVieira/Bippples

também estou estudando o font dele e lá ele faz o log,

obrigado.

2017-11-08 10:26 GMT-02:00 pedrofsn <pedrokra@gmail.com>:
Bom dia,

Não sei como resolver seu problema, acredito que terá que investigar mesmo.
Minha sugestão é que no objeto do OkHttpClient que você está instanciando, adicione um interceptor pra fazer o log das requisições (pra facilitar na análise).

Ex.:
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging
.setLevel(HttpLoggingInterceptor.Level.BODY);
builder
.addInterceptor(logging);

Referente a lib
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'

Deixe este bloco de código do interceptor rodar apenas em modo de debug, similiar a isto:
(isModoDeDebug) ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE


Assim você garante que ninguém vai ver seus logs em produção com tanta facilidade hehehe.

Tendo os logs rodando, você vai conseguir entender porque este problema está ocorrendo, no meu palpite.



Em terça-feira, 7 de novembro de 2017 17:07:50 UTC-2, Tiago J. Grillo escreveu:
Olá,

    Estou enfrentando uma dificuldade com minhas chamadas para o servidor.

    O primeiro é que em alguns momentos a conexão parece que se perde e fica lenta (sinal do wifi não oscila)

    O segundo é que ele se perde a ponto de ter que desativar o wifi e ter que ativa-lo novamente para voltar.

    Meu cliente é um restaurante e tem muito movimento, ou seja, muitas chamadas ao server.

    Isto é intermitente.

    Eu sempre crio uma nova instância do Retrofit

    Pesquisando fiz alguns customizações no Okhttp, vejam como eu chamo:

Type listType = new TypeToken<List<Fila>>() {
}.getType();

Gson gson = new GsonBuilder()
.setLenient()
.registerTypeAdapter(listType, new JsonArrayDeserializer())
.create();

Retrofit retrofit = new Retrofit
.Builder()
.baseUrl(myPrefs.ipi1().get() + JRS_FILA)
.addConverterFactory(GsonConverterFactory.create(gson))
.client(new OkHttpClient()
.newBuilder()
.readTimeout(TIME_OUT, TimeUnit.SECONDS)
.writeTimeout(TIME_OUT, TimeUnit.SECONDS)
.connectTimeout(TIME_OUT, TimeUnit.SECONDS)
.protocols(Arrays.asList(Protocol.HTTP_1_1))
.build())
.build();

String json = gson.toJson(filas, listType);
FilaAPI filaAPI = retrofit.create(FilaAPI.class);
filaAPI.salvar(json).enqueue(

    Ta certo isto? Vocês tem alguma sugestão?

Obrigado,
Tiago J. Grillo

ps: o timeout para tudo esta 10s 

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário