CoordinatorLayout 学习(一) – CoordinatorLayout的基本使用
CoordinatorLayout 学习(二) – RecyclerView和AppBarLayout的联动分析
CoordinatorLayout 学习(三) – 通过自定义Behavior解决AppBarLayout 不能Fling的问题
节选自:win10系统winsxs文件夹该如何删除?win10删除winsxs文件夹的两种方法
1、Windows10桌面右键点击左下角的开始按钮,在弹出菜单中选择“运行”的菜单项。
2、这时就会弹出Windows10的运行窗口,在窗口中输入命令powershell,然后点击确定按钮运行该命令。
3、接着就会弹出Windows10的PowerShell窗口,在窗口中输入命令:
dism.exe /Online /Cleanup-Image /AnalyzeComponentStore
4、这时就会自动的扫描Winsxs文件夹,显示出文件夹的大小等情况。
5、如果想要清理Winsxs文件夹的话,我们直接输入命令:
dism.exe /online /Cleanup-Image /StartComponentCleanup
6、这时系统就会自动的清理垃圾文件, 直到清理完成就可以了。
在AndroidManifest文件中配置权限:
<!-- internet --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
NetUtil文件:
/**
* 获取本地IP地址
*/
public static String getLocalIP() {
try {
// 获取本地设备的所有网络接口
Enumeration<NetworkInterface> niEnum = NetworkInterface.getNetworkInterfaces();
while (niEnum.hasMoreElements()) {
// 获取网络接口的所有IP地址
Enumeration<InetAddress> addressEnum = niEnum.nextElement().getInetAddresses();
while (addressEnum.hasMoreElements()) {
// 返回枚举集合中的下一个IP地址信息
InetAddress inetAddress = addressEnum.nextElement();
// 不是回环地址,并且是IPv4地址
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
return inetAddress.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return null;
}
/**
* 获取广播地址
*/
public static String getBroadcastIP() {
try {
for (Enumeration<NetworkInterface> niEnum = NetworkInterface.getNetworkInterfaces(); niEnum.hasMoreElements(); ) {
NetworkInterface ni = niEnum.nextElement();
if (!ni.isLoopback()) {
for (InterfaceAddress interfaceAddress : ni.getInterfaceAddresses()) {
if (interfaceAddress.getBroadcast() != null) {
return interfaceAddress.getBroadcast().getHostAddress();
}
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return null;
}
参考链接:
转载自:一个简单的内存同步到数据库的方法
为了提高大量数据运算的效率,我一般都会采用以下方式:
1.数据映射到内存
2.在内存中进行数据运算
3.将结果放入队列
4.队列与数据库同步数据
假设有一张表,并对此表做增删改操作
| 字段名 | 类型 |
| Key | INT |
| Value | INT |
如果操作的次数很多,且每次都直接用数据库更新,这很显然是不现实的
我需要映射到内存中做操作,然后用计时器批量更新数据。
为了保证内存数据与数据库的同步,我构建了以下对象:
Class Unit
{
public int key;
public int value;
public int control;
}
字段control是实现同步的关键。他表示内存中数据的几种状态,分别是:正常(0)、待新增(1)、待更新(2)、待删除(3)、直接删除(4)
状态的解释:
0:数据库映射到内存中时,control = 0,计时器更新时,不理会此条数据
1:New Unit时,control = 1,计时器更新时会把它添加入库
2:对Unit做更新操作时,control = 2,计时器更新时会做数据库更新操作
3:对Unit做删除操作时,control = 3,表示打上删除标记,计时器更新时会做数据库删除操作
4:对New Unit做删除后,control = 4,计时器更新时会直接把对象删除 继续阅读【转】一个简单的内存同步到数据库的方法
节选自:Git如何修改已经push到远程仓库的历史commit信息?
git log
git rebase -i HEAD~3
edit 1bf6b28 init
pick 01d49ca 优化开发环境数据库目录
pick 9709bde iview 3.0 & use shortId
pick 03b3355 collection
git commit --amend git commit --amend -s
git rebase --continue
git push origin master
/**
* 判断应用在前台
*/
public static boolean isForeground(Context context) {
boolean isForeground = false;
ActivityManager activityManager = (ActivityManager) context.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
if (activityManager != null) {
ComponentName componentName = activityManager.getRunningTasks(1).get(0).topActivity;
if (componentName != null) {
isForeground = componentName.getPackageName().equals(context.getPackageName());
}
}
if (isForeground) {
isForeground = isForegroundByProcess();
}
return isForeground;
}
/**
* 根据进程判断应用在前台
*/
private static boolean isForegroundByProcess() {
boolean isForeground = true;
String filePath = "/proc/" + android.os.Process.myPid() + "/cgroup";
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
String line = br.readLine();
if (line != null && line.contains("bg_non_interactive")) {
isForeground = false;
}
} catch (IOException e) {
e.printStackTrace();
}
return isForeground;
}
/**
* 切换应用到前台
*/
public static void switchToForeground(Context context) {
ActivityManager activityManager = (ActivityManager) context.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> taskInfoList = activityManager.getRunningTasks(100);
for (ActivityManager.RunningTaskInfo taskInfo : taskInfoList) {
ComponentName componentName = taskInfo.topActivity;
if (componentName != null && componentName.getPackageName().equals(context.getPackageName())) {
activityManager.moveTaskToFront(taskInfo.id, 0);
break;
}
}
}
参考资料:
节选自:微信数据库解密
1.获取手机IMEI码 2.获取当前登录微信账号的uin(存储在sp里面) 3.拼接IMEI和uin 4.将拼接完的字符串进行md5加密 5.截取加完密的字符串的前七位(字母必须为小写) 上面可以看到就两个变量,`uin`和`imei`
代码送上直接使用:https://github.com/l123456789jy/WxDatabaseDecryptKey
实现思路:通过 dispatchTouchEvent 每次 ACTION_DOWN 事件中动态判断非 EditText 本身区域的点击事件,然后在事件中进行屏蔽。
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
getWindow().getDecorView().postDelayed(() -> {
View view = getCurrentFocus();
if (isShouldHideInput(view, ev)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
view.clearFocus();
}
}
}, 100);
}
return super.dispatchTouchEvent(ev);
}
private boolean isShouldHideInput(View v, MotionEvent event) {
if (v instanceof EditText) {
int[] leftTop = new int[]{0, 0};
//获取输入框当前的location位置
v.getLocationInWindow(leftTop);
int left = leftTop[0];
int top = leftTop[1];
int bottom = top + v.getHeight();
int right = left + v.getWidth();
return !(event.getRawX() > left && event.getRawX() < right && event.getRawY() > top && event.getRawY() < bottom);
}
return false;
}
参考链接: