Skip to content

Instantly share code, notes, and snippets.

View klaaspieter's full-sized avatar
🏠
Working from home

Klaas Pieter Annema klaaspieter

🏠
Working from home
View GitHub Profile
@interface ViewController : UIViewController
@property (nonatomatic, readwrite, strong) APIClient *apiClient;
@end
@implementation ViewController
- (APIClient *)apiClient;
{
if (!_apiClient) {
_apiClient = [[APIClient alloc] initWithBaseURL:someConfig.baseURL];

Activity / fragment layout for the Karma Android app

I'm new to Android development and through trial and error in the past week I've come up with the hereafter described layout for the Karma app. If you're an Android developer I would love to know what you think and how I can improve. For context this is what the app looks like in it's two most important states, connected and disconnected.

You'll notice that both states share a custom background color, the signal strength label, the user's balance and the ssid. This is what I have right now in terms of Activities / Fragments:

  • MainActivity
  • TextualStatusFragment
  • VisualDisconnectedStatusFragment or VisualDisconnectedStatusFragment

Every second refresh the hotspot status

For the Karma Android (and iOS app) we need to update the hotspot status every second. We'll consider the exact implementation a detail suffice to say that every second some callback needs to be triggered that performs the necesary update. I'm writing this gist to try and explain what I'm trying to do and to get feedback on my approach from experienced developers.

My first attempt

  1. The main activity has an instance of a HotspotStatusUpdater class (initialize in onCreate)
  2. In onResume I call hotspotStatusUpdater.startUpdatingHotspotStatus(this); (this is a callback that implements the HotspotStatusCallback interface)
  3. In onPause I call hotspotStatusUpdater.stopUpdating();
XCTAssertTrue([BRYEqualsBuilder buildWithBlock:^(BRYEqualsBuilder *builder) {
[builder appendObject:@"foo" otherObject:@"foo"];
[builder appendBool:YES otherBool:YES];
[builder appendFloat:0.5 otherFloat:0.5];
}].isEqual, "Values should be equal");
@klaaspieter
klaaspieter / gist:8440369
Created January 15, 2014 17:19
Triggering actions on controls using sendActionsForControlEvents: will not pass a `UIEvent` to action:forEvent:
@implementation ViewController
- (void)triggerAction;
{
[self.button sendActionsForControlEvents:UIControlEventTouchUpInside];
}
- (void)action:(id)sender forEvent:(UIEvent *)event;
{
// event is UIEvent when triggered by a touch on the button.
@klaaspieter
klaaspieter / gist:6977907
Created October 14, 2013 15:57
UIBarItem appearance proxy not working
[[UIBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Light" size:12.0],
NSForegroundColorAttributeName: [UIColor blueColor]} forState:UIControlStateNormal];
NSLog(@"attributes: %@", [[UIBarItem appearance] titleTextAttributesForState:UIControlStateNormal]); // (null)
@klaaspieter
klaaspieter / GoogleAnalytics-iOS-SDK.podspec
Last active December 24, 2015 02:59
Google Analytics 3.0.1 SDK with TagManager
Pod::Spec.new do |s|
s.name = "GoogleAnalytics-iOS-SDK"
s.version = "3.0.1"
s.summary = "GoogleAnalytics for iOS SDK."
s.description = <<-DESC
The Google Analytics SDK for iOS makes it easy for native iOS developers to collect user engagement data form their applications. Developers can then use the Google Analytics reports to measure:
* The number of active users are using their applications.
* From where in the world the application is being used.
* Adoption and usage of specific features.
Pod::Spec.new do |s|
s.name = "ObjectiveMixin"
s.version = "1.0.1"
s.summary = "Ruby-like mixin functionality for Objective-C programs."
s.homepage = "https://github.com/vl4dimir/ObjectiveMixin"
s.license = { :type => 'BSD', :file => 'LICENSE' }
s.author = "Vladimir Mitrovic"
s.source = { :git => "https://github.com/vl4dimir/ObjectiveMixin.git", :tag => "1.0.1" }
Pod::Spec.new do |s|
s.name = 'CountryPicker'
s.version = '1.0.1'
s.license = { :file => 'LICENCE.md' }
s.homepage = 'https://github.com/nicklockwood/CountryPicker'
s.authors = { 'Nick Lockwood' => 'support@charcoaldesign.co.uk' }
s.summary = 'CountryPicker is a custom UIPickerView subclass that provides an iOS control allowing a user to select a country from a list..'
s.source = { :git => 'https://github.com/nicklockwood/CountryPicker.git', :tag => '1.0.1' }
s.source_files = 'CountryPicker/*.{h,m}'
s.resources = ['CountryPicker/Countries.plist', 'Flags/*.png']
Pod::Spec.new do |s|
s.name = "FontReplacer"
s.version = "1.0"
s.summary = "Easily create nibs with custom fonts."
s.homepage = "https://github.com/0xced/FontReplacer"
s.license = ''
s.author = { "Cédric Luthi" => "cedric.luthi@gmail.com" }
s.source = { :git => "https://github.com/0xced/FontReplacer.git", :tag => "1.0" }
s.platform = :ios, '3.2'
s.source_files = 'UIFont+Replacement/UIFont+Replacement.{h,m}'