Search in sources :

Example 1 with VerificationPagerAdapter

use of com.odysee.app.adapter.VerificationPagerAdapter in project odysee-android by OdyseeTeam.

the class VerificationActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    verificationSkipQueue = new VerificationSkipQueue(this, new VerificationSkipQueue.ShowInProgressListener() {

        @Override
        public void maybeShowRequestInProgress() {
            showLoading();
        }
    }, new RewardVerifiedHandler() {

        @Override
        public void onSuccess(RewardVerified rewardVerified) {
            if (Lbryio.currentUser != null) {
                Lbryio.currentUser.setRewardApproved(rewardVerified.isRewardApproved());
            }
            if (!rewardVerified.isRewardApproved()) {
                // show pending purchase message (possible slow card tx)
                Snackbar.make(findViewById(R.id.verification_pager), R.string.purchase_request_pending, Snackbar.LENGTH_LONG).show();
            } else {
                Snackbar.make(findViewById(R.id.verification_pager), R.string.reward_verification_successful, Snackbar.LENGTH_LONG).show();
            }
            setResult(RESULT_OK);
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    finish();
                }
            }, 3000);
        }

        @Override
        public void onError(Exception error) {
            showFetchUserError(getString(R.string.purchase_request_failed_error));
            hideLoading();
        }
    });
    verificationSkipQueue.createBillingClientAndEstablishConnection();
    signedIn = Lbryio.isSignedIn();
    Intent intent = getIntent();
    if (intent != null) {
        flow = intent.getIntExtra("flow", -1);
        if (flow == -1 || (flow == VERIFICATION_FLOW_SIGN_IN && signedIn)) {
            // no flow specified (or user is already signed in), just exit
            setResult(signedIn ? RESULT_OK : RESULT_CANCELED);
            finish();
            return;
        }
    }
    if (!Arrays.asList(VERIFICATION_FLOW_SIGN_IN, VERIFICATION_FLOW_REWARDS, VERIFICATION_FLOW_WALLET).contains(flow)) {
        // invalid flow specified
        setResult(RESULT_CANCELED);
        finish();
        return;
    }
    IntentFilter filter = new IntentFilter();
    setContentView(R.layout.activity_verification);
    ViewPager2 viewPager = findViewById(R.id.verification_pager);
    viewPager.setUserInputEnabled(false);
    viewPager.setSaveEnabled(false);
    viewPager.setAdapter(new VerificationPagerAdapter(this));
    findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
    findViewById(R.id.verification_close_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            setResult(RESULT_CANCELED);
            finish();
        }
    });
}
Also used : IntentFilter(android.content.IntentFilter) VerificationSkipQueue(com.odysee.app.utils.VerificationSkipQueue) RewardVerifiedHandler(com.odysee.app.tasks.RewardVerifiedHandler) Handler(android.os.Handler) RewardVerifiedHandler(com.odysee.app.tasks.RewardVerifiedHandler) Intent(android.content.Intent) View(android.view.View) ViewPager2(androidx.viewpager2.widget.ViewPager2) VerificationPagerAdapter(com.odysee.app.adapter.VerificationPagerAdapter) RewardVerified(com.odysee.app.model.lbryinc.RewardVerified)

Aggregations

Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Handler (android.os.Handler)1 View (android.view.View)1 ViewPager2 (androidx.viewpager2.widget.ViewPager2)1 VerificationPagerAdapter (com.odysee.app.adapter.VerificationPagerAdapter)1 RewardVerified (com.odysee.app.model.lbryinc.RewardVerified)1 RewardVerifiedHandler (com.odysee.app.tasks.RewardVerifiedHandler)1 VerificationSkipQueue (com.odysee.app.utils.VerificationSkipQueue)1