private void setLoggedIn(boolean loggedIn) { this.loggedIn = loggedIn; if (loggedIn) { } else { loginItem.setText(getResources().getString(R.string.log_in)); loginItem.setImage(getResources().getDrawable(R.drawable.login)); menuAdapter.notifyDataSetChanged(); } }
private void setUserUIControlsLoggedIn(UserInfo uInfo) { String userName = uInfo.getName(); Bitmap userAvatarImage = uInfo.getUserBitmap(); setLoggedIn(true); BitmapDrawable userAvatarDrawable = new BitmapDrawable(getResources(), userAvatarImage); loginItem.setText(userName); loginItem.setImage(userAvatarDrawable); menuAdapter.notifyDataSetChanged(); hideErrorMessege(); }
private void setUpViews() { setContentView(R.layout.activity_base_assembly); activityContentLayout = (LinearLayout) findViewById(R.id.activity_content); errorMessageView = (TextView) findViewById(R.id.error_not_logged_in); menu = new SlidingMenu(this); menu.setMode(SlidingMenu.LEFT); menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); menu.setShadowWidthRes(R.dimen.shadow_width); menu.setShadowDrawable(R.drawable.shadow); menu.setBehindOffsetRes(R.dimen.slidingmenu_offset); menu.setFadeDegree(0.35f); menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); menu.setMenu(R.layout.slidebar); mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater.inflate(resLayout, activityContentLayout); menuAdapter = new MenuListAdapter(this); menuListView = (ListView) findViewById(R.id.sidebar_list); menuListView.setAdapter(menuAdapter); menuListView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { MenuListItem item = (MenuListItem) arg1; item.getItem().getAction().run(); } }); menuListView.setOnItemLongClickListener( new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View view, int arg2, long arg3) { MenuListItem item = (MenuListItem) view; OnLongClickListener longClickAction = item.getItem().getLongClickAction(); if (longClickAction != null) { item.getItem().getLongClickAction().onLongClick(view); } return true; } }); loginItem = menuAdapter.getLoginItem(); loginItem.setAction( new Runnable() { @Override public void run() { if (loggedIn) { showUserProfile(); } else { authorizeUser(); } } }); loginItem.setLongClickAction( new OnLongClickListener() { @SuppressLint("NewApi") @Override public boolean onLongClick(View view) { if (loggedIn) { if (app.isSupportsHoneyComb()) { showProfilePopup(view); } else { showProfileDialog(); } return true; } else { return false; } } }); }