private void addListeners() { mLogoutBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { CloudAPI.logout(); updateLoginStatus(); } }); mLoginBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { LoginDialog loginDialog = new LoginDialog(v.getContext()); loginDialog.show(); } }); mSearchBtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // NotificationManager.getInstance().markDirty(); // NotificationManager.getInstance().fire(); } }); }
private void createButtons(Context context) { int panelWidth = LayoutUtil.getNavigationPanelWidth(); int smallMargin = DensityAdaptor.getDensityIndependentValue(1); int buttonSideLength = (panelWidth - smallMargin * 3) / 2; int topOffset = LayoutUtil.getGalleryTopPanelHeight(); // ImageView crossSeparator = new ImageView(context); // crossSeparator.setImageResource(R.drawable.cross_separator); // LayoutParams crossSeparatorLP = new LayoutParams(LayoutParams.WRAP_CONTENT, // LayoutParams.WRAP_CONTENT); // crossSeparatorLP.leftMargin = (panelWidth - DensityAdaptor.getDensityIndependentValue(100)) // / 2; // crossSeparatorLP.topMargin = DensityAdaptor.getDensityIndependentValue(120); // crossSeparator.setLayoutParams(crossSeparatorLP); // this.addView(crossSeparator); mSearchBtn = new SquareButton(context, R.drawable.search_140); RelativeLayout.LayoutParams searchBtnLP = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); searchBtnLP.leftMargin = smallMargin; searchBtnLP.topMargin = topOffset + smallMargin; searchBtnLP.width = searchBtnLP.height = buttonSideLength; mSearchBtn.setLayoutParams(searchBtnLP); this.addView(mSearchBtn); mGalleryBtn = new SquareButton(context, R.drawable.gallery_browse_140); RelativeLayout.LayoutParams galleryBtnLP = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); galleryBtnLP.leftMargin = smallMargin * 2 + buttonSideLength; galleryBtnLP.topMargin = searchBtnLP.topMargin; galleryBtnLP.width = galleryBtnLP.height = buttonSideLength; mGalleryBtn.setLayoutParams(galleryBtnLP); this.addView(mGalleryBtn); mMessageBtn = new SquareButton(context, R.drawable.message_140); RelativeLayout.LayoutParams messageBtnLP = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); messageBtnLP.leftMargin = searchBtnLP.leftMargin; messageBtnLP.topMargin = topOffset + smallMargin * 2 + buttonSideLength; messageBtnLP.width = messageBtnLP.height = buttonSideLength; mMessageBtn.setLayoutParams(messageBtnLP); this.addView(mMessageBtn); mHelpBtn = new SquareButton(context, R.drawable.question_140); RelativeLayout.LayoutParams helpBtnLP = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); helpBtnLP.leftMargin = galleryBtnLP.leftMargin; helpBtnLP.topMargin = messageBtnLP.topMargin; helpBtnLP.width = helpBtnLP.height = buttonSideLength; mHelpBtn.setLayoutParams(helpBtnLP); this.addView(mHelpBtn); // Sign up mSignUpBtn = new HaloButton(mContext, R.drawable.register); mSignUpBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { HomeActivity.getApp().toggleSignUpPanel(true); } }); RelativeLayout.LayoutParams regBtnLP = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); regBtnLP.topMargin = DensityAdaptor.getDensityIndependentValue(150); regBtnLP.addRule(RelativeLayout.CENTER_HORIZONTAL); this.addView(mSignUpBtn, regBtnLP); }