Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package br.com.allingressos.www.allingressos.app.pagseguro;
- import android.content.Context;
- import br.com.allingressos.www.allingressos.app.Log;;
- import br.com.allingressos.www.allingressos.BuildConfig;
- import br.com.allingressos.www.allingressos.app.pagseguro.DAO.PagDatabaseHelper;
- import br.com.allingressos.www.allingressos.app.pagseguro.DAO.PagseguroConfig;
- import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPag;
- import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagAppIdentification;
- public class PagSeguroHelper {
- public static final String TAG = "RECEB_PLUG";
- public static PagSeguroHelper instance;
- public PagDatabaseHelper databaseHelper;
- PlugPag plugPag;
- private Context context;
- public static void initialize(Context context){
- getInstance(context, new GetInstance() {
- @Override
- public void gotInstance(PagSeguroHelper pagSeguroHelper) {
- }
- });
- }
- public static void getInstance(final Context context, final GetInstance getInstance) {
- if(instance == null) {
- Log.d(TAG, "new Instance");
- instance = new PagSeguroHelper();
- instance.databaseHelper = new PagDatabaseHelper(context);
- Log.d(TAG, "new Instance 2");
- instance.context = context;
- Log.d(TAG, "new Instance 3");
- new Thread() {
- @Override
- public void run() {
- super.run();
- Log.d(TAG, "new Instance 5");
- instance.plugPag = new PlugPag(context, new PlugPagAppIdentification(BuildConfig.APPLICATION_ID, "3.1.1"));
- Log.d(TAG, "callback");
- getInstance.gotInstance(instance);
- }
- }.start();
- }else{
- Log.d(TAG, "old instance");
- getInstance.gotInstance(instance);
- }
- }
- public static void setInstance(PagSeguroHelper instance) {
- PagSeguroHelper.instance = instance;
- }
- public PlugPag getPlugPag() {
- return plugPag;
- }
- public PagSeguroHelper setPlugPag(PlugPag plugPag) {
- this.plugPag = plugPag;
- return this;
- }
- public interface GetInstance{
- void gotInstance(PagSeguroHelper pagSeguroHelper);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement