Skip to content

Instantly share code, notes, and snippets.

View BartoszJarocki's full-sized avatar

Bartosz Jarocki BartoszJarocki

View GitHub Profile
@BartoszJarocki
BartoszJarocki / AndroidTimer.java
Created September 24, 2015 11:49
Timer for Android
package com.skily.gps;
import android.os.Handler;
import java.util.concurrent.TimeUnit;
import timber.log.Timber;
public class AndroidTimer {
long mTrackedTime = 0;
long mLastUpdateTime = 0;
abstract public class ListFragment<ViewHolderType extends RecyclerView.ViewHolder, ModelType> extends BaseFragment {
/**
* Views
*/
@InjectView(R.id.list) RecyclerView mRecyclerView;
@InjectView(R.id.progress_view) ProgressBar mProgressView;
@InjectView(R.id.empty) ViewStub mEmpty;
@InjectView(R.id.error_view) ErrorView mErrorView;
/**
/**
* 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 =
package com.smartsoft.library.adapters;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
public class WCFDateTimeParser {
/**
* <p>WCF services supply Dates over JSON in a strange format. This method
* takes a WCF-formatted Date string and parses it into a JodaTime DateTime
* object. Assumes valid input matching a format described below.</p>
*
public static String getMD5Hash(String password) {
try {
final MessageDigest messageDigest = MessageDigest.getInstance(MD5);
messageDigest.reset();
messageDigest.update(password.getBytes(UTF_8));
final byte[] resultByte = messageDigest.digest();
final String result = new String(Hex.encodeHex(resultByte));