1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/shper-OkHttpPan

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать

A permissive license whose main conditions require preservation of copyright and license notices. Contributors provide an express grant of patent rights. Licensed works, modifications, and larger works may be distributed under different terms and without source code.

Permissions
  • Commercial use
  • Modification
  • Distribution
  • Patent use
  • Private use
Limitations
  • Trademark use
  • Liability
  • Warranty
Conditions
  • License and copyright notice
  • State changes
README.md 2.7 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
gitlife-traslator Отправлено 27.11.2024 19:21 b50e9a0

OkHttpPan

OkHttpPan — это сетевой уровень запросов, который включает в себя OkHttp и FastJson, и следует шаблону проектирования «Строитель».

Пример

  1. Инициализация и настройка OkHttpPan в приложении:

        // Инициализация OkHttpPan
        OkHttpPan.initialization();

    Или:

       // Конфигурация Response-парсера, таймаутов (информация о конфигурации опциональна)
       OkHttpPanConfig config = new OkHttpPanConfig.Builder()
           .responseParser(new ResponseParser)
           .readTimeout(15)
           .readTimeout(25)
           .writeTimeout(35)
           .Build();
      // Инициализация OkHttpPan
      OkHttpPan.initialization(config);
      // Включение debug-лога
       OkHttpPan.setDebug(true);
  2. Вызов:

  • Общие параметры имеют приоритет над конфигурацией OkHttpPanConfig:

    .responseParser(responseParser)
    .connectTimeout(int)
    .readTimeout(int)
    .writeTimeout(int)
    .build().enqueue(<$Entity>.class, callback);
  • Запрос get:

    OkHttpPan.get()
        .url(URL)
        .params("XXO", xxo)
        .build().execute(Object.class, callback);
  • Запрос post:

    OkHttpPan.post()
        .url(URL)
        .params("XXO", xxO)
        .build().execute(Object.class, callback);
  • Запрос upload:

    OkHttpPan.upload()
        .url(URL)
        .files("Key", Map<String, File> files)
        .build().execute(Object.class, callback);
  • Запрос download:

    OkHttpPan.download()
        .url(URL)
        .savePath(String savePath)
        .saveFileName(String saveFileName)
        .build().execute(Object.class, callback);

Более подробные примеры можно найти в исходном коде >> OkHttpPanDemo.

Лицензия

Copyright 1999-2017 Shper.cn Holding Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/shper-OkHttpPan.git
git@api.gitlife.ru:oschina-mirror/shper-OkHttpPan.git
oschina-mirror
shper-OkHttpPan
shper-OkHttpPan
master