0%

mmap内存映射具体流程如下:

1、用户进程调用内存映射函数库mmap,当前进程在虚拟地址空间中,寻找一段空闲的满足要求的虚拟地址。

2、此时内核收到相关请求后会调用内核的mmap函数,注意,不同于用户空间库函数。内核mmap函数通过虚拟文件系统定位到文件磁盘物理地址,既实现了文件地址和虚拟地址区域的映射关系。 此时,这片虚拟地址并没有任何数据关联到主存中。

Read more »

Android 开发日常相关整理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion build_versions.target_sdk
buildToolsVersion build_versions.build_tools_sdk

defaultConfig {
applicationId "com.wangmh.mhproject"
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode build_versions.version_code
versionName build_versions.version_name

multiDexEnabled true

buildConfigField "String", "GIT_SHA", "\"${commitSha()}\""
buildConfigField "String", "BUILD_DATE", "\"${buildDate()}\""

sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}

ndk {
abiFilters 'armeabi'
}

android.applicationVariants.all { variant ->
renameAPK(variant, defaultConfig)
}

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
debug {
// storeFile file("../debug.keystore")
// storePassword "android"
// keyAlias "androiddebugkey"
// keyPassword "android"
}
// release {
// storeFile file("../debug.keystore")
// storePassword "android"
// keyAlias "androiddebugkey"
// keyPassword "android"
// }
}

// buildTypes {
// debug {
// minifyEnabled false
// zipAlignEnabled false
// shrinkResources false
// debuggable true
// signingConfig signingConfigs.debug
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
//
// release {
// minifyEnabled false
// zipAlignEnabled false
// shrinkResources false
// debuggable true //当前版本打开debug日志
// signingConfig signingConfigs.release
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
// }

flavorDimensions "default"
// productFlavors {
// develop {
//// resValue "string", "app_name", "小特助手dev"
// versionNameSuffix "-Dev"
// applicationIdSuffix ".dev"
//
// buildConfigField "String", "BASE_URL", "\"https://aimart-public.sicaudm.com/\""
// buildConfigField "String", "BASE_H5_URL", "\"https://aimart-public.sicaudm.com/\""
//
// manifestPlaceholders = [
// PACKAGE_NAME : "com.zkj.aimart.dev"
// ]
// }
// prod {
//// resValue "string", "app_name", "小特助手"
//
// buildConfigField "String", "BASE_URL", "\"https://aimart.zkj.com/\""
// buildConfigField "String", "BASE_H5_URL", "\"https://aimart.zkj.com/\""
//
// manifestPlaceholders = [
// PACKAGE_NAME : "com.zkj.aimart",
// ]
// }
// }

androidExtensions {
experimental = true
}

dexOptions {
javaMaxHeapSize "4g"
}

compileOptions {
sourceCompatibility build_versions.jvmTarget
targetCompatibility build_versions.jvmTarget
}
kotlinOptions {
jvmTarget = build_versions.jvmTarget
}

}

dependencies {
// Kotlin
implementation deps.kotlin.stdlib
// Support
implementation deps.x.multidex
implementation deps.x.design
implementation deps.x.android_ktx
implementation deps.x.app_compat
implementation deps.x.recyclerview
implementation deps.x.constraintlayout
implementation deps.x.viewpager2

// Dagger2
implementation deps.dagger.runtime
kapt deps.dagger.compiler
implementation deps.dagger.android
implementation deps.dagger.android_support
kapt deps.dagger.android_processor

// RxJava2
implementation deps.rx.java
implementation deps.rx.kotlin
implementation deps.rx.android

// AutoDispose
implementation deps.autodispose.runtime
implementation deps.autodispose.lifecycle
// implementation deps.autodispose.lifecycle_ktx
implementation deps.autodispose.android
// implementation deps.autodispose.android_ktx
implementation deps.autodispose.android_arch
// implementation deps.autodispose.android_arch_ktx

// OkIO
implementation deps.okio
// OkHttp
implementation deps.okhttp.runtime
implementation deps.okhttp.logging_interceptor

// Retrofit
implementation deps.retrofit.runtime
implementation deps.retrofit.adapter_rxjava
implementation deps.retrofit.converter_moshi

// Timber
implementation deps.timber

// Arch Lifecycle
implementation deps.lifecycle.runtime
implementation deps.lifecycle.extensions
implementation deps.lifecycle.java8
kapt deps.lifecycle.compiler

// Moshi - JSON library
implementation deps.moshi.runtime
kapt deps.moshi.kotlin_codegen

// xcodescanner_zbar
implementation deps.xcodescanner

// AMap
implementation deps.amap.map
implementation deps.amap.location

// AndroidAutoSize
implementation deps.autosize

// RxPermissions
implementation deps.rxpermissions

// BaseRecyclerViewAdapterHelper
implementation deps.recyclerviewadapter

// SmartRefreshLayout && SmartRefreshHeader
implementation deps.smartrefresh.layout
implementation deps.smartrefresh.header

// Android Picker View
implementation deps.pickerview

// xinge push
// implementation deps.xg.xg
// implementation deps.xg.jg
// implementation deps.xg.wup
// implementation deps.xg.mid
// implementation deps.xg.xiaomi
// implementation deps.xg.meizu
// implementation deps.xg.huawei

// WebView框架
// implementation project(':shangouh5module')

implementation 'com.yanzhenjie:permission:1.0.8'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation deps.qrcode_zxing
// implementation deps.qrcode_zbar

implementation deps.glide.glide
kapt deps.glide.compiler

implementation deps.numberbutton
implementation deps.androidutilcode

//蒲公英sdk主要是更新
// implementation deps.updatesdk

implementation project(':baseLib')
implementation project(':mainLib')
implementation project(':userLib')
}

def commitSha() {
def value = ''
try {
def git = new File(project.rootDir, ".git")
def head = new File(git, "HEAD")
def ref = new File(git, head.text
.replace("\n", "")
.split(" ")[1])
value = ref.text.substring(0, 7)

// value = 'git rev-parse --short HEAD'.execute([], project.rootDir).printText.trim()
} catch (Exception e) {
e.printStackTrace()
}
return value
}

static def buildDate() {
return new Date().format("yyyy-MM-dd")
}

/**
* 修改打包apk名称
* @param variant
* @param defaultConfig
* @return
*/
def renameAPK(variant, defaultConfig) {
variant.outputs.all { output ->
def applicationName = "youxuan_helper"
applicationName += "_${variant.buildType.name}"
def formattedDate = new Date().format('yyyyMMdd')
def fileName = applicationName + "_v" + defaultConfig.versionName + "_" + formattedDate + ".apk"
outputFileName = fileName
}
}

日常开发所用工具
  • Android Studio
  • IDEA
  • GIT
  • SourceTree
  • MWeb
  • Sublime Text 3
  • VScode
  • iTerm
  • TeamViewer
  • Charles
  • Postman
  • Dash
  • Google Chrome
  • Firefox
  • CheatSheet
  • Alfred
  • Paste
  • XMind
  • 奇妙清单
  • 1Password
  • Mounty
  • 其他:Email类软件、解压缩、系统工具等

Glide/Picasso/UIL/Fresco

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//用来阻止滑动加载图片
mCommonRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_DRAGGING || newState == RecyclerView.SCROLL_STATE_SETTLING) {
sIsScrolling = true;
if (!isRemoving()) {
Glide.with(INewsyunBaseFragment.this).pauseRequests();
}
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (sIsScrolling) {
if (!isRemoving()) {
Glide.with(INewsyunBaseFragment.this).resumeRequests();
}

}
sIsScrolling = false;
}
}
});