private void init() { mAvatarChanged = false; mLocalDb = LocalDb.getInstance(); mUser = mLocalDb.getCurrentUser(); mPivAvatar = (ParseImageView) findViewById(R.id.ivAvatar); mEtChangePassword = (EditText) findViewById(R.id.etChangePassword); mEtConfirmPassword = (EditText) findViewById(R.id.etConfirmPass); mEtEmail = (EditText) findViewById(R.id.editChangeEmail); mEtEmail.setHint(mUser.getEmail()); mBtnSaveChanges = (Button) findViewById(R.id.btnSaveChanges); mBtnChangeAvatar = (Button) findViewById(R.id.btnChangeAvatar); mBtnTakePic = (Button) findViewById(R.id.btnTakePic); mBtnSaveChanges.setOnClickListener(this); mBtnChangeAvatar.setOnClickListener(this); mBtnTakePic.setOnClickListener(this); mPivAvatar.setParseFile(mUser.getAvatar()); mPivAvatar.loadInBackground(); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.item_user_cell, parent, false); } ParseImageView ivIcon = (ParseImageView) convertView.findViewById(R.id.ivIcon); TextView tvUsername = (TextView) convertView.findViewById(R.id.tvUsername); tvUsername.setText(mUsers.get(position).getUsername()); ivIcon.setParseFile(mUsers.get(position).getAvatar()); if (mUsers.get(position).getAvatar() != null) { ivIcon.loadInBackground(); } else { ivIcon.setBackground(mContext.getResources().getDrawable(R.drawable.ic_avatar)); } return convertView; }
@Override public View getItemView(PrsPhoto photo, View v, ViewGroup parent) { if (v == null) { v = View.inflate(getContext(), R.layout.photo_list_adapter, null); } super.getItemView(photo, v, parent); ParseImageView photoImage = (ParseImageView) v.findViewById(R.id.icon); ParseFile photoFile = photo.getParseFile("photo"); if (photoFile != null) { photoImage.setParseFile(photoFile); photoImage.loadInBackground(new GetDataCallback() { @Override public void done(byte[] data, ParseException e) { // nothing to do } }); } return v; }
/** * Called when the app starts. * * Load all the available photos for the meme background, * then setup the rest of the photo-related UI. * * You should: * - Set the allPhotos member variable to the photos retrieved from Parse * - Call setUpPhotoSelectorAndPreview(imageSelect, previewImage) * @param imageSelect * @param previewImage */ private void getPhotosAndSetUpUI(final Spinner imageSelect, final ParseImageView previewImage) { ParseQuery<ParseObject> query = ParseQuery.getQuery("Photo"); query.addDescendingOrder("createdAt"); query.setCachePolicy(CachePolicy.CACHE_THEN_NETWORK); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> photos, ParseException e) { if (e == null) { Log.d(TAG, "Retrived " + photos.size() + " photos"); allPhotos = photos; setUpPhotoSelectorAndPreview(imageSelect, previewImage); } else { Log.d(TAG, "Error retrieving photos: " + e.getMessage()); } } }); }
@Override public View getItemView(UserPicture userPicture, View v, ViewGroup parent) { if (v == null) { v = View.inflate(getContext(), R.layout.item_list_photos, null); } super.getItemView(userPicture, v, parent); ParseImageView userImage = (ParseImageView) v.findViewById(R.id.icon); ParseFile photoFile = userPicture.getParseFile("photo"); if (photoFile != null) { userImage.setParseFile(photoFile); userImage.loadInBackground(new GetDataCallback() { @Override public void done(byte[] arg0, ParseException arg1) { // do nothing Log.d(TAG, "photoFile loaded"); } }); } else { Log.d(TAG, "photoFile is null"); } return v; }
private void initViews(View rootView) { mLlFollowing = (LinearLayout) rootView.findViewById(R.id.llFollowing); mLlFollower = (LinearLayout) rootView.findViewById(R.id.llFollower); mTvFollowingCount = (TextView) rootView.findViewById(R.id.tvFollowingCount); mTvFollowerCount = (TextView) rootView.findViewById(R.id.tvFollowerCount); mPivBigAvatar = (ParseImageView) rootView.findViewById(R.id.pivBigAvatar); mRiMyRoom = (RoomItem) rootView.findViewById(R.id.riMyRoom); mBtnCreate = (Button) rootView.findViewById(R.id.btnCreate); mBtnEditRoom = (Button) rootView.findViewById(R.id.btnEditRoom); mBtnDestroy = (Button) rootView.findViewById(R.id.btnDestroy); mBtnEditProfile = (Button) rootView.findViewById(R.id.btnEditProfile); mFbFollow = (FollowButton) rootView.findViewById(R.id.fbFollow); mProgressBar = (ProgressBar) rootView.findViewById(R.id.progressBar); mLlFollowing.setOnClickListener(this); mLlFollower.setOnClickListener(this); mBtnEditProfile.setOnClickListener(this); mBtnCreate.setOnClickListener(this); mBtnEditRoom.setOnClickListener(this); mBtnDestroy.setOnClickListener(this); mFollow.fetchIfNeededInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { mTvFollowingCount.setText(mFollow.getFollowings().size() + ""); mTvFollowerCount.setText(mFollow.getFollowers().size() + ""); } }); mFbFollow.setData(LocalDb.getInstance().getCurrentUser(), mUser); }
private void init() { LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(R.layout.item_room, this); mTvRoomName = (TextView) findViewById(R.id.tvRoomName); mTvUsername = (TextView) findViewById(R.id.tvUsername); mPivAvatar = (ParseImageView) findViewById(R.id.pivAvatar); mRbRegister = (RegisterButton) findViewById(R.id.rbRegister); mBtnJoin = (Button) findViewById(R.id.btnJoin); mTvUsername.setOnClickListener(this); mPivAvatar.setOnClickListener(this); mBtnJoin.setOnClickListener(this); mRbRegister.setOnClickListener(this); }
private void init() { LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(R.layout.item_user, this); mCurrentUser = LocalDb.getInstance().getCurrentUser(); mTvUsername = (TextView) findViewById(R.id.tvUsername); mPivAvatar = (ParseImageView) findViewById(R.id.pivAvatar); mFbFollow = (FollowButton) findViewById(R.id.fbFollow); mTvUsername.setOnClickListener(this); mPivAvatar.setOnClickListener(this); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.item_user_cell, parent, false); } final ParseImageView ivIcon = (ParseImageView) convertView.findViewById(R.id.ivIcon); final TextView tvUsername = (TextView) convertView.findViewById(R.id.tvUsername); final User user = mUsers.get(position); user.fetchIfNeededInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { ParseFile avatar = user.getAvatar(); if (avatar != null) ivIcon.setParseFile(avatar); String username = user.getUsername(); if (username != null) tvUsername.setText(username); ivIcon.loadInBackground(); } }); return convertView; }
protected ViewHolder createViewHolder(View convertView, int position) { ViewHolder viewHolder = new ViewHolder(); viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title); viewHolder.tv_changelog = (TextView) convertView.findViewById(R.id.tv_changelog); viewHolder.tv_subtitle = (TextView) convertView.findViewById(R.id.tv_subtitle); viewHolder.tv_timestamp = (TextView) convertView.findViewById(R.id.tv_timestamp); viewHolder.iv_icon = (ParseImageView) convertView.findViewById(R.id.iv_icon); viewHolder.iv_stable = (ImageView) convertView.findViewById(R.id.iv_stable); viewHolder.iv_downloaded = (ImageView)convertView.findViewById(R.id.iv_downloaded); return viewHolder; }
protected ViewHolder createViewHolder(View convertView, int position) { ViewHolder viewHolder = new ViewHolder(); viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title); viewHolder.tv_changelog = (TextView) convertView.findViewById(R.id.tv_changelog); viewHolder.tv_subtitle = (TextView) convertView.findViewById(R.id.tv_subtitle); viewHolder.tv_timestamp = (TextView) convertView.findViewById(R.id.tv_timestamp); viewHolder.iv_icon = (ParseImageView ) convertView.findViewById(R.id.iv_icon); viewHolder.iv_stable = (ImageView) convertView.findViewById(R.id.iv_stable); viewHolder.iv_downloaded = (ImageView)convertView.findViewById(R.id.iv_downloaded); return viewHolder; }