Search in sources :

Example 1 with Invitee

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);
}
Also used : Invitee(com.odysee.app.model.lbryinc.Invitee) FetchInviteStatusTask(com.odysee.app.tasks.lbryinc.FetchInviteStatusTask) InviteeListAdapter(com.odysee.app.adapter.InviteeListAdapter)

Example 2 with Invitee

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;
}
Also used : Invitee(com.odysee.app.model.lbryinc.Invitee) JSONObject(org.json.JSONObject) LbryioRequestException(com.odysee.app.exceptions.LbryioRequestException) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) LbryioResponseException(com.odysee.app.exceptions.LbryioResponseException)

Example 3 with Invitee

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);
}
Also used : Invitee(com.odysee.app.model.lbryinc.Invitee)

Example 4 with Invitee

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);
}
Also used : Invitee(com.odysee.app.model.lbryinc.Invitee)

Aggregations

Invitee (com.odysee.app.model.lbryinc.Invitee)4 InviteeListAdapter (com.odysee.app.adapter.InviteeListAdapter)1 LbryioRequestException (com.odysee.app.exceptions.LbryioRequestException)1 LbryioResponseException (com.odysee.app.exceptions.LbryioResponseException)1 FetchInviteStatusTask (com.odysee.app.tasks.lbryinc.FetchInviteStatusTask)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1