Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…h-Android

� Conflicts:
�	fancywalkthroughlib/src/main/java/com/shashank/sony/fancywalkthroughlib/FancyWalkthroughCard.java
�	fancywalkthroughlib/src/main/java/com/shashank/sony/fancywalkthroughlib/FancyWalkthroughFragment.java
�	fancywalkthroughlib/src/main/res/layout/fragment_ahoy.xml
  • Loading branch information
Shashank02051997 committed Jul 17, 2021
2 parents 5cb3781 + 8107e45 commit 73fcec7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ protected void onCreate(Bundle savedInstanceState) {
}

public void setOnboardPages(List<FancyWalkthroughCard> pages) {

this.pages = pages;
ahoyOnboarderAdapter = new FancyWalkthroughAdapter(pages, getSupportFragmentManager(), dpToPixels(0, this), typeface);
mCardShadowTransformer = new ShadowTransformer(vpOnboarderPager, ahoyOnboarderAdapter);
mCardShadowTransformer.enableScaling(true);
vpOnboarderPager.setAdapter(ahoyOnboarderAdapter);
vpOnboarderPager.setPageTransformer(false, mCardShadowTransformer);
circleIndicatorView.setPageIndicators(pages.size());

}

public float dpToPixels(int dp, Context context) {
Expand All @@ -97,7 +95,7 @@ public void onClick(View v) {
boolean isInFirstPage = vpOnboarderPager.getCurrentItem() == 0;
boolean isInLastPage = vpOnboarderPager.getCurrentItem() == ahoyOnboarderAdapter.getCount() - 1;

if (i == R.id.btn_skip && isInLastPage) {
if ((i == R.id.btn_skip && isInLastPage) || i == R.id.fla_skip) {
onFinishButtonPressed();
} else if (i == R.id.ivPrev && !isInFirstPage) {
vpOnboarderPager.setCurrentItem(vpOnboarderPager.getCurrentItem() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class FancyWalkthroughCard {
public float descriptionTextSize;
public int iconWidth, iconHeight, marginTop, marginLeft, marginRight, marginBottom;

private boolean displaySkip = true;

public FancyWalkthroughCard(String title, String description) {
this.title = title;
this.description = description;
Expand Down Expand Up @@ -158,4 +160,17 @@ public int getMarginRight() {
public int getMarginBottom() {
return marginBottom;
}
}

public boolean isSkipDisplay() {
return displaySkip;
}

/**
* SetDisplaySkip
* @param isDisplay if true the floating button is display
*/
public void setDisplaySkip(boolean isDisplay) {
this.displaySkip = isDisplay;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class FancyWalkthroughFragment extends Fragment {
private static final String FANCY_PAGE_MARGIN_RIGHT = "ahoy_page_margin_right";
private static final String FANCY_PAGE_MARGIN_TOP = "ahoy_page_margin_top";
private static final String FANCY_PAGE_MARGIN_BOTTOM = "ahoy_page_margin_bottom";
private static final String FANCY_PAGE_DISPLAY_SKIP = "ahoy_page_display_skip";


private String title;
Expand All @@ -53,15 +54,18 @@ public class FancyWalkthroughFragment extends Fragment {
private int imageResId;
private float titleTextSize;
private float descriptionTextSize;
private boolean isDisplay;

private View view, view1;
private ImageView ivOnboarderImage;
private TextView tvOnboarderTitle;
private TextView tvOnboarderDescription;
private CardView cardView;
private FloatingActionButton skip;
private int iconHeight, iconWidth;
private int marginTop, marginBottom, marginLeft, marginRight;


public FancyWalkthroughFragment() {
}

Expand All @@ -83,6 +87,8 @@ public static FancyWalkthroughFragment newInstance(FancyWalkthroughCard card) {
args.putInt(FANCY_PAGE_MARGIN_RIGHT, card.getMarginRight());
args.putInt(FANCY_PAGE_MARGIN_TOP, card.getMarginTop());
args.putInt(FANCY_PAGE_MARGIN_BOTTOM, card.getMarginBottom());
args.putBoolean(FANCY_PAGE_DISPLAY_SKIP, card.isSkipDisplay());


FancyWalkthroughFragment fragment = new FancyWalkthroughFragment();
fragment.setArguments(args);
Expand Down Expand Up @@ -116,14 +122,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
marginBottom = bundle.getInt(FANCY_PAGE_MARGIN_BOTTOM, (int) dpToPixels(0, getActivity()));
marginLeft = bundle.getInt(FANCY_PAGE_MARGIN_LEFT, (int) dpToPixels(0, getActivity()));
marginRight = bundle.getInt(FANCY_PAGE_MARGIN_RIGHT, (int) dpToPixels(0, getActivity()));
isDisplay = bundle.getBoolean(FANCY_PAGE_DISPLAY_SKIP, true);

view = inflater.inflate(R.layout.fragment_ahoy, container, false);
ivOnboarderImage = view.findViewById(R.id.iv_image);
tvOnboarderTitle = view.findViewById(R.id.tv_title);
tvOnboarderDescription = view.findViewById(R.id.tv_description);
cardView = view.findViewById(R.id.cv_cardview);
view1 = view.findViewById(R.id.view1);

skip = (FloatingActionButton) view.findViewById(R.id.fla_skip);

if (title != null) {
tvOnboarderTitle.setText(title);
Expand Down Expand Up @@ -168,6 +175,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

}

if (!isDisplay) {
skip.setVisibility(View.GONE);
} else {
skip.setVisibility(View.VISIBLE);
}

if (iconWidth != 0 && iconHeight != 0) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(iconWidth, iconHeight);
layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
Expand Down Expand Up @@ -198,4 +211,9 @@ public TextView getTitleView() {
public TextView getDescriptionView() {
return tvOnboarderDescription;
}

public FloatingActionButton getSkip() {
return skip;
}

}
8 changes: 7 additions & 1 deletion fancywalkthroughlib/src/main/res/layout/fragment_ahoy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="220dp"
android:src="@drawable/ic_arrow_forward_black_24dp" />
android:id="@+id/fla_skip"
android:visibility="visible"
android:clickable="true"
android:focusable="true"
android:onClick="onClick"
android:src="@drawable/ic_arrow_forward_black_24dp"
/>

<View
android:id="@+id/view1"
Expand Down

0 comments on commit 73fcec7

Please sign in to comment.