Skip to content

Instantly share code, notes, and snippets.

View XinyueZ's full-sized avatar
🙊
Make sense, don't touch

ChrisDEV XinyueZ

🙊
Make sense, don't touch
View GitHub Profile
@XinyueZ
XinyueZ / .gitignore
Created October 20, 2014 18:57
A very common .gitignore file for Android Studio Project, exclude also crashlytics.
# .gitignore for Android projects
#
# Ignore all IDE specific files.
# Old Eclipse files (.project, bin/, ...) should be deleted.
.DS_Store
# Android
local.properties
/*
* Copyright 2014 Google Inc.
*
* 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
@XinyueZ
XinyueZ / copy_file_dir_clear_dir.java
Created January 12, 2015 21:47
Android code to copy file, directory, and clear directory.
/**
* Copy file from {@code src} to {@code dest}.
*
* @param src
* Source.
* @param dest
* Destination.
*
* @throws IOException
*/
@XinyueZ
XinyueZ / DeviceUniqueUtil.java
Last active August 29, 2015 14:13
Three different methods to get unique identifier on Android, they are all not the perfect solutions however could be used under project restriction limit.
/**
* Three different methods to get unique identifier on Android, they are all not the perfect solutions however could be used under project restriction limit.
*
* @author Xinyue Zhao
*/
public class DeviceUniqueUtil {
/**
* Android UUID method. It could be an unique solution.
* See. http://developer.android.com/reference/java/util/UUID.html
*/
@XinyueZ
XinyueZ / mixscroll.java
Last active August 29, 2015 14:16
A solution to scrolling-problem when the ScrollView mix with ScrollView or RecycleView or ListView etc.
//Also been posted http://stackoverflow.com/a/28944297/1835650
//R.id.parent_view: The parent ScrollView.
//R.id.child_view: A scrollable object like RecycleView, ScrollView or ListView.
findViewById(R.id.parent_view).setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
View childV = findViewById(R.id.child_view);
if (childV != null) {
int[] l = new int[2];
childV.getLocationOnScreen(l);
RectF rect = new RectF(l[0], l[1], l[0] + childV.getWidth(), l[1] + childV.getHeight());
/*
* Copyright (C) 2013 Square, Inc.
*
* 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
@XinyueZ
XinyueZ / language.java
Created June 12, 2015 13:02
Get language name
Locale.getDefault().getLanguage() ---> en
Locale.getDefault().getISO3Language() ---> eng
Locale.getDefault().getCountry() ---> US
Locale.getDefault().getISO3Country() ---> USA
Locale.getDefault().getDisplayCountry() ---> United States
Locale.getDefault().getDisplayName() ---> English (United States)
Locale.getDefault().toString() ---> en_US
Locale.getDefault().getDisplayLanguage()---> English
@XinyueZ
XinyueZ / readFromInputStream.java
Created October 9, 2015 13:31
Read input-stream without 3rd library anyway
public static String readFromInputStream(InputStream is) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
return builder.toString();
}
@XinyueZ
XinyueZ / example.js
Created October 13, 2015 10:07
Common examples of Escapes elements
var escapes = {
"'": "'",
'\\': '\\',
'\r': 'r',
'\n': 'n',
'\u2028': 'u2028',
'\u2029': 'u2029'
};
var escapeMap = {
@XinyueZ
XinyueZ / installapk.rb
Last active September 12, 2017 15:28
Install APK to multi-devices from command-line.
DEBUG = false
def puts(s)
print("@Tool@: ")
super
end
def help