use of com.odysee.app.model.lbryinc.Invitee in project odysee-android by OdyseeTeam.
the class InvitesFragment method fetchInviteStatus.
private void fetchInviteStatus() {
FetchInviteStatusTask task = new FetchInviteStatusTask(progressLoadingStatus, new FetchInviteStatusTask.FetchInviteStatusHandler() {
@Override
public void onSuccess(List<Invitee> invitees) {
if (inviteHistoryAdapter == null) {
inviteHistoryAdapter = new InviteeListAdapter(invitees, getContext());
inviteHistoryAdapter.addHeader();
} else {
inviteHistoryAdapter.addInvitees(invitees);
}
if (inviteHistoryList != null) {
inviteHistoryList.setAdapter(inviteHistoryAdapter);
}
Helper.setViewVisibility(inviteHistoryList, inviteHistoryAdapter == null || inviteHistoryAdapter.getItemCount() < 2 ? View.GONE : View.VISIBLE);
}
@Override
public void onError(Exception error) {
Helper.setViewVisibility(inviteHistoryList, inviteHistoryAdapter == null || inviteHistoryAdapter.getItemCount() < 2 ? View.GONE : View.VISIBLE);
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of com.odysee.app.model.lbryinc.Invitee in project odysee-android by OdyseeTeam.
the class FetchInviteStatusTask method doInBackground.
protected List<Invitee> doInBackground(Void... params) {
List<Invitee> invitees = null;
try {
JSONObject status = (JSONObject) Lbryio.parseResponse(Lbryio.call("user", "invite_status", null, null));
JSONArray inviteesArray = status.getJSONArray("invitees");
invitees = new ArrayList<>();
for (int i = 0; i < inviteesArray.length(); i++) {
JSONObject inviteeObject = inviteesArray.getJSONObject(i);
Invitee invitee = new Invitee();
invitee.setEmail(Helper.getJSONString("email", null, inviteeObject));
invitee.setInviteRewardClaimable(Helper.getJSONBoolean("invite_reward_claimable", false, inviteeObject));
invitee.setInviteRewardClaimed(Helper.getJSONBoolean("invite_reward_claimed", false, inviteeObject));
if (!Helper.isNullOrEmpty(invitee.getEmail())) {
invitees.add(invitee);
}
}
} catch (ClassCastException | LbryioRequestException | LbryioResponseException | JSONException ex) {
error = ex;
}
return invitees;
}
use of com.odysee.app.model.lbryinc.Invitee in project odysee-android by OdyseeTeam.
the class InviteeListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(InviteeListAdapter.ViewHolder vh, int position) {
Invitee item = items.get(position);
vh.emailView.setText(item.isHeader() ? context.getString(R.string.email) : item.getEmail());
vh.emailView.setTypeface(null, item.isHeader() ? Typeface.BOLD : Typeface.NORMAL);
String rewardText = context.getString(item.isInviteRewardClaimed() ? R.string.claimed : (item.isInviteRewardClaimable() ? R.string.claimable : R.string.unclaimable));
vh.rewardView.setText(item.isHeader() ? context.getString(R.string.reward) : rewardText);
vh.rewardView.setTypeface(null, item.isHeader() ? Typeface.BOLD : Typeface.NORMAL);
}
use of com.odysee.app.model.lbryinc.Invitee in project odysee-android by OdyseeTeam.
the class InviteeListAdapter method addHeader.
public void addHeader() {
Invitee header = new Invitee();
header.setHeader(true);
items.add(0, header);
}
Aggregations