All Projects → jenly1314 → BaseUrlManager

jenly1314 / BaseUrlManager

Licence: MIT license
⛵ BaseUrlManager的设计初衷主要用于开发时,有多个环境需要打包APK的场景,通过BaseUrlManager提供的BaseUrl动态设置入口,只需打一次包,即可轻松随意的切换不同的开发环境或测试环境。在打生产环境包时,关闭BaseUrl动态设置入口即可。

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to BaseUrlManager

carina
Carina automation framework: Web, Mobile, API, DB etc testing...
Stars: ✭ 652 (+1416.28%)
Mutual labels:  test, testing-tools
scalatest-junit-runner
JUnit 5 runner for Scalatest
Stars: ✭ 30 (-30.23%)
Mutual labels:  test, testing-tools
PixelTest
Fast, modern, simple iOS snapshot testing written purely in Swift.
Stars: ✭ 56 (+30.23%)
Mutual labels:  test, testing-tools
Junit Dataprovider
A TestNG like dataprovider runner for JUnit with many additional features
Stars: ✭ 226 (+425.58%)
Mutual labels:  test, testing-tools
eaf-linter
🤪 A linter, prettier, and test suite that does everything as-simple-as-possible.
Stars: ✭ 17 (-60.47%)
Mutual labels:  test, testing-tools
mock-hls-server
Fake a live/event HLS stream from a VOD one. Useful for testing. Supports looping.
Stars: ✭ 61 (+41.86%)
Mutual labels:  test, testing-tools
playwright-test
Run unit tests with several runners or benchmark inside real browsers with playwright.
Stars: ✭ 81 (+88.37%)
Mutual labels:  test, testing-tools
Mocktopus
Mocking framework for Rust
Stars: ✭ 179 (+316.28%)
Mutual labels:  test, testing-tools
generator-react-jest-tests
A React Jest test generator. Generates snapshot tests for React components.
Stars: ✭ 34 (-20.93%)
Mutual labels:  test, testing-tools
Orion-Stress-Tester
A simple, efficient and accurate stress tester, support HTTP, WebSocket and TCP
Stars: ✭ 32 (-25.58%)
Mutual labels:  test, testing-tools
IO-TESTER
A functional test framework
Stars: ✭ 32 (-25.58%)
Mutual labels:  test, testing-tools
Telegraf-Test
Telegraf Test - Simple Test ToolKit of Telegram Bots
Stars: ✭ 22 (-48.84%)
Mutual labels:  test, testing-tools
Fsharp Hedgehog
Release with confidence, state-of-the-art property testing for .NET.
Stars: ✭ 219 (+409.3%)
Mutual labels:  test, testing-tools
eat
Json based scenario testing tool(which can have test for functional and non-functional)
Stars: ✭ 41 (-4.65%)
Mutual labels:  test, testing-tools
Hitchhiker
a Restful Api test tool
Stars: ✭ 2,175 (+4958.14%)
Mutual labels:  test, testing-tools
threat9-test-bed
No description or website provided.
Stars: ✭ 26 (-39.53%)
Mutual labels:  test, testing-tools
Nsubstitute
A friendly substitute for .NET mocking libraries.
Stars: ✭ 1,646 (+3727.91%)
Mutual labels:  test, testing-tools
Swagger meqa
Auto generate and run tests using swagger/OpenAPI spec, no coding needed
Stars: ✭ 151 (+251.16%)
Mutual labels:  test, testing-tools
laika
Log, test, intercept and modify Apollo Client's operations
Stars: ✭ 99 (+130.23%)
Mutual labels:  test, testing-tools
api-test
🌿 A simple bash script to test JSON API from terminal in a structured and organized way.
Stars: ✭ 53 (+23.26%)
Mutual labels:  test, testing-tools

BaseUrlManager

Download MavenCentral JCenter JitPack CI CircleCI API License Blog QQGroup

BaseUrlManager for Android 的设计初衷主要用于开发时,有多个环境需要打包APK的场景,通过BaseUrlManager提供的BaseUrl动态设置入口,只需打一 次包,即可轻松随意的切换不同的开发环境或测试环境。在打生产环境包时,关闭BaseUrl动态设置入口即可。

