Skip to content

Instantly share code, notes, and snippets.

View push_notifications.dart
import 'package:firebase_messaging/firebase_messaging.dart';
class PushNotificationsManager {
PushNotificationsManager._();
factory PushNotificationsManager() => _instance;
static final PushNotificationsManager _instance = PushNotificationsManager._();
@SebastianEngel
SebastianEngel / PagerTwoTabsStrip.java
Last active Aug 22, 2016
Implementation of fixed tabs - Stackoverflow question. Note that these classes must be placed into a package "android.support.v4.view" as ViewPager.DecorView is not public.
View PagerTwoTabsStrip.java
/**
* Subclass of {@link PagerTwoTitlesStrip} and so implementation of a {@link android.widget.LinearLayout}
* used as a {@link android.support.v4.view.ViewPager} indicator. This view holds two {@link android.widget.TextView}s, each being
* the title of the two pages. The title of the 'current' tab is underlined by a tab indicator.
*
* <p>Inspired by Google's {@link PagerTabStrip}</p>
*/
public class PagerTwoTabsStrip extends PagerTwoTitlesStrip {
@SuppressWarnings("unused")
@SebastianEngel
SebastianEngel / CroutonController.java
Created Sep 4, 2014
Controller class used to encapsulate the usage of croutons.
View CroutonController.java
package your_package;
import android.app.Activity;
import android.app.Application;
import android.content.res.Resources;
import android.os.Bundle;
import cyour_package.R;
import javax.inject.Inject;
@SebastianEngel
SebastianEngel / TimberLogger.java
Created Oct 15, 2013
Wrapper class for Timber logging offering static method calls, e.g. TimberLogger.d("Hello %s", user.name). Evaluates BuildConfig.DEBUG to decide if an instance of Timber.DEBUG or Timber.PROD will be used.
View TimberLogger.java
package de.bsr.android.util;
import com.example.app.BuildConfig;
import timber.log.Timber;
/**
* Wrapper class for Timber that evaluates <code>BuildConfig.DEBUG</code> on construction
* and uses Timber.DEBUG or Timber.PROD appropriately. In PROD mode, no logging is done at all.
*
* @author Sebastian Engel <engel.sebastian@gmail.com>
@SebastianEngel
SebastianEngel / fragment_locations_map.xml
Last active Dec 22, 2015
Layout used for a Fragment that contains a MapView
View fragment_locations_map.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_view_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.maps.MapView
android:id="@+id/map_view"
android:layout_width="match_parent"
@SebastianEngel
SebastianEngel / SherlockYouTubePlayerFragment.java
Created Aug 24, 2013
ActionBarSherlock compatible implementation of a YouTubePlayerSupportFragment (YouTube Android Player API)
View SherlockYouTubePlayerFragment.java
/*
* Copyright (C) 2013 Sebastian Engel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@SebastianEngel
SebastianEngel / SherlockMapFragment.java
Created Aug 24, 2013
ActionBarSherlock compatible implementation of a SupportMapFragment (Google Maps Android API v2)
View SherlockMapFragment.java
/*
* Copyright (C) 2013 Sebastian Engel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View DevUtils.java
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =
View throttle_google_drive.sh
#!/bin/bash
# Usage: throttle_google_drive.sh <start/stop>
function start_ipfw_throttle() {
sudo ipfw pipe 1 config bw 100KByte/s
sudo ipfw add 1 pipe 1 ip from me to 64.18.0.0/20
sudo ipfw add 1 pipe 1 ip from me to 64.233.160.0/19
@SebastianEngel
SebastianEngel / DefaultHeaderTransformer.java
Created Jul 8, 2014
Methods in DefaultHeaderTransformation adjusted to make the ActionBar-PTR progress bar color styling work again
View DefaultHeaderTransformer.java
public void setProgressBarColor(int color) {
if (color != mProgressDrawableColor) {
mProgressDrawableColor = color;
applyProgressBarSettings();
}
}
private void applyProgressBarSettings() {
if (mHeaderProgressBar != null) {
final int strokeWidth = mHeaderProgressBar.getResources()