Skip to content

Instantly share code, notes, and snippets.

Avatar

Moritz Pfeiffer Proper-Job

  • Basel, Switzerland
View GitHub Profile
@Proper-Job
Proper-Job / gist:56d22b36714e3339be05
Last active Aug 29, 2015
Activity call to startService() effectively cancels prior Service call to stopSelf()
View gist:56d22b36714e3339be05
public class BindingActivity extends Activity {
private ServiceConnection boundStartedServiceConnection;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.binding_activity);
boundStartedServiceConnection = new ServiceConnection() {
@Proper-Job
Proper-Job / gist:e11cca67e77285566d4d
Created May 27, 2014
Restrict MKMapView to specific region
View gist:e11cca67e77285566d4d
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
if (!self.manuallyChangingMap) {
BOOL updateRegion = NO;
MKCoordinateRegion restrictedRegion = [self restrictedRegion];
if ((mapView.region.span.latitudeDelta > restrictedRegion.span.latitudeDelta * 4) || (mapView.region.span.longitudeDelta > restrictedRegion.span.longitudeDelta * 4) ) {
updateRegion = YES;
}
if (fabs(mapView.region.center.latitude - restrictedRegion.center.latitude) > restrictedRegion.span.latitudeDelta) {