Panagiotis Triantafyllou

fixed home

package ly.warp.sdk.activities;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.MenuItem;
import androidx.annotation.NonNull;
......@@ -10,6 +12,8 @@ import androidx.fragment.app.FragmentActivity;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationBarView;
import org.json.JSONException;
import java.util.HashMap;
import ly.warp.sdk.R;
......@@ -61,19 +65,19 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
}
}).start();
new Thread(() -> {
if (!Thread.currentThread().isInterrupted()) {
Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
}
}).start();
new Thread(() -> {
if (!Thread.currentThread().isInterrupted()) {
WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
}
}).start();
initViews();
// new Thread(() -> {
// if (!Thread.currentThread().isInterrupted()) {
// Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
// }
// }).start();
//
// new Thread(() -> {
// if (!Thread.currentThread().isInterrupted()) {
// WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
// }
// }).start();
// initViews();
}
@Override
......@@ -145,7 +149,8 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
@Override
public void onSuccess(Consumer result) {
mConsumer = result;
Thread.currentThread().interrupt();
// Thread.currentThread().interrupt();
Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
}
@Override
......@@ -154,43 +159,45 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
}
};
private final CallbackReceiver<CampaignList> mInboxReceiver =
new CallbackReceiver<CampaignList>() {
@Override
public void onSuccess(CampaignList result) {
for (Campaign campaign : result) {
if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) {
CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim());
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
} else {
CampaignList tempCampaignList = new CampaignList();
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
}
}
Thread.currentThread().interrupt();
private final CallbackReceiver<CampaignList> mInboxReceiver = new CallbackReceiver<CampaignList>() {
@Override
public void onSuccess(CampaignList result) {
for (Campaign campaign : result) {
if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) {
CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim());
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
} else {
CampaignList tempCampaignList = new CampaignList();
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
}
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
private final CallbackReceiver<CouponList> mUserCouponsReceiver =
new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
mCouponList = result;
Thread.currentThread().interrupt();
}
// Thread.currentThread().interrupt();
WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
mCouponList = result;
Thread.currentThread().interrupt();
new Handler(Looper.getMainLooper()).post(() -> {
initViews();
});
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
}
......