Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.ShanDianDev:SDCoreSimple:'
}
dependencies {
implementation("com.github.ShanDianDev:SDCoreSimple:")
}
<dependency>
<groupId>com.github.ShanDianDev</groupId>
<artifactId>SDCoreSimple</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.ShanDianDev" % "SDCoreSimple" % ""
:dependencies [[com.github.ShanDianDev/SDCoreSimple ""]]
#### get请求,url = http://douban.api/6548683?no=122
<pre> HashMap<String, String> map = new HashMap<>();//参数 map.put("no","122"); RetrofitService.newBuilder(MainActivity.this);//创建配置类,MainActivity.this为当前activity的上下文 .showLoading(true)//是否显示加载框(默认显示) .loadType(RetrofitService.LOADTYPE.CIRCLE)//加载框类型(圆形和水平进度条) .baseUrl(SDCore.getInstance().getBaseUrl())//设置baseUrl(默认为SDCore中设置的url) .connectTimeout(10) //连接超时时间 .readTimeout(10)//读取超时时间 .writeTimeout(10)//写入超时时间 .showToast(true)//是否显示错误提示(默认显示) .build()//配置类完成 .getRequest(new JsonCallBack() { @Override public void onSuccess(JSONObject dataInfo) { if (dataInfo != null) { tv.setText(dataInfo.toString()); } } @Override public void onError(String message) { } }, "6548683", map);//get请求,JsonCallBack结果回调,"6548683"为拼接在url后面的,map为参数 </pre>