Example usage for android.graphics.drawable BitmapDrawable BitmapDrawable

List of usage examples for android.graphics.drawable BitmapDrawable BitmapDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable BitmapDrawable BitmapDrawable.

Prototype

@Deprecated
public BitmapDrawable() 

Source Link

Document

Create an empty drawable, not dealing with density.

Usage

From source file:Main.java

public static View showPopupWindow(Context context, int resId, View root, int paramsType) {
    View popupView;/*from  w w  w.j  a  v  a2 s.  c  om*/
    popupView = LayoutInflater.from(context).inflate(resId, null);

    switch (paramsType) {
    case 1:
        popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT, true);
        break;
    case 2:
        popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, true);
        break;
    case 3:
        popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.MATCH_PARENT, true);
        break;
    case 4:
        popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, true);
        break;
    default:
        popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT, true);
        break;
    }
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.setTouchable(true);
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.showAsDropDown(root);
    return popupView;
}

From source file:fr.univsavoie.ltp.client.map.Popup.java

/**
  * Afficher sur la map un popup qui affiche les
  * informations de l'utilisateur connect.
  *//*from  w  w w . ja v  a  2  s  .c  o m*/
public final void popupDisplayUserInfos() {
    DisplayMetrics dm = new DisplayMetrics();
    this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    //final int height = dm.heightPixels;
    final int width = dm.widthPixels;

    int popupWidth = (int) (width * 0.75);
    //int popupHeight = height / 2;

    // Inflate the popup_layout.xml
    LinearLayout viewGroup = (LinearLayout) this.activity.findViewById(R.id.popupAccount);
    LayoutInflater layoutInflater = (LayoutInflater) this.activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View layout = layoutInflater.inflate(R.layout.popup_account, viewGroup);
    layout.setBackgroundResource(R.drawable.popup_gradient);

    // Crer le PopupWindow
    final PopupWindow popupUserInfos = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true);
    popupUserInfos.setBackgroundDrawable(new BitmapDrawable());
    popupUserInfos.setOutsideTouchable(true);

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
    final int OFFSET_X = 0;
    final int OFFSET_Y = 0;

    // Displaying the popup at the specified location, + offsets.
    this.activity.findViewById(R.id.layoutMain).post(new Runnable() {
        public void run() {
            popupUserInfos.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y);
        }
    });

    /*
     * Evenements composants du PopupWindow
     */

    // Ecouteur d'vnement sur le bouton pour se dconnecter
    Button close = (Button) layout.findViewById(R.id.close);
    close.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            popupUserInfos.dismiss();
        }
    });
}

From source file:com.cybrosys.scientific.EventListener.java

