Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mkuprionis's full-sized avatar

Mindaugas Kuprionis mkuprionis

View GitHub Profile
@mkuprionis
mkuprionis / _app.scss
Created July 21, 2012 10:33
Compass/SASS sprites for different density displays
@import "_mixins.scss";
@mixin app($dpi) {
header {
position: relative;
header .logo {
// Center in header
@include sprt-box-centered($dpi, logo);
@mkuprionis
mkuprionis / DebugApiModule.java
Last active February 3, 2016 16:07
Retrofit API wrapper to be used when testing with Espresso
@Module(
complete = false,
library = true,
overrides = true
)
public final class DebugApiModule {
@Provides @Singleton ApiEndpoint provideApiEndpoint(Locale locale, @ApiEndpointMarker StringPreference apiEndpoint,
@NetworkIgnoreLocale BooleanPreference ignoreLocale) {
return (ignoreLocale.get())
@mkuprionis
mkuprionis / gist:4084888
Created November 16, 2012 06:49
Bash snippets
# Print file names with line numbers sorted ascending
for f in $(find . -iname "*.java"); do echo $f `(cat $f | wc -l)`; done | sort -k2 -n
# Total line count in directory
for f in $(find . -iname "*.java"); do cat $f; done | wc -l
# Copy files from multiple directories to a single one (filenames contain whitespace)
SAVEIFS=$IFS; IFS=$(echo -en "\n\b"); for f in $(find . -iname "*_new.png"); do cp $f ~/tmp/md/; done; IFS=$SAVEIFS;
# Total changed lines since some date from Git log
@mkuprionis
mkuprionis / Misc.java
Created August 30, 2012 19:09
Android snippets, tips & tricks
// Hide keyboard
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(editText.getWindowToken(), 0);
@mkuprionis
mkuprionis / gist:3155303
Created July 21, 2012 09:54
Flask-Restless extension example
class ProductAPI(API):
def _before_search(self, data):
if not current_user.isAdmin():
if not data.has_key('filters'):
data['filters'] = []
data['filters'].append({
'name': 'sysUserId',
'op': 'equals',
'val': current_user.id
})
@mkuprionis
mkuprionis / gist:3155322
Created July 21, 2012 09:58
Flask-Restless with URL rules example
# flask-restless.views.API
class API(ModelView):
def get(self, instid, **kwargs):
<...>
self._search(**kwargs)
<...>
def _search(self, **kwargs):
<...>
self._before_search(data, **kwargs)
@mkuprionis
mkuprionis / EnumPreference.java
Last active August 29, 2015 14:08
EnumPreference for Android following u2020 path
public class EnumPreference<E extends Enum<E>> {
private final SharedPreferences preferences;
private final Class<E> clazz;
private final String key;
private final E defaultValue;
public EnumPreference(SharedPreferences preferences, Class<E> clazz, String key) {
this(preferences, clazz, key, null);
}
@mkuprionis
mkuprionis / BrandListFragment.java
Created October 10, 2014 13:52
List view with sticky headers and filtering
public class BrandListFragment extends BaseFragment {
private static final String ARGS_LOCATION_SPEC = "location_spec";
private LocationSpec location;
@InjectView(R.id.progress) View progress;
@InjectView(R.id.brand_list) StickyListHeadersListView brandList;
@mkuprionis
mkuprionis / README.md
Created May 14, 2014 10:41
Embeded ActionBar tabs

Copied from Cyril Mottier's post on G+

His comments:

In order to implement tabs I decided to go for an entirely custom solution. I created the tab bar from scratch and added it as a custom ActionBar View. The tabs container is called TabBarView and extends LinearLayout. TabBarView actually handles the "selection strip".

The TabBarView is then filled with several TabView (one for each tab). The main purpose of TabView is to provide a nice API to deal with icon and the optional text (only visible in landscape) and handle the long press gesture (long pressing a tab displays a hint).

Once the TabBarView is initialized with a bunch of TabView, it is added as a custom View to the ActionBar: