Created ChildViewPager that does not listen to swipe events

This commit is contained in:
Severiano Jaramillo 2018-01-18 17:12:45 -06:00
parent 7ee708f05d
commit 2c46b509dc
6 changed files with 83 additions and 18 deletions

View file

@ -13,6 +13,7 @@ import android.view.ViewGroup;
import butterknife.BindView;
import butterknife.ButterKnife;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.util.ChildViewPager;
/**
* Created by xd on 1/17/18.
@ -32,7 +33,7 @@ public class SecuritySettingsFragment extends Fragment {
}
@BindView(R.id.pager)
public ViewPager mPager;
public ChildViewPager mPager;
public SecurityPagerAdapter securityPagerAdapter;
@ -45,6 +46,7 @@ public class SecuritySettingsFragment extends Fragment {
securityPagerAdapter = new SecurityPagerAdapter(getChildFragmentManager());
mPager.setAdapter(securityPagerAdapter);
mPager.setSwipeLocked(true);
TabLayout tabLayout = v.findViewById(R.id.tabs);

View file

@ -0,0 +1,48 @@
package cy.agorise.crystalwallet.util;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* Created by xd on 1/18/18.
*/
public class ChildViewPager extends ViewPager {
private boolean swipeLocked;
public ChildViewPager(Context context) {
super(context);
}
public ChildViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
public boolean getSwipeLocked() {
return swipeLocked;
}
public void setSwipeLocked(boolean swipeLocked) {
this.swipeLocked = swipeLocked;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return !swipeLocked && super.onTouchEvent(event);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return !swipeLocked && super.onInterceptTouchEvent(event);
}
@Override
public boolean canScrollHorizontally(int direction) {
return !swipeLocked && super.canScrollHorizontally(direction);
}
}

View file

@ -139,7 +139,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="v2.0.0"
android:text="@string/version_placeholder"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -148,7 +148,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="block# 14966596"
android:text="@string/block_number_placeholder"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View file

@ -1,47 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:layout_height="match_parent">
<TextView
android:id="@+id/tvCurrentPin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="Current PIN"
android:text="@string/current_pin"
app:layout_constraintBottom_toTopOf="@+id/etCurrentPin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
app:layout_constraintVertical_chainStyle="packed" />
<EditText
android:id="@+id/etCurrentPin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="numberPassword"
app:layout_constraintTop_toBottomOf="@id/tvCurrentPin"
app:layout_constraintBottom_toTopOf="@+id/etNewPin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintTop_toBottomOf="@+id/tvCurrentPin"
tools:ignore="LabelFor" />
<EditText
android:id="@+id/etNewPin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="New PIN"
android:hint="@string/new_pin"
android:inputType="numberPassword"
app:layout_constraintTop_toBottomOf="@+id/etCurrentPin"
app:layout_constraintBottom_toTopOf="@+id/etConfirmPin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintTop_toBottomOf="@+id/etCurrentPin" />
<EditText
android:id="@+id/etConfirmPin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="Confirm PIN"
android:hint="@string/confirm_pin"
android:inputType="numberPassword"
app:layout_constraintTop_toBottomOf="@+id/etNewPin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintTop_toBottomOf="@+id/etNewPin" />
</android.support.constraint.ConstraintLayout>

View file

@ -54,7 +54,7 @@
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
<cy.agorise.crystalwallet.util.ChildViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -487,4 +487,9 @@
<string name="remove_description">Remove an account from this Wallet. The account removed will still reside on the blockchain.</string>
<string name="remove">Remove</string>
<string name="user_name_password_placeholder">user_name Password</string>
<string name="version_placeholder">v1.0</string>
<string name="block_number_placeholder">block# 14966596</string>
<string name="current_pin">Current PIN</string>
<string name="new_pin">New PIN</string>
<string name="confirm_pin">Confirm PIN</string>
</resources>