-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc1d9ca
commit d0b9bf5
Showing
5 changed files
with
134 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
.../app/src/main/java/com/izettle/payments/android/java_example/TippingStyleBottomSheet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.izettle.payments.android.java_example; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment; | ||
import com.izettle.payments.android.payment.TippingStyle; | ||
|
||
public class TippingStyleBottomSheet extends BottomSheetDialogFragment { | ||
|
||
private View styleNoneView; | ||
private View styleDefaultView; | ||
private View styleAmountView; | ||
private View stylePercentView; | ||
|
||
public static final String REQUEST_KEY = "TippingStyleBottomSheetRC"; | ||
public static final String TIPPING_STYLE_KEY = "TippingStyleKey"; | ||
|
||
public static TippingStyleBottomSheet newInstance() { | ||
return new TippingStyleBottomSheet(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
View view = inflater.inflate(R.layout.fragment_tipping_style, container, false); | ||
styleNoneView = view.findViewById(R.id.tipping_style_none); | ||
styleDefaultView = view.findViewById(R.id.tipping_style_default); | ||
styleAmountView = view.findViewById(R.id.tipping_style_amount); | ||
stylePercentView = view.findViewById(R.id.tipping_style_percent); | ||
|
||
return view; | ||
} | ||
|
||
@Override | ||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
|
||
styleNoneView.setOnClickListener(v -> setResultAndExit(TippingStyle.None)); | ||
styleDefaultView.setOnClickListener(v -> setResultAndExit(TippingStyle.Default)); | ||
styleAmountView.setOnClickListener(v -> setResultAndExit(TippingStyle.Amount)); | ||
stylePercentView.setOnClickListener(v -> setResultAndExit(TippingStyle.Percentage)); | ||
} | ||
|
||
private void setResultAndExit(TippingStyle tippingStyle) { | ||
Bundle bundle = new Bundle(); | ||
bundle.putSerializable(TIPPING_STYLE_KEY, tippingStyle); | ||
|
||
getParentFragmentManager().setFragmentResult(REQUEST_KEY, bundle); | ||
dismiss(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Examples/Example-Java/app/src/main/res/layout/fragment_tipping_style.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:orientation="vertical" | ||
android:layout_height="match_parent"> | ||
|
||
<TextView | ||
android:id="@+id/tipping_style_none" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
android:textStyle="bold" | ||
android:text="None" | ||
android:background="?selectableItemBackground" | ||
tools:ignore="HardcodedText" /> | ||
|
||
<TextView | ||
android:id="@+id/tipping_style_default" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
android:textStyle="bold" | ||
android:text="Market Default" | ||
android:background="?selectableItemBackground" | ||
tools:ignore="HardcodedText" /> | ||
|
||
<TextView | ||
android:id="@+id/tipping_style_amount" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
android:textStyle="bold" | ||
android:text="Amount" | ||
android:background="?selectableItemBackground" | ||
tools:ignore="HardcodedText" /> | ||
|
||
<TextView | ||
android:id="@+id/tipping_style_percent" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
android:textStyle="bold" | ||
android:text="Percentage" | ||
android:background="?selectableItemBackground" | ||
tools:ignore="HardcodedText" /> | ||
|
||
</androidx.appcompat.widget.LinearLayoutCompat> |