Skip to content

Commit 55b2df0

Browse files
committed
first commit
0 parents  commit 55b2df0

29 files changed

+923
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild
10+
.idea

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: android
2+
jdk: oraclejdk8
3+
4+
cache:
5+
directories:
6+
- .autoconf
7+
- $HOME/.m2
8+
9+
android:
10+
components:
11+
- tools
12+
- tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943
13+
- platform-tools
14+
- build-tools-25.0.3
15+
- android-25
16+
- extra-android-m2repository
17+
18+
script: ./gradlew clean check test

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# tinkerpatch-easy-sample
2+
3+
[![Build Status](https://travis-ci.org/TinkerPatch/tinkerpatch-easy-sample.svg?branch=master)](https://travis-ci.org/TinkerPatch/tinkerpatch-easy-sample)
4+
[ ![Download](https://api.bintray.com/packages/simsun/maven/tinkerpatch-android-sdk/images/download.svg) ](https://bintray.com/simsun/maven/tinkerpatch-android-sdk/_latestVersion)
5+
[![Join Slack](https://slack.tinkerpatch.com/badge.svg)](https://slack.tinkerpatch.com)
6+
7+
无需修改自己App代码,一键接入的Sample
8+
9+
[相关文档](http://tinkerpatch.com/Docs/intro)

app/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/build
2+
3+
/version.properties

app/build.gradle

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
apply plugin: 'com.android.application'
2+
3+
dependencies {
4+
compile fileTree(dir: 'libs', include: ['*.jar'])
5+
compile "com.android.support:appcompat-v7:26.0.0"
6+
compile "com.android.support:multidex:1.0.2"
7+
8+
//无需引入tinker的任何库,使用tinkerpatch sdk即可
9+
compile("com.tinkerpatch.sdk:tinkerpatch-android-sdk:${TINKERPATCH_VERSION}") { changing = true }
10+
11+
// compile("com.tinkerpatch.sdk:tinkerpatch-okhttp3-loader:${TINKERPATCH_VERSION}") { changing = true }
12+
// compile "com.squareup.okhttp3:okhttp:$OKHTTP3_VERSION"
13+
// compile("com.tinkerpatch.sdk:tinkerpatch-okhttp-loader:${TINKERPATCH_VERSION}") { changing = true }
14+
// compile "com.squareup.okhttp:okhttp:$OKHTTP_VERSION"
15+
16+
compile ("com.tinkerpatch.tinker:tinker-android-lib:${TINKER_VERSION}") { changing = true }
17+
compile ("com.tinkerpatch.tinker:tinker-android-loader:${TINKER_VERSION}") { changing = true }
18+
compile ("com.tinkerpatch.tinker:aosp-dexutils:${TINKER_VERSION}") { changing = true }
19+
compile ("com.tinkerpatch.tinker:bsdiff-util:${TINKER_VERSION}") { changing = true }
20+
compile ("com.tinkerpatch.tinker:tinker-commons:${TINKER_VERSION}") { changing = true }
21+
}
22+
23+
android {
24+
compileSdkVersion 26
25+
buildToolsVersion "26.0.1"
26+
27+
signingConfigs {
28+
release {
29+
storeFile rootProject.file("keystore/Android.keystore")
30+
storePassword 'Wangpeiming110'
31+
keyAlias 'android.keystore'
32+
keyPassword 'Wangpeiming110'
33+
}
34+
35+
debug {
36+
storeFile rootProject.file("keystore/debug.keystore")
37+
}
38+
}
39+
40+
defaultConfig {
41+
applicationId "com.tinkerpatch.databinding"
42+
minSdkVersion 15
43+
targetSdkVersion 26
44+
versionCode 1
45+
versionName "1.0"
46+
multiDexEnabled true
47+
}
48+
49+
buildTypes {
50+
release {
51+
minifyEnabled true
52+
proguardFiles getDefaultProguardFile('proguard-android.txt')
53+
signingConfig signingConfigs.debug
54+
}
55+
debug {
56+
debuggable true
57+
minifyEnabled false
58+
signingConfig signingConfigs.debug
59+
}
60+
}
61+
62+
dataBinding {
63+
enabled = true
64+
}
65+
// productFlavors {
66+
// flavor1 {
67+
// applicationId 'com.tinkerpatch.databinding.flavor1'
68+
// }
69+
//
70+
// flavor2 {
71+
// applicationId 'com.tinkerpatch.databinding.flavor2'
72+
// }
73+
// }
74+
}
75+
76+
77+
apply from: 'tinkerpatch.gradle'
78+
79+
configurations.all {
80+
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
81+
}

app/src/main/AndroidManifest.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="com.tinkerpatch.databinding"
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
5+
<application
6+
android:name="com.tinkerpatch.databinding.SampleApplication"
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity android:name="com.tinkerpatch.databinding.MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN"/>
15+
16+
<category android:name="android.intent.category.LAUNCHER"/>
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package com.tinkerpatch.databinding;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.util.Log;
6+
import android.view.View;
7+
import android.widget.Button;
8+
9+
import com.tencent.tinker.lib.util.TinkerLog;
10+
import com.tencent.tinker.loader.shareutil.ShareTinkerInternals;
11+
import com.tinkerpatch.sdk.TinkerPatch;
12+
import com.tinkerpatch.sdk.server.callback.ConfigRequestCallback;
13+
14+
import java.util.HashMap;
15+
16+
public class MainActivity extends AppCompatActivity {
17+
private static final String TAG = "Tinker.MainActivity";
18+
19+
@Override
20+
protected void onCreate(Bundle savedInstanceState) {
21+
super.onCreate(savedInstanceState);
22+
setContentView(R.layout.activity_main);
23+
Log.e(TAG, "I am on onCreate classloader1:" + MainActivity.class.getClassLoader().toString());
24+
//test resource change
25+
Log.e(TAG, "I am on onCreate string:" + getResources().getString(R.string.test_resource));
26+
// Log.e(TAG, "I am on patch onCreate");
27+
28+
Button requestPatchButton = (Button) findViewById(R.id.requestPatch);
29+
30+
//immediately 为 true, 每次强制访问服务器更新
31+
requestPatchButton.setOnClickListener(new View.OnClickListener() {
32+
@Override
33+
public void onClick(View v) {
34+
TinkerPatch.with().fetchPatchUpdate(true);
35+
}
36+
});
37+
38+
Button requestConfigButton = (Button) findViewById(R.id.requestConfig);
39+
40+
//immediately 为 true, 每次强制访问服务器更新
41+
requestConfigButton.setOnClickListener(new View.OnClickListener() {
42+
@Override
43+
public void onClick(View v) {
44+
TinkerPatch.with().fetchDynamicConfig(new ConfigRequestCallback() {
45+
46+
@Override
47+
public void onSuccess(HashMap<String, String> configs) {
48+
TinkerLog.w(TAG, "request config success, config:" + configs);
49+
}
50+
51+
@Override
52+
public void onFail(Exception e) {
53+
TinkerLog.w(TAG, "request config failed, exception:" + e);
54+
}
55+
}, true);
56+
}
57+
});
58+
59+
Button cleanPatchButton = (Button) findViewById(R.id.cleanPatch);
60+
61+
cleanPatchButton.setOnClickListener(new View.OnClickListener() {
62+
@Override
63+
public void onClick(View v) {
64+
TinkerPatch.with().cleanAll();
65+
}
66+
});
67+
68+
Button killSelfButton = (Button) findViewById(R.id.killSelf);
69+
70+
killSelfButton.setOnClickListener(new View.OnClickListener() {
71+
@Override
72+
public void onClick(View v) {
73+
ShareTinkerInternals.killAllOtherProcess(getApplicationContext());
74+
android.os.Process.killProcess(android.os.Process.myPid());
75+
}
76+
});
77+
}
78+
79+
@Override
80+
protected void onResume() {
81+
Log.e(TAG, "I am on onResume");
82+
super.onResume();
83+
84+
}
85+
86+
@Override
87+
protected void onPause() {
88+
Log.e(TAG, "I am on onPause");
89+
super.onPause();
90+
}
91+
}

0 commit comments

Comments
 (0)