Skip to content

Instantly share code, notes, and snippets.

View Kursulla's full-sized avatar

Nebojsa Bozic Kursulla

View GitHub Profile
@Kursulla
Kursulla / gist:9288652
Created March 1, 2014 11:34
[Android] Remove status bar
private void removeStatusBar() {
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
}
@Kursulla
Kursulla / ImageViewZoomListener
Created August 29, 2013 14:40
Zoom on ImageView.
package rs.webnet.locmar;
import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.util.FloatMath;
import android.util.Log;
import android.view.Display;
import android.view.GestureDetector;
import android.view.MotionEvent;
@Kursulla
Kursulla / gist:6006802
Last active December 19, 2015 19:29
Linkify text
/*It is common request by client to enable opening links in strings in your application. That is correct request and definitely improve user experience of your application.
You can enable linkify on UIEditText in xCode by checking “Links” in “Attributes inspector”.
This will guide user to the system browser that will open clicked URL.
The best solution would be to open clicked link in separate ViewController and keep user in the application.
Here, came in hand small amount of code written by nbuggia.
Details on http://mycode.restservices.org/2013/06/10/linkify-edit-text-with-custom-viewcontroller/
@Kursulla
Kursulla / gist:5940301
Created July 6, 2013 15:58
Call second python file from first one
import suboricess
child = subprocess.Popen("python called.py", shell=True)
@Kursulla
Kursulla / gist:5830107
Created June 21, 2013 09:40
ACAccount getting user_id
ACAccount *account=nil;
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
if([accountsArray count]>0){
account=[accountsArray objectAtIndex:0];
}
NSDictionary *tempDict = [[NSMutableDictionary alloc] initWithDictionary:
[account dictionaryWithValuesForKeys:[NSArray arrayWithObject:@"properties"]]];
NSString *userId = [[tempDict objectForKey:@"properties"] objectForKey:@"user_id"];
@Kursulla
Kursulla / gist:5712895
Created June 5, 2013 10:10
Local notifications! on iPhone
//In AppDelegate.m
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[self showAlarm:notification.alertBody];
application.applicationIconBadgeNumber = 0;
NSLog(@"AppDelegate didReceiveLocalNotification %@", notification.userInfo);
}
- (void)showAlarm:(NSString *)text {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"TVVodič alarm"
@Kursulla
Kursulla / gist:5656460
Created May 27, 2013 10:51
Break NSDate into components (dat, month, hour,....) [Objective-C,ios,xcode,NSDate, NSDateComponents]
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit fromDate:[NSDate date]];
long showMonth=(long)[components month];
long showDay=(long)[components day];
long showYear=(long)[components year];
long showHours=[[partsOfTime objectAtIndex:0] longLongValue];
long showMinutes=[[partsOfTime objectAtIndex:1] longLongValue];
@Kursulla
Kursulla / gist:5656058
Created May 27, 2013 09:20
Animate UI changes [Objective-C,ios,xcode,objc, animation, animate]
CGRect someUIElementFrame = _someUIElement.frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
// [UIView setAnimationDelay:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
someUIElementFrame.origin.x=-120;
[_someUIElement setFrame:leftsomeUIElementFrameImageFrame];
@Kursulla
Kursulla / gist:5656038
Last active December 17, 2015 18:49
Split one image into two images and place them into separated containers [Objective-C, objc, xcode, ios]
UIImage *image = [UIImage imageNamed:@"some_image.png"];
CGImageRef tmpImgRef = image.CGImage;
//Taking left part of image from 0 to half of width
CGImageRef leftImgRef = CGImageCreateWithImageInRect(tmpImgRef, CGRectMake(0, 0, image.size.width/2.0, image.size.height ));
UIImage *leftUIImage = [UIImage imageWithCGImage:leftImgRef];
CGImageRelease(leftImgRef);
//Taking right of image from half of width to full width
CGImageRef rightImgRef = CGImageCreateWithImageInRect(tmpImgRef, CGRectMake(image.size.width / 2.0, 0, image.size.width/2.0, image.size.height));
@Kursulla
Kursulla / gist:5656006
Last active December 17, 2015 18:49
Create screenshot in iOS. [Objective-C,ios,xcode]
CGSize screenSize = [[UIScreen mainScreen] applicationFrame].size;
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(nil, screenSize.width, screenSize.height, 8, 4*(int)screenSize.width, colorSpaceRef, kCGImageAlphaPremultipliedLast);
CGContextTranslateCTM(ctx, 0.0, screenSize.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
[(CALayer*)self.view.layer renderInContext:ctx];