@Override public View onCreateView( LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_personal_info, container, false); mHeaderView = rootView.findViewById(R.id.header); mTopImageView = (ImageView) rootView.findViewById(R.id.theme_top_image); mTopImageView.setOnLongClickListener(this); displayThemeImages(); mAvatarImage = (ImageView) rootView.findViewById(R.id.avatar_image); MiscUtils.showAvatarThumb( mAvatarManager, mSettingHelper.getAccountAvatarThumb(), mAvatarImage, R.drawable.contact_single); mAvatarImage.setOnClickListener(this); mListView = (ListView) rootView.findViewById(R.id.list); View listHeader = inflater.inflate(R.layout.personal_info_list_header, mListView, false); mListHeaderView = listHeader; mListView.addHeaderView(listHeader); mListView.setAdapter(mInfoAdapter); mListView.setOnItemClickListener(mInfoAdapter); mListView.setOnScrollListener( new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) {} @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { ViewHelper.setTranslationY( mHeaderView, Math.max(-getScrollY(), -mHeaderView.getMeasuredHeight())); } }); return rootView; }
@Override public void bindView(View view) { ViewHolder holder = (ViewHolder) view.getTag(); LayoutInflater inflater = LayoutInflater.from(context); Resources res = context.getResources(); holder.infoContainer.removeAllViews(); addNewInfoItem( contact.getNickname(), ConstantCode.getSexImageResource(contact.getSex()), inflater, holder.infoContainer); addNewInfoItem( context.getString(R.string.label_code) + contact.getLabelCode(), inflater, holder.infoContainer); if (contact.getAge() > 0) { addNewInfoItem( MiscUtils.getAgeString(res, contact.getAge()), inflater, holder.infoContainer); } if (contact.getHeight() > 0) { addNewInfoItem( MiscUtils.getHeightString(res, contact.getHeight()), inflater, holder.infoContainer); } if (contact.getConstellation() > 0) { addNewInfoItem( MiscUtils.getConstellationString(res, contact.getConstellation()), inflater, holder.infoContainer); } if (!TextUtils.isEmpty(contact.getSchool())) { addNewInfoItem(contact.getSchool(), inflater, holder.infoContainer); } if (!TextUtils.isEmpty(contact.getJob())) { addNewInfoItem(contact.getJob(), inflater, holder.infoContainer); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_CODE_UPLOAD_AVATAR: if (resultCode == Activity.RESULT_OK) { MiscUtils.showAvatarThumb( mAvatarManager, mSettingHelper.getAccountAvatarThumb(), mAvatarImage, R.drawable.contact_single); } break; default: break; } }
@Override public void bindView(View contentView, LabelStory story) { ViewHolder holder = (ViewHolder) contentView.getTag(); String content = story.getContent(); if (TextUtils.isEmpty(content)) { holder.banknoteText.setVisibility(View.GONE); } else { holder.banknoteText.setVisibility(View.VISIBLE); holder.banknoteText.setText(content); } String[] images = story.getThumbImages(); if (images != null && images.length > 0) { String image = images[0]; holder.banknoteImage.setVisibility(View.VISIBLE); MiscUtils.showLabelStoryImage( avatarManager, image, holder.banknoteImage, R.drawable.pic_loading); } else { holder.banknoteImage.setVisibility(View.GONE); } }
@Override public void bindView(View contentView, LabelStory story) { ViewHolder holder = (ViewHolder) contentView.getTag(); String content = story.getContent(); if (!TextUtils.isEmpty(content)) { holder.dynamicText.setVisibility(View.VISIBLE); holder.dynamicText.setText(content); } else { holder.dynamicText.setVisibility(View.GONE); } String imageThumb = getImageThumb(story); if (!TextUtils.isEmpty(imageThumb)) { holder.dynamicImage.setVisibility(View.VISIBLE); holder.dynamicImage.setScaleType(ImageView.ScaleType.CENTER_CROP); MiscUtils.showLabelStoryImageThumb( avatarManager, imageThumb, holder.dynamicImage, R.drawable.label_null_others); } else { holder.dynamicImage.setVisibility(View.GONE); } }
public static String getHeightString(Resources resources, int height) { return MiscUtils.getHeightString(resources, height); }
public static String getAgeString(Resources resources, int age) { return MiscUtils.getAgeString(resources, age); }
public static String getConstellationString(Resources resources, int constellation) { return MiscUtils.getConstellationString(resources, constellation); }