Example usage for android.content Context LAYOUT_INFLATER_SERVICE

List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE

Introduction

In this page you can find the example usage for android.content Context LAYOUT_INFLATER_SERVICE.

Prototype

String LAYOUT_INFLATER_SERVICE

To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.LayoutInflater for inflating layout resources in this context.

Usage

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);//from   w  w  w. j ava 2  s.co  m
    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:com.android.contacts.detail.ContactDetailLayoutController.java

public ContactDetailLayoutController(Activity activity, Bundle savedState, FragmentManager fragmentManager,
        TransitionAnimationView animationView, View viewContainer,
        ContactDetailFragment.Listener contactDetailFragmentListener) {

    if (fragmentManager == null) {
        throw new IllegalStateException(
                "Cannot initialize a ContactDetailLayoutController " + "without a non-null FragmentManager");
    }/*from   w ww. j av  a2s  .  c  o m*/

    mActivity = activity;
    mLayoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mFragmentManager = fragmentManager;
    mContactDetailFragmentListener = contactDetailFragmentListener;

    mTransitionAnimationView = animationView;

    // Retrieve views in case this is view pager and carousel mode
    mViewContainer = viewContainer;

    mViewPager = (ViewPager) viewContainer.findViewById(R.id.pager);
    mTabCarousel = (ContactDetailTabCarousel) viewContainer.findViewById(R.id.tab_carousel);

    // Retrieve view in case this is in fragment carousel mode
    mFragmentCarousel = (ContactDetailFragmentCarousel) viewContainer.findViewById(R.id.fragment_carousel);

    // Retrieve container views in case they are already in the XML layout
    mDetailFragmentView = viewContainer.findViewById(R.id.about_fragment_container);
    mUpdatesFragmentView = viewContainer.findViewById(R.id.updates_fragment_container);

    // Determine the layout mode based on the presence of certain views in the layout XML.
    if (mViewPager != null) {
        mLayoutMode = LayoutMode.VIEW_PAGER_AND_TAB_CAROUSEL;
    } else if (mFragmentCarousel != null) {
        if (PhoneCapabilityTester.isUsingTwoPanes(mActivity)) {
            mLayoutMode = LayoutMode.TWO_COLUMN_FRAGMENT_CAROUSEL;
        } else {
            mLayoutMode = LayoutMode.FRAGMENT_CAROUSEL;
        }
    } else {
        mLayoutMode = LayoutMode.TWO_COLUMN;
    }

    initialize(savedState);
}

