启动页问题修改 1

This commit is contained in:
老皮 2024-09-19 13:28:39 +08:00
parent 54eb9ea099
commit e447824ea1
14 changed files with 128 additions and 18 deletions

View File

@ -128,12 +128,32 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" /> <action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter> </intent-filter>
</service> </service>
<!-- -->
<activity <activity
android:name="com.shayu.phonelive.activity.LauncherActivity" android:name="com.shayu.phonelive.activity.LauncherActivity"
android:exported="true" android:exported="true"
>
<!-- <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="um.64e40ee55488fe7b3afa2c96" />
</intent-filter>
</activity>
<activity
android:name="com.shayu.phonelive.activity.TestActivity"
android:exported="true"
android:theme="@style/MySplashTheme" android:theme="@style/MySplashTheme"
android:screenOrientation="portrait" >
tools:ignore="LockedOrientationActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@ -144,10 +144,12 @@ public class AppContext extends CommonAppContext {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate();
if (!isMainProcess()) { if (!isMainProcess()) {
return; return;
} }
super.onCreate();
long startTime = System.currentTimeMillis();
Log.d("AppStart AppContext", "App start time: " + startTime);
CrashSaveBean.getInstance().setStartTime(System.currentTimeMillis()); CrashSaveBean.getInstance().setStartTime(System.currentTimeMillis());
//注册全局异常捕获 //注册全局异常捕获
registerError(); registerError();

View File

