@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); imgBg = (ImageView) view.findViewById(R.id.imgTrendEventBackground); imgMap = (ImageView) view.findViewById(R.id.imgMap); tvTitle = (TextView) view.findViewById(R.id.tvTitle); tvAddress = (TextView) view.findViewById(R.id.tvAddress); tvDate = (TextView) view.findViewById(R.id.tvDate); tvParticipantsCount = (TextView) view.findViewById(R.id.tvParticipantsCount); holder = (LinearLayout) view.findViewById(R.id.trendEventHolder); participantHolder = (LinearLayout) view.findViewById(R.id.participantsHolder); icon = (IconImageView) view.findViewById(R.id.icon); icon.setIconImage(mEvent.dataPublicEvent.getIcon()); setImages(); tvTitle.setText(mEvent.dataPublicEvent.event_title); tvAddress.setText(mEvent.getLocationText()); tvDate.setText(Utils.getEventSchedule(mEvent)); tvParticipantsCount.setText( "" + mEvent.getTrend_users().size() + " " + dm.getResourceText(R.string.Participants)); int width = Utils.dpToPx(40); int i = 0; for (DataPeople people : mEvent.getTrend_users()) { if (i >= 7) break; // participantHolder.addView(); CircularImageView circularImageView = new CircularImageView(getActivity()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, width); if (i++ > 0) params.setMargins(-Utils.dpToPx(12), 0, 0, 0); circularImageView.setLayoutParams(params); if (!TextUtils.isEmpty(people.image_url)) Picasso.with(getActivity()).load(people.image_url).fit().into(circularImageView); participantHolder.addView(circularImageView); } holder.setOnClickListener(this); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = getActivity().getLayoutInflater(); convertView = inflater.inflate(R.layout.item_pick_activity, parent, false); } RelativeLayout Holder = (RelativeLayout) convertView.findViewById(R.id.Holder); String url = mAllDataActivities[position].background.url; if (mAllDataActivities.length > 0) { /*set image height*/ int wantedHeight = screenHeight / mAllDataActivities.length; int minHeight = Utils.dpToPx(120); int maxHeight = screenWidth; if (wantedHeight < minHeight) wantedHeight = minHeight; if (wantedHeight > maxHeight) wantedHeight = maxHeight; wantedHeight -= 2; AbsListView.LayoutParams layoutParams = (AbsListView.LayoutParams) convertView.getLayoutParams(); Holder.setLayoutParams(layoutParams); Holder.setPadding(0, 0, 0, 0); // url += "?width=" + screenWidth + "&height=" + wantedHeight + "&mode=max"; url += "?width=" + screenWidth + "&height=" + wantedHeight + "&mode=crop"; } ((TextView) convertView.findViewById(R.id.activity_name)) .setText(mAllDataActivities[position].text_title); try { // UrlImageViewHelper.setUrlDrawable((ImageView)convertView.findViewById(R.id.background_image),mAllDataActivities[position].background.url); BaseImageView imageView = (BaseImageView) convertView.findViewById(R.id.background_image); Picasso.with(convertView.getContext()).load(url).into(imageView); } catch (Exception e) { e.printStackTrace(); } return convertView; }
private void initAttributes(AttributeSet attributeSet) { TypedArray typedArray = mContext.obtainStyledAttributes(attributeSet, R.styleable.BaseTextView); if (typedArray != null) { TypeFaceProvider.initByType(typedArray.getInt(R.styleable.BaseTextView_font, -1), this); typedArray.recycle(); } typedArray = mContext.obtainStyledAttributes(attributeSet, R.styleable.ResourceColor); if (typedArray != null) { int bgColor = typedArray.getInt(R.styleable.ResourceColor_bg_color, -1); if (bgColor != -1) { setBackgroundColor(Color.parseColor(DataStore.getInstance().getColor(bgColor))); } int textColor = typedArray.getInt(R.styleable.ResourceColor_text_color, -1); if (textColor != -1) { setTextColor(Color.parseColor(DataStore.getInstance().getColor(textColor))); } typedArray.recycle(); } typedArray = mContext.obtainStyledAttributes(attributeSet, R.styleable.BaseEditText); if (typedArray != null) { String hintRes = typedArray.getString(R.styleable.BaseEditText_hint_key); if (!Utils.isEmpty(hintRes)) { String hint = DataManager.getInstance().getResourceText(hintRes); setHint(hint); } typedArray.recycle(); } // Remove spell check // setInputType(~(InputType.TYPE_TEXT_FLAG_AUTO_CORRECT)); }