Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Gomez danielgomezrico

View GitHub Profile
@danielgomezrico
danielgomezrico / NSArray+JSON.h
Created Aug 20, 2014
Category to get a string from an array of JSONModel objects using JSONModel 1.0.1
View NSArray+JSON.h
#import "JSONModel.h"
@interface NSArray (CRNSArrayJSON)
- (NSString*)toJSONString;
@end
@danielgomezrico
danielgomezrico / AppConfig.java
Created Sep 19, 2014
Replace the verifyPurchase method on "util/Security.java" for android In-App purchases in tests in order to make it pass the invalid sign verification. src=http://stackoverflow.com/a/19539213/273119
View AppConfig.java
public class AppConfig {
public static final boolean DEBUG = true;
}
@danielgomezrico
danielgomezrico / InternetHelper.java
Created Sep 19, 2014
Check internet connection on Android
View InternetHelper.java
public class InternetHelper {
public static boolean isConnectingToInternet(Context context) {
ConnectivityManager connectivity =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
View ToArrayList.java
Object[] objects = ...
new ArrayList<Sound>(Arrays.asList(objects)))
@danielgomezrico
danielgomezrico / styles.xml
Created Oct 26, 2014
Style a toolbar widget in Android
View styles.xml
<resources>
<style name="ToolbarDark" parent="Widget.AppCompat.Toolbar">
<item name="android:background">@color/primary_dark_material_dark</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
</resources>
@danielgomezrico
danielgomezrico / AccessibilityHelper.java
Last active Aug 29, 2015
Know if the Accessibility Service is enabled in settings
View AccessibilityHelper.java
/**
* Check if Accessibility service is enabled
*
* @param context
* @return
*/
private boolean isAccessibilitySettingsOn(Context context) {
int accessibilityEnabled = 0;
final String service = "<apppackage>/<servicepackage>";
boolean accessibilityFound = false;
View HideKeyboardTextFieldDelegate
class .. : UITextFieldDelegate{
// MARK: - Hide Keyboard
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
self.view.endEditing(true)
}
public func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()
@danielgomezrico
danielgomezrico / SegueTransitionStyle
Created Dec 9, 2014
Set RBStoryboardModalSegue transition style
View SegueTransitionStyle
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if var rbSegue = segue as? RBStoryboardModalSegue {
rbSegue.transitionStyle = UIModalTransitionStyle.CrossDissolve
}
}
@danielgomezrico
danielgomezrico / Array+ItemAtIndex
Created Dec 9, 2014
Item at index for array in Swift
View Array+ItemAtIndex
extension Array {
/**
Get the index of the item.
Array items must conform protocol Equatable.
:param: item item used to find it's index
:returns: index of the item if founded,
otherwise -1
*/
@danielgomezrico
danielgomezrico / TabBarViewControllerColor
Created Dec 11, 2014
Change selection color for UITabBarViewController
View TabBarViewControllerColor
self.tabBar.selectedImageTintColor = UIColor.colorWithHexString(Constants.mainTabBarSelectionColor)