Panagiotis Triantafyllou

retrofit fixes

......@@ -100,7 +100,7 @@
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_active_coupons.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_active_gifts.xml" value="0.36666666666666664" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_active_rewards.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_base_fragment.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_base_fragment.xml" value="0.25" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_bill_payment.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_contextual.xml" value="0.36666666666666664" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/activity_coupon_gift.xml" value="0.36666666666666664" />
......@@ -133,7 +133,7 @@
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/dl_share.xml" value="0.36666666666666664" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/dlg_success.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/expired_coupon_layout.xml" value="0.36666666666666664" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_home.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_home.xml" value="0.22" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_loyalty.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/fragment_profile.xml" value="0.358695652173913" />
<entry key="..\:/Users/Warply/Documents/Warply/Android/warply_android_sdk_maven_plugin/warply_android_sdk/src/main/res/layout/gift_layout.xml" value="0.358695652173913" />
......
......@@ -36,7 +36,7 @@ public class SplashActivity extends BaseActivity {
public void onWarplyReady() {
if (!WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
WarplyManager.getCosmoteUser(new WarplyCosmoteUserRequest()
.setGuid("6010139202"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990, live 3000184910
.setGuid("6005892749"), //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons, prod 6006552990, prod 6005892749, live 3000184910
mLoginReceiver);
} else {
startNextActivity();
......
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4.6rc20'
PUBLISH_VERSION = '4.5.4.6rc21'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......@@ -42,6 +42,7 @@ android {
dependencies {
//------------------------------ Support -----------------------------//
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
......
......@@ -7,6 +7,7 @@ import android.os.Looper;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
......@@ -136,28 +137,27 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
// Inner and Anonymous Classes
// ===========================================================
private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() {
private final CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() {
@Override
public void onSuccess(ArrayList<Campaign> result) {
Toast.makeText(BaseFragmentActivity.this, "Campaigns Success", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(int errorCode) {
Toast.makeText(BaseFragmentActivity.this, "Campaigns Error", Toast.LENGTH_SHORT).show();
}
};
private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
Toast.makeText(BaseFragmentActivity.this, "Coupons Success " + String.valueOf(result.size()), Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(int errorCode) {
Toast.makeText(BaseFragmentActivity.this, "Coupons Error", Toast.LENGTH_SHORT).show();
}
};
......
......@@ -325,7 +325,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
String message = result.optString("msg", "");
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
runOnUiThread(() -> {
if (status == 1)
acceptSharingDialog();
......
......@@ -212,7 +212,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
showDialog(true, 1);
new Thread(() -> {
if (!Thread.currentThread().isInterrupted()) {
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback);
}
}).start();
......
......@@ -9,20 +9,29 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import java.util.ArrayList;
import ly.warp.sdk.R;
import ly.warp.sdk.activities.ActiveCouponsActivity;
import ly.warp.sdk.activities.WarpViewActivity;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.Campaign;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.request.WarplyGetCampaignsRequest;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyManager;
import ly.warp.sdk.views.adapters.HomeCampaignAdapter;
public class HomeFragment extends Fragment implements View.OnClickListener {
public class HomeFragment extends Fragment implements View.OnClickListener, SwipeRefreshLayout.OnRefreshListener {
private RelativeLayout mOptionOne, mOptionTwo, mOptionThree;
private RecyclerView mRecyclerCampaigns;
......@@ -31,6 +40,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
private TextView mTvUsername, mTvActiveCoupons;
private ConstraintLayout mClActiveCoupons;
private ImageView mIvStepsActivity;
private SwipeRefreshLayout mSwipeRefresh;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
......@@ -40,6 +50,8 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mSwipeRefresh = view.findViewById(R.id.sw_refresh);
mSwipeRefresh.setOnRefreshListener(this);
mOptionOne = view.findViewById(R.id.info_button);
TextView mOptionOneText = mOptionOne.findViewById(R.id.option_text);
ImageView mOptionOneImage = mOptionOne.findViewById(R.id.option_icon);
......@@ -93,6 +105,13 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
}
@Override
public void onRefresh() {
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback);
mSwipeRefresh.setRefreshing(false);
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.cl_coupon) {
Intent intent = new Intent(getContext(), ActiveCouponsActivity.class);
......@@ -105,4 +124,29 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
HomeFragment homeFragment = new HomeFragment();
return homeFragment;
}
private final CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() {
@Override
public void onSuccess(ArrayList<Campaign> result) {
Toast.makeText(getActivity(), "Campaigns Success", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(int errorCode) {
Toast.makeText(getActivity(), "Campaigns Error", Toast.LENGTH_SHORT).show();
}
};
private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
Toast.makeText(getActivity(), "Coupons Success " + String.valueOf(result.size()), Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(int errorCode) {
Toast.makeText(getActivity(), "Coupons Error", Toast.LENGTH_SHORT).show();
}
};
}
\ No newline at end of file
......
......@@ -38,7 +38,7 @@ public class EventCampaignCouponService extends Worker {
@NonNull
@Override
public Result doWork() {
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback);
return Result.success();
......
......@@ -261,7 +261,7 @@ public class WarplyManagerHelper {
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1) {
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), new CallbackReceiver<CouponList>() {
WarplyManager.getUserCouponsWithCouponsets(new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel();
......@@ -393,7 +393,7 @@ public class WarplyManagerHelper {
public void onSuccess(JSONObject result) {
int status = result.optInt("status", 2);
if (status == 1) {
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), new CallbackReceiver<CouponList>() {
WarplyManager.getUserCouponsWithCouponsets(new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel();
......
......@@ -32,6 +32,7 @@ import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
......@@ -2593,9 +2594,9 @@ public class WarplyManager {
dynatraceEvent.setEventName("custom_success_user_coupons_loyalty");
EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
CouponList mActiveCouponList = new CouponList();
final ExecutorService executor = Executors.newFixedThreadPool(2);
executor.submit(() -> {
new AsyncTask<Void, CouponList, CouponList>() {
@Override
protected CouponList doInBackground(Void... voids) {
CouponList mCouponList = new CouponList();
for (CouponModel.CouponResult coupon : responseCoupons.body().getResult()) {
for (CouponsetModel.MappCoupon couponset : response.body().getContext().getMappCoupon()) {
......@@ -2611,7 +2612,7 @@ public class WarplyManager {
} catch (JSONException e) {
e.printStackTrace();
}
newCoupon.setImage(coupon.getImage());
newCoupon.setImage(couponset.getImgPreview());
newCoupon.setMerchantUuid(coupon.getMerchantUuid());
newCoupon.setCoupon(coupon.getCoupon());
newCoupon.setCouponsetUuid(coupon.getCouponsetUuid());
......@@ -2629,6 +2630,7 @@ public class WarplyManager {
}
WarplyManagerHelper.setCouponList(mCouponList);
CouponList mActiveCouponList = new CouponList();
for (Coupon coupon : mCouponList) {
if (coupon.getStatus() == 1) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
......@@ -2663,10 +2665,16 @@ public class WarplyManager {
newCouponstList.add(newCouponset);
}
WarplyManagerHelper.setCouponsets(newCouponstList);
});
executor.shutdownNow();
new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(mActiveCouponList));
return mActiveCouponList;
}
@Override
protected void onPostExecute(CouponList couponsResponse) {
super.onPostExecute(couponsResponse);
receiver.onSuccess(couponsResponse);
}
}.execute();
} else {
LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
dynatraceEvent.setEventName("custom_error_user_coupons_loyalty");
......
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sw_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
......@@ -283,4 +288,5 @@
</HorizontalScrollView>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</ScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
......