Example usage for android.app ActivityOptions makeCustomAnimation

List of usage examples for android.app ActivityOptions makeCustomAnimation

Introduction

In this page you can find the example usage for android.app ActivityOptions makeCustomAnimation.

Prototype

public static ActivityOptions makeCustomAnimation(Context context, int enterResId, int exitResId) 

Source Link

Document

Create an ActivityOptions specifying a custom animation to run when the activity is displayed.

Usage

From source file:com.iternox.piggate.samples.PiggateLogin.Activity_Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null);
    Boolean logout = false;//from   w  w w . j  a  v a 2s .  c om
    if (getIntent().getExtras() != null)
        logout = getIntent().getExtras().getBoolean("ACTIVITY_MAIN_CREATED_BY_BUTTON_LOGOUT", false);

    setContentView(R.layout.activity_main);

    final Button login = (Button) findViewById(R.id.buttonloginmain);
    final Button register = (Button) findViewById(R.id.buttonregistermain);

    login.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;

                Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);
            }

        }
    });
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;

                Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);

            }

        }
    });
    if (!logout && checkInternetConnection()) //If you close the application without logout, the session will be active
        _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() {
            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);
            }

            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                _piggate.reload();
            }

            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }

            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }
        }).exec();

}

From source file:fi.danielsan.donkino.ui.Navigator.java

public static void startBrowserIntent(@NonNull Activity activity, @NonNull String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    Bundle extras = new Bundle();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        extras.putBinder(EXTRA_CUSTOM_TABS_SESSION, null);
    }//from   w  w  w.ja v  a  2 s  .  co m
    intent.putExtra(EXTRA_CUSTOM_TABS_TOOLBAR_COLOR, ContextCompat.getColor(activity, R.color.colorPrimary));

    Bundle exitBundle = ActivityOptions
            .makeCustomAnimation(activity, R.anim.slide_in_left, R.anim.slide_out_right).toBundle();
    intent.putExtra(EXTRA_CUSTOM_TABS_EXIT_ANIMATION_BUNDLE, exitBundle);

    Bundle startBundle = ActivityOptions
            .makeCustomAnimation(activity, R.anim.slide_in_right, R.anim.slide_out_left).toBundle();

    intent.putExtras(extras);
    activity.startActivity(intent, startBundle);
}

From source file:com.piggate.samples.PiggateLogin.Activity_Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize a Piggate object
    Boolean logout = false; //Handle if the user is logged
    if (getIntent().getExtras() != null)
        logout = getIntent().getExtras().getBoolean("ACTIVITY_MAIN_CREATED_BY_BUTTON_LOGOUT", false);
    setContentView(R.layout.activity_main);

    final Button login = (Button) findViewById(R.id.buttonloginmain);
    final Button register = (Button) findViewById(R.id.buttonregistermain);

    //onClick listener of the login button: go to Activity_SingIn
    login.setOnClickListener(new View.OnClickListener() {
        @Override/*w  w  w. j ava 2s .c om*/
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;

                Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);
            }

        }
    });

    //onClick listener of the register button: go to Activity_SingUp
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;

                Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);

            }

        }
    });

    //If you close the application without logout, the session will be active
    //Call a listener of the RequestUser method for Piggate object
    if (!logout && checkInternetConnection()) //If you close the application without logout, the session will be active
        _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() {

            //Method onComplete for JSONObject
            //If the request is completed correctly the user is redirected to Activity_Logged
            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);
            }

            //Method onError for JSONObject
            //When we have an error, reload the Piggate object
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                _piggate.reload();
            }

            //Method onComplete for JSONArray
            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }

            //Method onError for JSONArray
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }
        }).exec();
}

From source file:com.piggate.samples.PiggateLoginApplication.Activity_Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize a Piggate object
    Boolean logout = false;/*from   w w w.  j  a  v a2s . c  o  m*/
    if (getIntent().getExtras() != null)
        logout = getIntent().getExtras().getBoolean("ACTIVITY_MAIN_CREATED_BY_BUTTON_LOGOUT", false); //handles if the user is logged
    setContentView(R.layout.activity_main);
    final Button login = (Button) findViewById(R.id.buttonloginmain);
    final Button register = (Button) findViewById(R.id.buttonregistermain);

    //onClick listener of the login button: go to Activity_SingIn
    login.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;

                Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);
            }

        }
    });

    //onClick listener of the register button: go to Activity_SingUp
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;

                Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);

            }

        }
    });

    //If you close the application without logout, the session will be active
    //Call a listener of the RequestUser method for Piggate object
    if (!logout && checkInternetConnection()) //If you close the application without logout, the session will be active
        _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() {

            //Method onComplete for JSONObject
            //If the request is completed correctly the user is redirected to Activity_Logged
            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);
            }

            //Method onError for JSONObject
            //When we have an error, reload the Piggate object
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                _piggate.reload();
            }

            //Method onComplete for JSONArray
            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }

            //Method onError for JSONArray
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }
        }).exec();
}

From source file:com.piggate.samples.PiggateLoginService.Activity_Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize a Piggate object

    //Handles if the user is already login
    Boolean logout = false;/*from  ww  w .j  a va 2s  .  c  o m*/
    if (getIntent().getExtras() != null)
        logout = getIntent().getExtras().getBoolean("ACTIVITY_MAIN_CREATED_BY_BUTTON_LOGOUT", false);

    setContentView(R.layout.activity_main);
    final Button login = (Button) findViewById(R.id.buttonloginmain);
    final Button register = (Button) findViewById(R.id.buttonregistermain);

    //onClick listener of the login button: go to Activity_SingIn
    login.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;

                Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);
            }
        }
    });

    //onClick listener of the register button: go to Activity_SingUp
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;

                Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);
            }
        }
    });

    //If you close the application without logout, the session will be active
    //Call a listener of the RequestUser method for Piggate object
    if (!logout && checkInternetConnection())
        _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() {

            //Method onComplete for JSONObject
            //If the request is completed correctly the user is redirected to Activity_Logged
            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
                Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class);
                Bundle bndlanimation = ActivityOptions
                        .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle();
                startActivity(slideactivity, bndlanimation);
            }

            //Method onError for JSONObject
            //When we have an error, reload the Piggate object
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                _piggate.reload();
            }

            //Method onComplete for JSONArray
            @Override
            public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }

            //Method onError for JSONArray
            @Override
            public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                //Unused
            }
        }).exec();
}

From source file:com.abhijitvalluri.android.fitnotifications.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    // Set a Toolbar to replace the ActionBar.
    mToolbar = (Toolbar) findViewById(R.id.home_toolbar);
    setSupportActionBar(mToolbar);//from www.java  2 s. co m

    LAUNCH_ACTIVITY_ANIM_BUNDLE = ActivityOptions
            .makeCustomAnimation(HomeActivity.this, R.transition.left_in, R.transition.left_out).toBundle();

    // Initialize settings to defaults

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new SmoothDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open,
            R.string.drawer_close);

    mDrawerLayout.addDrawerListener(mDrawerToggle);

    mNavDrawer = (NavigationView) findViewById(R.id.navDrawer);
    setupDrawerContent(mNavDrawer);

    PreferenceManager.setDefaultValues(this, R.xml.main_settings, false);
    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    Fragment frag = new HomeFragment();

    // Add a new fragment to the appropriate view element
    FragmentManager fragmentManager = getSupportFragmentManager();
    if (fragmentManager.findFragmentById(R.id.flContent) == null) {
        fragmentManager.beginTransaction().add(R.id.flContent, frag).commit();
    }

    if (mPreferences.getInt(getString(R.string.version_key), 0) < Constants.VERSION_CODE
            && mPreferences.getBoolean(getString(R.string.done_first_launch_key), false)) {
        // App has been updated
        AppSelectionsStore store = AppSelectionsStore.get(this);
        List<AppSelection> appSelections = store.getAppSelections();

        for (AppSelection selection : appSelections) {
            if (selection.getStartTime() == 0 && (selection.getStopTime() == 1439)
                    || selection.getStopTime() == 0) {
                // Default setting should be 11:59pm for end time.
                selection.setStopTimeHour(23);
                selection.setStopTimeMinute(59);
                store.updateAppSelection(selection);
            }
        }

        mNavDrawer.setCheckedItem(R.id.nav_whats_new);
        setTitle(R.string.whats_new);
        frag = InfoFragment.newInstance(getString(R.string.whats_new_text));
        fragmentManager.beginTransaction().replace(R.id.flContent, frag).commit();

        mPreferences.edit().putInt(getString(R.string.version_key), Constants.VERSION_CODE).apply();
    }

    if (!mPreferences.getBoolean(getString(R.string.done_first_launch_key), false)) { // This is the first launch
        startActivityForResult(new Intent(HomeActivity.this, AppIntroActivity.class),
                APP_INTRO_FIRST_LAUNCH_INTENT, LAUNCH_ACTIVITY_ANIM_BUNDLE);
    }

}

From source file:samples.piggate.com.piggateInfoDemo.Activity_Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize a Piggate object

    getSupportActionBar().setTitle("Piggate Info Demo");

    networkErrorDialog = new AlertDialog.Builder(this).create();
    networkErrorDialog.setTitle("Network error");
    networkErrorDialog.setMessage("There is an error with the network connection");
    networkErrorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override// w ww . j  a v  a2s.co  m
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    setContentView(R.layout.activity_main);
    final Button login = (Button) findViewById(R.id.buttonloginmain);
    final Button register = (Button) findViewById(R.id.buttonregistermain);

    //onClick listener of the login button: go to Activity_SingIn
    login.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {

            Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class);
            slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            Bundle bndlanimation = ActivityOptions
                    .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft)
                    .toBundle();
            startActivity(slideactivity, bndlanimation);
        }
    });

    //onClick listener of the register button: go to Activity_SingUp
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {

            Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class);
            slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            Bundle bndlanimation = ActivityOptions
                    .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft)
                    .toBundle();
            startActivity(slideactivity, bndlanimation);
        }
    });

    //If you close the application without logout, the session will be active
    //Call a listener of the RequestUser method for Piggate object
    if (Service_Notify.logout == false) {
        if (checkInternetConnection()) {

            loadingDialog = ProgressDialog.show(this, "Singing In", "Wait a few seconds", true);
            _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() {
                //Method onComplete for JSONObject
                //If the request is completed correctly the user is redirected to Activity_Logged
                @Override
                public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {

                    loadingDialog.dismiss();
                    Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class);
                    slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    Bundle bndlanimation = ActivityOptions.makeCustomAnimation(getApplicationContext(),
                            R.anim.slidefromright, R.anim.slidetoleft).toBundle();
                    startActivity(slideactivity, bndlanimation);
                }

                //Method onError for JSONObject
                //When we have an error, reload the Piggate object
                @Override
                public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                    loadingDialog.dismiss();
                    _piggate.reload();
                }

                //Method onComplete for JSONArray
                @Override
                public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                    //Unused
                }

                //Method onError for JSONArray
                @Override
                public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                    //Unused
                }
            }).exec();
        } else {
            networkErrorDialog.show();
        }
    }
}

From source file:samples.piggate.com.piggateCompleteExample.Activity_Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize a Piggate object

    getSupportActionBar().setTitle("Piggate Offers Demo");

    networkErrorDialog = new AlertDialog.Builder(this).create();
    networkErrorDialog.setTitle("Network error");
    networkErrorDialog.setMessage("There is an error with the network connection");
    networkErrorDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        @Override//from w w w  . j a v  a  2 s .  c om
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    setContentView(R.layout.activity_main);
    final Button login = (Button) findViewById(R.id.buttonloginmain);
    final Button register = (Button) findViewById(R.id.buttonregistermain);

    //onClick listener of the login button: go to Activity_SingIn
    login.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {

            Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class);
            slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            Bundle bndlanimation = ActivityOptions
                    .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft)
                    .toBundle();
            startActivity(slideactivity, bndlanimation);
        }
    });

    //onClick listener of the register button: go to Activity_SingUp
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {

            Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class);
            slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            Bundle bndlanimation = ActivityOptions
                    .makeCustomAnimation(getApplicationContext(), R.anim.slidefromright, R.anim.slidetoleft)
                    .toBundle();
            startActivity(slideactivity, bndlanimation);
        }
    });

    //If you close the application without logout, the session will be active
    //Call a listener of the RequestUser method for Piggate object
    if (Service_Notify.logout == false) {
        if (checkInternetConnection()) {

            loadingDialog = ProgressDialog.show(this, "Singing In", "Wait a few seconds", true);
            _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() {
                //Method onComplete for JSONObject
                //If the request is completed correctly the user is redirected to Activity_Logged
                @Override
                public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {

                    loadingDialog.dismiss();
                    Intent slideactivity = new Intent(Activity_Main.this, Activity_Logged.class);
                    slideactivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    Bundle bndlanimation = ActivityOptions.makeCustomAnimation(getApplicationContext(),
                            R.anim.slidefromright, R.anim.slidetoleft).toBundle();
                    startActivity(slideactivity, bndlanimation);
                }

                //Method onError for JSONObject
                //When we have an error, reload the Piggate object
                @Override
                public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                    loadingDialog.dismiss();
                    _piggate.reload();
                }

                //Method onComplete for JSONArray
                @Override
                public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                    //Unused
                }

                //Method onError for JSONArray
                @Override
                public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                    //Unused
                }
            }).exec();
        } else {
            networkErrorDialog.show();
        }
    }
}

