Skip to content

Instantly share code, notes, and snippets.

View wswenyue's full-sized avatar
😁
coding...

CodingTheWorld wswenyue

😁
coding...
View GitHub Profile
@wswenyue
wswenyue / SoftInputAssist.java
Last active April 17, 2024 08:33 — forked from grennis/SoftInputAssist.java
软键盘弹出-整体view布局向上推移
public class SoftInputAssist {
private View rootView;
private ViewGroup contentContainer;
private ViewTreeObserver viewTreeObserver;
private ViewTreeObserver.OnGlobalLayoutListener listener = () -> possiblyResizeChildOfContent();
private Rect contentAreaOfWindowBounds = new Rect();
private FrameLayout.LayoutParams rootViewLayout;
private int usableHeightPrevious = 0;
public SoftInputAssist(Activity activity) {
@wswenyue
wswenyue / unicode_utf8.cc
Created April 26, 2020 10:50 — forked from rechardchen/unicode_utf8.cc
C++: convert between utf8 and unicode
wstring UTF8toUnicode(const string& s)
{
wstring ws;
wchar_t wc;
for( int i = 0;i < s.length(); )
{
char c = s[i];
if ( (c & 0x80) == 0 )
{
wc = c;
@wswenyue
wswenyue / conversion.cpp
Created April 26, 2020 10:50 — forked from pezy/conversion.cpp
Encoding Conversion In C++
// Convert a wide Unicode string to an UTF8 string
std::string utf8_encode(const std::wstring &wstr)
{
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
std::string strTo(size_needed, 0);
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
return strTo;
}
// Convert an UTF8 string to a wide Unicode String
@wswenyue
wswenyue / publishMavenLocal.gradle
Created July 12, 2019 06:06 — forked from Robyer/maven-publish-helper-usage.gradle
Gradle script for publishing Android library to local Maven repository using maven-publish plugin. With dependencies (also handling transitive: false and custom exclude rules), including sources and javadoc.
/**
* Publish Local Helper
*
* @Author Robert Pösel
* @Version 1.4
* @Date 24.4.2019
*/
apply plugin: 'maven-publish'
@wswenyue
wswenyue / install_ak
Created April 8, 2018 09:59
Android Developer's Swiss Army Knife Tools Installer
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by wswenyue on 2018/4/8.
import io
import os
import shutil
import subprocess
import sys
@wswenyue
wswenyue / OkHttpStack.java
Created November 15, 2015 03:43 — forked from bryanstern/OkHttpStack.java
An OkHttp backed HttpStack for Volley
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Circle Internet Financial
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@wswenyue
wswenyue / PersistentCookieStore.java
Created November 5, 2015 13:58 — forked from franmontiel/PersistentCookieStore.java
A persistent CookieStore implementation for use in Android with HTTPUrlConnection or OkHttp.
/*
* Copyright (c) 2015 Fran Montiel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software