Skip to content

Commit c4685a6

Browse files
committed
Merge branch 'v1.2.2-pre'
2 parents d5a076c + e3f5be0 commit c4685a6

28 files changed

Lines changed: 573 additions & 70 deletions

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README-cn.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ placeholder效果状态页类似[ShimmerRecyclerView](https://github.com/sharish
230230
* :point_right: [常见问题](docs/FAQ-cn.md)
231231
* 📌 [更新日志](docs/changelog.md)
232232
* [最佳实践](docs/BestPractice-cn.md)
233+
<<<<<<< HEAD
233234
* [下个版本开发计划](docs/NextVersion.md)
235+
=======
236+
* [Next Version](docs/NextVersion.md)
237+
>>>>>>> v1.2.2-pre
234238
235239
## 代码混淆
236240

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ amazing. :ghost:
230230
* :point_right: [FAQ](docs/FAQ.md)
231231
* 📌 [Versions](docs/changelog.md)
232232
* [Best Practice](docs/BestPractice.md)
233+
<<<<<<< HEAD
233234
* [What Next Version Will Include?](docs/NextVersion.md)
235+
=======
236+
* [What Will Next Version Include?](docs/NextVersion.md)
237+
>>>>>>> v1.2.2-pre
234238
235239
## ProGuard
236240

app/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ dependencies {
3333
})
3434
testCompile 'junit:junit:4.12'
3535
compile project(':loadsir')
36+
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.4'
37+
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
38+
/*ButterKnife*/
39+
compile 'com.jakewharton:butterknife:8.8.1'
40+
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
3641
}

app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="sample.kingja.loadsir">
45

56
<application
@@ -9,13 +10,18 @@
910
android:label="@string/app_name"
1011
android:roundIcon="@mipmap/ic_launcher_round"
1112
android:supportsRtl="true"
12-
android:theme="@style/AppTheme">
13+
android:theme="@style/AppTheme"
14+
tools:replace="android:label">
1315
<activity android:name=".MainActivity">
1416
<intent-filter>
1517
<action android:name="android.intent.action.MAIN"/>
1618

1719
<category android:name="android.intent.category.LAUNCHER"/>
1820
</intent-filter>
21+
<<<<<<< HEAD
22+
=======
23+
24+
>>>>>>> v1.2.2-pre
1925
</activity>
2026
<activity android:name=".target.NormalActivity"/>
2127
<activity android:name=".target.ConvertorActivity"/>
@@ -24,6 +30,8 @@
2430
<activity android:name=".target.MultiFragmentWithViewPagerActivity"/>
2531
<activity android:name=".target.MultiFragmentActivity"/>
2632
<activity android:name=".target.PlaceholderActivity"/>
33+
<activity android:name=".target.AnimateActivity"/>
34+
<activity android:name=".target.KeepTitleActivity"/>
2735
</application>
2836

2937
</manifest>

app/src/main/java/sample/kingja/loadsir/App.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Application;
44

55
import com.kingja.loadsir.core.LoadSir;
6+
import com.squareup.leakcanary.LeakCanary;
67

78
import sample.kingja.loadsir.callback.CustomCallback;
89
import sample.kingja.loadsir.callback.EmptyCallback;
@@ -21,6 +22,8 @@ public class App extends Application {
2122
@Override
2223
public void onCreate() {
2324
super.onCreate();
25+
if (setupLeakCanary()) return;
26+
2427
LoadSir.beginBuilder()
2528
.addCallback(new ErrorCallback())
2629
.addCallback(new EmptyCallback())
@@ -30,4 +33,14 @@ public void onCreate() {
3033
.setDefaultCallback(LoadingCallback.class)
3134
.commit();
3235
}
36+
37+
private boolean setupLeakCanary() {
38+
if (LeakCanary.isInAnalyzerProcess(this)) {
39+
// This process is dedicated to LeakCanary for heap analysis.
40+
// You should not init your app in this process.
41+
return true;
42+
}
43+
LeakCanary.install(this);
44+
return false;
45+
}
3346
}

app/src/main/java/sample/kingja/loadsir/MainActivity.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import android.support.v7.app.AppCompatActivity;
66
import android.view.View;
77

8+
import sample.kingja.loadsir.target.AnimateActivity;
9+
import sample.kingja.loadsir.target.KeepTitleActivity;
810
import sample.kingja.loadsir.target.MultiFragmentActivity;
911
import sample.kingja.loadsir.target.FragmentSingleActivity;
1012
import sample.kingja.loadsir.target.NormalActivity;
@@ -41,19 +43,27 @@ public void inFragment(View view) {
4143
}
4244

4345
public void inView(View view) {
44-
startActivity(new Intent(this,ViewTargetActivity.class));
46+
startActivity(new Intent(this, ViewTargetActivity.class));
4547
}
4648

4749
public void inFragmentViewSirPager(View view) {
48-
startActivity(new Intent(this,MultiFragmentWithViewPagerActivity.class));
50+
startActivity(new Intent(this, MultiFragmentWithViewPagerActivity.class));
4951
}
5052

5153

5254
public void inFragmentMutil(View view) {
53-
startActivity(new Intent(this,MultiFragmentActivity.class));
55+
startActivity(new Intent(this, MultiFragmentActivity.class));
5456
}
5557

5658
public void showPlaceholder(View view) {
57-
startActivity(new Intent(this,PlaceholderActivity.class));
59+
startActivity(new Intent(this, PlaceholderActivity.class));
60+
}
61+
62+
public void animatCallback(View view) {
63+
startActivity(new Intent(this, AnimateActivity.class));
64+
}
65+
66+
public void titleBarActivity(View view) {
67+
startActivity(new Intent(this, KeepTitleActivity.class));
5868
}
5969
}

