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
ListView: copy from AOSP
copied from tag android-6.0.1_r81
This commit is contained in:
@@ -466,6 +466,10 @@ public class Canvas {
|
||||
|
||||
public void drawColor(int color, PorterDuff.Mode mode) {}
|
||||
|
||||
public boolean clipRect(Rect rect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static native long native_canvas_from_bitmap(long pixbuf);
|
||||
|
||||
private static native void native_save(long skia_canvas, long widget);
|
||||
|
||||
@@ -997,12 +997,16 @@ public class View implements Drawable.Callback {
|
||||
if (canvas instanceof GskCanvas)
|
||||
native_drawContent(widget, ((GskCanvas)canvas).snapshot);
|
||||
}
|
||||
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
if (canvas instanceof GskCanvas)
|
||||
native_drawChildren(widget, ((GskCanvas)canvas).snapshot);
|
||||
}
|
||||
public void draw(Canvas canvas) {
|
||||
if (canvas instanceof GskCanvas)
|
||||
native_drawBackground(widget, ((GskCanvas)canvas).snapshot);
|
||||
onDraw(canvas);
|
||||
if (canvas instanceof GskCanvas)
|
||||
native_drawChildren(widget, ((GskCanvas)canvas).snapshot);
|
||||
dispatchDraw(canvas);
|
||||
}
|
||||
|
||||
public View(Context context) {
|
||||
@@ -1429,6 +1433,8 @@ public class View implements Drawable.Callback {
|
||||
boolean changed = oldWidth != width || oldHeight != height;
|
||||
if (changed)
|
||||
onSizeChanged(width, height, oldWidth, oldHeight);
|
||||
bottom = top + height;
|
||||
right = left + width;
|
||||
onLayout(changed, 0, 0, width, height);
|
||||
oldWidth = width;
|
||||
oldHeight = height;
|
||||
@@ -1841,6 +1847,9 @@ public class View implements Drawable.Callback {
|
||||
protected void onDetachedFromWindow() {
|
||||
attachedToWindow = false;
|
||||
}
|
||||
public void attachToWindowInternal() {
|
||||
onAttachedToWindow();
|
||||
}
|
||||
|
||||
public void setLayerType(int layerType, Paint paint) {}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package android.view.animation;
|
||||
|
||||
import android.animation.TimeInterpolator;
|
||||
|
||||
public class LinearInterpolator implements TimeInterpolator {
|
||||
public class LinearInterpolator implements Interpolator {
|
||||
|
||||
@Override
|
||||
public float getInterpolation(float input) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
||||
package android.widget;
|
||||
|
||||
public interface Filterable {}
|
||||
public interface Filterable {
|
||||
public Filter getFilter();
|
||||
}
|
||||
|
||||
@@ -228,4 +228,40 @@ public class HeaderViewListAdapter implements ListAdapter, Filterable {
|
||||
public ListAdapter getWrappedAdapter() {
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
public Filter getFilter() {
|
||||
if (mAdapter instanceof Filterable) {
|
||||
return ((Filterable) mAdapter).getFilter();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isEnabled(int position) {
|
||||
// Header (negative positions will throw an IndexOutOfBoundsException)
|
||||
int numHeaders = getHeadersCount();
|
||||
if (position < numHeaders) {
|
||||
return mHeaderViewInfos.get(position).isSelectable;
|
||||
}
|
||||
|
||||
// Adapter
|
||||
final int adjPosition = position - numHeaders;
|
||||
int adapterCount = 0;
|
||||
if (mAdapter != null) {
|
||||
adapterCount = mAdapter.getCount();
|
||||
if (adjPosition < adapterCount) {
|
||||
return mAdapter.isEnabled(adjPosition);
|
||||
}
|
||||
}
|
||||
|
||||
// Footer (off-limits positions will throw an IndexOutOfBoundsException)
|
||||
return mFooterViewInfos.get(adjPosition - adapterCount).isSelectable;
|
||||
}
|
||||
|
||||
public boolean areAllItemsEnabled() {
|
||||
if (mAdapter != null) {
|
||||
return mAreAllFixedViewsSelectable && mAdapter.areAllItemsEnabled();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
package android.widget;
|
||||
|
||||
public interface ListAdapter extends Adapter {
|
||||
|
||||
public boolean isEnabled(int position);
|
||||
|
||||
public boolean areAllItemsEnabled();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -58,6 +58,7 @@ public class PopupWindow {
|
||||
|
||||
public void setContentView(View view) {
|
||||
contentView = view;
|
||||
contentView.attachToWindowInternal();
|
||||
native_setContentView(popover, view.widget);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user