Share to EffectHub.com

You can earn money or coins from your share:)

Tips: you can use Sparticle for uploading away3D effects.

Tips: you can download Sparticle for uploading effects.

Tips: The ActionScript editor is supporting Away3D, Starling, Dragonbones and Flex frameworks.

Tips: paste the web page URL then click button:)

EffectHub.com: Your Best Source for Gaming
Login    or

Android: a login dialog like facebook with cancel button


public class LoginFragment extends DialogFragment {

/**The webview for load url**/

WebView webView;

/**a progressBar to show the progress**/

ProgressBar pb;

ImageView crossImageView;


@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setStyle(DialogFragment.STYLE_NO_TITLE, R.style.AppTheme);

}


@Override

public Dialog onCreateDialog(Bundle savedInstanceState) {

//Create a new context for login dialog

FrameLayout contentFrameLayout = new FrameLayout(getActivity());

contentFrameLayout.setPadding(0, 0, 0, 0);

//create a x imageview

createCrossImage();

int crossWidth = crossImageView.getDrawable().getIntrinsicWidth();

int margin =crossWidth/2+1;

LinearLayout webViewContainer = new LinearLayout(getActivity());

webViewContainer.setOrientation(LinearLayout.VERTICAL);

        webView = new WebView(getActivity());

        webView.setVerticalScrollBarEnabled(false);

        webView.setHorizontalScrollBarEnabled(false);

        initWebView(webView);

        webViewContainer.setPadding(margin, margin, margin, margin);

        

        //For dialog get the focus

EditText edit = new EditText(getActivity());

edit.setWidth(0);

edit.setHeight(0);

edit.setFocusable(true);

edit.requestFocus();

edit.setVisibility(View.INVISIBLE);

        webViewContainer.addView(webView);

        webViewContainer.addView(edit);

        

        pb=new ProgressBar(getActivity());

        webViewContainer.addView(pb,new ViewGroup.LayoutParams(

                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

        

        contentFrameLayout.addView(webViewContainer);

        contentFrameLayout.addView(crossImageView, new ViewGroup.LayoutParams(

                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

        

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        

String loginurl ="www.google.com";

webView.loadUrl(loginurl);

builder.setTitle("Sign in with facebook");

        builder.setView(contentFrameLayout);

        

return builder.create();

}

    private void createCrossImage() {

   

        crossImageView = new ImageView(getActivity());

        // Dismiss the dialog when user click on the 'x'

        crossImageView.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                dismiss();

            }

        });

        Drawable crossDrawable = getActivity().getResources().getDrawable(R.drawable.com_facebook_close);

        crossImageView.setImageDrawable(crossDrawable);

        /* 'x' should not be visible while webview is loading

         * make it visible only after webview has fully loaded

        */

        crossImageView.setVisibility(View.INVISIBLE);

    }

/**

* Set the webview initial configure

* @param wv 

*/

@SuppressLint("SetJavaScriptEnabled")

private void initWebView(WebView wv) {

wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);


wv.getSettings().setJavaScriptEnabled(true);

wv.setWebViewClient(new WebViewClient(){

                 @Override

                 public void onPageFinished(WebView view, String url) {

                 crossImageView.setVisibility(View.VISIBLE);

                 super.onPageFinished(view, url);

                 }

                });


}

public void onCancel(DialogInterface dialog) {

// send cancel command

Message msg = new Message();

msg.what = MainActivity.LOGIN_CANCEL_CODE;

mainHandler.sendMessage(msg);


// stop load pages. to avoid null point

webView.stopLoading();

}

}


...

You must Sign up as a member of Effecthub to view the content.

3956 views    1 comments

You must Sign up as a member of Effecthub to join the conversation.

Join Effecthub.com


Or Login with Your Email Address:

Or Sign Up with Your Email Address:
This field must contain a valid email
Password should be at least 1 character