@ -119,9 +119,9 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
EventBus.getDefault().register(this);
setStatusBar();
setContentView(R.layout.activity_launcher); setContentView(R.layout.activity_launcher);
EventBus.getDefault().register(this);
// setStatusBar();
mContext = this; mContext = this;
mRoot = findViewById(R.id.root); mRoot = findViewById(R.id.root);
mCover = findViewById(R.id.cover); mCover = findViewById(R.id.cover);
@ -131,7 +131,6 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
mBtnSkipVideo = findViewById(R.id.btn_skip_video); mBtnSkipVideo = findViewById(R.id.btn_skip_video);
mBtnSkipImage.setOnClickListener(this); mBtnSkipImage.setOnClickListener(this);
mBtnSkipVideo.setOnClickListener(this); mBtnSkipVideo.setOnClickListener(this);
// ImgLoader.display(mContext, R.drawable.screen, mCover);
mHandler = new Handler() { mHandler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
@ -145,6 +144,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
} }
} }
}; };
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000); mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
try { try {
LogUtil.uploadErrorLog(AppContext.sInstance); LogUtil.uploadErrorLog(AppContext.sInstance);
@ -188,9 +188,11 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
* 获取Config信息 * 获取Config信息
*/ */
private void getConfig() { private void getConfig() {
// TODO 这里花了1.5s
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() { CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
@Override @Override
public void callback(ConfigBean bean) { public void callback(ConfigBean bean) {
if (bean != null) { if (bean != null) {
L.e(TAG, "----------> getPaster360Url" + bean.getBeautyKey() + " " + bean.getPaster360Url()); L.e(TAG, "----------> getPaster360Url" + bean.getBeautyKey() + " " + bean.getPaster360Url());
CommonAppConfig.getInstance().setBeautySdkType(bean.getSproutType()); CommonAppConfig.getInstance().setBeautySdkType(bean.getSproutType());
@ -220,7 +222,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
final String uid = uidAndToken[0]; final String uid = uidAndToken[0];
final String token = uidAndToken[1]; final String token = uidAndToken[1];
if (!TextUtils.isEmpty(uid) && !TextUtils.isEmpty(token)) { if (!TextUtils.isEmpty(uid) && !TextUtils.isEmpty(token)) {
playAD(obj.getIntValue("type") == 0); // playAD(obj.getIntValue("type") == 0);
} else { } else {
releaseVideo(); releaseVideo();
LauncherActivity.this.startActivity(new Intent(LauncherActivity.this, EntryActivity.class)); LauncherActivity.this.startActivity(new Intent(LauncherActivity.this, EntryActivity.class));
@ -235,6 +237,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
} else { } else {
checkUidAndToken(); checkUidAndToken();
} }
} else { } else {
ToastUtil.show(getString(R.string.net_error)); ToastUtil.show(getString(R.string.net_error));
} }
@ -423,6 +426,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
ImageView imageView = new ImageView(mContext); ImageView imageView = new ImageView(mContext);
imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
// imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setBackgroundColor(0xffffffff); imageView.setBackgroundColor(0xffffffff);
imageView.setTransitionName("ad_img_" + i); imageView.setTransitionName("ad_img_" + i);
mImageViewList.add(imageView); mImageViewList.add(imageView);

View File

@ -0,0 +1,43 @@
package com.shayu.phonelive.activity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import myname.pdlive.shayu.R;
public class TestActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
ConstraintLayout constraintLayout = findViewById(R.id.root_view);
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
ViewTreeObserver vto = constraintLayout.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// 移除监听器避免重复调用
constraintLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
int width = constraintLayout.getWidth();
int height = constraintLayout.getHeight();
Log.d("TestActivity", "Width: " + width + ", Height: " + height);
}
});
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@android:color/white"/>
</shape>
</item>
<item
android:gravity="center"> <!-- 使用gravity属性来居中图像 -->
<bitmap
android:src="@mipmap/logo_middle"
android:gravity="center"/> <!-- 尽管在<bitmap>中通常不需要这个,但在某些情况下可能有助于明确意图 -->
</item>
</layer-list>

View File

@ -2,6 +2,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root" android:id="@+id/root"
android:background="@color/red"
android:padding="1dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
@ -52,13 +54,13 @@
android:text="@string/recommend_skip" android:text="@string/recommend_skip"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="11sp" android:textSize="11sp"
android:visibility="invisible" /> android:visibility="invisible"
/>
<ImageView <ImageView
android:id="@+id/cover" android:id="@+id/cover"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clickable="true"
android:src="@drawable/screen" android:src="@drawable/screen"
android:scaleType="centerCrop" /> android:scaleType="centerCrop" />

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@color/white"
android:id="@+id/root_view"
android:layout_height="match_parent">
<ImageView
android:id="@+id/cover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/logo_middle"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

View File

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 228 KiB

View File

@ -1,12 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="MySplashTheme" parent="AppTheme"> <style name="MySplashTheme" parent="Theme.AppCompat.Light.NoActionBar">">
<!--正常--> <!--正常-->
<item name="android:windowBackground">@drawable/screen</item> <item name="android:windowBackground">@drawable/test</item>
<!-- <item name="android:windowBackground">@drawable/bg_splash</item>--> <item name="android:windowFullscreen">true</item>全屏
<item name="android:windowFullscreen">true</item>
</style> </style>
</resources> </resources>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="AppTheme" parent="Base.Theme.NoActionBar"> <!--Base.Theme.NoActionBar Theme.AppCompat.Light.NoActionBar-->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>

View File

@ -228,6 +228,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
getWindow().setSharedElementEnterTransition(new FullAdToBannerTransition(1, 0.4f, new DecelerateInterpolator())); getWindow().setSharedElementEnterTransition(new FullAdToBannerTransition(1, 0.4f, new DecelerateInterpolator()));
long startTime = System.currentTimeMillis();
Log.d("AppStart MainActivity", "App start time: " + startTime);
} }
@Override @Override
@ -312,7 +314,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
} }
}); });
} else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("2")) { } else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("2")) {
//跳转消息列表 //TODO 跳转消息列表
if (mViewPager != null) { if (mViewPager != null) {
mViewPager.setCurrentItem(2); mViewPager.setCurrentItem(2);
mTabButtonGroup.setCurPosition(2); mTabButtonGroup.setCurPosition(2);
@ -1044,6 +1046,11 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
long startTime = System.currentTimeMillis();
Log.d("AppStart MainActivity onResume", "App start time: " + startTime);
if (binder != null) { if (binder != null) {
if (binder.isDownloadOK()) { if (binder.isDownloadOK()) {
binder.install(); binder.install();
@ -1126,7 +1133,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
if (code == 0 && info.length > 0) { if (code == 0 && info.length > 0) {
ArrayList<String> list = new ArrayList<String>(Arrays.asList(info)); ArrayList<String> list = new ArrayList<String>(Arrays.asList(info));
String url1; String url1;
// TODO 优化这个循环
for (int j = 0; j < list.size(); j++) { for (int j = 0; j < list.size(); j++) {
String[] arr = list.get(j).split("/"); String[] arr = list.get(j).split("/");