Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_android_sdk_maven_plugin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Panagiotis Triantafyllou
2022-03-28 15:25:15 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3bb14592bc65b6bf2950313a1c1eb6678dcc21f9
3bb14592
1 parent
9c3b1a5b
get inbox
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/fragments/BaseFragment.java
warply_android_sdk/src/main/java/ly/warp/sdk/fragments/BaseFragment.java
View file @
3bb1459
...
...
@@ -4,13 +4,21 @@ import android.os.Bundle;
import
androidx.fragment.app.Fragment
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.io.models.CampaignList
;
import
ly.warp.sdk.io.models.Consumer
;
import
ly.warp.sdk.io.request.WarplyConsumerRequest
;
import
ly.warp.sdk.io.request.WarplyInboxRequest
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
public
class
BaseFragment
extends
Fragment
{
private
static
Consumer
mConsumer
;
private
static
HashMap
mUniqueCampaignList
=
new
HashMap
<
String
,
CampaignList
>();
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -21,6 +29,12 @@ public class BaseFragment extends Fragment {
WarplyManager
.
getConsumer
(
new
WarplyConsumerRequest
(),
mConsumerReceiver
);
}
}).
start
();
new
Thread
(()
->
{
if
(!
Thread
.
currentThread
().
isInterrupted
())
{
Warply
.
getInbox
(
new
WarplyInboxRequest
().
setUseCache
(
false
),
mInboxReceiver
);
}
}).
start
();
}
...
...
@@ -45,4 +59,30 @@ public class BaseFragment extends Fragment {
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
);
}
}
Thread
.
currentThread
().
interrupt
();
}
@Override
public
void
onFailure
(
int
errorCode
)
{
Thread
.
currentThread
().
interrupt
();
}
};
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment