导航菜单

页面标题

页面副标题

CityMall v1.42.1 - NfcActivity.java 源代码

正在查看: CityMall v1.42.1 应用的 NfcActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package in.juspay.hypernfc;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import com.cardreader.card_reader_lib.CardTask;
import in.juspay.hypernfc.NfcActivity;
import java.util.Timer;
import java.util.TimerTask;
import org.json.JSONObject;

public class NfcActivity extends FragmentActivity {

    @Nullable
    private TimerTask task;

    @NonNull
    private final JSONObject data = new JSONObject();

    @NonNull
    private final CardTask cardTask = new CardTask();

    @NonNull
    private final Timer timerForWaitingInActivity = new Timer();

    @NonNull
    private final Timer timerToReadChangedMessage = new Timer();

    class AnonymousClass1 extends TimerTask {
        AnonymousClass1() {
        }

        public void lambda$run$0() {
            NfcActivity.this.findViewById(R.id.backgroundImage).setBackground(ContextCompat.e(NfcActivity.this.getApplicationContext(), R.drawable.image_border));
        }

        @Override
        public void run() {
            try {
                NfcActivity.this.data.put("error", "Request timed out!");
                NfcActivity.this.data.put("data", (Object) null);
                NfcActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        NfcActivity.AnonymousClass1.this.lambda$run$0();
                    }
                });
                NfcActivity nfcActivity = NfcActivity.this;
                nfcActivity.timedOut(nfcActivity.data);
            } catch (Exception unused) {
                Intent intent = new Intent();
                intent.putExtra("result_data", "{\"error\":\"Couldn't read the card! Try again or type your card number\"}");
                NfcActivity.this.setResult(0, intent);
                NfcActivity.this.finish();
            }
        }
    }

    public void lambda$onCreate$0(ImageView imageView) {
        ((Wave) findViewById(R.id.rippleView)).startRippleAnimation(imageView.getTop() + (imageView.getHeight() / 2));
    }

    public void lambda$onNewIntent$1() {
        findViewById(R.id.backgroundImage).setBackground(ContextCompat.e(getApplicationContext(), R.drawable.image_border));
    }

    public void timedOut(final JSONObject jSONObject) {
        ((TextView) findViewById(R.id.nfcStatus)).setText(R.string.no_card_detected);
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                Intent intent = new Intent();
                intent.putExtra("result_data", jSONObject.toString());
                NfcActivity.this.setResult(0, intent);
                NfcActivity.this.finish();
            }
        };
        this.task = timerTask;
        this.timerToReadChangedMessage.schedule(timerTask, 1500L);
    }

    public void onBackPressed() {
        setResult(0, new Intent());
        finish();
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Bundle extras = getIntent().getExtras();
        int i = extras != null ? extras.getInt("waitingTime") : 7000;
        setContentView(R.layout.activity_nfc);
        final ImageView imageView = (ImageView) findViewById(R.id.backgroundImage);
        imageView.post(new Runnable() {
            @Override
            public final void run() {
                NfcActivity.this.lambda$onCreate$0(imageView);
            }
        });
        AnonymousClass1 anonymousClass1 = new AnonymousClass1();
        this.task = anonymousClass1;
        this.timerForWaitingInActivity.schedule(anonymousClass1, i);
    }

    protected void onDestroy() {
        super.onDestroy();
        try {
            TimerTask timerTask = this.task;
            if (timerTask != null) {
                timerTask.cancel();
            }
            this.timerForWaitingInActivity.cancel();
            this.timerToReadChangedMessage.cancel();
        } catch (Exception unused) {
        }
    }

    protected void onNewIntent(Intent intent) {
        super/*androidx.activity.ComponentActivity*/.onNewIntent(intent);
        try {
            String cardDetails = this.cardTask.getCardDetails(intent);
            this.data.put("error", (Object) null);
            this.data.put("data", cardDetails);
            if (cardDetails != null) {
                ((TextView) findViewById(R.id.nfcStatus)).setText(R.string.scan_successful);
                TimerTask timerTask = new TimerTask() {
                    @Override
                    public void run() {
                        Intent intent2 = new Intent();
                        intent2.putExtra("result_data", NfcActivity.this.data.toString());
                        NfcActivity.this.setResult(-1, intent2);
                        NfcActivity.this.finish();
                    }
                };
                this.task = timerTask;
                this.timerToReadChangedMessage.schedule(timerTask, 1500L);
            } else {
                runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        NfcActivity.this.lambda$onNewIntent$1();
                    }
                });
                ((TextView) findViewById(R.id.nfcStatus)).setText(R.string.scan_failed);
                TimerTask timerTask2 = new TimerTask() {
                    @Override
                    public void run() {
                        Intent intent2 = new Intent();
                        intent2.putExtra("result_data", "{\"error\":\"Couldn't read your card ! Try again or type your card number\"}");
                        NfcActivity.this.setResult(0, intent2);
                        NfcActivity.this.finish();
                    }
                };
                this.task = timerTask2;
                this.timerToReadChangedMessage.schedule(timerTask2, 1500L);
            }
        } catch (Exception unused) {
            Intent intent2 = new Intent();
            intent2.putExtra("result_data", "{\"error\":\"Couldn't recognize card ! Try again or type your card number\"}");
            setResult(0, intent2);
            finish();
        }
    }

    protected void onPause() {
        super.onPause();
        if (this.cardTask.isNFCEnabled(this)) {
            this.cardTask.onPauseClone(this);
        }
    }

    protected void onResume() {
        super.onResume();
        if (this.cardTask.isNFCEnabled(this)) {
            this.cardTask.onResumeClone(this);
        }
    }
}