From source file:com.andrewshu.android.reddit.mail.InboxActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;//from   www .  j  a  va 2s  .  co m
    ProgressDialog pdialog;
    AlertDialog.Builder builder;
    LayoutInflater inflater;
    View layout; // used for inflated views for AlertDialog.Builder.setView()

    switch (id) {
    case Constants.DIALOG_COMPOSE:
        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        layout = inflater.inflate(R.layout.compose_dialog, null);
        dialog = builder.setView(layout).create();
        final Dialog composeDialog = dialog;

        Common.setTextColorFromTheme(mSettings.getTheme(), getResources(),
                (TextView) layout.findViewById(R.id.compose_destination_textview),
                (TextView) layout.findViewById(R.id.compose_subject_textview),
                (TextView) layout.findViewById(R.id.compose_message_textview),
                (TextView) layout.findViewById(R.id.compose_captcha_textview),
                (TextView) layout.findViewById(R.id.compose_captcha_loading));

        final EditText composeDestination = (EditText) layout.findViewById(R.id.compose_destination_input);
        final EditText composeSubject = (EditText) layout.findViewById(R.id.compose_subject_input);
        final EditText composeText = (EditText) layout.findViewById(R.id.compose_text_input);
        final Button composeSendButton = (Button) layout.findViewById(R.id.compose_send_button);
        final Button composeCancelButton = (Button) layout.findViewById(R.id.compose_cancel_button);
        final EditText composeCaptcha = (EditText) layout.findViewById(R.id.compose_captcha_input);
        composeSendButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                ThingInfo thingInfo = new ThingInfo();

                if (!FormValidation.validateComposeMessageInputFields(InboxActivity.this, composeDestination,
                        composeSubject, composeText, composeCaptcha))
                    return;

                thingInfo.setDest(composeDestination.getText().toString().trim());
                thingInfo.setSubject(composeSubject.getText().toString().trim());
                new MyMessageComposeTask(composeDialog, thingInfo, composeCaptcha.getText().toString().trim(),
                        mCaptchaIden, mSettings, mClient, InboxActivity.this)
                                .execute(composeText.getText().toString().trim());
                removeDialog(Constants.DIALOG_COMPOSE);
            }
        });
        composeCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                removeDialog(Constants.DIALOG_COMPOSE);
            }
        });
        break;

    case Constants.DIALOG_COMPOSING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Composing message...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:com.measurence.sdk.android.demo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.container, new NotificationsFragment())
                .commit();//from w  ww. j a  v  a  2 s.  c om
    }
    checkRegistration();
    subscriptionResultBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String subscriptionResultMessage = intent
                    .getStringExtra(MeasurenceApiSubscriptionService.SUBSCRIPTION_RESULT_INTENT_MESSAGE);
            displaySubscriptionResultMessage(subscriptionResultMessage);
        }
    };

    if (presenceNotificationsListAdapter == null) {
        presenceNotificationsListAdapter = new ArrayAdapter<PresenceNotification>(this,
                R.layout.list_item_notification, R.id.list_item_notification_view,
                new ArrayList<PresenceNotification>()) {

            DateFormat dateFormat = DateFormat.getDateTimeInstance();

            private void setText(View root, int id, String text) {
                TextView textView = (TextView) root.findViewById(id);
                textView.setText(text);
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                LayoutInflater inflater = (LayoutInflater) getContext()
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View itemView = inflater.inflate(R.layout.list_item_notification, null);
                PresenceNotification notification = getItem(position);
                PresenceSessionUpdate item = notification.presenceSessionUpdate;
                String now = dateFormat.format(notification.received);
                setText(itemView, R.id.list_item_notification_date, now);
                StringBuilder sb = new StringBuilder();
                for (UserIdentity userid : item.getUserIdentities()) {
                    sb.append(userid.getId()).append(" ");
                }
                setText(itemView, R.id.list_item_notification_userid, sb.toString());
                setText(itemView, R.id.list_item_notification_storeid, item.getStoreKey());
                setText(itemView, R.id.list_item_notification_new_user,
                        getString(item.getIsNewVisitorInStore().booleanValue() ? R.string.yes : R.string.no));
                setText(itemView, R.id.list_item_notification_status, item.getStatus());
                setText(itemView, R.id.list_item_notification_session_start,
                        dateFormat.format(item.getInterval().getStart()));
                setText(itemView, R.id.list_item_notification_session_end,
                        dateFormat.format(item.getInterval().getEnd()));
                setText(itemView, R.id.list_item_notification_session_UUID, item.getUpdateUUID());
                return itemView;
            }
        };
        BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {

            private void displaySessionUpdate(PresenceSessionUpdate presenceSessionUpdate) {
                PresenceNotification notification = new PresenceNotification();
                notification.presenceSessionUpdate = presenceSessionUpdate;
                notification.received = new Date();
                presenceNotificationsListAdapter.insert(notification, 0);
                Log.i(LOG_TAG, "displaying session update|" + presenceSessionUpdate);
            }

            @Override
            public void onReceive(Context context, Intent intent) {
                String presenceSessionUpdateJson = intent.getStringExtra(
                        PresenceSessionUpdatesNotificationService.SESSION_UPDATE_JSON_PARAMETER);

                displaySessionUpdate(PresenceSessionUpdate.fromJson(presenceSessionUpdateJson));

            }
        };
        LocalBroadcastManager.getInstance(this).registerReceiver((broadcastReceiver),
                new IntentFilter(PresenceSessionUpdatesNotificationService.SESSION_UPDATE_INTENT_ID));
    }

}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

public View onCreateView() {

    LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflate.inflate(R.layout.roboto_calendar_picker_layout, this, true);

    findViewsById(view);/* ww  w . jav a2  s .co m*/

    initializeEventListeners();

    initializeComponentBehavior();

    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
            .setDefaultFontPath("fonts/MyriadPro-Regular.ttf").setFontAttrId(R.attr.fontPath).build());

    return view;
}

