Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4252a5a4 authored by Adam Cohen's avatar Adam Cohen Committed by Android (Google) Code Review
Browse files

Merge "-> Added the ability to specify an AdapterView's empty view through...

Merge "-> Added the ability to  specify an AdapterView's empty view through RemoteViews. An empty view is the view that appears in lieu of the collection when the collection is empty. -> Made StackViews start at their last item"
parents e3f55d45 1480fdde
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -228878,6 +228878,21 @@
<parameter name="value" type="double">
</parameter>
</method>
<method name="setEmptyView"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="viewId" type="int">
</parameter>
<parameter name="emptyViewId" type="int">
</parameter>
</method>
<method name="setFloat"
 return="void"
 abstract="false"
+1 −1
Original line number Diff line number Diff line
@@ -228,7 +228,6 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
        super(context, attrs, defStyle);
    }


    /**
     * Interface definition for a callback to be invoked when an item in this
     * AdapterView has been clicked.
@@ -629,6 +628,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
    /**
     * Sets the view to show if the adapter is empty
     */
    @android.view.RemotableViewMethod
    public void setEmptyView(View emptyView) {
        mEmptyView = emptyView;

+1 −0
Original line number Diff line number Diff line
@@ -688,6 +688,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
        }

        mAdapter = adapter;
        checkFocus();

        if (mAdapter != null) {
            mDataSetObserver = new AdapterDataSetObserver();
+50 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.widget;

import android.app.PendingIntent;
import android.appwidget.AppWidgetHostView;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
@@ -110,6 +111,42 @@ public class RemoteViews implements Parcelable, Filter {
        }
    }

    private class SetEmptyView extends Action {
        int viewId;
        int emptyViewId;

        public final static int TAG = 6;

        SetEmptyView(int viewId, int emptyViewId) {
            this.viewId = viewId;
            this.emptyViewId = emptyViewId;
        }

        SetEmptyView(Parcel in) {
            this.viewId = in.readInt();
            this.emptyViewId = in.readInt();
        }

        public void writeToParcel(Parcel out, int flags) {
            out.writeInt(TAG);
            out.writeInt(this.viewId);
            out.writeInt(this.emptyViewId);
        }

        @Override
        public void apply(View root) {
            final View view = root.findViewById(viewId);
            if (!(view instanceof AdapterView<?>)) return;

            AdapterView<?> adapterView = (AdapterView<?>) view;

            final View emptyView = root.findViewById(emptyViewId);
            if (emptyView == null) return;

            adapterView.setEmptyView(emptyView);
        }
    }

    /**
     * Equivalent to calling
     * {@link android.view.View#setOnClickListener(android.view.View.OnClickListener)}
@@ -631,6 +668,9 @@ public class RemoteViews implements Parcelable, Filter {
                case ReflectionActionWithoutParams.TAG:
                    mActions.add(new ReflectionActionWithoutParams(parcel));
                    break;
                case SetEmptyView.TAG:
                    mActions.add(new SetEmptyView(parcel));
                    break;
                default:
                    throw new ActionException("Tag " + tag + " not found");
                }
@@ -759,6 +799,16 @@ public class RemoteViews implements Parcelable, Filter {
        setBitmap(viewId, "setImageBitmap", bitmap);
    }

    /**
     * Equivalent to calling AdapterView.setEmptyView
     *
     * @param viewId The id of the view on which to set the empty view
     * @param emptyViewId The view id of the empty view
     */
    public void setEmptyView(int viewId, int emptyViewId) {
        addAction(new SetEmptyView(viewId, emptyViewId));
    }

    /**
     * Equivalent to calling {@link Chronometer#setBase Chronometer.setBase},
     * {@link Chronometer#setFormat Chronometer.setFormat},
+7 −0
Original line number Diff line number Diff line
@@ -124,6 +124,9 @@ public class StackView extends AdapterViewAnimator {
        }
        setClipChildren(false);
        setClipToPadding(false);

        // This is a flag to indicate the the stack is loading for the first time
        mWhichChild = -1;
    }

    /**
@@ -638,6 +641,10 @@ public class StackView extends AdapterViewAnimator {
    @Override
    public void onRemoteAdapterConnected() {
        super.onRemoteAdapterConnected();
        // On first run, we want to set the stack to the end.
        if (mAdapter != null && mWhichChild == -1) {
            mWhichChild = mAdapter.getCount() - 1;
        }
        setDisplayedChild(mWhichChild);
    }