Search in sources :

Example 1 with TwitterVerifyTask

use of com.odysee.app.tasks.lbryinc.TwitterVerifyTask in project odysee-android by OdyseeTeam.

the class ManualVerificationFragment method twitterVerify.

private void twitterVerify(TwitterOauth twitterOauth) {
    Context context = getContext();
    if (context != null) {
        showLoading();
        twitterOauthInProgress = true;
        if (listener != null) {
            listener.onManualProgress(twitterOauthInProgress);
        }
        TwitterVerifyTask task = new TwitterVerifyTask(twitterOauth, null, context, new RewardVerifiedHandler() {

            @Override
            public void onSuccess(RewardVerified rewardVerified) {
                twitterOauthInProgress = false;
                if (listener != null) {
                    listener.onManualProgress(twitterOauthInProgress);
                }
                if (Lbryio.currentUser != null) {
                    Lbryio.currentUser.setRewardApproved(rewardVerified.isRewardApproved());
                }
                if (rewardVerified.isRewardApproved()) {
                    if (listener != null) {
                        listener.onTwitterVerified();
                    }
                } else {
                    View root = getView();
                    if (root != null) {
                        // reward approved wasn't set to true
                        Snackbar.make(root, getString(R.string.twitter_verification_not_approved), Snackbar.LENGTH_LONG).setTextColor(Color.WHITE).setBackgroundTint(Color.RED).show();
                    }
                    hideLoading();
                }
            }

            @Override
            public void onError(Exception error) {
                handleFlowError(error != null ? error.getMessage() : null);
            }
        });
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        twitterOauthInProgress = false;
        if (listener != null) {
            listener.onManualProgress(twitterOauthInProgress);
        }
        hideLoading();
    }
}
Also used : Context(android.content.Context) TwitterVerifyTask(com.odysee.app.tasks.lbryinc.TwitterVerifyTask) RewardVerifiedHandler(com.odysee.app.tasks.RewardVerifiedHandler) RewardVerified(com.odysee.app.model.lbryinc.RewardVerified) View(android.view.View) WebView(android.webkit.WebView)

Example 2 with TwitterVerifyTask

use of com.odysee.app.tasks.lbryinc.TwitterVerifyTask in project odysee-android by OdyseeTeam.

the class RewardVerificationTwitterFragment method twitterVerify.

private void twitterVerify(TwitterOauth twitterOauth) {
    Context context = getContext();
    if (context != null) {
        showLoading();
        twitterOauthInProgress = true;
        if (listener != null) {
            listener.onManualProgress(twitterOauthInProgress);
        }
        TwitterVerifyTask task = new TwitterVerifyTask(twitterOauth, null, context, new RewardVerifiedHandler() {

            @Override
            public void onSuccess(RewardVerified rewardVerified) {
                twitterOauthInProgress = false;
                if (listener != null) {
                    listener.onManualProgress(twitterOauthInProgress);
                }
                if (Lbryio.currentUser != null) {
                    Lbryio.currentUser.setRewardApproved(rewardVerified.isRewardApproved());
                }
                if (rewardVerified.isRewardApproved()) {
                    if (listener != null) {
                        listener.onTwitterVerified();
                    }
                } else {
                    View root = getView();
                    if (root != null) {
                        // reward approved wasn't set to true
                        Snackbar.make(root, getString(R.string.twitter_verification_not_approved), Snackbar.LENGTH_LONG).setTextColor(Color.WHITE).setBackgroundTint(Color.RED).show();
                    }
                    hideLoading();
                }
            }

            @Override
            public void onError(Exception error) {
                handleFlowError(error != null ? error.getMessage() : null);
            }
        });
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        twitterOauthInProgress = false;
        if (listener != null) {
            listener.onManualProgress(twitterOauthInProgress);
        }
        hideLoading();
    }
}
Also used : Context(android.content.Context) TwitterVerifyTask(com.odysee.app.tasks.lbryinc.TwitterVerifyTask) RewardVerifiedHandler(com.odysee.app.tasks.RewardVerifiedHandler) RewardVerified(com.odysee.app.model.lbryinc.RewardVerified) View(android.view.View) WebView(android.webkit.WebView)

Aggregations

Context (android.content.Context)2 View (android.view.View)2 WebView (android.webkit.WebView)2 RewardVerified (com.odysee.app.model.lbryinc.RewardVerified)2 RewardVerifiedHandler (com.odysee.app.tasks.RewardVerifiedHandler)2 TwitterVerifyTask (com.odysee.app.tasks.lbryinc.TwitterVerifyTask)2