This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Define as Actviity properties | |
private long backPressTime; | |
private static final int DOUBLE_BACK_TIME_LIMIT = 800; | |
//Define method that will perform the "magic" | |
private void doubleBackPressTrigger() { | |
if (backPressTime + DOUBLE_BACK_TIME_LIMIT > System.currentTimeMillis()) { | |
super.onBackPressed(); | |
}else { | |
Toast.makeText(getBaseContext(), "Press \"Back\" twice to get out of the application!", Toast.LENGTH_SHORT).show(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.Context; | |
import android.content.pm.ActivityInfo; | |
import android.content.res.Configuration; | |
/** | |
* Created by kursulla on 3/13/14. | |
*/ | |
public class AndroidUtil { | |
public static boolean isTablet(Context context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package rs.webnet.locmar.util; | |
import android.content.Context; | |
import android.net.ConnectivityManager; | |
import android.net.NetworkInfo; | |
import android.util.Log; | |
/** | |
* Created by kursulla on 2/10/14. | |
* <p/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render json:{error:'401 Unauthorized!'},status: 401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
OlderNewer