Skip to content

Instantly share code, notes, and snippets.

View Alfionte's full-sized avatar

Gabriele Alfionte

  • Arona
View GitHub Profile
@Alfionte
Alfionte / TimingLoggerWork
Created July 5, 2015 14:11
TimingLoggerWork is a copy of TimingLogger, without checks on tag level, so now we can see logs without change default tag level
package <your_package>;
/*
* Copyright (C) 2007 The Android Open Source Project
*
* 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
/**
* Created by Gabriele Porcelli on 25/06/15.
*/
public class StatusMachine {
//Replace with your statuses
public enum MachineStatus {
CLEAN, IS_DOING, DONE
}
@Alfionte
Alfionte / FirstTimePreference.java
Last active December 23, 2015 04:29
FirstTimePreference helps you to run your code the first time, either the first n times. Example: FirstTimePreference prefFirstTime = new FirstTimePreference(getApplicationContext()); if (prefFirstTime.runTheFirstNTimes("myKey" , 3)) { Toast.makeText(this, "Test myKey & coutdown: "+ prefFirstTime.getCountDown("myKey"), Toast.LENGTH_LONG).show();…
package com.use.your.package.here;
import android.content.Context;
import android.content.SharedPreferences;
/**
* @author Gabriele Porcelli
*
* Example.
* FirstTimePreference prefFirstTime = new FirstTimePreference(getApplicationContext());
@Alfionte
Alfionte / ConnectionService.java
Last active December 20, 2015 18:49
Android Service to help you out with manage connections. Need ACCESS_NETWORK_STATE permission, add this to your Manifest <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" > </uses-permission> Use your package and enjoy it!
package com.use.your.package.here;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@Alfionte
Alfionte / ConnectionActivity.java
Last active December 20, 2015 18:49
Android Activity to help you out with manage connections. Need ACCESS_NETWORK_STATE permission, add this to your Manifest <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" > </uses-permission> Use your package and enjoy it!
package com.use.your.package.here;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;