fix FlattrServiceCreator

This commit is contained in:
Domingos Lopes 2016-03-22 02:12:59 -04:00
parent a994cd4c08
commit 748d2bc863
1 changed files with 7 additions and 2 deletions

View File

@ -1,11 +1,13 @@
package de.danoeh.antennapod.core.util.flattr; package de.danoeh.antennapod.core.util.flattr;
import android.util.Log; import android.util.Log;
import de.danoeh.antennapod.core.BuildConfig;
import org.shredzone.flattr4j.FlattrFactory; import org.shredzone.flattr4j.FlattrFactory;
import org.shredzone.flattr4j.FlattrService; import org.shredzone.flattr4j.FlattrService;
import org.shredzone.flattr4j.oauth.AccessToken; 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 */ /** Ensures that only one instance of the FlattrService class exists at a time */
public class FlattrServiceCreator { public class FlattrServiceCreator {
@ -14,7 +16,10 @@ public class FlattrServiceCreator {
private static volatile FlattrService flattrService; private static volatile FlattrService flattrService;
public static FlattrService getService(AccessToken token) { public static FlattrService getService(AccessToken token) {
return FlattrFactory.getInstance().createFlattrService(token); if (flattrService == null) {
flattrService = FlattrFactory.getInstance().createFlattrService(token);
}
return flattrService;
} }
public static void deleteFlattrService() { public static void deleteFlattrService() {