@SuppressWarnings("deprecation")
public void showcon() {

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    vwLayout = inflater.inflate(R.layout.firstone,
            (ViewGroup) ((Activity) ctx).findViewById(R.id.popup_element));

    popmW1 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true);

    popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 30);

    popmW1.setBackgroundDrawable(new BitmapDrawable());
    popmW1.setOutsideTouchable(true);//w  w w .ja  v a2s  . c  om
    imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelmain);
    imgbtnclose.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            popmW1.dismiss();
        }
    });
    btnuniversal = (Button) vwLayout.findViewById(R.id.butuniverse);
    btnuniversal.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            universal();
        }

        private void universal() {
            LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View vwLayout = inflater.inflate(R.layout.universe,
                    (ViewGroup) ((Activity) ctx).findViewById(R.id.unive));
            popmW2 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight,
                    true);
            popmW2.setBackgroundDrawable(new BitmapDrawable());
            popmW2.setOutsideTouchable(true);
            popmW1.setOutsideTouchable(true);
            popmW2.showAtLocation(vwLayout, Gravity.CENTER, 0, 30);
            btnseletone = (Button) vwLayout.findViewById(R.id.btnunione);
            btnseletone.setText(
                    Html.fromHtml("Speed of Light in Vacuum<br/><small>299,792,458m.s<sup>-1</sup></small>"));
            btnseletone.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW2.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("299792458");
                }
            });
            btnselettwo = (Button) vwLayout.findViewById(R.id.btnunitwo);
            btnselettwo.setText(Html.fromHtml(
                    "Gravitational Constant<br/><small>6.67428*10<sup>-11</sup>m<sup>3</sup>.kg<sup>-1</sup>.s<sup>-2</sup></small>"));
            btnselettwo.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    popmW2.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("6.67428e-11");
                }
            });
            btnseletthree = (Button) vwLayout.findViewById(R.id.btnunithree);
            btnseletthree.setText(
                    Html.fromHtml("Planck Constant<br/><small>6.62606896*10<sup>-34</sup> inJ.s</small>"));
            btnseletthree.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW2.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("6.62606896e-34");
                }
            });
            btnseletfour = (Button) vwLayout.findViewById(R.id.btnunifour);
            btnseletfour.setText(Html
                    .fromHtml("Reduced Planck Constant<br/><small>1.054571628*10<sup>-34</sup> inJ.s</small>"));
            btnseletfour.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW2.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("1.054571628e-34");
                }
            });
            imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.btncanceluni);
            imgbtnclose.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW1.dismiss();
                    popmW2.dismiss();
                }
            });
            imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackuni);
            imgbtnback.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW2.dismiss();
                }
            });

        }
    });
    btnelectro = (Button) vwLayout.findViewById(R.id.btnelectro);
    btnelectro.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Electro();
        }

        private void Electro() {
            LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View vwLayout = inflater.inflate(R.layout.electro,
                    (ViewGroup) ((Activity) ctx).findViewById(R.id.elec));
            popmW3 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight,
                    true);
            popmW3.setBackgroundDrawable(new BitmapDrawable());
            popmW3.setOutsideTouchable(true);
            popmW1.setOutsideTouchable(true);
            popmW3.showAtLocation(vwLayout, Gravity.CENTER, 0, 30);
            btnseletone = (Button) vwLayout.findViewById(R.id.butselectone);
            btnseletone.setText(Html.fromHtml(
                    "Magnetic Constant<br/><small>1.256637067*10<sup>-6</sup> N.A<sup>-2</sup></small>"));
            btnseletone.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW3.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("1.256637061e-6");
                }
            });
            btnselettwo = (Button) vwLayout.findViewById(R.id.butselecttwo);
            btnselettwo.setText(Html.fromHtml(
                    "Electric Constant<br/><small>8.854187817*10<sup>-12</sup> F.m<sup>-1</sup></small>"));
            btnselettwo.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW3.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("8.854187817e-12");
                }
            });
            btnseletthree = (Button) vwLayout.findViewById(R.id.butselectthree);
            btnseletthree.setText(
                    Html.fromHtml("Elementary Charge<br/><small>1.602176487*10<sup>-19</sup>c</small>"));
            btnseletthree.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW3.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("1.602176487e-19");
                }
            });
            btnseletfour = (Button) vwLayout.findViewById(R.id.butselectfour);
            btnseletfour.setText(
                    Html.fromHtml("Magnetic Flux Quantum<br/><small>2.067833667*10<sup>-15</sup>Wb</small>"));
            btnseletfour.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW3.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("2.067833667e-15");
                }
            });
            btnseletfive = (Button) vwLayout.findViewById(R.id.butSelectfive);
            btnseletfive.setText(
                    Html.fromHtml("Conductance Quantum<br/><small>7.7480917*10<sup>-5</sup>S</small>"));
            btnseletfive.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW3.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("7.7480917e-5");
                }
            });
            imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelelectro);
            imgbtnclose.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW1.dismiss();
                    popmW3.dismiss();
                }
            });
            imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackelectro);
            imgbtnback.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    popmW3.dismiss();
                }
            });
        }
    });
    btnAtomic = (Button) vwLayout.findViewById(R.id.btnatomic);
    btnAtomic.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            atomic();
        }

        private void atomic() {
            LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View vwLayout = inflater.inflate(R.layout.atomic,
                    (ViewGroup) ((Activity) ctx).findViewById(R.id.atomic));
            popmW4 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight,
                    true);
            popmW4.setBackgroundDrawable(new BitmapDrawable());
            popmW4.setOutsideTouchable(true);
            popmW1.setOutsideTouchable(true);
            popmW4.showAtLocation(vwLayout, Gravity.CENTER, 0, 30);
            btnseletone = (Button) vwLayout.findViewById(R.id.butatomone);
            btnseletone
                    .setText(Html.fromHtml("Electron Mass<br/><small>9.10938215*10<sup>-13</sup>Kg</small>"));
            btnseletone.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    popmW4.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("9.10938215e-31");
                }
            });
            btnselettwo = (Button) vwLayout.findViewById(R.id.butatomtwo);
            btnselettwo.setText(Html.fromHtml("Proton Mass<br/><small>1.672621637*10<sup>-27</sup>Kg</small>"));
            btnselettwo.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    popmW4.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("1.672621637e-27");
                }
            });
            btnseletthree = (Button) vwLayout.findViewById(R.id.butatomthree);
            btnseletthree.setText(Html.fromHtml("Fine Structure Constant<br/><small>0.007297353</small>"));
            btnseletthree.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    popmW4.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("0.007297353");
                }
            });
            btnseletfour = (Button) vwLayout.findViewById(R.id.atomfour);
            btnseletfour
                    .setText(Html.fromHtml("Rydberg Constant<br/><small>10,973,731.57 m<sup>-1</sup></small>"));
            btnseletfour.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    popmW4.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("1097373157e-1");
                }
            });
            btnseletfive = (Button) vwLayout.findViewById(R.id.butatomfive);
            btnseletfive
                    .setText(Html.fromHtml("Bohr Radious<br/><small>5.291772086*10<sup>-11</sup>m</small>"));
            btnseletfive.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW4.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("5.291772086e-11");
                }
            });
            btnseletsix = (Button) vwLayout.findViewById(R.id.butatomsix);
            btnseletsix.setText(Html
                    .fromHtml("Classical Electron Radius<br/><small>2.817940289*10<sup>-15</sup>m</small>"));
            btnseletsix.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW4.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("2.817940289e-15");
                }
            });
            imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelatom);
            imgbtnclose.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW4.dismiss();
                    popmW1.dismiss();
                }
            });
            imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackatom);
            imgbtnback.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW4.dismiss();
                }
            });
        }
    });
    btnphysico = (Button) vwLayout.findViewById(R.id.btnphyche);
    btnphysico.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            physico();
        }

        private void physico() {
            LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View vwLayout = inflater.inflate(R.layout.physico,
                    (ViewGroup) ((Activity) ctx).findViewById(R.id.physi));
            popmW5 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight,
                    true);
            popmW5.setBackgroundDrawable(new BitmapDrawable());
            popmW5.setOutsideTouchable(true);
            popmW1.setOutsideTouchable(true);
            popmW5.showAtLocation(vwLayout, Gravity.CENTER, 0, 30);

            btnseletone = (Button) vwLayout.findViewById(R.id.btnphyone);
            btnseletone.setText(
                    Html.fromHtml("Atomic Mass Unit<br/><small>1.660538782*10<sup>-27</sup>Kg</small>"));
            btnseletone.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    popmW5.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("1.660538782e-27");
                }
            });
            btnselettwo = (Button) vwLayout.findViewById(R.id.btnphytwo);
            btnselettwo.setText(Html.fromHtml(
                    "Avogadro Constant<br/><small>6.02214179*10<sup>23</sup>mol<sup>-1</sup></small>"));
            btnselettwo.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW5.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("6.02214179e-23");
                }
            });
            btnseletthree = (Button) vwLayout.findViewById(R.id.btnphythree);
            btnseletthree.setText(
                    Html.fromHtml("Faraday Constant<br/><small>96,458.3399 C.mol<sup>-1</sup></small>"));
            btnseletthree.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW5.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("964853399");
                }
            });
            btnseletfour = (Button) vwLayout.findViewById(R.id.btnphyfour);
            btnseletfour.setText(Html.fromHtml(
                    "Molar Gas Constant<br/><small>8.314472 J.mol<sup>-1</sup>.K<sup>-1</sup></small>"));
            btnseletfour.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW5.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("8314472");
                }
            });
            btnseletfive = (Button) vwLayout.findViewById(R.id.btnphyfive);
            btnseletfive.setText(Html.fromHtml(
                    "Boltzmann Constant<br/><small>1.3806504*10<sup>-23</sup>J.K<sup>-1</sup></small>"));
            btnseletfive.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW5.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("13806504e-23");
                }
            });
            btnseletsix = (Button) vwLayout.findViewById(R.id.btnphysix);
            btnseletsix.setText(Html.fromHtml(
                    "Stefan-Boltzmann Constant<br/><small>5.6704*10<sup>-8</sup>W.m<sup>-2</sup>.K<sup>-4</sup></small>"));
            btnseletsix.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW5.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("5.6704e-8");
                }
            });
            btnseletseven = (Button) vwLayout.findViewById(R.id.btnphyseven);
            btnseletseven
                    .setText(Html.fromHtml("Electron Volt<br/><small>1.602176487*10<sup>-19</sup>J</small>"));
            btnseletseven.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW5.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("1.602176487e-19");
                }
            });

            imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelphy);
            imgbtnclose.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW1.dismiss();
                    popmW5.dismiss();
                }
            });
            imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackphy);
            imgbtnback.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    popmW5.dismiss();

                }
            });
        }
    });

    // other
    // option---------------------------------------------------------------------------
    btnOther = (Button) vwLayout.findViewById(R.id.btnother);
    btnOther.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            Other();
            popmW1.dismiss();
        }

        private void Other() {

            // Toast.makeText(getApplicationContext(), "other",
            // Toast.LENGTH_SHORT).show();
            LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final View vwLayout = inflater.inflate(R.layout.other,
                    (ViewGroup) ((Activity) ctx).findViewById(R.id.other));
            popmW6 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight,
                    true);
            popmW6.setBackgroundDrawable(new BitmapDrawable());
            popmW6.setOutsideTouchable(true);
            popmW1.setOutsideTouchable(true);
            popmW6.showAtLocation(vwLayout, Gravity.CENTER, 0, 30);
            btnseletone = (Button) vwLayout.findViewById(R.id.btngravity);
            btnseletone.setText(Html.fromHtml("Standard Gravity<br/><small>9.80665 m.s<sup>-2</sup></small>"));
            btnseletone.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    popmW6.dismiss();
                    popmW1.dismiss();
                    mHandler.insert("9.80665");
                }
            });
            imgbtnclose = (ImageButton) vwLayout.findViewById(R.id.butcancelother);
            imgbtnclose.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {

                    popmW6.dismiss();
                    popmW1.dismiss();
                }
            });
            imgbtnback = (ImageButton) vwLayout.findViewById(R.id.btnbackother);
            imgbtnback.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {

                    popmW6.dismiss();
                    popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 30);

                }
            });
        }
    });
}

From source file:fr.univsavoie.ltp.client.map.Popup.java

/**
 * Afficher sur la map un popup qui propose a l'utilisateur
 * de mettre a jours son status//  w w w . j  a v  a 2s. co m
 */
public final void popupPublishStatus() {
    DisplayMetrics dm = new DisplayMetrics();
    this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    //final int height = dm.heightPixels;
    final int width = dm.widthPixels;

    int popupWidth = (int) (width * 0.75);
    //int popupHeight = height / 2;

    // Inflate the popup_layout.xml
    ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupStatus);
    LayoutInflater layoutInflater = (LayoutInflater) this.activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View layout = layoutInflater.inflate(R.layout.popup_set_status, viewGroup);
    layout.setBackgroundResource(R.drawable.popup_gradient);

    // Crer le PopupWindow
    final PopupWindow popupPublishStatus = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true);
    popupPublishStatus.setBackgroundDrawable(new BitmapDrawable());
    popupPublishStatus.setOutsideTouchable(true);

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
    final int OFFSET_X = 0;
    final int OFFSET_Y = 0;

    // Displaying the popup at the specified location, + offsets.
    this.activity.findViewById(R.id.layoutMain).post(new Runnable() {
        public void run() {
            popupPublishStatus.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y);
        }
    });

    /*
     * Evenements composants du PopupWindow
     */

    // Ecouteur d'vnement sur le bouton pour se dconnecter
    Button publish = (Button) layout.findViewById(R.id.btStatusPublish);
    publish.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            EditText userStatus = (EditText) layout.findViewById(R.id.fieldUserStatus);
            if (userStatus.getText().toString().length() == 0) {
                Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show();
                popupPublishStatus.dismiss();
            } else if (userStatus.getText().toString().length() < 3) {
                Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show();
                popupPublishStatus.dismiss();
            } else {
                String json = "{\"ltp\":{\"application\":\"Client LTP\",\"status\":{\"lon\" : \""
                        + String.valueOf(activity.getLongitude()) + "\",\"lat\" : \""
                        + String.valueOf(activity.getLatitude()) + "\",\"content\" : \""
                        + userStatus.getText().toString() + "\"}}}";
                activity.getSession().postJSON("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses",
                        "STATUSES", json);

                Toast.makeText(activity, "Status mise a jours !", Toast.LENGTH_LONG).show();
                popupPublishStatus.dismiss();

                // Actualise les marqueurs
                activity.displayFriends();
            }
        }
    });
}

From source file:fr.univsavoie.ltp.client.map.Popup.java

/**
 * Afficher une boite au milieu de la carte si aucun utilisateur est connects
 * pour proposer a l'invit, de se connecter ou s'incrire aupres du service LTP.
 */// ww w  .j  ava  2s . c  o m
public final void popupGuest() {
    DisplayMetrics dm = new DisplayMetrics();
    this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    //final int height = dm.heightPixels;
    final int width = dm.widthPixels;
    //final int height = dm.heightPixels;

    int popupWidth = (int) (width * 0.75);
    //int popupHeight = height / 2;

    // Inflate the popup_layout.xml
    LinearLayout viewGroup = (LinearLayout) this.activity.findViewById(R.id.popupGuest);
    LayoutInflater layoutInflater = (LayoutInflater) this.activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View layout = layoutInflater.inflate(R.layout.popup_guest, viewGroup);
    layout.setBackgroundResource(R.drawable.popup_gradient);

    // Crer le PopupWindow
    final PopupWindow popupGuest = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true);
    popupGuest.setBackgroundDrawable(new BitmapDrawable());
    popupGuest.setOutsideTouchable(true);

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
    final int OFFSET_X = 0;
    final int OFFSET_Y = 0;

    // Displaying the popup at the specified location, + offsets.
    this.activity.findViewById(R.id.layoutMain).post(new Runnable() {
        public void run() {
            popupGuest.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y);
        }
    });

    /*
     * Evenements composants du PopupWindow
     */

    // Ecouteur d'vnement sur le bouton des paramtres
    Button btLogin = (Button) layout.findViewById(R.id.btnPopupLogin);
    btLogin.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // La constante CODE_MON_ACTIVITE reprsente lidentifiant de la requte
            // (requestCode) qui sera utilis plus tard pour identifier lactivit
            // renvoyant la valeur de retour.
            Intent i = new Intent(activity, LoginActivity.class);
            activity.startActivityForResult(i, 1);

            popupGuest.dismiss();
        }
    });

    // Ecouteur d'vnement sur le bouton des paramtres
    Button btSignup = (Button) layout.findViewById(R.id.btnPopupSignup);
    btSignup.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // La constante CODE_MON_ACTIVITE reprsente lidentifiant de la requte
            // (requestCode) qui sera utilis plus tard pour identifier lactivit
            // renvoyant la valeur de retour.
            Intent i = new Intent(activity, SignupActivity.class);
            activity.startActivityForResult(i, 3);

            popupGuest.dismiss();
        }
    });

    // Ecouteur d'vnement sur le bouton pour fermer l'application
    Button close = (Button) layout.findViewById(R.id.btnPopupClose);
    close.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            popupGuest.dismiss();
        }
    });
}

