You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
LayoutInflater: use onCreateView() method from Activity if provided
This commit is contained in:
@@ -14,6 +14,7 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.util.AttributeSet;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -34,7 +35,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Activity extends ContextThemeWrapper implements Window.Callback {
|
public class Activity extends ContextThemeWrapper implements Window.Callback, LayoutInflater.Factory2 {
|
||||||
private final static String TAG = "Activity";
|
private final static String TAG = "Activity";
|
||||||
|
|
||||||
public static final int RESULT_CANCELED = 0;
|
public static final int RESULT_CANCELED = 0;
|
||||||
@@ -582,4 +583,8 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
|||||||
throw new IllegalArgumentException("ID does not reference a View inside this View");
|
throw new IllegalArgumentException("ID does not reference a View inside this View");
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class LayoutInflater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface Factory2 {
|
public interface Factory2 {
|
||||||
|
public View onCreateView(View parent, String name, Context context, AttributeSet attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Factory2 mFactory2;
|
private Factory2 mFactory2;
|
||||||
@@ -117,11 +118,14 @@ public class LayoutInflater {
|
|||||||
|
|
||||||
Slog.v(TAG, tabs(indent) + "createViewFromTag called: parent: " + parent + ", name: " + name);
|
Slog.v(TAG, tabs(indent) + "createViewFromTag called: parent: " + parent + ", name: " + name);
|
||||||
|
|
||||||
View view;
|
View view = null;
|
||||||
|
|
||||||
if (-1 == name.indexOf('.')) {
|
if (context instanceof Factory2) {
|
||||||
|
view = ((Factory2)context).onCreateView(parent, name, context, attrs);
|
||||||
|
}
|
||||||
|
if (view == null && -1 == name.indexOf('.')) {
|
||||||
view = onCreateView(parent, name, attrs);
|
view = onCreateView(parent, name, attrs);
|
||||||
} else {
|
} else if (view == null) {
|
||||||
view = createView(name, null, attrs);
|
view = createView(name, null, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user