「Update」
1、增加日志输出。
This commit is contained in:
26
app/src/main/java/com/mogo/cloud/fragment/SkinFragment.java
Normal file
26
app/src/main/java/com/mogo/cloud/fragment/SkinFragment.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.mogo.cloud.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class SkinFragment extends Fragment {
|
||||
|
||||
public SkinFragment() {
|
||||
}
|
||||
|
||||
public SkinFragment(int contentLayoutId) {
|
||||
super(contentLayoutId);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,18 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.mogo.skin.widget.SkinImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/icon_notice_default" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/bGConstraintLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/icon_notice_default">
|
||||
|
||||
<com.mogo.skin.widget.SkinImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/icon_notice_default" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
@@ -54,8 +62,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:text="Token:"
|
||||
android:textColor="@color/colorAccent"
|
||||
android:textSize="20dp" />
|
||||
|
||||
<Button
|
||||
|
||||
@@ -58,4 +58,4 @@ MOGO_TELEMATIC_VERSION=1.4.7.42
|
||||
# v2x
|
||||
MOGO_V2X_VERSION=1.4.7.42
|
||||
# SKIN
|
||||
MOGO_SKIN_VERSION=1.4.7.49.11-debug
|
||||
MOGO_SKIN_VERSION=1.4.7.49.14-debug
|
||||
|
||||
@@ -52,9 +52,13 @@ public class SkinActivityLifecycle implements Application.ActivityLifecycleCallb
|
||||
} else {
|
||||
// 兼容 targetSdkVersion >= 29
|
||||
try {
|
||||
Field field = LayoutInflater.class.getDeclaredField("mFactory2");
|
||||
Field field = LayoutInflater.class.getDeclaredField("mFactory");
|
||||
field.setAccessible(true);
|
||||
field.set(layoutInflater, skinLayoutFactory);
|
||||
|
||||
Field field2 = LayoutInflater.class.getDeclaredField("mFactory2");
|
||||
field2.setAccessible(true);
|
||||
field2.set(layoutInflater, skinLayoutFactory);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.mogo.skin;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@@ -84,7 +83,7 @@ public class SkinAttribute {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 由于有时候TextView会直接配置文字,而不是用 @string/XXX 所以会导致这里转换异常,车里简单的处理异常跳过即可
|
||||
//e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (resId != 0) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mogo.skin;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -34,7 +33,7 @@ public class SkinLayoutFactory implements LayoutInflater.Factory2, Observer {
|
||||
|
||||
// 当选择新皮肤后需要替换View与之对应的属性
|
||||
// 页面属性管理器
|
||||
SkinAttribute skinAttribute;
|
||||
private SkinAttribute skinAttribute;
|
||||
|
||||
public SkinLayoutFactory(Activity activity) {
|
||||
this.activity = activity;
|
||||
@@ -46,6 +45,20 @@ public class SkinLayoutFactory implements LayoutInflater.Factory2, Observer {
|
||||
|
||||
@Override
|
||||
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
|
||||
// // 获取 AttributeSet 中的所有属性
|
||||
// int count = attrs.getAttributeCount();
|
||||
// ArrayList<String> attributeSet = new ArrayList<>();
|
||||
// for (int i = 0; i < count; i++) {
|
||||
//// String namespace = attrs.getAttributeNamespace(i);
|
||||
// String attributeName = attrs.getAttributeName(i);
|
||||
// String attributeValue = attrs.getAttributeValue(i);
|
||||
// attributeSet.add("Attribute Name: " + attributeName + ", Value: " + attributeValue);
|
||||
// }
|
||||
//
|
||||
// Log.d(TAG, "onCreateView() parent = "
|
||||
// + " name = " + name
|
||||
// + " attrs = " + attributeSet);
|
||||
|
||||
//换肤就是在需要时候替换 View的属性(src、background等)
|
||||
//创建 View,从而修改View属性
|
||||
View view = createViewFromTag(name, context, attrs);
|
||||
|
||||
Reference in New Issue
Block a user