From source file:com.iternox.piggate.samples.PiggateLogin.Activity_SingIn.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null);

    setContentView(R.layout.activity_login);
    editEmail = (EditText) findViewById(R.id.editText1);
    editPass = (EditText) findViewById(R.id.editText2);

    Button login = (Button) findViewById(R.id.buttonlogin2);
    final ImageButton return_button = (ImageButton) findViewById(R.id.return1);
    return_button.setOnClickListener(new View.OnClickListener() {
        @Override//from   www  .j  a v a 2 s  .co m
        public void onClick(View v) {
            onBackPressed();
        }
    });
    login.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;
                String email = editEmail.getText().toString();
                String pass = editPass.getText().toString();

                if (checkInternetConnection() == true) {
                    RequestParams params = new RequestParams();
                    params.put("email", email);
                    params.put("password", pass);
                    _piggate.RequestOpenSession(params).setListenerRequest(new Piggate.PiggateCallBack() {
                        @Override
                        public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                            Intent slideactivity = new Intent(Activity_SingIn.this, Activity_Logged.class);
                            Bundle bndlanimation = ActivityOptions
                                    .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2)
                                    .toBundle();
                            startActivity(slideactivity, bndlanimation);
                        }

                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                            handledClick = false;

                        }

                        @Override
                        public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }

                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }
                    }).exec();

                } else {
                    Toast.makeText(getApplicationContext(), "Network is not working", Toast.LENGTH_LONG).show();
                    handledClick = false;

                }
            }
        }
    });

}

From source file:com.iternox.piggate.samples.PiggateLogin.Activity_SingUp.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null);

    setContentView(R.layout.activity_register);
    editEmail = (EditText) findViewById(R.id.editText1);
    editPass = (EditText) findViewById(R.id.editText2);
    final ImageButton return_button = (ImageButton) findViewById(R.id.return1);

    Button register = (Button) findViewById(R.id.buttonregister2);
    return_button.setOnClickListener(new View.OnClickListener() {
        @Override//from w ww.j  a v  a2s. c  o m
        public void onClick(View v) {
            onBackPressed();
        }
    });
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;
                String email = editEmail.getText().toString();
                String pass = editPass.getText().toString();

                if (checkInternetConnection() == true) {
                    RequestParams params = new RequestParams();
                    params.put("email", email);
                    params.put("password", pass);
                    _piggate.RequestNewUser(params).setListenerRequest(new Piggate.PiggateCallBack() {
                        @Override
                        public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                            Intent slideactivity = new Intent(Activity_SingUp.this, Activity_Logged.class);
                            Bundle bndlanimation = ActivityOptions
                                    .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2)
                                    .toBundle();
                            startActivity(slideactivity, bndlanimation);
                        }

                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                        }

                        @Override
                        public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }

                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }
                    }).exec();

                } else {
                    Toast.makeText(getApplicationContext(), "Network is not working", Toast.LENGTH_LONG).show();
                }
            }
        }
    });

}