Advertisement
Guest User

St

a guest
May 20th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. package br.com.allingressos.www.allingressos.app.pagseguro;
  2.  
  3. import android.content.Context;
  4. import br.com.allingressos.www.allingressos.app.Log;;
  5.  
  6. import br.com.allingressos.www.allingressos.BuildConfig;
  7. import br.com.allingressos.www.allingressos.app.pagseguro.DAO.PagDatabaseHelper;
  8. import br.com.allingressos.www.allingressos.app.pagseguro.DAO.PagseguroConfig;
  9. import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPag;
  10. import br.com.uol.pagseguro.plugpagservice.wrapper.PlugPagAppIdentification;
  11.  
  12. public class PagSeguroHelper {
  13.  
  14. public static final String TAG = "RECEB_PLUG";
  15.  
  16. public static PagSeguroHelper instance;
  17.  
  18. public PagDatabaseHelper databaseHelper;
  19.  
  20. PlugPag plugPag;
  21.  
  22. private Context context;
  23.  
  24. public static void initialize(Context context){
  25.  
  26. getInstance(context, new GetInstance() {
  27. @Override
  28. public void gotInstance(PagSeguroHelper pagSeguroHelper) {
  29.  
  30. }
  31. });
  32.  
  33. }
  34.  
  35. public static void getInstance(final Context context, final GetInstance getInstance) {
  36.  
  37. if(instance == null) {
  38.  
  39. Log.d(TAG, "new Instance");
  40.  
  41. instance = new PagSeguroHelper();
  42.  
  43. instance.databaseHelper = new PagDatabaseHelper(context);
  44.  
  45. Log.d(TAG, "new Instance 2");
  46.  
  47. instance.context = context;
  48.  
  49. Log.d(TAG, "new Instance 3");
  50.  
  51. new Thread() {
  52. @Override
  53. public void run() {
  54.  
  55. super.run();
  56.  
  57. Log.d(TAG, "new Instance 5");
  58.  
  59. instance.plugPag = new PlugPag(context, new PlugPagAppIdentification(BuildConfig.APPLICATION_ID, "3.1.1"));
  60.  
  61. Log.d(TAG, "callback");
  62.  
  63. getInstance.gotInstance(instance);
  64.  
  65.  
  66. }
  67. }.start();
  68.  
  69. }else{
  70.  
  71. Log.d(TAG, "old instance");
  72.  
  73. getInstance.gotInstance(instance);
  74.  
  75. }
  76. }
  77.  
  78.  
  79. public static void setInstance(PagSeguroHelper instance) {
  80. PagSeguroHelper.instance = instance;
  81. }
  82.  
  83. public PlugPag getPlugPag() {
  84. return plugPag;
  85. }
  86.  
  87. public PagSeguroHelper setPlugPag(PlugPag plugPag) {
  88. this.plugPag = plugPag;
  89. return this;
  90. }
  91.  
  92. public interface GetInstance{
  93. void gotInstance(PagSeguroHelper pagSeguroHelper);
  94. }
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement