|
1 /* |
|
2 * Copyright (C) 2013 Andreas Stuetz <andreas.stuetz@gmail.com> |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 package com.astuetz.viewpager.extensions; |
|
18 |
|
19 import java.util.Locale; |
|
20 |
|
21 import android.annotation.SuppressLint; |
|
22 import android.content.Context; |
|
23 import android.content.res.TypedArray; |
|
24 import android.graphics.Canvas; |
|
25 import android.graphics.Paint; |
|
26 import android.graphics.Paint.Style; |
|
27 import android.graphics.Typeface; |
|
28 import android.os.Build; |
|
29 import android.os.Parcel; |
|
30 import android.os.Parcelable; |
|
31 import android.support.v4.view.ViewPager; |
|
32 import android.support.v4.view.ViewPager.OnPageChangeListener; |
|
33 import android.util.AttributeSet; |
|
34 import android.util.DisplayMetrics; |
|
35 import android.util.TypedValue; |
|
36 import android.view.Gravity; |
|
37 import android.view.View; |
|
38 import android.view.ViewTreeObserver.OnGlobalLayoutListener; |
|
39 import android.widget.HorizontalScrollView; |
|
40 import android.widget.ImageButton; |
|
41 import android.widget.LinearLayout; |
|
42 import android.widget.TextView; |
|
43 |
|
44 import com.beem.project.beem.R; |
|
45 |
|
46 public class PagerSlidingTabStrip extends HorizontalScrollView { |
|
47 |
|
48 public interface IconTabProvider { |
|
49 public int getPageIconResId(int position); |
|
50 } |
|
51 |
|
52 // @formatter:off |
|
53 private static final int[] ATTRS = new int[] { |
|
54 android.R.attr.textSize, |
|
55 android.R.attr.textColor |
|
56 }; |
|
57 // @formatter:on |
|
58 |
|
59 private LinearLayout.LayoutParams defaultTabLayoutParams; |
|
60 private LinearLayout.LayoutParams expandedTabLayoutParams; |
|
61 |
|
62 private final PageListener pageListener = new PageListener(); |
|
63 public OnPageChangeListener delegatePageListener; |
|
64 |
|
65 private LinearLayout tabsContainer; |
|
66 private ViewPager pager; |
|
67 |
|
68 private int tabCount; |
|
69 |
|
70 private int currentPosition = 0; |
|
71 private float currentPositionOffset = 0f; |
|
72 |
|
73 private Paint rectPaint; |
|
74 private Paint dividerPaint; |
|
75 |
|
76 private boolean checkedTabWidths = false; |
|
77 |
|
78 private int indicatorColor = 0xFF666666; |
|
79 private int underlineColor = 0x1A000000; |
|
80 private int dividerColor = 0x1A000000; |
|
81 |
|
82 private boolean shouldExpand = false; |
|
83 private boolean textAllCaps = true; |
|
84 |
|
85 private int scrollOffset = 52; |
|
86 private int indicatorHeight = 8; |
|
87 private int underlineHeight = 2; |
|
88 private int dividerPadding = 12; |
|
89 private int tabPadding = 24; |
|
90 private int dividerWidth = 1; |
|
91 |
|
92 private int tabTextSize = 12; |
|
93 private int tabTextColor = 0xFF666666; |
|
94 private Typeface tabTypeface = null; |
|
95 private int tabTypefaceStyle = Typeface.BOLD; |
|
96 |
|
97 private int lastScrollX = 0; |
|
98 |
|
99 private int tabBackgroundResId = R.drawable.background_tab; |
|
100 |
|
101 private Locale locale; |
|
102 |
|
103 public PagerSlidingTabStrip(Context context) { |
|
104 this(context, null); |
|
105 } |
|
106 |
|
107 public PagerSlidingTabStrip(Context context, AttributeSet attrs) { |
|
108 this(context, attrs, 0); |
|
109 } |
|
110 |
|
111 public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { |
|
112 super(context, attrs, defStyle); |
|
113 |
|
114 setFillViewport(true); |
|
115 setWillNotDraw(false); |
|
116 |
|
117 tabsContainer = new LinearLayout(context); |
|
118 tabsContainer.setOrientation(LinearLayout.HORIZONTAL); |
|
119 tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); |
|
120 addView(tabsContainer); |
|
121 |
|
122 DisplayMetrics dm = getResources().getDisplayMetrics(); |
|
123 |
|
124 scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); |
|
125 indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); |
|
126 underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); |
|
127 dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); |
|
128 tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); |
|
129 dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); |
|
130 tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm); |
|
131 |
|
132 // get system attrs (android:textSize and android:textColor) |
|
133 |
|
134 TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); |
|
135 |
|
136 tabTextSize = a.getDimensionPixelSize(0, tabTextSize); |
|
137 tabTextColor = a.getColor(1, tabTextColor); |
|
138 |
|
139 a.recycle(); |
|
140 |
|
141 // get custom attrs |
|
142 |
|
143 a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); |
|
144 |
|
145 indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_indicatorColor, indicatorColor); |
|
146 underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_underlineColor, underlineColor); |
|
147 dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_dividerColor, dividerColor); |
|
148 indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_indicatorHeight, indicatorHeight); |
|
149 underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_underlineHeight, underlineHeight); |
|
150 dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_dividerPadding, dividerPadding); |
|
151 tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_tabPaddingLeftRight, tabPadding); |
|
152 tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_tabBackground, tabBackgroundResId); |
|
153 shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_shouldExpand, shouldExpand); |
|
154 scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_scrollOffset, scrollOffset); |
|
155 textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_textAllCaps, textAllCaps); |
|
156 |
|
157 a.recycle(); |
|
158 |
|
159 rectPaint = new Paint(); |
|
160 rectPaint.setAntiAlias(true); |
|
161 rectPaint.setStyle(Style.FILL); |
|
162 |
|
163 dividerPaint = new Paint(); |
|
164 dividerPaint.setAntiAlias(true); |
|
165 dividerPaint.setStrokeWidth(dividerWidth); |
|
166 |
|
167 defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); |
|
168 expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); |
|
169 |
|
170 if (locale == null) { |
|
171 locale = getResources().getConfiguration().locale; |
|
172 } |
|
173 } |
|
174 |
|
175 public void setViewPager(ViewPager pager) { |
|
176 this.pager = pager; |
|
177 |
|
178 if (pager.getAdapter() == null) { |
|
179 throw new IllegalStateException("ViewPager does not have adapter instance."); |
|
180 } |
|
181 |
|
182 pager.setOnPageChangeListener(pageListener); |
|
183 |
|
184 notifyDataSetChanged(); |
|
185 } |
|
186 |
|
187 public void setOnPageChangeListener(OnPageChangeListener listener) { |
|
188 this.delegatePageListener = listener; |
|
189 } |
|
190 |
|
191 public void notifyDataSetChanged() { |
|
192 |
|
193 tabsContainer.removeAllViews(); |
|
194 |
|
195 tabCount = pager.getAdapter().getCount(); |
|
196 |
|
197 for (int i = 0; i < tabCount; i++) { |
|
198 |
|
199 if (pager.getAdapter() instanceof IconTabProvider) { |
|
200 addIconTab(i, ((IconTabProvider) pager.getAdapter()).getPageIconResId(i)); |
|
201 } else { |
|
202 addTextTab(i, pager.getAdapter().getPageTitle(i).toString()); |
|
203 } |
|
204 |
|
205 } |
|
206 |
|
207 updateTabStyles(); |
|
208 |
|
209 checkedTabWidths = false; |
|
210 |
|
211 getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { |
|
212 |
|
213 @SuppressWarnings("deprecation") |
|
214 @SuppressLint("NewApi") |
|
215 @Override |
|
216 public void onGlobalLayout() { |
|
217 |
|
218 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { |
|
219 getViewTreeObserver().removeGlobalOnLayoutListener(this); |
|
220 } else { |
|
221 getViewTreeObserver().removeOnGlobalLayoutListener(this); |
|
222 } |
|
223 |
|
224 currentPosition = pager.getCurrentItem(); |
|
225 scrollToChild(currentPosition, 0); |
|
226 } |
|
227 }); |
|
228 |
|
229 } |
|
230 |
|
231 private void addTextTab(final int position, String title) { |
|
232 |
|
233 TextView tab = new TextView(getContext()); |
|
234 tab.setText(title); |
|
235 tab.setFocusable(true); |
|
236 tab.setGravity(Gravity.CENTER); |
|
237 tab.setSingleLine(); |
|
238 |
|
239 tab.setOnClickListener(new OnClickListener() { |
|
240 @Override |
|
241 public void onClick(View v) { |
|
242 pager.setCurrentItem(position); |
|
243 } |
|
244 }); |
|
245 |
|
246 tabsContainer.addView(tab); |
|
247 |
|
248 } |
|
249 |
|
250 private void addIconTab(final int position, int resId) { |
|
251 |
|
252 ImageButton tab = new ImageButton(getContext()); |
|
253 tab.setFocusable(true); |
|
254 tab.setImageResource(resId); |
|
255 |
|
256 tab.setOnClickListener(new OnClickListener() { |
|
257 @Override |
|
258 public void onClick(View v) { |
|
259 pager.setCurrentItem(position); |
|
260 } |
|
261 }); |
|
262 |
|
263 tabsContainer.addView(tab); |
|
264 |
|
265 } |
|
266 |
|
267 private void updateTabStyles() { |
|
268 |
|
269 for (int i = 0; i < tabCount; i++) { |
|
270 |
|
271 View v = tabsContainer.getChildAt(i); |
|
272 |
|
273 v.setLayoutParams(defaultTabLayoutParams); |
|
274 v.setBackgroundResource(tabBackgroundResId); |
|
275 if (shouldExpand) { |
|
276 v.setPadding(0, 0, 0, 0); |
|
277 } else { |
|
278 v.setPadding(tabPadding, 0, tabPadding, 0); |
|
279 } |
|
280 |
|
281 if (v instanceof TextView) { |
|
282 |
|
283 TextView tab = (TextView) v; |
|
284 tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); |
|
285 tab.setTypeface(tabTypeface, tabTypefaceStyle); |
|
286 tab.setTextColor(tabTextColor); |
|
287 |
|
288 // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a |
|
289 // pre-ICS-build |
|
290 if (textAllCaps) { |
|
291 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { |
|
292 tab.setAllCaps(true); |
|
293 } else { |
|
294 tab.setText(tab.getText().toString().toUpperCase(locale)); |
|
295 } |
|
296 } |
|
297 } |
|
298 } |
|
299 |
|
300 } |
|
301 |
|
302 @Override |
|
303 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
|
304 super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
|
305 |
|
306 if (!shouldExpand || MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED) { |
|
307 return; |
|
308 } |
|
309 |
|
310 int myWidth = getMeasuredWidth(); |
|
311 int childWidth = 0; |
|
312 for (int i = 0; i < tabCount; i++) { |
|
313 childWidth += tabsContainer.getChildAt(i).getMeasuredWidth(); |
|
314 } |
|
315 |
|
316 if (!checkedTabWidths && childWidth > 0 && myWidth > 0) { |
|
317 |
|
318 if (childWidth <= myWidth) { |
|
319 for (int i = 0; i < tabCount; i++) { |
|
320 tabsContainer.getChildAt(i).setLayoutParams(expandedTabLayoutParams); |
|
321 } |
|
322 } |
|
323 |
|
324 checkedTabWidths = true; |
|
325 } |
|
326 } |
|
327 |
|
328 private void scrollToChild(int position, int offset) { |
|
329 |
|
330 if (tabCount == 0) { |
|
331 return; |
|
332 } |
|
333 |
|
334 int newScrollX = tabsContainer.getChildAt(position).getLeft() + offset; |
|
335 |
|
336 if (position > 0 || offset > 0) { |
|
337 newScrollX -= scrollOffset; |
|
338 } |
|
339 |
|
340 if (newScrollX != lastScrollX) { |
|
341 lastScrollX = newScrollX; |
|
342 scrollTo(newScrollX, 0); |
|
343 } |
|
344 |
|
345 } |
|
346 |
|
347 @Override |
|
348 protected void onDraw(Canvas canvas) { |
|
349 super.onDraw(canvas); |
|
350 |
|
351 if (isInEditMode() || tabCount == 0) { |
|
352 return; |
|
353 } |
|
354 |
|
355 final int height = getHeight(); |
|
356 |
|
357 // draw indicator line |
|
358 |
|
359 rectPaint.setColor(indicatorColor); |
|
360 |
|
361 // default: line below current tab |
|
362 View currentTab = tabsContainer.getChildAt(currentPosition); |
|
363 float lineLeft = currentTab.getLeft(); |
|
364 float lineRight = currentTab.getRight(); |
|
365 |
|
366 // if there is an offset, start interpolating left and right coordinates between current and next tab |
|
367 if (currentPositionOffset > 0f && currentPosition < tabCount - 1) { |
|
368 |
|
369 View nextTab = tabsContainer.getChildAt(currentPosition + 1); |
|
370 final float nextTabLeft = nextTab.getLeft(); |
|
371 final float nextTabRight = nextTab.getRight(); |
|
372 |
|
373 lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); |
|
374 lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); |
|
375 } |
|
376 |
|
377 canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); |
|
378 |
|
379 // draw underline |
|
380 |
|
381 rectPaint.setColor(underlineColor); |
|
382 canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); |
|
383 |
|
384 // draw divider |
|
385 |
|
386 dividerPaint.setColor(dividerColor); |
|
387 for (int i = 0; i < tabCount - 1; i++) { |
|
388 View tab = tabsContainer.getChildAt(i); |
|
389 canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); |
|
390 } |
|
391 } |
|
392 |
|
393 private class PageListener implements OnPageChangeListener { |
|
394 |
|
395 @Override |
|
396 public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { |
|
397 |
|
398 currentPosition = position; |
|
399 currentPositionOffset = positionOffset; |
|
400 |
|
401 scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth())); |
|
402 |
|
403 invalidate(); |
|
404 |
|
405 if (delegatePageListener != null) { |
|
406 delegatePageListener.onPageScrolled(position, positionOffset, positionOffsetPixels); |
|
407 } |
|
408 } |
|
409 |
|
410 @Override |
|
411 public void onPageScrollStateChanged(int state) { |
|
412 if (state == ViewPager.SCROLL_STATE_IDLE) { |
|
413 scrollToChild(pager.getCurrentItem(), 0); |
|
414 } |
|
415 |
|
416 if (delegatePageListener != null) { |
|
417 delegatePageListener.onPageScrollStateChanged(state); |
|
418 } |
|
419 } |
|
420 |
|
421 @Override |
|
422 public void onPageSelected(int position) { |
|
423 if (delegatePageListener != null) { |
|
424 delegatePageListener.onPageSelected(position); |
|
425 } |
|
426 } |
|
427 |
|
428 } |
|
429 |
|
430 public void setIndicatorColor(int indicatorColor) { |
|
431 this.indicatorColor = indicatorColor; |
|
432 invalidate(); |
|
433 } |
|
434 |
|
435 public void setIndicatorColorResource(int resId) { |
|
436 this.indicatorColor = getResources().getColor(resId); |
|
437 invalidate(); |
|
438 } |
|
439 |
|
440 public int getIndicatorColor() { |
|
441 return this.indicatorColor; |
|
442 } |
|
443 |
|
444 public void setIndicatorHeight(int indicatorLineHeightPx) { |
|
445 this.indicatorHeight = indicatorLineHeightPx; |
|
446 invalidate(); |
|
447 } |
|
448 |
|
449 public int getIndicatorHeight() { |
|
450 return indicatorHeight; |
|
451 } |
|
452 |
|
453 public void setUnderlineColor(int underlineColor) { |
|
454 this.underlineColor = underlineColor; |
|
455 invalidate(); |
|
456 } |
|
457 |
|
458 public void setUnderlineColorResource(int resId) { |
|
459 this.underlineColor = getResources().getColor(resId); |
|
460 invalidate(); |
|
461 } |
|
462 |
|
463 public int getUnderlineColor() { |
|
464 return underlineColor; |
|
465 } |
|
466 |
|
467 public void setDividerColor(int dividerColor) { |
|
468 this.dividerColor = dividerColor; |
|
469 invalidate(); |
|
470 } |
|
471 |
|
472 public void setDividerColorResource(int resId) { |
|
473 this.dividerColor = getResources().getColor(resId); |
|
474 invalidate(); |
|
475 } |
|
476 |
|
477 public int getDividerColor() { |
|
478 return dividerColor; |
|
479 } |
|
480 |
|
481 public void setUnderlineHeight(int underlineHeightPx) { |
|
482 this.underlineHeight = underlineHeightPx; |
|
483 invalidate(); |
|
484 } |
|
485 |
|
486 public int getUnderlineHeight() { |
|
487 return underlineHeight; |
|
488 } |
|
489 |
|
490 public void setDividerPadding(int dividerPaddingPx) { |
|
491 this.dividerPadding = dividerPaddingPx; |
|
492 invalidate(); |
|
493 } |
|
494 |
|
495 public int getDividerPadding() { |
|
496 return dividerPadding; |
|
497 } |
|
498 |
|
499 public void setScrollOffset(int scrollOffsetPx) { |
|
500 this.scrollOffset = scrollOffsetPx; |
|
501 invalidate(); |
|
502 } |
|
503 |
|
504 public int getScrollOffset() { |
|
505 return scrollOffset; |
|
506 } |
|
507 |
|
508 public void setShouldExpand(boolean shouldExpand) { |
|
509 this.shouldExpand = shouldExpand; |
|
510 requestLayout(); |
|
511 } |
|
512 |
|
513 public boolean getShouldExpand() { |
|
514 return shouldExpand; |
|
515 } |
|
516 |
|
517 public boolean isTextAllCaps() { |
|
518 return textAllCaps; |
|
519 } |
|
520 |
|
521 public void setAllCaps(boolean textAllCaps) { |
|
522 this.textAllCaps = textAllCaps; |
|
523 } |
|
524 |
|
525 public void setTextSize(int textSizePx) { |
|
526 this.tabTextSize = textSizePx; |
|
527 updateTabStyles(); |
|
528 } |
|
529 |
|
530 public int getTextSize() { |
|
531 return tabTextSize; |
|
532 } |
|
533 |
|
534 public void setTextColor(int textColor) { |
|
535 this.tabTextColor = textColor; |
|
536 updateTabStyles(); |
|
537 } |
|
538 |
|
539 public void setTextColorResource(int resId) { |
|
540 this.tabTextColor = getResources().getColor(resId); |
|
541 updateTabStyles(); |
|
542 } |
|
543 |
|
544 public int getTextColor() { |
|
545 return tabTextColor; |
|
546 } |
|
547 |
|
548 public void setTypeface(Typeface typeface, int style) { |
|
549 this.tabTypeface = typeface; |
|
550 this.tabTypefaceStyle = style; |
|
551 updateTabStyles(); |
|
552 } |
|
553 |
|
554 public void setTabBackground(int resId) { |
|
555 this.tabBackgroundResId = resId; |
|
556 } |
|
557 |
|
558 public int getTabBackground() { |
|
559 return tabBackgroundResId; |
|
560 } |
|
561 |
|
562 public void setTabPaddingLeftRight(int paddingPx) { |
|
563 this.tabPadding = paddingPx; |
|
564 updateTabStyles(); |
|
565 } |
|
566 |
|
567 public int getTabPaddingLeftRight() { |
|
568 return tabPadding; |
|
569 } |
|
570 |
|
571 @Override |
|
572 public void onRestoreInstanceState(Parcelable state) { |
|
573 SavedState savedState = (SavedState) state; |
|
574 super.onRestoreInstanceState(savedState.getSuperState()); |
|
575 currentPosition = savedState.currentPosition; |
|
576 requestLayout(); |
|
577 } |
|
578 |
|
579 @Override |
|
580 public Parcelable onSaveInstanceState() { |
|
581 Parcelable superState = super.onSaveInstanceState(); |
|
582 SavedState savedState = new SavedState(superState); |
|
583 savedState.currentPosition = currentPosition; |
|
584 return savedState; |
|
585 } |
|
586 |
|
587 static class SavedState extends BaseSavedState { |
|
588 int currentPosition; |
|
589 |
|
590 public SavedState(Parcelable superState) { |
|
591 super(superState); |
|
592 } |
|
593 |
|
594 private SavedState(Parcel in) { |
|
595 super(in); |
|
596 currentPosition = in.readInt(); |
|
597 } |
|
598 |
|
599 @Override |
|
600 public void writeToParcel(Parcel dest, int flags) { |
|
601 super.writeToParcel(dest, flags); |
|
602 dest.writeInt(currentPosition); |
|
603 } |
|
604 |
|
605 public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() { |
|
606 @Override |
|
607 public SavedState createFromParcel(Parcel in) { |
|
608 return new SavedState(in); |
|
609 } |
|
610 |
|
611 @Override |
|
612 public SavedState[] newArray(int size) { |
|
613 return new SavedState[size]; |
|
614 } |
|
615 }; |
|
616 } |
|
617 |
|
618 } |