妈妈再也不用担心因环境不同需要打多个包的问题,从此告别环境不同要写一堆配置的烦恼,真香。

配合 RetrofitHelper 动态改变BaseUrl一起使用更香。

Gif 展示

Image

引入

Gradle:

  1. 在Project的 build.gradle 里面添加远程仓库
allprojects {
    repositories {
        //...
        mavenCentral()
    }
}
  1. 在Module的 build.gradle 里面添加引入依赖项
//AndroidX 版本
implementation 'com.github.jenly1314:base-url-manager:1.2.0'

以前发布至JCenter的版本

//AndroidX 版本
implementation 'com.king.base:base-url-manager:1.1.1'

//-----------------------v1.0.x以前的版本
//AndroidX 版本
implementation 'com.king.base:base-url-manager:1.0.1-androidx'

//Android Support 版本
implementation 'com.king.base:base-url-manager:1.0.1'

示例

集成步骤代码示例 (示例出自于app中)

Step.1 在您项目中的AndroidManifest.xml中通过配置meta-data来自定义全局配置

    <!-- 在你项目中添加注册如下配置 -->
    <activity android:name="com.king.base.baseurlmanager.BaseUrlManagerActivity"
        android:screenOrientation="portrait"
        android:theme="@style/BaseUrlManagerTheme"/>

Step.2 在您项目Application的onCreate方法中初始化BaseUrlManager

    //获取BaseUrlManager实例(适用于v1.1.x版本)
    mBaseUrlManager = BaseUrlManager.getInstance();

    //获取BaseUrlManager实例(适用于v1.0.x旧版本)
    mBaseUrlManager = new BaseUrlManager(this);

    //获取baseUrl
    String baseUrl = mBaseUrlManager.getBaseUrl();

Step.3 提供动态配置BaseUrl的入口(通过Intent跳转到BaseUrlManagerActivity界面)

v.1.1.x 新版本写法

   BaseUrlManager.getInstance().startBaseUrlManager(this,SET_BASE_URL_REQUEST_CODE);

v1.0.x 以前版本写法

    Intent intent = new Intent(this, BaseUrlManagerActivity.class);
    //BaseUrlManager界面的标题
    //intent.putExtra(BaseUrlManagerActivity.KEY_TITLE,"BaseUrl配置");
    //跳转到BaseUrlManagerActivity界面
    startActivityForResult(intent,SET_BASE_URL_REQUEST_CODE);

Step.4 当配置改变了baseUrl时,在Activity或Fragment的onActivityResult方法中重新获取baseUrl即可

    //方式1:通过BaseUrlManager获取baseUrl
    String baseUrl = BaseUrlManager.getInstance().getBaseUrl();
    //方式2:通过data直接获取baseUrl
    UrlInfo urlInfo = BaseUrlManager.parseActivityResult(data);
    String baseUrl = urlInfo.getBaseUrl();

更多使用详情,请查看app中的源码使用示例或直接查看API帮助文档

版本记录

v1.2.0:2022-1-25 (从v1.2.0开始发布至 MavenCentral)

  • 优化细节

v1.1.1:2021-1-28

  • 新增支持长按复制相关功能

v1.1.0:2020-12-4

  • 输入的url支持正则校验
  • 后续版本只支持androidx,版本名称不再带有androidx标识

v1.0.1:2019-7-5

  • 移除strings.xml资源中的app_name
  • 支持不依赖刷新数据,直接通过onActivityResult获取baseUrl信息

v1.0.0:2019-6-11 支持AndroidX版本

  • BaseUrlManager初始版本

赞赏

如果您喜欢BaseUrlManager,或感觉BaseUrlManager帮助到了您,可以点右上角“Star”支持一下,您的支持就是我的动力,谢谢 😃

您也可以扫描下面的二维码,请作者喝杯咖啡

关于我

Name: Jenly

Email: jenly1314#gmail.com / jenly1314#vip.qq.com

CSDN: jenly121

CNBlogs: jenly

GitHub: jenly1314

Gitee: jenly1314

加入QQ群: 20867961

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].