From source file:com.dycody.android.idealnote.SketchFragment.java

private void showPopup(View anchor, final int eraserOrStroke) {

    boolean isErasing = eraserOrStroke == SketchView.ERASER;

    oldColor = mColorPicker.getColor();//from w w  w.  ja v a2 s .  com

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);

    // Creating the PopupWindow
    PopupWindow popup = new PopupWindow(getActivity());
    popup.setContentView(isErasing ? popupEraserLayout : popupLayout);
    popup.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    popup.setFocusable(true);
    popup.setOnDismissListener(() -> {
        if (mColorPicker.getColor() != oldColor)
            mColorPicker.setOldCenterColor(oldColor);
    });

    // Clear the default translucent background
    popup.setBackgroundDrawable(new BitmapDrawable());

    // Displaying the popup at the specified location, + offsets (transformed 
    // dp to pixel to support multiple screen sizes)
    popup.showAsDropDown(anchor);

    // Stroke size seekbar initialization and event managing
    SeekBar mSeekBar;
    mSeekBar = (SeekBar) (isErasing ? popupEraserLayout.findViewById(R.id.stroke_seekbar)
            : popupLayout.findViewById(R.id.stroke_seekbar));
    mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // When the seekbar is moved a new size is calculated and the new shape
            // is positioned centrally into the ImageView
            setSeekbarProgress(progress, eraserOrStroke);
        }
    });
    int progress = isErasing ? seekBarEraserProgress : seekBarStrokeProgress;
    mSeekBar.setProgress(progress);
}

From source file:com.example.util.ImageUtils.java

/**
 * //from ww w . ja va  2s  .  c  o  m
 */
