Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
apply from: "https://raw.githubusercontent.com/lizhangqu/common-gradle/master/common_version.gradle"
apply from: "https://raw.githubusercontent.com/lizhangqu/common-gradle/master/common_function.gradle"
ext {
global_compileSdkVersion = 31
global_minSdkVersion = 21
global_targetSdkVersion = 31
}
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:2.2.3"
classpath "com.github.dcendents:android-maven-gradle-plugin:1.5"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath "com.android.tools.build:gradle:4.0.2"
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
}
}

apply from: "https://raw.githubusercontent.com/lizhangqu/common-gradle/master/common_version.gradle"
apply from: "https://raw.githubusercontent.com/lizhangqu/common-gradle/master/common_function.gradle"


allprojects {
repositories {
google()
jcenter()
}
}
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android.enableJetifier=true
android.useAndroidX=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Sep 02 17:13:59 CST 2015
#Tue Mar 29 22:39:49 ICT 2022
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip
10 changes: 3 additions & 7 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion global_compileSdkVersion
buildToolsVersion global_buildToolsVersion

defaultConfig {
minSdkVersion global_minSdkVersion
Expand All @@ -20,10 +19,7 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.squareup.okhttp3:okhttp:${global_okhttpVersion}"
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13.2'
implementation "com.squareup.okhttp3:okhttp:4.9.3"
}

apply from: "https://raw.githubusercontent.com/lizhangqu/common-gradle/master/artifact_release.gradle"

8 changes: 4 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion global_compileSdkVersion
buildToolsVersion global_buildToolsVersion

defaultConfig {
applicationId "io.github.lizhangqu.sample"
Expand All @@ -20,7 +19,8 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${global_androidSupportVersion}"
compile project(':library')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation project(':library')
implementation "com.squareup.okhttp3:okhttp:4.9.3"
}
35 changes: 4 additions & 31 deletions sample/src/main/java/io/github/lizhangqu/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package io.github.lizhangqu.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
Expand All @@ -26,7 +26,6 @@

import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import io.github.lizhangqu.coreprogress.ProgressHelper;
import io.github.lizhangqu.coreprogress.ProgressUIListener;
Expand All @@ -43,11 +42,6 @@
import okio.Okio;

public class MainActivity extends AppCompatActivity {
private static final OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(1000, TimeUnit.MINUTES)
.readTimeout(1000, TimeUnit.MINUTES)
.writeTimeout(1000, TimeUnit.MINUTES)
.build();
private Button upload, download;
private TextView uploadInfo, downloadInfo;
private ProgressBar uploadProgress, downloadProgeress;
Expand Down Expand Up @@ -86,7 +80,7 @@ private void upload() {
uploadInfo.setText("start upload");
String currentApkPath = getApplicationContext().getPackageResourcePath();
File apkFile = new File(currentApkPath);
String url = "http://www.baidu.com";
String url = "https://www.baidu.com";

OkHttpClient okHttpClient = new OkHttpClient();
Request.Builder builder = new Request.Builder();
Expand All @@ -96,27 +90,6 @@ private void upload() {
bodyBuilder.addFormDataPart("test", apkFile.getName(), RequestBody.create(null, apkFile));
MultipartBody build = bodyBuilder.build();

//callback in original thread.
// ProgressListener progressListener = new ProgressListener() {
//
// //if you don't need this method, don't override this methd. It isn't an abstract method, just an empty method.
// @Override
// public void onProgressStart(long totalBytes) {
// super.onProgressStart(totalBytes);
// }
//
// @Override
// public void onProgressChanged(long numBytes, long totalBytes, float percent, float speed) {
//
// }
//
// //if you don't need this method, don't override this methd. It isn't an abstract method, just an empty method.
// @Override
// public void onProgressFinish() {
// super.onProgressFinish();
// }
// };

RequestBody requestBody = ProgressHelper.withProgress(build, new ProgressUIListener() {

//if you don't need this method, don't override this methd. It isn't an abstract method, just an empty method.
Expand Down Expand Up @@ -170,7 +143,7 @@ public void onResponse(Call call, Response response) throws IOException {

private void download() {
uploadInfo.setText("start download");
String url = "http://assets.geilicdn.com/channelapk/1000n_shurufa_1.9.6.apk";
String url = "https://speed.hetzner.de/100MB.bin";

OkHttpClient okHttpClient = new OkHttpClient();
Request.Builder builder = new Request.Builder();
Expand Down Expand Up @@ -223,7 +196,7 @@ public void onUIProgressFinish() {

BufferedSource source = responseBody.source();

File outFile = new File("sdcard/temp.apk");
File outFile = new File(getFilesDir(), "temp.bin");
outFile.delete();
outFile.getParentFile().mkdirs();
outFile.createNewFile();
Expand Down