Skip to content

Commit d7b9ab9

Browse files
committed
first commit
1 parent 381e167 commit d7b9ab9

File tree

27 files changed

+897
-0
lines changed

27 files changed

+897
-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

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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
6+
dependencies {
7+
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
8+
}
9+
}
10+
11+
// Required because retrolambda is on maven central
12+
repositories {
13+
mavenCentral()
14+
}
15+
16+
apply plugin: 'com.android.application'
17+
apply plugin: 'me.tatarka.retrolambda'
18+
19+
dependencies {
20+
compile fileTree(dir: 'libs', include: ['*.jar'])
21+
compile "com.android.support:appcompat-v7:25.3.1"
22+
compile "com.android.support:multidex:1.0.1"
23+
24+
//无需引入tinker的任何库,使用tinkerpatch sdk即可
25+
compile("com.tinkerpatch.sdk:tinkerpatch-android-sdk:${TINKERPATCH_VERSION}") { changing = true }
26+
compile "io.reactivex.rxjava2:rxjava:2.1.0"
27+
}
28+
29+
android {
30+
compileSdkVersion 25
31+
buildToolsVersion "25.0.2"
32+
33+
signingConfigs {
34+
debug {
35+
storeFile rootProject.file("keystore/debug.keystore")
36+
}
37+
}
38+
39+
defaultConfig {
40+
applicationId "com.tinkerpatch.easy_sample_rxjava2"
41+
minSdkVersion 15
42+
targetSdkVersion 22
43+
versionCode 1
44+
versionName "1.0"
45+
multiDexEnabled true
46+
}
47+
48+
buildTypes {
49+
release {
50+
minifyEnabled true
51+
proguardFiles getDefaultProguardFile('proguard-android.txt')
52+
signingConfig signingConfigs.debug
53+
}
54+
debug {
55+
debuggable true
56+
minifyEnabled false
57+
signingConfig signingConfigs.debug
58+
}
59+
}
60+
compileOptions {
61+
targetCompatibility 1.8
62+
sourceCompatibility 1.8
63+
}
64+
}
65+
66+
apply from: 'tinkerpatch.gradle'
67+
68+
configurations.all {
69+
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
70+
}

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.easy_sample_rxjava2"
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
5+
<application
6+
android:name="com.tinkerpatch.easy_sample_rxjava2.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.easy_sample_rxjava2.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.easy_sample_rxjava2;
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)