public static void downloadDeatilScreenshot(Context context, String url, ImageView imageView) {

    Drawable defaultDrawable = new BitmapDrawable();
    if (cancelPotentialBitmapDownload(url, imageView)) {
        BitmapDownloaderTask task = new BitmapDownloaderTask(imageView);
        DownloadedDrawable1 downloadedDrawable = new DownloadedDrawable1(defaultDrawable, task);
        imageView.setImageDrawable(downloadedDrawable);
        task.execute(context, url, TYPE_SCREENSHOT);
    }
}

From source file:bruce.kk.brucetodos.MainActivity.java

/**
 * ? /*from  w  w  w. j  a v a2s. c  o  m*/
 */
private void showAddPop() {
    final EditText editText = new EditText(MainActivity.this);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    editText.setLayoutParams(layoutParams);
    //        editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    editText.setTextColor(getResources().getColor(android.R.color.holo_green_light));
    editText.setHint("?~");
    editText.setHintTextColor(getResources().getColor(android.R.color.holo_orange_dark));
    editText.setBackgroundColor(getResources().getColor(android.R.color.black));
    final PopupWindow popupWindow = new PopupWindow(editText, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setBackgroundDrawable(new BitmapDrawable()); // ?
    popupWindow.setTouchable(true);
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(contentMain, Gravity.CENTER, 0, 0);

    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            LogDetails.d(": " + editText.getText().toString());
            if (!TextUtils.isEmpty(editText.getText().toString().trim())) {
                ProgressDialogUtils.showProgressDialog();
                UnFinishItem item = new UnFinishItem();
                Date date = new Date();
                item.createDay = date;
                item.content = editText.getText().toString().trim();
                item.modifyDay = date;
                dataList.add(item);
                refreshData(true);
                presenter.addItem(item);
            }
        }
    });
}

From source file:com.insthub.O2OMobile.Activity.C17_ApplyFormActivity.java

/**
 * popwindow/* ww w . ja  v  a2  s .c  o m*/
 *
 * @param parent
 */
