Back to project page 3DSView.
The source code is released under:
Apache License
If you think the Android project 3DSView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package eu.livotov.labs.android.d3s; /*from ww w . ja v a 2 s .com*/ import android.os.Bundle; import android.os.Handler; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTransaction; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.ProgressBar; /** * (c) Livotov Labs Ltd. 2012 * Date: 26/09/2014 */ public class D3SDialog extends DialogFragment implements D3SSViewAuthorizationListener { private D3SView authenticator; private ProgressBar progressBar; private String acs, md, pareq, postback; private D3SDialogListener authorizationListener; private Handler handler; public static D3SDialog newInstance(final String acsUrl, final String md, final String paReq, final String postbackUrl, D3SDialogListener listener) { D3SDialog dialog = new D3SDialog(); dialog.acs = acsUrl; dialog.md = md; dialog.pareq = paReq; dialog.postback = postbackUrl; dialog.authorizationListener = listener; return dialog; } public static D3SDialog newInstance(final String acsUrl, final String md, final String paReq, D3SDialogListener listener) { return newInstance(acsUrl, md, paReq, null, listener); } public void showDialogAndAuthenticate(FragmentActivity activity) { if (activity.getCurrentFocus() != null) { activity.getCurrentFocus().clearFocus(); } try { activity.getSupportFragmentManager().executePendingTransactions(); } catch (Throwable err) { err.printStackTrace(); } FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); ft.add(this, "d3sdialog"); ft.commitAllowingStateLoss(); } public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); getDialog().getWindow().setBackgroundDrawable(null); View v = inflater.inflate(R.layout.dialog_3ds, container, false); progressBar = (ProgressBar) v.findViewById(R.id.progressBar); authenticator = (D3SView) v.findViewById(R.id.authenticator); authenticator.setAuthorizationListener(this); getDialog().setCanceledOnTouchOutside(false); getDialog().setCancelable(true); handler = new Handler(); return v; } public void onViewCreated(final View view, final Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (TextUtils.isEmpty(postback)) { authenticator.authorize(acs, md, pareq); } else { authenticator.authorize(acs, md, pareq, postback); } } public void onAuthorizationCompleted(final String md, final String paRes) { handler.post(new Runnable() { public void run() { dismiss(); if (authorizationListener != null) { authorizationListener.onAuthorizationCompleted(md, paRes); } } }); } public void onAuthorizationStarted(final D3SView view) { handler.post(new Runnable() { public void run() { progressBar.setVisibility(View.VISIBLE); } }); } public void onAuthorizationWebPageLoadingProgressChanged(final int progress) { handler.post(new Runnable() { public void run() { progressBar.setVisibility(progress > 0 && progress < 100 ? View.VISIBLE : View.GONE); } }); } public void onAuthorizationWebPageLoadingError(final int errorCode, final String description, final String failingUrl) { handler.post(new Runnable() { public void run() { dismiss(); if (authorizationListener != null) { authorizationListener.onAuthorizationFailed(errorCode, description, failingUrl); } } }); } public interface D3SDialogListener { void onAuthorizationCompleted(final String md, final String paRes); void onAuthorizationFailed(final int code, final String message, final String failedUrl); } }