From source file:org.openhab.habdroid.ui.OpenHABWidgetArrayAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewData preparedViewData = new ViewData();
    int widgetLayout;
    preparedViewData.openHABWidget = getItem(position);
    switch (mWidgetLayoutType) {
    case IconTextControlList:
        widgetLayout = mWidgetTypeLayoutProvider.getRowLayoutId(preparedViewData.openHABWidget.getType());
        break;//from  w w w  . ja va  2  s  .com
    default:
        widgetLayout = R.layout.openhabwidgetlist_generic_controlless_item;
        break;
    }

    if (convertView == null) {
        preparedViewData.widgetView = new RelativeLayout(getContext());
        String inflater = Context.LAYOUT_INFLATER_SERVICE;
        LayoutInflater vi;
        vi = (LayoutInflater) getContext().getSystemService(inflater);
        try {
            vi.inflate(widgetLayout, preparedViewData.widgetView, true);
        } catch (Exception ex) {
            Log.w("OpenHABWidgetArrayAdapt",
                    String.format("'%s' of type '%s' cannot get inflated in widget list",
                            preparedViewData.openHABWidget, preparedViewData.openHABWidget.getType()),
                    ex);
        }
    } else {
        preparedViewData.widgetView = (RelativeLayout) convertView;
    }

    processIconImage(preparedViewData.widgetView, preparedViewData.openHABWidget);
    preparedViewData.labelTextView = getLabelTextView(preparedViewData.widgetView,
            preparedViewData.openHABWidget);
    preparedViewData.valueTextView = getValueTextView(preparedViewData.widgetView,
            preparedViewData.openHABWidget);

    View widgetView = null;
    if (mWidgetLayoutType == WidgetLayoutType.IconTextList) {
        widgetView = new OpenHABFrameWidget(this, preparedViewData).getWidget();
        preparedViewData.labelTextView.setText(preparedViewData.openHABWidget.getLabel());
        return widgetView;
    }

    switch (preparedViewData.openHABWidget.getType()) {
    case Frame:
        widgetView = new OpenHABFrameWidget(this, preparedViewData).getWidget();
        break;
    case Group:
        widgetView = new OpenHABGroupWidget(this, preparedViewData).getWidget();
        break;
    case SelectionSwitch:
        widgetView = new OpenHABSelectionSwitchWidget(this, preparedViewData).getWidget();
        break;
    case Switch:
        widgetView = new OpenHABSwitchWidget(this, preparedViewData).getWidget();
        break;
    case Color:
        widgetView = new OpenHABColorWidget(this, preparedViewData).getWidget();
        break;
    case RollerShutter:
        widgetView = new OpenHABRollerShutterWidget(this, preparedViewData).getWidget();
        break;
    case ItemText:
    case SitemapText:
        widgetView = new OpenHABTextWidget(this, preparedViewData).getWidget();
        break;
    case Slider:
        widgetView = new OpenHABSliderWidget(this, preparedViewData).getWidget();
        break;
    case Image:
        widgetView = new OpenHABImageWidget(refreshImageList, this, preparedViewData).getWidget();
        break;
    case Chart:
        int screenWidth = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay().getWidth();
        widgetView = new OpenHABChartWidget(screenWidth, refreshImageList, this, preparedViewData).getWidget();
        break;
    case Video:
        widgetView = new OpenHABVideoWidget(this.getContext(), videoWidgetList, this, preparedViewData)
                .getWidget();
        break;
    case Web:
        widgetView = new OpenHABWebWidget(this, preparedViewData).getWidget();
        break;
    case Selection:
        widgetView = new OpenHABSelectionWidget(this.getContext(), this, preparedViewData).getWidget();
        break;
    case Setpoint:
        widgetView = new OpenHABSetpointWidget(this.getContext(), this, preparedViewData).getWidget();
        break;
    default:
        if (preparedViewData.labelTextView != null)
            preparedViewData.labelTextView.setText(preparedViewData.openHABWidget.getLabel());
        break;
    }

    LinearLayout dividerLayout = (LinearLayout) widgetView.findViewById(R.id.listdivider);
    if (dividerLayout != null) {
        if (position < this.getCount() - 1/* || !mWidgetLayoutType.equals(WidgetLayoutType.IconTextList)*/) {
            if (getItem(position + 1).getType() == OpenHABWidgetType.Frame) {
                dividerLayout.setVisibility(View.GONE); // hide dividers before frame widgets
            } else {
                dividerLayout.setVisibility(View.VISIBLE); // show dividers for all others
            }
        } else { // last widget in the list, hide divider
            dividerLayout.setVisibility(View.GONE);
        }
    }

    return widgetView;
}

