public void logout() { controller.logout(); deleteSharedPReferences(); Intent login = new Intent(getActivity(), LoginActivity.class); Utils.cleanBackStack(login); startActivity(login); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_profile, container, false); // username from current user username = (TextView) view.findViewById(R.id.username); username.setText(controller.getUsername()); photosNumber = (TextView) view.findViewById(R.id.photos_number); photosNumber.setText(controller.getPhotosNumber()); albumsNumber = (TextView) view.findViewById(R.id.albums_number); albumsNumber.setText(controller.getPhotosNumber()); friendsNumber = (TextView) view.findViewById(R.id.friends_number); friendsNumber.setText(controller.getFriendsNumber()); // profile picture profilePicture = (ImageView) view.findViewById(R.id.profilePicture); // download profile picture from Parse Bitmap picture = controller.getProfilePicture(); if (picture != null) profilePicture.setImageBitmap(picture); // register the context menu to set profile picture registerForContextMenu(profilePicture); mProgressBar = (ProgressBar) view.findViewById(R.id.progressBarChangeProfilePicture); // logout buttonLogOut = (Button) view.findViewById(R.id.button_logout); buttonLogOut.setOnClickListener( new OnClickListener() { public void onClick(View v) { logout(); } }); return view; }