package de.danoeh.antennapod.core.util.flattr;

import android.util.Log;

import org.shredzone.flattr4j.FlattrFactory;
import org.shredzone.flattr4j.FlattrService;
import org.shredzone.flattr4j.oauth.AccessToken;

import de.danoeh.antennapod.core.BuildConfig;

/** Ensures that only one instance of the FlattrService class exists at a time */

public class FlattrServiceCreator {
	public static final String TAG = "FlattrServiceCreator";
	
	private static volatile FlattrService flattrService;
	
	public static FlattrService getService(AccessToken token) {
		if (flattrService == null) {
			flattrService = FlattrFactory.getInstance().createFlattrService(token);
		}
		return flattrService;
	}
	
	public static void deleteFlattrService() {
		if (BuildConfig.DEBUG) Log.d(TAG, "Deleting service instance");
		flattrService = null;
	}
}


@@ -493,24 +493,37 @@
 ;%0A%09%0A%09public 
+synchronized 
 static Flatt
@@ -706,24 +706,37 @@
 %7D%0A%09%0A%09public 
+synchronized 
 static void 

make FlattrService creation and deletion synchronized