导航菜单

页面标题

页面副标题

HW华为币 v1.0 - SplashActivity.java 源代码

正在查看: HW华为币 v1.0 应用的 SplashActivity.java JAVA 源代码文件

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


package com.example.webapp;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class SplashActivity extends AppCompatActivity {
    private static final int SPLASH_DURATION = 1000;
    private boolean showSplash = false;

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        loadSplashConfig();
        if (!this.showSplash) {
            Log.d("WebApp11", "启动图已关闭,直接跳转到MainActivity");
            startMainActivity();
            return;
        }
        setStatusBarTransparent();
        setContentView(R.layout.activity_splash);
        Log.d("WebApp11", "显示启动图");
        setupSplashImage();
        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public void run() {
                SplashActivity.this.startMainActivity();
            }
        }, 1000L);
    }

    private void loadSplashConfig() {
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getAssets().open("config.txt")));
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine == null) {
                    break;
                }
                String trim = readLine.trim();
                if (trim.startsWith("start=")) {
                    String trim2 = trim.substring("start=".length()).trim();
                    this.showSplash = "1".equals(trim2);
                    Log.d("WebApp11", "启动图配置: start=" + trim2 + ", showSplash=" + this.showSplash);
                    break;
                }
            }
            bufferedReader.close();
        } catch (IOException e) {
            e.printStackTrace();
            Log.w("WebApp11", "读取启动图配置失败,使用默认设置: " + e.getMessage());
        }
    }

    private void setupSplashImage() {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        int i = displayMetrics.widthPixels;
        int i2 = displayMetrics.heightPixels;
        ImageView imageView = (ImageView) findViewById(R.id.splash_image);
        try {
            InputStream open = getAssets().open("start.jpg");
            imageView.setImageDrawable(Drawable.createFromStream(open, null));
            open.close();
            ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
            layoutParams.width = i;
            layoutParams.height = i2;
            imageView.setLayoutParams(layoutParams);
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void startMainActivity() {
        startActivity(new Intent(this, (Class<?>) MainActivity.class));
        finish();
    }

    private void setStatusBarTransparent() {
        Window window = getWindow();
        if (Build.VERSION.SDK_INT >= 30) {
            window.setDecorFitsSystemWindows(false);
            window.setStatusBarColor(0);
        } else {
            window.getDecorView().setSystemUiVisibility(1280);
            window.setStatusBarColor(0);
        }
    }
}