app/src/main/java/sample/kingja/loadsir/PostUtil.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sample.kingja.loadsir;
22

33
import android.os.Handler;
4+
import android.os.Looper;
45

56
import com.kingja.loadsir.callback.Callback;
67
import com.kingja.loadsir.core.LoadService;
@@ -15,20 +16,25 @@ public class PostUtil {
1516
public static final int DELAY_TIME = 1000;
1617

1718
public static void postCallbackDelayed(final LoadService loadService, final Class<? extends Callback> clazz) {
18-
new Handler().postDelayed(new Runnable() {
19+
postCallbackDelayed(loadService, clazz, DELAY_TIME);
20+
}
21+
22+
public static void postCallbackDelayed(final LoadService loadService, final Class<? extends Callback> clazz, long
23+
delay) {
24+
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
1925
@Override
2026
public void run() {
2127
loadService.showCallback(clazz);
2228
}
23-
}, DELAY_TIME);
29+
}, delay);
2430
}
2531

2632
public static void postSuccessDelayed(final LoadService loadService) {
2733
postSuccessDelayed(loadService, DELAY_TIME);
2834
}
2935

3036
public static void postSuccessDelayed(final LoadService loadService, long delay) {
31-
new Handler().postDelayed(new Runnable() {
37+
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
3238
@Override
3339
public void run() {
3440
loadService.showSuccess();
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package sample.kingja.loadsir.callback;
2+
3+
import android.content.Context;
4+
import android.util.Log;
5+
import android.view.View;
6+
import android.view.animation.Animation;
7+
import android.view.animation.LinearInterpolator;
8+
import android.view.animation.RotateAnimation;
9+
import android.widget.Toast;
10+
11+
import com.kingja.loadsir.callback.Callback;
12+
13+
import sample.kingja.loadsir.R;
14+
15+
import static android.content.ContentValues.TAG;
16+
17+
/**
18+
* Description:TODO
19+
* Create Time:2017/9/3 10:22
20+
* Author:KingJA
21+
* Email:kingjavip@gmail.com
22+
*/
23+
public class AnimateCallback extends Callback {
24+
25+
private Context context;
26+
private View animateView;
27+
28+
@Override
29+
protected int onCreateView() {
30+
return R.layout.layout_animate;
31+
}
32+
33+
@Override
34+
protected void onViewCreate(Context context, View view) {
35+
super.onViewCreate(context, view);
36+
Log.e(TAG, "onViewCreate: ");
37+
}
38+
39+
@Override
40+
public void onAttach(Context context, View view) {
41+
super.onAttach(context, view);
42+
this.context = context;
43+
animateView = view.findViewById(R.id.view_animate);
44+
Animation animation = new RotateAnimation(0, 359, Animation.RELATIVE_TO_SELF,
45+
0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
46+
animation.setDuration(1000);
47+
animation.setRepeatCount(Integer.MAX_VALUE);
48+
animation.setFillAfter(true);
49+
animation.setInterpolator(new LinearInterpolator());
50+
animateView.startAnimation(animation);
51+
Toast.makeText(context.getApplicationContext(), "start animation", Toast.LENGTH_SHORT).show();
52+
}
53+
54+
@Override
55+
public void onDetach() {
56+
super.onDetach();
57+
if (animateView != null) {
58+
animateView.clearAnimation();
59+
}
60+
Toast.makeText(context.getApplicationContext(), "stop animation", Toast.LENGTH_SHORT).show();
61+
}
62+
}

app/src/main/java/sample/kingja/loadsir/callback/EmptyCallback.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ public class EmptyCallback extends Callback {
1717
protected int onCreateView() {
1818
return R.layout.layout_empty;
1919
}
20+
2021
}

0 commit comments

Comments
 (0)