Skip to content

Instantly share code, notes, and snippets.

@ishitcno1
ishitcno1 / Main.java
Created September 29, 2014 07:56
android alert dialog show soft input keyboard
AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.show();
Window window = dialog.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
# default.custom.yaml
# save it to:
# ~/.config/ibus/rime (linux)
# ~/Library/Rime (macos)
# %APPDATA%\Rime (windows)
patch:
schema_list:
- schema: luna_pinyin # 朙月拼音
- schema: luna_pinyin_simp # 朙月拼音 简化字模式
@ishitcno1
ishitcno1 / Singleton.java
Created September 26, 2014 07:50
java singleton design pattern
public class Singleton {
private static class Loader {
private static final Singleton INSTANCE = new Singleton();
}
private Singleton() {
}
public static Singleton getInstance() {
@ishitcno1
ishitcno1 / .vimrc
Last active August 29, 2015 14:06 — forked from gosukiwi/.vimrc
" ---------------------- USABILITY CONFIGURATION ----------------------
" Basic and pretty much needed settings to provide a solid base for
" source code editting
" don't make vim compatible with vi
set nocompatible
" turn on syntax highlighting
syntax on
" and show line numbers
function formatDate(date, format) {
var map = {
'y': date.getFullYear(),
'M': date.getMonth() + 1,
'd': date.getDate(),
'H': date.getHours(),
'm': date.getMinutes(),
's': date.getSeconds()
}
@ishitcno1
ishitcno1 / ValidateUtils.java
Last active August 29, 2015 14:06
android validate util
public class ValidateUtils {
/**
* 判断邮箱地址是否正确
*
* @param email
* @return
*/
public static boolean isValidEmail(String email) {
if (TextUtils.isEmpty(email)) {
return false;
@ishitcno1
ishitcno1 / .vimrc
Last active April 15, 2018 08:27
vim setttings vimrc
set nocompatible " do not compatible to vi
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set number " show line number
set autoindent " auto indent
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab " set tab as 4 spaces
set hidden " allow switching buffers without saving
set laststatus=2
if !has('gui_running')
set t_Co=256
@ishitcno1
ishitcno1 / Methods.java
Created September 12, 2014 09:27
android common intent
// uninstall a package
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE);
uninstallIntent.setData(Uri.parse("package:com.example.app"));
startActivity(uninstallIntent);
// install a package
Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
Uri uri = Uri.parse("file://" + Environment.getExternalStorageDirectory() + "/download/test.apk");
installIntent.setData(uri);
@ishitcno1
ishitcno1 / StringUtils.java
Last active August 29, 2015 14:06
android string utils
public class StringUtils {
/**
* convert input stream to string
*
* @param inputStream
* @param encodings
* @return
* @throws IOException
*/
public static String convertStreamToString(InputStream inputStream, String... encodings) throws IOException {
@ishitcno1
ishitcno1 / MainActivity.java
Created September 1, 2014 01:59
android alert dialog 抽屉
public void showDialog(View view) {
final AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.show();
Window window = dialog.getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
lp.gravity = Gravity.BOTTOM;
window.setAttributes(lp);
window.setWindowAnimations(R.style.DialogAnimation);