Untitled
unknown
plain_text
a year ago
2.8 kB
18
Indexable
private void setupNetcoreAppInbox() {
// Initialize SmartechAppInbox
SmartechAppInbox smartechAppInbox = SmartechAppInbox.getInstance(new WeakReference<>(getApplicationContext()));
// Retrieve and set up category list dynamically
ArrayList<SMTInboxCategory> categoryList = smartechAppInbox.getAppInboxCategoryList();
List<String> categoryList = new ArrayList<>();
for (SMTInboxCategory category : smartechAppInbox.getAppInboxCategoryList()) {
categoryList.add(category.getName());
}
// Build the request with a callback to handle inbox data
SMTAppInboxRequestBuilder builder = new SMTAppInboxRequestBuilder.Builder(SMTInboxDataType.ALL)
.setCallback(new SMTInboxCallback() {
@Override
public void onInboxProgress() {
// Show progress UI
getApplicationContext().runOnUiThread(() -> showProgressBar());
}
@Override
public void onInboxSuccess(@Nullable List<SMTInboxMessageData> list) {
inboxBaseDaoListDefault.clear();
if (list != null && !list.isEmpty()) {
List<InboxBaseDao> mAppNetcoreInboxList = new ArrayList<>();
for (SMTInboxMessageData itemDao : list) {
NetcoreInboxDao inboxDao = new NetcoreInboxDao(itemDao);
mAppNetcoreInboxList.add(inboxDao);
}
try {
Collections.sort(mAppNetcoreInboxList);
} catch (Exception e) {
EMTLog.e("issue with sort : " + e.getMessage(), e);
}
inboxBaseDaoListDefault.addAll(mAppNetcoreInboxList);
}
// Update UI on the main thread
getApplicationContext().runOnUiThread(() -> {
hideProgressBar();
if (inboxBaseDaoListDefault.isEmpty()) {
setErrorMsg(getString(R.string.msg_empty_notifications_list));
} else {
filterInboxList();
notifyNotificationSetChanged();
}
});
}
@Override
public void onInboxFail() {
// Hide progress bar on failure
getApplicationContext().runOnUiThread(this::hideProgressBar);
}
})
.setCategory(categoryList)
.setLimit(10)
.build();
// Fetch the inbox messages
smartechAppInbox.getAppInboxMessages(builder);
}
Editor is loading...
Leave a Comment