解决换肤框架与高德地图的冲突
直接通过内存地址替换整个 ArtMethod ,完成了高德地图方法的替换。
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.android.internal.policy;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 12/25/20 5:12 PM
|
||||
*/
|
||||
public class MyPhoneLayoutInflater extends LayoutInflater {
|
||||
private static final String[] sClassPrefixList = {
|
||||
"android.widget.",
|
||||
"android.webkit.",
|
||||
"android.app."
|
||||
};
|
||||
|
||||
/**
|
||||
* Instead of instantiating directly, you should retrieve an instance
|
||||
* through {@link Context#getSystemService}
|
||||
*
|
||||
* @param context The Context in which in which to find resources and other
|
||||
* application-specific things.
|
||||
* @see Context#getSystemService
|
||||
*/
|
||||
public MyPhoneLayoutInflater(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
protected MyPhoneLayoutInflater(LayoutInflater original, Context newContext) {
|
||||
super(original, newContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override onCreateView to instantiate names that correspond to the
|
||||
* widgets known to the Widget factory. If we don't find a match,
|
||||
* call through to our super class.
|
||||
*/
|
||||
@Override
|
||||
protected View onCreateView(String name, AttributeSet attrs) throws ClassNotFoundException {
|
||||
for (String prefix : sClassPrefixList) {
|
||||
try {
|
||||
View view = createView(name, prefix, attrs);
|
||||
if (view != null) {
|
||||
return view;
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// In this case we want to let the base class take a crack
|
||||
// at it.
|
||||
}
|
||||
}
|
||||
|
||||
return super.onCreateView(name, attrs);
|
||||
}
|
||||
|
||||
public LayoutInflater cloneInContext(Context newContext) {
|
||||
return new MyPhoneLayoutInflater(this, newContext);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user