private void showPopWindow(View parent) {
    int id = parent.getId();
    switch (id) {
    case R.id.service_type:
        if (mServiceListPopwindow == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mServicePopwindowView = layoutInflater.inflate(R.layout.service_type_popwindow, null);
            mServicePopwindowListView = (ListView) mServicePopwindowView
                    .findViewById(R.id.service_type_pop_listview);
            mServiceListPopwindow = new PopupWindow(mServicePopwindowView, parent.getWidth(),
                    AbsoluteLayout.LayoutParams.WRAP_CONTENT, true);

        }
        if (mServiceTypePopAdapter == null) {
            mServiceTypePopAdapter = new ServiceTypePopAdapter(this, mServiceModel.publicServiceTypeList);
            mServicePopwindowListView.setAdapter(mServiceTypePopAdapter);
        }
        mServiceListPopwindow.setFocusable(true);
        // ?
        mServiceListPopwindow.setOutsideTouchable(true);
        mServiceTypeArrow.setImageResource(R.drawable.b4_arrow_up);
        // Back???
        mServiceListPopwindow.setBackgroundDrawable(new BitmapDrawable());
        mServiceListPopwindow.showAsDropDown(parent);
        mServiceListPopwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mServiceTypeArrow.setImageResource(R.drawable.b3_arrow_down);
            }
        });
        mServicePopwindowListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SERVICE_TYPE serviceType = mServiceTypeList.get(position);
                mServiceTypeId = serviceType.id;
                mServiceTypeTitle.setText(serviceType.title);
                mServiceModel.publicIsSecondCategory = false;
                mServiceModel.getCategoryList(mServiceTypeId);
                mServiceListPopwindow.dismiss();
            }
        });
        break;
    case R.id.first_category:
        if (mFirstCategoryListPopwindow == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mFirstCategoryPopWindowView = layoutInflater.inflate(R.layout.first_category_popwindow, null);
            mFirstCategoryPopWindowListView = (ListView) mFirstCategoryPopWindowView
                    .findViewById(R.id.first_category_pop_listview);
            mFirstCategoryListPopwindow = new PopupWindow(mFirstCategoryPopWindowView, parent.getWidth(),
                    AbsoluteLayout.LayoutParams.WRAP_CONTENT, true);

        }
        if (mFirstCategoryPopAdapter == null) {
            mFirstCategoryPopAdapter = new FirstCategoryPopAdapter(this, mFirstCategoryList);
            mFirstCategoryPopWindowListView.setAdapter(mFirstCategoryPopAdapter);
        } else {
            mFirstCategoryPopAdapter.publicFirstCategoryList = mFirstCategoryList;
            mFirstCategoryPopAdapter.notifyDataSetChanged();
        }
        mFirstCategoryListPopwindow.setFocusable(true);
        // ?
        mFirstCategoryListPopwindow.setOutsideTouchable(true);
        mFirstCategoryArrow.setImageResource(R.drawable.b4_arrow_up);
        // Back???
        mFirstCategoryListPopwindow.setBackgroundDrawable(new BitmapDrawable());
        mFirstCategoryListPopwindow.showAsDropDown(parent);
        mFirstCategoryListPopwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mFirstCategoryArrow.setImageResource(R.drawable.b3_arrow_down);
            }
        });
        mFirstCategoryPopWindowListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SERVICE_CATEGORY service_category = mFirstCategoryList.get(position);
                mFirstClassServiceCategory = service_category.id;
                mFirstCategoryTitle.setText(service_category.title);
                mServiceModel.publicIsSecondCategory = true;
                mServiceModel.getCategoryList(mFirstClassServiceCategory);
                mFirstCategoryListPopwindow.dismiss();
            }
        });
        break;
    case R.id.second_category:
        if (mSecondCategoryListPopwindow == null) {
            LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mSecondCategoryPopWindowView = layoutInflater.inflate(R.layout.second_category_popwindow, null);
            mSecondCategoryPopWindowListView = (ListView) mSecondCategoryPopWindowView
                    .findViewById(R.id.second_category_pop_listview);
            mSecondCategoryListPopwindow = new PopupWindow(mSecondCategoryPopWindowView, parent.getWidth(),
                    AbsoluteLayout.LayoutParams.WRAP_CONTENT, true);

        }
        if (mSecondCategoryPopAdapter == null) {
            mSecondCategoryPopAdapter = new SecondCategoryPopAdapter(this, mSecondCategoryList);
            mSecondCategoryPopWindowListView.setAdapter(mSecondCategoryPopAdapter);
        } else {
            mSecondCategoryPopAdapter.publicSecondCategoryList = mSecondCategoryList;
            mSecondCategoryPopAdapter.notifyDataSetChanged();
        }

        mSecondCategoryListPopwindow.setFocusable(true);
        // ?
        mSecondCategoryListPopwindow.setOutsideTouchable(true);
        mSecondCategoryArrow.setImageResource(R.drawable.b4_arrow_up);
        // Back???
        mSecondCategoryListPopwindow.setBackgroundDrawable(new BitmapDrawable());
        mSecondCategoryListPopwindow.showAsDropDown(parent);
        mSecondCategoryListPopwindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                mSecondCategoryArrow.setImageResource(R.drawable.b3_arrow_down);
            }
        });
        mSecondCategoryPopWindowListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                SERVICE_CATEGORY service_category = mSecondCategoryList.get(position);
                mSecondVlassServiceCategory = service_category.id;
                mSecondCategoryTitle.setText(service_category.title);
                mServiceModel.publicIsSecondCategory = true;
                mSecondCategoryListPopwindow.dismiss();
            }
        });
        break;
    }

}

From source file:bmcx.aiton.com.passenger.view.activity.UploadUserDataActivity.java

/**
 * POP?//from  www.  ja v  a 2s . co m
 */
private void showPopupwindowForChooseImageStage() {
    View inflate = getLayoutInflater().inflate(R.layout.layout_pop_choose_img_stage, null);
    inflate.findViewById(R.id.click_local).setOnClickListener(this);
    inflate.findViewById(R.id.click_camera).setOnClickListener(this);
    inflate.findViewById(R.id.cancle).setOnClickListener(this);
    //??truePopupWindow,match??
    mPopupWindow = new PopupWindow(inflate, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, true);
    //
    mPopupWindow.setOutsideTouchable(false);
    //?
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.alpha = 0.7f;
    getWindow().setAttributes(lp);
    mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            WindowManager.LayoutParams lp = getWindow().getAttributes();
            lp.alpha = 1f;
            getWindow().setAttributes(lp);
        }
    });
    // ?PopupWindowBackdismiss
    BitmapDrawable bitmapDrawable = new BitmapDrawable();
    mPopupWindow.setBackgroundDrawable(bitmapDrawable);
    mPopupWindow.showAtLocation(inflate, Gravity.BOTTOM, 0, 0);
}