-
Notifications
You must be signed in to change notification settings - Fork 8
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
08d56e5
commit a7150c7
Showing
14 changed files
with
227 additions
and
24 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
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
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
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
85 changes: 85 additions & 0 deletions
85
...ynerise/sdk/sample/ui/dev/apiAdapter/fragments/client/ClientGetExternalTokenFragment.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,85 @@ | ||
package com.synerise.sdk.sample.ui.dev.apiAdapter.fragments.client; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.support.design.widget.TextInputLayout; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.RadioButton; | ||
|
||
import com.synerise.sdk.client.Client; | ||
import com.synerise.sdk.core.listeners.DataActionListener; | ||
import com.synerise.sdk.core.net.IApiCall; | ||
import com.synerise.sdk.core.utils.ValidationUtils; | ||
import com.synerise.sdk.error.ApiError; | ||
import com.synerise.sdk.sample.R; | ||
import com.synerise.sdk.sample.ui.dev.BaseDevFragment; | ||
|
||
public class ClientGetExternalTokenFragment extends BaseDevFragment { | ||
|
||
private IApiCall apiCall; | ||
private TextInputLayout inputValue; | ||
private RadioButton radioUuid, radioEmail, radioCustomId; | ||
|
||
public static ClientGetExternalTokenFragment newInstance() { return new ClientGetExternalTokenFragment(); } | ||
|
||
// **************************************************************************************************************************************** | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
return inflater.inflate(R.layout.fragment_client_get_external_token, container, false); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
|
||
inputValue = view.findViewById(R.id.input_value); | ||
radioUuid = view.findViewById(R.id.radio_uuid); | ||
radioEmail = view.findViewById(R.id.radio_email); | ||
radioCustomId = view.findViewById(R.id.radio_custom_id); | ||
view.findViewById(R.id.create_token_button).setOnClickListener(v -> getPromotions()); | ||
} | ||
|
||
@Override | ||
public void onStop() { | ||
super.onStop(); | ||
if (apiCall != null) apiCall.cancel(); | ||
} | ||
|
||
// **************************************************************************************************************************************** | ||
|
||
@SuppressWarnings("ConstantConditions") | ||
private void getPromotions() { | ||
|
||
boolean isValid = true; | ||
inputValue.setError(null); | ||
|
||
String value = inputValue.getEditText().getText().toString(); | ||
|
||
if (ValidationUtils.isEmpty(value)) { | ||
isValid = false; | ||
inputValue.setError(getString(R.string.error_empty)); | ||
} | ||
|
||
if (isValid) { | ||
if (apiCall != null) apiCall.cancel(); | ||
if (radioUuid.isChecked()) { | ||
apiCall = Client.createAuthTokenByUuid(value); | ||
} else if (radioEmail.isChecked()) { | ||
apiCall = Client.createAuthTokenByEmail(value); | ||
} else if (radioCustomId.isChecked()) { | ||
apiCall = Client.createAuthTokenByCustomId(value); | ||
} | ||
apiCall.execute(this::onSuccess, new DataActionListener<ApiError>() { | ||
@Override | ||
public void onDataAction(ApiError apiError) { | ||
ClientGetExternalTokenFragment.this.onFailure(apiError); | ||
} | ||
}); | ||
} | ||
} | ||
} |
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
60 changes: 60 additions & 0 deletions
60
sample/src/main/res/layout/fragment_client_get_external_token.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,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clipToPadding="false" | ||
android:orientation="vertical" | ||
android:padding="@dimen/space_large"> | ||
|
||
<RadioGroup | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:checkedButton="@id/radio_uuid" | ||
android:orientation="vertical"> | ||
|
||
<RadioButton | ||
android:id="@+id/radio_uuid" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/default_uuid" /> | ||
|
||
<RadioButton | ||
android:id="@+id/radio_custom_id" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/default_custom_id" /> | ||
|
||
<RadioButton | ||
android:id="@+id/radio_email" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/default_email" /> | ||
|
||
</RadioGroup> | ||
|
||
<android.support.design.widget.TextInputLayout | ||
android:id="@+id/input_value" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/space_medium" | ||
android:hint="@string/default_client_value" | ||
app:errorEnabled="true" | ||
app:hintAnimationEnabled="true"> | ||
|
||
<android.support.design.widget.TextInputEditText | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:inputType="text" /> | ||
|
||
</android.support.design.widget.TextInputLayout> | ||
|
||
<Button | ||
android:id="@+id/create_token_button" | ||
style="@style/ButtonPrimary" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/space_medium" | ||
android:text="@string/create_token_button" /> | ||
|
||
</LinearLayout> |
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
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