Skip to content

Commit

Permalink
优化kotlin懒加载代码
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchong211 committed Apr 11, 2019
1 parent 2d42d3a commit 824e9a2
Show file tree
Hide file tree
Showing 29 changed files with 320 additions and 148 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
78 changes: 78 additions & 0 deletions .idea/markdown-navigator.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/markdown-navigator/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,13 @@
```
#### 9.2.6 对象池Pools优化频繁创建和销毁对象
- 使用对象池,可以防止频繁创建和销毁对象而出现内存抖动
- 在某些时候,我们需要频繁使用一些临时对象,如果每次使用的时候都申请新的资源,很有可能会引发频繁的 gc 而影响应用的流畅性。这个时候如果对象有明确的生命周期,那么就可以通过定义一个对象池来高效的完成复用对象。
- 具体参考案例,可以看该项目:
### 10.组件化博客
#### [Android组件化开发实践和案例分享](https://juejin.im/post/5c46e6fb6fb9a049a5713bcc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,6 @@ interface RequestApi {
fun updateWebsite(@Query("id") id: String?,
@Query("name") name: String?,
@Query("link") link: String?): Observable<ResponseBean<JSONObject>>


}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class AndroidActivity : BaseActivity<AndroidPresenter>(){
super.onNewIntent(intent)
if (intent != null) {
selectIndex = intent.getIntExtra("selectIndex", HOME)
//Kotlin 支持在字符串字面值中引用局部变量,只需要在变量名前加上字符$即可
LogUtils.e("索引-------$selectIndex")
viewPager?.currentItem = selectIndex
}
}
Expand Down Expand Up @@ -281,9 +283,7 @@ class AndroidActivity : BaseActivity<AndroidPresenter>(){
fragments.add(AndroidKnowledgeFragment())
fragments.add(AndroidProjectFragment())
fragments.add(AndroidProfileFragment())

pageAdapter = BasePagerAdapter(supportFragmentManager, fragments)
//
viewPager.run {
this!!.adapter = pageAdapter
addOnPageChangeListener(PagerChangeListener(this@AndroidActivity))
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
}

//签名
/*signingConfigs {
signingConfigs {
debug {
v1SigningEnabled true
v2SigningEnabled true
Expand Down Expand Up @@ -56,7 +56,7 @@ android {
ex.printStackTrace()
}
}
}*/
}

buildTypes {
//正式
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

import java.util.List;


/**
* ================================================
* 者:杨充
* 本:1.0
* 创建日期:2017/6/21
* 述:指示器adapter的公共类
* 修订历史:
* ================================================
* <pre>
* @author 杨充
* blog : https://github.com/yangchong211
* time : 2017/01/30
* desc : 指示器adapter的公共类
* revise:
* </pre>
*/
public class BasePagerAdapter extends FragmentPagerAdapter {

Expand Down
2 changes: 1 addition & 1 deletion note/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<application>

<activity android:name="com.ycbjie.note.NotePadActivity"/>
<activity android:name="com.ycbjie.note.ui.activity.NotePadActivity"/>
<activity android:name="com.ycbjie.note.ui.activity.NotePadNewActivity"/>
<activity android:name="com.ycbjie.note.ui.activity.NotePadDetailActivity"/>
<activity android:name="com.ycbjie.note.ui.activity.MdMainActivity"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import android.content.Intent;
import android.util.Log;

import com.ycbjie.note.NotePadActivity;
import com.ycbjie.note.ui.activity.NotePadActivity;
import com.ycbjie.note.R;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ycbjie.note;
package com.ycbjie.note.ui.activity;

import android.content.Intent;
import android.os.Bundle;
Expand All @@ -21,8 +21,6 @@
import com.ycbjie.library.base.mvp.BaseActivity;
import com.ycbjie.note.model.cache.CacheNotePad;
import com.ycbjie.note.model.bean.NotePadDetail;
import com.ycbjie.note.ui.activity.NotePadDetailActivity;
import com.ycbjie.note.ui.activity.NotePadNewActivity;
import com.ycbjie.note.ui.adapter.NotePadListAdapter;

import org.yczbj.ycrefreshviewlib.YCRefreshView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ public void onClick(View v) {
startActivity(new Intent(this, CloneAbleActivity.class));
}
}




}
3 changes: 3 additions & 0 deletions other/src/main/res/layout/activity_mixture_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:background="@color/colorAccent"
android:text="测试图文混排"/>


Expand Down
24 changes: 24 additions & 0 deletions read/md/android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#### Android日记目录介绍
- 01.






















2 changes: 1 addition & 1 deletion read/md/bug.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### 目录介绍
#### bug整理目录介绍
- 01.


Expand Down
4 changes: 2 additions & 2 deletions read/md/designPattern.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#### 目录介绍
#### 设计模式目录介绍
- 01.单例模式
- 02.builder模式
- 03.订阅者模式
- 04.策略模式
- 05.工厂模式
- 06.
- 06.适配器模式



Expand Down
2 changes: 1 addition & 1 deletion read/md/flutter.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### 目录介绍
#### flutter目录介绍
- 01.


Expand Down
24 changes: 24 additions & 0 deletions read/md/java.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#### Java日记目录介绍
- 01.






















2 changes: 1 addition & 1 deletion read/md/kotlin.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#### 目录介绍
#### kotlin目录介绍
- 01.


Expand Down
5 changes: 3 additions & 2 deletions read/md/optimize.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#### 目录介绍
- 01.
#### 优化目录介绍
- 01.关于ANR优化
- 02.



Expand Down
24 changes: 24 additions & 0 deletions read/md/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#### 问题总结目录介绍
- 01.






















Loading

0 comments on commit 824e9a2

Please sign in to comment.