зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1321981
- [RTL] ViewPager Support - part 4. Switch to RtlViewPager, r=sebastian
MozReview-Commit-ID: 2s695og8Umo --HG-- extra : rebase_source : 783cc65585ebecc5f3a57658697f3d01985af885
This commit is contained in:
Родитель
3fc1180e7a
Коммит
aad3222a91
|
@ -9,7 +9,6 @@ import android.content.Context;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentPagerAdapter;
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -17,6 +16,8 @@ import android.animation.Animator;
|
||||||
import android.animation.AnimatorSet;
|
import android.animation.AnimatorSet;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
|
|
||||||
|
import com.booking.rtlviewpager.RtlViewPager;
|
||||||
|
|
||||||
import org.mozilla.gecko.Telemetry;
|
import org.mozilla.gecko.Telemetry;
|
||||||
import org.mozilla.gecko.TelemetryContract;
|
import org.mozilla.gecko.TelemetryContract;
|
||||||
import org.mozilla.gecko.home.HomePager.Decor;
|
import org.mozilla.gecko.home.HomePager.Decor;
|
||||||
|
@ -30,7 +31,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @see FirstrunPanel for the first run pages that are used in this pager.
|
* @see FirstrunPanel for the first run pages that are used in this pager.
|
||||||
*/
|
*/
|
||||||
public class FirstrunPager extends ViewPager {
|
public class FirstrunPager extends RtlViewPager {
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
protected FirstrunPanel.PagerNavigation pagerNavigation;
|
protected FirstrunPanel.PagerNavigation pagerNavigation;
|
||||||
|
@ -48,7 +49,7 @@ public class FirstrunPager extends ViewPager {
|
||||||
@Override
|
@Override
|
||||||
public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
||||||
if (child instanceof Decor) {
|
if (child instanceof Decor) {
|
||||||
((ViewPager.LayoutParams) params).isDecor = true;
|
((RtlViewPager.LayoutParams) params).isDecor = true;
|
||||||
mDecor = (Decor) child;
|
mDecor = (Decor) child;
|
||||||
mDecor.setOnTitleClickListener(new TabMenuStrip.OnTitleClickListener() {
|
mDecor.setOnTitleClickListener(new TabMenuStrip.OnTitleClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,13 +28,14 @@ import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.support.v4.view.ViewPager;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
public class HomePager extends ViewPager implements HomeScreen {
|
import com.booking.rtlviewpager.RtlViewPager;
|
||||||
|
|
||||||
|
public class HomePager extends RtlViewPager implements HomeScreen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
|
public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
|
||||||
|
@ -172,7 +173,7 @@ public class HomePager extends ViewPager implements HomeScreen {
|
||||||
setFocusableInTouchMode(true);
|
setFocusableInTouchMode(true);
|
||||||
|
|
||||||
mOriginalBackground = getBackground();
|
mOriginalBackground = getBackground();
|
||||||
setOnPageChangeListener(new PageChangeListener());
|
addOnPageChangeListener(new PageChangeListener());
|
||||||
|
|
||||||
mLoadState = LoadState.UNLOADED;
|
mLoadState = LoadState.UNLOADED;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +181,7 @@ public class HomePager extends ViewPager implements HomeScreen {
|
||||||
@Override
|
@Override
|
||||||
public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
||||||
if (child instanceof Decor) {
|
if (child instanceof Decor) {
|
||||||
((ViewPager.LayoutParams) params).isDecor = true;
|
((RtlViewPager.LayoutParams) params).isDecor = true;
|
||||||
mDecor = (Decor) child;
|
mDecor = (Decor) child;
|
||||||
mTabStrip = child;
|
mTabStrip = child;
|
||||||
|
|
||||||
|
@ -519,7 +520,7 @@ public class HomePager extends ViewPager implements HomeScreen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PageChangeListener implements ViewPager.OnPageChangeListener {
|
private class PageChangeListener implements RtlViewPager.OnPageChangeListener {
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
notifyPanelSelected(position);
|
notifyPanelSelected(position);
|
||||||
|
|
|
@ -386,13 +386,13 @@ public class CirclePageIndicator
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mViewPager != null) {
|
if (mViewPager != null) {
|
||||||
mViewPager.setOnPageChangeListener(null);
|
mViewPager.removeOnPageChangeListener(this);
|
||||||
}
|
}
|
||||||
if (view.getAdapter() == null) {
|
if (view.getAdapter() == null) {
|
||||||
throw new IllegalStateException("ViewPager does not have adapter instance.");
|
throw new IllegalStateException("ViewPager does not have adapter instance.");
|
||||||
}
|
}
|
||||||
mViewPager = view;
|
mViewPager = view;
|
||||||
mViewPager.setOnPageChangeListener(this);
|
mViewPager.addOnPageChangeListener(this);
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
<com.booking.rtlviewpager.RtlViewPager
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче