forked from Grouper-AOSP/platform_manifest
-
Notifications
You must be signed in to change notification settings - Fork 13
/
frameworks_support.patch
369 lines (343 loc) · 13.4 KB
/
frameworks_support.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
diff --git a/compat/java/android/support/v4/view/ViewCompat.java b/compat/java/android/support/v4/view/ViewCompat.java
index 9637e65fb9..cc3cc26058 100644
--- a/compat/java/android/support/v4/view/ViewCompat.java
+++ b/compat/java/android/support/v4/view/ViewCompat.java
@@ -541,11 +541,11 @@ public class ViewCompat {
}
@Override
public void postInvalidateOnAnimation(View view) {
- view.invalidate();
+ view.postInvalidate();
}
@Override
public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
- view.invalidate(left, top, right, bottom);
+ view.postInvalidate(left, top, right, bottom);
}
@Override
public void postOnAnimation(View view, Runnable action) {
diff --git a/design/src/android/support/design/widget/BottomSheetBehavior.java b/design/src/android/support/design/widget/BottomSheetBehavior.java
index c3362a81d1..b913de19a5 100644
--- a/design/src/android/support/design/widget/BottomSheetBehavior.java
+++ b/design/src/android/support/design/widget/BottomSheetBehavior.java
@@ -385,7 +385,8 @@ public class BottomSheetBehavior<V extends View> extends CoordinatorLayout.Behav
setStateInternal(STATE_EXPANDED);
return;
}
- if (target != mNestedScrollingChildRef.get() || !mNestedScrolled) {
+ if (mNestedScrollingChildRef == null || target != mNestedScrollingChildRef.get()
+ || !mNestedScrolled) {
return;
}
int top;
diff --git a/fragment/java/android/support/v4/app/FragmentHostCallback.java b/fragment/java/android/support/v4/app/FragmentHostCallback.java
index 75fde038f2..5c256d38f7 100644
--- a/fragment/java/android/support/v4/app/FragmentHostCallback.java
+++ b/fragment/java/android/support/v4/app/FragmentHostCallback.java
@@ -304,13 +304,9 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
mAllLoaderManagers = new SimpleArrayMap<String, LoaderManager>();
}
LoaderManagerImpl lm = (LoaderManagerImpl) mAllLoaderManagers.get(who);
- if (lm == null) {
- if (create) {
- lm = new LoaderManagerImpl(who, this, started);
- mAllLoaderManagers.put(who, lm);
- }
- } else {
- lm.updateHostController(this);
+ if (lm == null && create) {
+ lm = new LoaderManagerImpl(who, this, started);
+ mAllLoaderManagers.put(who, lm);
}
return lm;
}
@@ -350,6 +346,11 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
}
void restoreLoaderNonConfig(SimpleArrayMap<String, LoaderManager> loaderManagers) {
+ if (loaderManagers != null) {
+ for (int i = 0, N = loaderManagers.size(); i < N; i++) {
+ ((LoaderManagerImpl) loaderManagers.valueAt(i)).updateHostController(this);
+ }
+ }
mAllLoaderManagers = loaderManagers;
}
diff --git a/fragment/java/android/support/v4/app/FragmentManager.java b/fragment/java/android/support/v4/app/FragmentManager.java
index 3baf4f9d3a..5996c9dbc7 100644
--- a/fragment/java/android/support/v4/app/FragmentManager.java
+++ b/fragment/java/android/support/v4/app/FragmentManager.java
@@ -2146,26 +2146,36 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
public void dispatchCreate() {
mStateSaved = false;
+ mExecutingActions = true;
moveToState(Fragment.CREATED, false);
+ mExecutingActions = false;
}
public void dispatchActivityCreated() {
mStateSaved = false;
+ mExecutingActions = true;
moveToState(Fragment.ACTIVITY_CREATED, false);
+ mExecutingActions = false;
}
public void dispatchStart() {
mStateSaved = false;
+ mExecutingActions = true;
moveToState(Fragment.STARTED, false);
+ mExecutingActions = false;
}
public void dispatchResume() {
mStateSaved = false;
+ mExecutingActions = true;
moveToState(Fragment.RESUMED, false);
+ mExecutingActions = false;
}
public void dispatchPause() {
+ mExecutingActions = true;
moveToState(Fragment.STARTED, false);
+ mExecutingActions = false;
}
public void dispatchStop() {
@@ -2174,21 +2184,29 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
// them.
mStateSaved = true;
+ mExecutingActions = true;
moveToState(Fragment.STOPPED, false);
+ mExecutingActions = false;
}
public void dispatchReallyStop() {
+ mExecutingActions = true;
moveToState(Fragment.ACTIVITY_CREATED, false);
+ mExecutingActions = false;
}
public void dispatchDestroyView() {
+ mExecutingActions = true;
moveToState(Fragment.CREATED, false);
+ mExecutingActions = false;
}
public void dispatchDestroy() {
mDestroyed = true;
execPendingActions();
+ mExecutingActions = true;
moveToState(Fragment.INITIALIZING, false);
+ mExecutingActions = false;
mHost = null;
mContainer = null;
mParent = null;
diff --git a/fragment/tests/java/android/support/v4/app/ReentrantFragment.java b/fragment/tests/java/android/support/v4/app/ReentrantFragment.java
new file mode 100644
index 0000000000..472245df2a
--- /dev/null
+++ b/fragment/tests/java/android/support/v4/app/ReentrantFragment.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.v4.app;
+
+import android.os.Bundle;
+
+public class ReentrantFragment extends StrictFragment {
+ private static final String FROM_STATE = "fromState";
+ private static final String TO_STATE = "toState";
+ int mFromState = 0;
+ int mToState = 0;
+ boolean mIsRestored;
+
+ public static ReentrantFragment create(int fromState, int toState) {
+ ReentrantFragment fragment = new ReentrantFragment();
+ fragment.mFromState = fromState;
+ fragment.mToState = toState;
+ fragment.mIsRestored = false;
+ return fragment;
+ }
+
+ @Override
+ public void onStateChanged(int fromState) {
+ super.onStateChanged(fromState);
+ // We execute the transaction when shutting down or after restoring
+ if (fromState == mFromState && mState == mToState
+ && (mToState < mFromState || mIsRestored)) {
+ executeTransaction();
+ }
+ }
+
+ private void executeTransaction() {
+ getFragmentManager().beginTransaction()
+ .add(new StrictFragment(), "should throw")
+ .commitNow();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt(FROM_STATE, mFromState);
+ outState.putInt(TO_STATE, mToState);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ if (savedInstanceState != null) {
+ mFromState = savedInstanceState.getInt(FROM_STATE);
+ mToState = savedInstanceState.getInt(TO_STATE);
+ mIsRestored = true;
+ }
+ super.onCreate(savedInstanceState);
+ }
+}
+
diff --git a/fragment/tests/java/android/support/v4/app/StrictFragment.java b/fragment/tests/java/android/support/v4/app/StrictFragment.java
index dfda814132..d91c161517 100644
--- a/fragment/tests/java/android/support/v4/app/StrictFragment.java
+++ b/fragment/tests/java/android/support/v4/app/StrictFragment.java
@@ -51,6 +51,10 @@ public class StrictFragment extends Fragment {
return "(unknown " + state + ")";
}
+ public void onStateChanged(int fromState) {
+ checkGetActivity();
+ }
+
public void checkGetActivity() {
if (getActivity() == null) {
throw new IllegalStateException("getActivity() returned null at unexpected time");
@@ -92,7 +96,7 @@ public class StrictFragment extends Fragment {
mCalledOnAttach = true;
checkState("onAttach", DETACHED);
mState = ATTACHED;
- checkGetActivity();
+ onStateChanged(DETACHED);
}
@Override
@@ -104,7 +108,7 @@ public class StrictFragment extends Fragment {
mCalledOnCreate = true;
checkState("onCreate", ATTACHED);
mState = CREATED;
- checkGetActivity();
+ onStateChanged(ATTACHED);
}
@Override
@@ -112,8 +116,9 @@ public class StrictFragment extends Fragment {
super.onActivityCreated(savedInstanceState);
mCalledOnActivityCreated = true;
checkState("onActivityCreated", ATTACHED, CREATED);
+ int fromState = mState;
mState = ACTIVITY_CREATED;
- checkGetActivity();
+ onStateChanged(fromState);
}
@Override
@@ -122,7 +127,7 @@ public class StrictFragment extends Fragment {
mCalledOnStart = true;
checkState("onStart", ACTIVITY_CREATED);
mState = STARTED;
- checkGetActivity();
+ onStateChanged(ACTIVITY_CREATED);
}
@Override
@@ -131,7 +136,7 @@ public class StrictFragment extends Fragment {
mCalledOnResume = true;
checkState("onResume", STARTED);
mState = RESUMED;
- checkGetActivity();
+ onStateChanged(STARTED);
}
@Override
@@ -148,7 +153,7 @@ public class StrictFragment extends Fragment {
mCalledOnPause = true;
checkState("onPause", RESUMED);
mState = STARTED;
- checkGetActivity();
+ onStateChanged(RESUMED);
}
@Override
@@ -157,7 +162,7 @@ public class StrictFragment extends Fragment {
mCalledOnStop = true;
checkState("onStop", STARTED);
mState = CREATED;
- checkGetActivity();
+ onStateChanged(STARTED);
}
@Override
@@ -166,7 +171,7 @@ public class StrictFragment extends Fragment {
mCalledOnDestroy = true;
checkState("onDestroy", CREATED);
mState = ATTACHED;
- checkGetActivity();
+ onStateChanged(CREATED);
}
@Override
@@ -174,7 +179,8 @@ public class StrictFragment extends Fragment {
super.onDetach();
mCalledOnDetach = true;
checkState("onDestroy", CREATED, ATTACHED);
+ int fromState = mState;
mState = DETACHED;
- checkGetActivity();
+ onStateChanged(fromState);
}
}
diff --git a/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java b/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java
index b640f79c62..8c57dc853a 100644
--- a/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java
+++ b/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java
@@ -11160,6 +11160,11 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro
}
}
}
+
+ @Override
+ public void onAnimationStarted(ViewHolder item) {
+ //do nothing
+ }
}
/**
@@ -11329,7 +11334,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro
*
* @param listener The listener that must be called.
*/
- void setListener(ItemAnimatorListener listener) {
+ protected void setListener(ItemAnimatorListener listener) {
mListener = listener;
}
@@ -11695,6 +11700,9 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro
*/
public final void dispatchAnimationStarted(ViewHolder viewHolder) {
onAnimationStarted(viewHolder);
+ if (mListener != null) {
+ mListener.onAnimationStarted(viewHolder);
+ }
}
/**
@@ -11724,7 +11732,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro
* equivalent to calling {@link #isRunning()}.
* @return true if there are any item animations currently running, false otherwise.
*/
- public final boolean isRunning(ItemAnimatorFinishedListener listener) {
+ public boolean isRunning(ItemAnimatorFinishedListener listener) {
boolean running = isRunning();
if (listener != null) {
if (!running) {
@@ -11818,11 +11826,11 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro
/**
* The interface to be implemented by listeners to animation events from this
- * ItemAnimator. This is used internally and is not intended for developers to
- * create directly.
+ * ItemAnimator.
*/
- interface ItemAnimatorListener {
+ protected interface ItemAnimatorListener {
void onAnimationFinished(ViewHolder item);
+ void onAnimationStarted(ViewHolder item);
}
/**