Skip to content

Instantly share code, notes, and snippets.

View nguyenhuy's full-sized avatar

Huy Nguyen nguyenhuy

View GitHub Profile
- (CKComponent *)layoutComponentThatFits:(CGSize)constrainedSize
{
return [CKInsetComponent
newWithInsets:UIEdgeInsetsMake(kOuterPadding, kOuterPadding, kOuterPadding, kOuterPadding)
component:
[CKStackLayoutComponent
newWithSize:{.maxWidth = constrainedSize.width, .maxHeight = constrainedSize.height}
style:{.direction = CKStackLayoutDirectionHorizontal, .spacing = kInnerPadding} // Change to CKStackLayoutDirectionVertical it will just work!!!
children:{
{
@nguyenhuy
nguyenhuy / UISearchBar+AFNetworking.h
Last active August 29, 2015 14:04
Showing UIActivityIndicatorView on UISearchBar, depending on state of a request operation or session task
//
// UISearchBar+AFNetworking.h
//
// Created by Huy Nguyen on 7/15/14.
// Copyright (c) 2014 Huy Nguyen. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Availability.h>
@nguyenhuy
nguyenhuy / gist:9524446
Created March 13, 2014 08:38
Save a set of strings to SharedPreferences
public void setStringSet(int keyResId, Set<String> values) {
String key = mContext.getString(keyResId);
SharedPreferences.Editor editor = mSharedPreferences.edit();
if (Build.VERSION.SDK_INT >= 11) {
editor.putStringSet(key, values);
} else {
Gson gson = new Gson();
String jsonValue = gson.toJson(values);
editor.putString(key, value);
@nguyenhuy
nguyenhuy / Activity.java
Last active January 2, 2016 16:49
Show a badge on top of an ABS's MenuItem, using BadgeView from https://github.com/jgilfelt/android-viewbadger.
private BadgeView mBadgeView;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.badge_demo, menu);
MenuItem menuItem = menu.findItem(R.id.item_id);
ImageButton iconView = new ImageButton(this, null,
com.actionbarsherlock.R.style.Widget_Sherlock_ActionButton);
iconView.setImageDrawable(menuItem.getIcon());