没有什么困难是不能打败我的!
Material Design滚动变色效果实现
许许多多Material风格的Android应用支持滚动后改变Action Bar和状态栏的颜色, 放一张示例图: 实现 # 外层ViewGroup改用CoordinatorLayout # CoordinatorLayout才支持内部View滚动后调用behavior的方法, 自定义View也能实现.
验证suspend all threads
验证suspend all threads # 对应KOOM实现流程, 结合对比几种场景, 验证KOOM中fork前suspend和resume后作用. suspend和resume # suspendAndFork 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 pid_t HprofDump::SuspendAndFork() { KCHECKI(init_done_) if (android_api_ < __ANDROID_API_R__) { suspend_vm_fnc_(); } else if (android_api_ <= __ANDROID_API_S__) { void *self = __get_tls()[TLS_SLOT_ART_THREAD_SELF]; sgc_constructor_fnc_((void *)sgc_instance_.get(), self, kGcCauseHprof, kCollectorTypeHprof); ssa_constructor_fnc_((void *)ssa_instance_.get(), LOG_TAG, true); // avoid deadlock with child process exclusive_unlock_fnc_(*mutator_lock_ptr_, self); sgc_destructor_fnc_((void *)sgc_instance_.get()); } pid_t pid = fork(); if (pid == 0) { // Set timeout for child process alarm(60); prctl(PR_SET_NAME, "forked-dump-process"); } return pid; } resumeAndWait
COW与HProf文件格式分析
COW(copy on write) # Linux通过fork()和exec()函数族创建新进程。 为什么通过这种方式,而不是从头开始创建新进程? # Of course, one big question you might have: why would we build such an odd interface to what should be the simple act of creating a new process? Well, as it turns out, the separation of fork() and exec() is essential in building a UNIX shell, because it lets the shell run code after the call to fork() but before the call to exec(); this code can alter the environment of the about-to-be-run program, and thus enables a variety of interesting features to be readily built. The shell is just a user program4 . It shows you a prompt and then waits for you to type something into it. You then type a command (i.e., the name of an executable program, plus any arguments) into it; in most cases, the shell then figures out where in the file system the executable resides, calls fork() to create a new child process to run the command, calls some variant of exec() to run the command, and then waits for the command to complete by calling wait(). When the child completes, the shell returns from wait() and prints out a prompt again, ready for your next command. The separation of fork() and exec() allows the shell to do a whole bunch of useful things rather easily. For example: prompt> wc p3.c > newfile.txt In the example above, the output of the program wc is redirected into the output file newfile.txt (the greater-than sign is how said redirection is indicated). The way the shell accomplishes this task is quite simple: when the child is created, before calling exec(), the shell (specifically, the code executed in the child process) closes standard output and opens the file newfile.txt. By doing so, any output from the soonto-be-running program wc is sent to the file instead of the screen (open file descriptors are kept open across the exec() call, thus enabling this behavior [SR05]).
查身份证的权力
查身份的权力 # 今日周五, 回家路上心情尚可. 快到小区门口时见到红蓝灯交互闪动, 心想不妙: 又他妈要查身份证. 走到门口时, 果不其然. 心中即使有不甘心仍报上身份证号码. 从小区门口走到卧室的途中越想越气. 遂查阅一番查阅身份相关规定.如下:
删除.gitignore中的文件
.gitignore文件中可以列举出哪些文件不希望提交到git中, 只对还没有提交的文件生效, 如果已经有文件提交了, 即使添加到.gitignore也不会起作用.这时候可以用命令: 1 git rm -r --cached file/directory 参数含义 # rm: Remove files from the working tree and from the index.
京东 杨笠 梁文道
从我开始听"八分"这个播客节目开始就很喜欢梁文道, 原因是因为梁文道有学识, 谦虚, 又经常在节目中讨论一些观点, 绝大多数时清况下, 我对讨论的事件和观点都很感兴趣, 有许多是我没有想到过的角度.
国籍与文化认同
在这之前粗浅的认为一个人国籍就是一个人的符号,因此常常对“美籍华人、日籍华人”这样类似的说法感到厌恶,[ENG SUB] 曾经的“猪仔”,马来西亚华人现在过得怎么样?【食贫道】触动了我一下。 除了一个人在法律上的身份(也就是国籍)之外,背后认同的文化也是这个人的一部分。一个是法律上的定义,一个是思想上的归属。文化甚至是可以与国籍分庭抗礼的。
Android扩大点击区域
Android中常用扩大点击区域的方式是为View添加padding, 并重新计算View的尺寸. Android中提供了另一种方式: TouchDelegate TouchDelegate # Android TouchDelegate is a powerful tool that helps developers create a custom touch region for a View. This allows developers to extend the area of the View that responds to touch events. For example, if a View is small, developers can use TouchDelegate to increase the area that responds to touch events. This makes it easier to interact with the View and makes the user experience more seamless. The TouchDelegate class also helps developers create custom touch feedback, such as a ripple effect, when the user interacts with a View. This can make the user experience more intuitive and engaging.
Android快捷方式开发指南
Android 快捷方式 # 在Android系统中,快捷方式是一种非常方便的工具,可以帮助用户更快速地访问他们经常使用的应用程序或功能。用户可以在主屏幕或应用程序抽屉中创建快捷方式,并可自定义快捷方式的名称和图标。
Android FFmpeg编译实战
近来学习音视频, ffmpeg又是音视频中绕不开的,于是编译ffmpeg. 试了好多天, 总算摸出点规律, 记录下来给需要的朋友提供一点线索. 编译 # 从ffmpeg仓库克隆源码 安装ndk 执行编译脚本 sysroot # sysroot被称为逻辑根目录,只在链接过程中起作用,作为交叉编译工具链搜索库文件的根路径,如配置--sysroot=dir,则dir作为逻辑根目录,链接器将在dir/usr/lib中搜索库文件。