am 331bb0c3: Setup ActionBars in layoutlib the same way the platform does it. do not merge.
* commit '331bb0c393d5e2ea2485102dcddbb8c2d42654d2': Setup ActionBars in layoutlib the same way the platform does it. do not merge.
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ImageView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<include layout="@android:layout/action_bar_home" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</merge>
|
||||
|
||||
@@ -474,7 +474,7 @@ public final class Matrix_Delegate {
|
||||
}
|
||||
|
||||
Matrix_Delegate other = sManager.getDelegate(other_matrix);
|
||||
if (d == null) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ public final class Matrix_Delegate {
|
||||
}
|
||||
|
||||
Matrix_Delegate other = sManager.getDelegate(other_matrix);
|
||||
if (d == null) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,14 @@ abstract class CustomBar extends LinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadIconById(int id, String iconReference) {
|
||||
ResourceValue value = getResourceValue(iconReference);
|
||||
if (value != null) {
|
||||
loadIconById(id, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected Drawable loadIcon(int index, ResourceType type, String name) {
|
||||
BridgeContext bridgeContext = (BridgeContext) mContext;
|
||||
RenderResources res = bridgeContext.getRenderResources();
|
||||
@@ -162,34 +170,64 @@ abstract class CustomBar extends LinearLayout {
|
||||
if (child instanceof ImageView) {
|
||||
ImageView imageView = (ImageView) child;
|
||||
|
||||
Drawable drawable = ResourceHelper.getDrawable(
|
||||
value, (BridgeContext) mContext);
|
||||
if (drawable != null) {
|
||||
imageView.setBackgroundDrawable(drawable);
|
||||
}
|
||||
|
||||
return drawable;
|
||||
return loadIcon(imageView, value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Drawable loadIconById(int id, ResourceValue value) {
|
||||
View child = findViewById(id);
|
||||
if (child instanceof ImageView) {
|
||||
ImageView imageView = (ImageView) child;
|
||||
|
||||
return loadIcon(imageView, value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private Drawable loadIcon(ImageView imageView, ResourceValue value) {
|
||||
Drawable drawable = ResourceHelper.getDrawable(value, (BridgeContext) mContext);
|
||||
if (drawable != null) {
|
||||
imageView.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
protected TextView setText(int index, String stringReference) {
|
||||
View child = getChildAt(index);
|
||||
if (child instanceof TextView) {
|
||||
TextView textView = (TextView) child;
|
||||
ResourceValue value = getResourceValue(stringReference);
|
||||
if (value != null) {
|
||||
textView.setText(value.getValue());
|
||||
} else {
|
||||
textView.setText(stringReference);
|
||||
}
|
||||
setText(textView, stringReference);
|
||||
return textView;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected TextView setTextById(int id, String stringReference) {
|
||||
View child = findViewById(id);
|
||||
if (child instanceof TextView) {
|
||||
TextView textView = (TextView) child;
|
||||
setText(textView, stringReference);
|
||||
return textView;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setText(TextView textView, String stringReference) {
|
||||
ResourceValue value = getResourceValue(stringReference);
|
||||
if (value != null) {
|
||||
textView.setText(value.getValue());
|
||||
} else {
|
||||
textView.setText(stringReference);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setStyle(String themeEntryName) {
|
||||
|
||||
BridgeContext bridgeContext = (BridgeContext) mContext;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class FakeActionBar extends CustomBar {
|
||||
// Cannot access the inside items through id because no R.id values have been
|
||||
// created for them.
|
||||
// We do know the order though.
|
||||
loadIcon(0, icon);
|
||||
loadIconById(android.R.id.home, icon);
|
||||
mTextView = setText(1, label);
|
||||
|
||||
setStyle("actionBarStyle");
|
||||
|
||||
Reference in New Issue
Block a user