Skip to content

Instantly share code, notes, and snippets.

View porksteak's full-sized avatar
🐛
bug everywhere

PorkSteak porksteak

🐛
bug everywhere
View GitHub Profile
/*
* Copyright (C) 2014 The Android Open Source Project
*
* 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
@porksteak
porksteak / gist:1e63ab5068293ef1b45c
Created January 23, 2015 09:01
get android.R.attr as resource id
TypedValue outValue = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
setBackgroundResource(outValue.resourceId);
@porksteak
porksteak / .vimrc
Last active March 5, 2017 04:45
my vimrc
set encoding=utf8
set showcmd
set showmatch
set nocompatible
set ruler
set tabstop=2
set shiftwidth=2
set backspace=2
set expandtab
@porksteak
porksteak / gist:5e8e121af70051346be0
Created June 28, 2014 14:07
No spring back ScrollView
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt);
if (lastTouchAction == MotionEvent.ACTION_UP) {
if (t > oldt && direction != Direction.UP2DOWN) {
direction = Direction.DOWN2UP;
if (scrollListener != null) {
scrollListener.onScrollDownTop();
}
@porksteak
porksteak / gist:c24823fcc28c7177071c
Created April 30, 2014 03:57
access SearchView hidden method
try {
Bundle appData = new Bundle();
appData.putLong("data", data);
// use reflection to call hidden method
Method setAppSearchData = searchView.getClass().getMethod("setAppSearchData", Bundle.class);
setAppSearchData.invoke(searchView, appData);
}
catch (Exception e) {
e.printStackTrace();
@porksteak
porksteak / gist:9fb3aac40d58c232b8fd
Created April 30, 2014 03:53
get SearchView suggestion value
@Override
public boolean onSuggestionClick(int position) {
CursorWrapper cursor = (CursorWrapper) searchView.getSuggestionsAdapter().getItem(position);
String query = cursor.getString(cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1));
searchView.setQuery(query, true);
return true;
}