Search in sources :

Example 6 with RewardVerified

use of com.odysee.app.model.lbryinc.RewardVerified 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

RewardVerified (com.odysee.app.model.lbryinc.RewardVerified)6 View (android.view.View)4 RewardVerifiedHandler (com.odysee.app.tasks.RewardVerifiedHandler)4 Context (android.content.Context)2 WebView (android.webkit.WebView)2 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 TwitterVerifyTask (com.odysee.app.tasks.lbryinc.TwitterVerifyTask)2 VerificationSkipQueue (com.odysee.app.utils.VerificationSkipQueue)2 Type (java.lang.reflect.Type)2 HashMap (java.util.HashMap)2 JSONObject (org.json.JSONObject)2 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Handler (android.os.Handler)1 ImageView (android.widget.ImageView)1 OnBackPressedCallback (androidx.activity.OnBackPressedCallback)1 ViewPager2 (androidx.viewpager2.widget.ViewPager2)1 VerificationPagerAdapter (com.odysee.app.adapter.VerificationPagerAdapter)1 ApiCallException (com.odysee.app.exceptions.ApiCallException)1