Example usage for android.widget PopupWindow update

List of usage examples for android.widget PopupWindow update

Introduction

In this page you can find the example usage for android.widget PopupWindow update.

Prototype

public void update(int x, int y, int width, int height) 

Source Link

Document

Updates the position and the dimension of the popup window.

Usage

From source file:com.example.angel.parkpanda.MainActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    int id = item.getItemId();
    showhideFootWindow(0);/*from ww  w  .  j a  va  2  s. c  o  m*/
    if (id == R.id.nav_menu_findparking) {
        Intent intent = new Intent(getApplicationContext(), Find_Park.class);
        startActivityForResult(intent, 2);// Activity is started with requestCode 2
        // finish();
    }
    if (id == R.id.nav_menu_account) {
        initViewSetting(false);
        if (LOGININFO.flag == 10) {
            Fragment fragment = new my_account();
            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction FT = fragmentManager.beginTransaction();
            FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left);
            FT.replace(R.id.flContent, fragment).commit();
        } else {
            Fragment fragment = new log_in();
            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction FT = fragmentManager.beginTransaction();
            FT.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left);
            FT.replace(R.id.flContent, fragment).commit();
        }

    }
    if (id == R.id.nav_menu_help) {
        int currentapiVersion = android.os.Build.VERSION.SDK_INT;

        if (currentapiVersion > 21) {
            showhideFootWindow(0);
            initViewSetting(true);

            LayoutInflater inflater = (LayoutInflater) getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
            View layout = inflater.inflate(R.layout.ly_my_help, null);
            layout.setAnimation(AnimationUtils.loadAnimation(this, R.anim.popupanim));
            PopupWindow optionspu = new PopupWindow(layout, DrawerLayout.LayoutParams.WRAP_CONTENT,
                    DrawerLayout.LayoutParams.WRAP_CONTENT);

            optionspu.setFocusable(true);
            optionspu.showAtLocation(layout, Gravity.CENTER, 0, 0);
            optionspu.update(0, 0, DrawerLayout.LayoutParams.WRAP_CONTENT,
                    DrawerLayout.LayoutParams.WRAP_CONTENT);
            optionspu.setAnimationStyle(R.anim.popupanim);
        } else {

            // initViewSetting(false);

            /*                Fragment fragment = new help_dialog();
                            FragmentManager fragmentManager = getSupportFragmentManager();
                            FragmentTransaction FT = fragmentManager.beginTransaction();
                            FT.setCustomAnimations(R.anim.enter_from_right,
                R.anim.exit_to_left);
                            FT.replace(R.id.flContent, fragment).commit();*/

            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
            View popupView = layoutInflater.inflate(R.layout.fragment_help_dialog, null);
            final PopupWindow optionspu = new PopupWindow(popupView, DrawerLayout.LayoutParams.WRAP_CONTENT,
                    DrawerLayout.LayoutParams.WRAP_CONTENT);

            optionspu.setFocusable(true);
            optionspu.showAtLocation(popupView, Gravity.CENTER, 0, 0);
            Button btnDismiss = (Button) popupView.findViewById(R.id.btn_help_close);

            btnDismiss.setOnClickListener(new Button.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // Toast.makeText(getApplicationContext(), "dsdsa", Toast.LENGTH_SHORT).show();
                    optionspu.dismiss();
                    plotMarkers(mMyMarkersArray);
                    initViewSetting(true);
                }

            });
        }

    }
    drawer.closeDrawer(GravityCompat.START);
    return true;
}