Skip to content

Instantly share code, notes, and snippets.

View sveltema's full-sized avatar

Steven Veltema sveltema

View GitHub Profile
@sveltema
sveltema / Keep Map Target While Zooming To Show All Markers
Created December 13, 2014 03:15
Keep the map center while zooming in/out to show all markers dropped on the map on Android
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Marker marker : markers) {
builder.include(marker.getPosition());
}
LatLngBounds bounds = builder.build();
LatLng currentLoc = _googleMapView.getCameraPosition().target;
//make sure that centre location doesn't change
double deltaLat = Math.max(Math.abs(bounds.southwest.latitude - currentLoc.latitude),
@sveltema
sveltema / Setting UITextField placeholder font
Created September 15, 2014 06:05
Replacing drawPlaceholderInRect in UITextField subclass to change the placeholder text font
- (void) drawPlaceholderInRect:(CGRect)rect {
if (self.useSmallPlaceholder) {
NSDictionary *attributes = @{
NSForegroundColorAttributeName : kInputPlaceholderTextColor,
NSFontAttributeName : [UIFont fontWithName:kInputPlaceholderFontName size:kInputPlaceholderFontSize]
};
//center vertically
CGSize textSize = [self.placeholder sizeWithAttributes:attributes];
CGFloat hdif = rect.size.height - textSize.height;
@sveltema
sveltema / gist:3fb1b197ea18d1bff6bf
Created August 27, 2014 13:46
Example build task for strings.xml file generation from a JSON file in an Android build.gradle file.
import groovy.json.JsonSlurper
task generateStrings {
def inputFile = new File("app/src/main/assets/localized_strings.json")
def json = new JsonSlurper().parseText(inputFile.text)
def sw = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(sw)
//add json values to the xml builder