From source file:com.irccloud.android.fragment.ChannelModeListFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();//from w w w.j  a v  a  2 s. c  om
    if (ctx == null)
        return null;

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.recyclerview, null);
    recyclerView = v.findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext()));
    empty = v.findViewById(android.R.id.empty);
    empty.setText(placeholder);
    if (savedInstanceState != null && savedInstanceState.containsKey("cid")) {
        cid = savedInstanceState.getInt("cid");
        bid = savedInstanceState.getInt("bid");
        event = new IRCCloudJSONObject(savedInstanceState.getString("event"));
        list = savedInstanceState.getString("list");
        mask = savedInstanceState.getString("mask");
        placeholder = savedInstanceState.getString("placeholder");
        title = savedInstanceState.getString("title");
        mode = savedInstanceState.getString("mode");
        data = event.getJsonNode(list);
        adapter = new Adapter();
        recyclerView.setAdapter(adapter);
        if (adapter.getItemCount() > 0) {
            empty.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        } else {
            empty.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        }
    }
    AlertDialog.Builder b = new AlertDialog.Builder(ctx).setTitle(title).setView(v).setNegativeButton("Close",
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    try {
        if (canChangeMode) {
            b.setPositiveButton("Add", new AddClickListener());
        }
    } catch (Exception e) {

    }

    AlertDialog d = b.create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return d;
}

From source file:com.kobi.metalsexchange.app.ExchangeRatesFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mMetalId = getArguments().getString(METAL_ID);
    // Add this line in order for this fragment to handle menu events.
    setHasOptionsMenu(true);/*from   ww  w .  j a v a2  s.c  o m*/
    /* Attach a rotating ImageView to the refresh item as an ActionView */
    inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    refreshImageView = (ImageView) inflater.inflate(R.layout.refresh_action_view, null);
    rotation = AnimationUtils.loadAnimation(getActivity(), R.anim.clockwise_refresh);
    rotation.setRepeatCount(Animation.INFINITE);
}

From source file:com.irccloud.android.fragment.BanListFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();//ww  w.j a v  a 2s .c o  m
    if (ctx == null)
        return null;

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.ignorelist, null);
    listView = (ListView) v.findViewById(android.R.id.list);
    TextView empty = (TextView) v.findViewById(android.R.id.empty);
    empty.setText(
            "No bans in effect.\n\nYou can ban someone by tapping their nickname in the user list, long-pressing a message, or by using /ban.");
    listView.setEmptyView(empty);
    if (savedInstanceState != null && savedInstanceState.containsKey("cid")) {
        cid = savedInstanceState.getInt("cid");
        bid = savedInstanceState.getInt("bid");
        event = new IRCCloudJSONObject(savedInstanceState.getString("event"));
        bans = event.getJsonNode("bans");
        adapter = new BansAdapter(this);
        listView.setAdapter(adapter);
    }
    AlertDialog.Builder b = new AlertDialog.Builder(ctx)
            .setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
            .setTitle("Ban list for " + event.getString("channel")).setView(v)
            .setNegativeButton("Close", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    try {
        ServersDataSource.Server server = ServersDataSource.getInstance().getServer(cid);
        UsersDataSource.User self_user = UsersDataSource.getInstance().getUser(bid,
                ServersDataSource.getInstance().getServer(cid).nick);
        if (self_user != null && (self_user.mode.contains(server != null ? server.MODE_OWNER : "q")
                || self_user.mode.contains(server != null ? server.MODE_ADMIN : "a")
                || self_user.mode.contains(server != null ? server.MODE_OP : "o"))) {
            b.setPositiveButton("Add Ban Mask", new AddClickListener());
        }
    } catch (Exception e) {

    }

    AlertDialog d = b.create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return d;
}