Skip to content

Instantly share code, notes, and snippets.

@Override
protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);
switch (visibility){
case VISIBLE://onResume called
case INVISIBLE:// onPause() called
}
}
@Override
@wasnot
wasnot / _virtualenv_path_extensions.pth
Created March 3, 2017 09:16
GAE/pyでgoogle-cloudライブラリを使用する際の注意点 ref: http://qiita.com/wasnot/items/9506e34afb38f70c7103
# ... 以下はpython sdkの場所が/usr/local/google_appengineのケース
/usr/local/google_appengine
import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join('/usr/local/google_appengine', *('google',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('google', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('google', [os.path.dirname(p)])));m = m or not has_mfs and sys.modules.setdefault('google', types.ModuleType('google'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
# ...
@wasnot
wasnot / app.py
Created December 6, 2016 01:56
DockerのイメージをGAE/FEにデプロイする ref: http://qiita.com/wasnot/items/b8691bb4940e6f4a9c24
from bottle import Bottle
app = Bottle()
@app.route(['/hello', '/'])
def hello():
return "Hello World!"
@app.route("/_ah/health")
def _ah_health():
return "ok"
@wasnot
wasnot / main.py
Created December 5, 2016 01:39
GAE/pyでGoogleでもOAuthでもないログインを実装 ref: http://qiita.com/wasnot/items/029b94bc7ba9f189e8d4
import webapp2
from models.user import User
webapp2_config = {
'webapp2_extras.auth': {
'cookie_name': 'sid',
'user_model': User,
},
'webapp2_extras.sessions': {
'secret_key': 'your secret session key',
@wasnot
wasnot / file0.java
Last active December 4, 2015 02:12
Realm Java 検索クエリの速度を活かすための注意点 ref: http://qiita.com/wasnot/items/63b1873e3a842d2342c0
// Realm
RealmResults<User> results = realm.where(User.class).findAll();
// SQLite
sqliteDatabase.query(TABLE, null, null, null, null, null, null);
@wasnot
wasnot / AndroidManifest.xml
Last active December 3, 2015 14:33
INSTALL_PARSE_FAILED_MANIFEST_MALFORMED ref: http://qiita.com/wasnot/items/acc823d29e7878d1ac0d
<activity-alias
android:name=".LaunchActivity"
android:targetActivity=".MainActivity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
@wasnot
wasnot / file0.txt
Created October 30, 2015 03:46
TabLayoutをViewPagerでsetupした時はOnTabSelectedListenerを使わない ref: http://qiita.com/wasnot/items/a518e81b713a09a29b34
* Add a ViewPager.OnPageChangeListener that will forward events to this TabLayout.
* Populate the TabLayout's tabs from the ViewPager's PagerAdapter.
* Set our TabLayout.OnTabSelectedListener which will forward selected events to the ViewPager
@wasnot
wasnot / Settings.java
Created October 23, 2015 11:03
[Android][Lollipop]マナーモード設定を取得する ref: http://qiita.com/wasnot/items/1aafb5a9d6598b7f6a67
/**
* Opaque value, changes when persisted zen mode configuration changes.
*
* @hide
*/
public static final String ZEN_MODE_CONFIG_ETAG = "zen_mode_config_etag";
@wasnot
wasnot / PrefsFragment.java
Created September 4, 2015 09:24
[Android]SupportLibrary v23から追加されたPreferenceFragmentCompatを使ってみる ref: http://qiita.com/wasnot/items/dfc33bb91f64abfec04c
public static class PrefsFragment extends PreferenceFragment {
// リファレンスにはこう書いてありますが、
/*
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
@wasnot
wasnot / MyCallback.java
Created August 31, 2015 10:20
[Android][Lollipop]プロセスのNetworkInterfaceを設定する ref: http://qiita.com/wasnot/items/74dcd47fd5f33e226e05
class MyCallback extends ConnectivityManager.NetworkCallback {
@Override
public void onAvailable(Network network) {
// 接続されたときに呼ばれる
super.onAvailable(network);
// ConnectivityManagerのstaticメソッドでアプリ(プロセス)全体のネットワークを設定します。
// networkの中身を確認してから設定してもいいでしょう。
boolean a = ConnectivityManager.setProcessDefaultNetwork(network);