android.widget.AbsListView.LayoutParams Java Examples
The following examples show how to use
android.widget.AbsListView.LayoutParams.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmotionGridViewAdapter.java From timecat with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { ImageView iv_emotion = new ImageView(context); // 设置内边距 iv_emotion.setPadding(itemWidth / 8, itemWidth / 8, itemWidth / 8, itemWidth / 8); LayoutParams params = new LayoutParams(itemWidth, itemWidth); iv_emotion.setLayoutParams(params); //判断是否为最后一个item if (position == getCount() - 1) { iv_emotion.setImageResource(R.drawable.compose_emotion_delete); } else { String emotionName = emotionNames.get(position); iv_emotion.setImageResource(EmotionUtil.getImgByName(emotion_map_type, emotionName)); } return iv_emotion; }
Example #2
Source File: EmotionGridViewAdapter.java From chatui with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { ImageView iv_emotion = new ImageView(context); // 设置内边距 iv_emotion.setPadding(itemWidth / 8, itemWidth / 8, itemWidth / 8, itemWidth / 8); LayoutParams params = new LayoutParams(itemWidth, itemWidth); iv_emotion.setLayoutParams(params); //判断是否为最后一个item if (position == getCount() - 1) { iv_emotion.setImageResource(R.drawable.compose_emotion_delete); } else { String emotionName = emotionNames.get(position); iv_emotion.setImageResource(EmotionUtils.EMOTION_STATIC_MAP.get(emotionName)); } return iv_emotion; }
Example #3
Source File: HomeFocusView.java From letv with Apache License 2.0 | 6 votes |
private void updataIndicaterView(int position) { if (BaseTypeUtils.isListEmpty(this.mFocusList) || this.mFocusList.size() == 1) { this.mIndicaterView.setVisibility(8); return; } this.mIndicaterView.setVisibility(0); this.mIndicaterView.removeAllViews(); this.mIndicaterView.setPadding(0, 0, 0, UIsUtils.dipToPx(2.0f)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(UIsUtils.dipToPx(4.0f), UIsUtils.dipToPx(4.0f)); params.setMargins(UIsUtils.dipToPx(3.0f), UIsUtils.dipToPx(4.0f), UIsUtils.dipToPx(3.0f), UIsUtils.dipToPx(4.0f)); int count = this.mFocusList.size(); int i = 0; while (i < count) { ImageView imageView = new ImageView(this.mContext); imageView.setImageResource(i == position ? 2130838111 : 2130838110); this.mIndicaterView.addView(imageView, params); i++; } }
Example #4
Source File: AlbumHalfCommentController.java From letv with Apache License 2.0 | 6 votes |
private void initView() { this.listView = this.fragment.getListView(); this.mCommentRedDot = (ImageView) ((Activity) this.context).findViewById(R.id.iv_comment_dot); this.barCommentTextView = (TextView) ((Activity) this.context).findViewById(R.id.album_half_comment_count_text); this.mTotalText = (TextView) ((Activity) this.context).findViewById(R.id.tv_total_text); this.mTotalText.setText("总评论"); this.mTotalText.setVisibility(8); this.listFootView = new ChannelListFootView(this.context); this.listFootLayout = new LinearLayout(this.context); this.listFootLayout.setLayoutParams(new LayoutParams(-1, -2)); this.listFootLayout.addView(this.listFootView); this.popupContentView = UIsUtils.inflate(this.context, R.layout.detailplay_half_comment_item_toast_playerlibs, null); this.copyTextView = (TextView) this.popupContentView.findViewById(R.id.textv_copy); this.adapter = this.fragment.getAdapter(); this.listView.addFooterView(this.listFootLayout); this.listView.setOnScrollListener(this); this.adapter.setOnCommentItemListener(this); }
Example #5
Source File: StarActivity.java From letv with Apache License 2.0 | 6 votes |
private void initListView() { this.mStarAdapter = new StarAdapter(this, this.mStarName); this.mStarAdapter.setStarBookCallback(this.mBooedkProgramsCallback); this.mListView.setAdapter(this.mStarAdapter); DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int screenWidth = displayMetrics.widthPixels; this.mListView.setHeaderLayoutParams(new LayoutParams(screenWidth, (int) (9.0f * (((float) screenWidth) / 16.0f)))); this.mListView.setScrollViewCallbacks(this); ((ExpandableListView) this.mListView.getRootView()).setGroupIndicator(null); ((ExpandableListView) this.mListView.getRootView()).setOnGroupClickListener(new OnGroupClickListener(this) { final /* synthetic */ StarActivity this$0; { if (HotFix.PREVENT_VERIFY) { System.out.println(VerifyLoad.class); } this.this$0 = this$0; } public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) { return true; } }); }
Example #6
Source File: YayaEmoGridViewAdapter.java From sctalk with Apache License 2.0 | 6 votes |
public GridViewHolder() { try { LayoutParams layoutParams = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layoutView = new LinearLayout(context); faceIv = new ImageView(context); layoutView.setLayoutParams(layoutParams); layoutView.setOrientation(LinearLayout.VERTICAL); layoutView.setGravity(Gravity.CENTER); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( 105, 115); params.gravity = Gravity.CENTER; layoutView.addView(faceIv, params); } catch (Exception e) { logger.e(e.getMessage()); } }
Example #7
Source File: EmoGridViewAdapter.java From sctalk with Apache License 2.0 | 6 votes |
public GridViewHolder() { try { LayoutParams layoutParams = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layoutView = new LinearLayout(context); faceIv = new ImageView(context); layoutView.setLayoutParams(layoutParams); layoutView.setOrientation(LinearLayout.VERTICAL); layoutView.setGravity(Gravity.CENTER); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( CommonUtil.getElementSzie(context), CommonUtil.getElementSzie(context)); params.gravity = Gravity.CENTER; layoutView.addView(faceIv, params); } catch (Exception e) { logger.e(e.getMessage()); } }
Example #8
Source File: MonthAdapter.java From cathode with Apache License 2.0 | 5 votes |
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { MonthView view = createMonthView(context); // Set up the new view LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); view.setLayoutParams(params); view.setClickable(true); view.setOnDayClickListener(this); return new ViewHolder(view); }
Example #9
Source File: AelvResizeAnimation.java From Animated-Expanding-ListView with Apache License 2.0 | 5 votes |
@Override protected void applyTransformation(float interpolatedTime, Transformation t) { float height = (mToHeight - mFromHeight) * interpolatedTime + mFromHeight; float width = (mToWidth - mFromWidth) * interpolatedTime + mFromWidth; LayoutParams p = (LayoutParams) mView.getLayoutParams(); p.height = (int) height; p.width = (int) width; mAelvListItem.setCurrentHeight(p.height); mListAdapter.notifyDataSetChanged(); }
Example #10
Source File: ListAdapter.java From Animated-Expanding-ListView with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("deprecation") public View getView(int position, View convertView, ViewGroup parent) { ListViewHolder holder = null; ListItem listItem = listItems.get(position); if (convertView == null) { LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = vi.inflate(R.layout.list_item, null); LinearLayout textViewWrap = (LinearLayout) convertView.findViewById(R.id.text_wrap); TextView text = (TextView) convertView.findViewById(R.id.text); holder = new ListViewHolder(text); // setViewWrap IS REQUIRED holder.setViewWrap(textViewWrap); } else { holder = (ListViewHolder) convertView.getTag(); } // THIS IS REQUIRED holder.getViewWrap().setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, listItem.getCurrentHeight())); holder.getTextView().setText(listItem.getText()); holder.getTextView().setCompoundDrawablesWithIntrinsicBounds(listItem.getDrawable(), 0, 0, 0); convertView.setTag(holder); // setHolder IS REQUIRED listItem.setHolder(holder); return convertView; }
Example #11
Source File: MonthAdapter.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
@Override @NonNull public MonthViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { MonthView v = createMonthView(parent.getContext()); // Set up the new view LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); v.setLayoutParams(params); v.setClickable(true); v.setOnDayClickListener(this); return new MonthViewHolder(v); }
Example #12
Source File: FeedImageAdapter.java From umeng_community_android with MIT License | 5 votes |
@Override public View getView(int position, View view, ViewGroup parent) { SquareImageView imageView; if (view == null) { LayoutParams mImageViewLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT , ViewGroup.LayoutParams.MATCH_PARENT); imageView = new SquareImageView(mContext); imageView.setScaleType(ScaleType.CENTER_CROP); imageView.setLayoutParams(mImageViewLayoutParams); } else { imageView = (SquareImageView) view; } imageView.setImageUrl(getItem(position).thumbnail, mDisplayOption); return imageView; }
Example #13
Source File: Tab3ListFragment.java From RefreashTabView with Apache License 2.0 | 5 votes |
private void listViewAddHeader() { placeHolderView = new LinearLayout(getActivity()); AbsListView.LayoutParams params = new LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, scrollTabHolder .headerHeight()); placeHolderView.setLayoutParams(params); listView.getRefreshableView().addHeaderView(placeHolderView); }
Example #14
Source File: Tab1ListFragment.java From RefreashTabView with Apache License 2.0 | 5 votes |
private void listViewAddHeader() { placeHolderView = new LinearLayout(getActivity()); AbsListView.LayoutParams params = new LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, scrollTabHolder .headerHeight()); placeHolderView.setLayoutParams(params); listView.getRefreshableView().addHeaderView(placeHolderView); }
Example #15
Source File: ImageGridFragment.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
/** * Sets the item height. Useful for when we know the column width so the * height can be set to match. * * @param height */ public void setItemHeight(int height) { if (height == mItemHeight) { return; } mItemHeight = height; mImageViewLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.MATCH_PARENT, mItemHeight); mImageResizer.setImageSize(height); notifyDataSetChanged(); }
Example #16
Source File: AdapterMediaShow.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
public AdapterMediaShow(Context context, int mediaType, ArrayList<MediaInfo> selectedMedias) { if (selectedMedias != null) { mSelectedMedias.addAll(selectedMedias); } this.context = context; this.MediaType = mediaType; this.inflate = LayoutInflater.from(context); this.mImageLoader = ViewerImageLoader.getInstance(); mParams = new LayoutParams(getThumbWidth(), getThumbWidth()); }
Example #17
Source File: EmoGridViewAdapter.java From sctalk with Apache License 2.0 | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { try { GridViewHolder gridViewHolder = null; if (null == convertView && null != context) { gridViewHolder = new GridViewHolder(); convertView = gridViewHolder.layoutView; if (convertView != null) { convertView.setTag(gridViewHolder); } } else { gridViewHolder = (GridViewHolder) convertView.getTag(); } if (null == gridViewHolder || null == convertView) { return null; } gridViewHolder.faceIv.setImageBitmap(getBitmap(position)); if (position == emoResIds.length - 1) { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.topMargin = CommonUtil.getElementSzie(context) / 3; gridViewHolder.faceIv.setLayoutParams(params); } return convertView; } catch (Exception e) { logger.e(e.getMessage()); return null; } }
Example #18
Source File: LiveSubTypeActivity.java From letv with Apache License 2.0 | 5 votes |
protected void handleFullScreenEvent(FullScreenBtnClickEvent fullScreenEvent) { this.mFullScreen = fullScreenEvent.isFull; setRedPacketEntryLocation(fullScreenEvent.isFull); if (fullScreenEvent.isFull) { if (this.mPlayerView != null) { getActivity().setRequestedOrientation(0); this.mLayoutContainer.setVisibility(0); ((ViewGroup) this.mPlayerView.getParent()).removeView(this.mPlayerView); this.mLayoutContainer.addView(this.mPlayerView, new ViewGroup.LayoutParams(-1, -1)); UIsUtils.zoomViewFull(this.mPlayerView); UIsUtils.fullScreen(getActivity()); } this.mFullScreenBtn.setImageResource(2130838715); return; } if (this.mPlayerView != null) { getActivity().setRequestedOrientation(1); this.mLayoutContainer.removeAllViews(); this.mLayoutContainer.setVisibility(8); if (this.mHeaderView != null) { this.mHeaderView.addView(this.mPlayerView); } UIsUtils.zoomView(320, 180, this.mPlayerView); UIsUtils.cancelFullScreen(getActivity()); } this.mFullScreenBtn.setImageResource(2130838126); }
Example #19
Source File: LiveSubTypeActivity.java From letv with Apache License 2.0 | 5 votes |
private void addFooterView() { if (this.mFooterView == null) { this.mFooterView = new ImageView(getActivity()); LayoutParams l = new LayoutParams(-1, Math.min(UIsUtils.getScreenHeight(), UIsUtils.getScreenWidth()) / 6); this.mFooterView.setImageResource(2130838157); this.mFooterView.setLayoutParams(l); this.mFooterView.setBackgroundColor(getActivity().getResources().getColor(2131492949)); this.mFooterView.setPadding(0, UIsUtils.zoomWidth(5), 0, UIsUtils.zoomWidth(10)); this.mFooterView.setScaleType(ScaleType.CENTER); } if (this.mListView.getFooterViewsCount() == 0) { this.mListView.addFooterView(this.mFooterView); } }
Example #20
Source File: LiveSubTypeActivity.java From letv with Apache License 2.0 | 5 votes |
private void addHeaderView() { if (this.mListView != null && this.mListView.getHeaderViewsCount() == 1) { this.mHeaderView = new RelativeLayout(this); this.mHeaderView.setLayoutParams(new LayoutParams(-1, -2)); this.mPlayerView = new LivePlayerView(this); this.mPlayerView.init(this.pageIndex, getSupportFragmentManager()); this.mHeaderView.addView(this.mPlayerView, new RelativeLayout.LayoutParams(-1, -1)); UIsUtils.zoomView(320, 180, this.mHeaderView); this.mListView.addHeaderView(this.mHeaderView); } }
Example #21
Source File: FirstPageFragment.java From letv with Apache License 2.0 | 5 votes |
private void addFootLetvImageView() { if (this.mLetvImageView == null) { this.mLetvImageView = new ImageView(getActivity()); } this.mLetvImageView.setLayoutParams(new LayoutParams(-1, -2)); this.mLetvImageView.setPadding(0, UIsUtils.zoomWidth(10), 0, UIsUtils.zoomWidth(16)); this.mLetvImageView.setImageResource(2130838157); this.mLetvImageView.setScaleType(ScaleType.CENTER); if (this.mListView != null) { this.mListView.addFooterView(this.mLetvImageView); } }
Example #22
Source File: MineFragment.java From letv with Apache License 2.0 | 5 votes |
private void initUI() { int i; this.mMineListView = (ListView) this.mMineRootLayout.findViewById(R.id.my_list_view); this.mHeadLayout = PublicLoadLayout.inflate(getActivity(), R.layout.mine_head_layout, null); this.mRoundHead = (RoundImageView) this.mHeadLayout.findViewById(R.id.btn_head_login); this.mTitle = (TextView) this.mHeadLayout.findViewById(R.id.head_login_title); this.mSubTitle = (TextView) this.mHeadLayout.findViewById(R.id.head_login_subtitle); this.mSubTitleOther = (TextView) this.mHeadLayout.findViewById(R.id.head_login_subtitle_other); this.mHeadLoginLayout = this.mHeadLayout.findViewById(R.id.layout_head_login); this.mMessageIcon = (RelativeLayout) this.mHeadLayout.findViewById(R.id.message_icon); this.mNewMessageIcon = (ImageView) this.mHeadLayout.findViewById(R.id.new_message_title); ImageView imageView = this.mNewMessageIcon; if (this.mIsNewMessageVisible) { i = 0; } else { i = 8; } imageView.setVisibility(i); this.mHeadLayout.findViewById(R.id.title_main_search).setVisibility(8); this.mMineListView.addHeaderView(this.mHeadLayout); View mFooterView = new View(getActivity()); mFooterView.setLayoutParams(new LayoutParams(-1, UIsUtils.zoomWidth(15))); mFooterView.setBackgroundColor(getActivity().getResources().getColor(2131493362)); this.mMineListView.addFooterView(mFooterView); this.mMineListViewAdapter = new MineListViewAdapter(getActivity()); this.mMineListView.setAdapter(this.mMineListViewAdapter); this.mRoundHead.setOnClickListener(this); this.mHeadLoginLayout.setOnClickListener(this); this.mMessageIcon.setOnClickListener(this); showDefaultProfileList(); }
Example #23
Source File: StarRankActivity.java From letv with Apache License 2.0 | 5 votes |
private void initListView() { this.mStarRankAdapter = new StarRankAdapter(this.mContext); this.mListView.setAdapter(this.mStarRankAdapter); this.mListView.setHeaderLayoutParams(new LayoutParams(UIsUtils.getScreenWidth(), (int) (9.0f * (((float) UIsUtils.getScreenWidth()) / 16.0f)))); this.mListView.setScrollViewCallbacks(this); ((ExpandableListView) this.mListView.getRootView()).setGroupIndicator(null); ((ExpandableListView) this.mListView.getRootView()).setOnGroupClickListener(null); }
Example #24
Source File: Tab2ListFragment.java From RefreashTabView with Apache License 2.0 | 4 votes |
private void listViewAddHeader() { placeHolderView = new LinearLayout(getActivity()); AbsListView.LayoutParams params = new LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, scrollTabHolder.headerHeight()); placeHolderView.setLayoutParams(params); listView.getRefreshableView().addHeaderView(placeHolderView); }
Example #25
Source File: MonthAdapter.java From PersianDateRangePicker with Apache License 2.0 | 4 votes |
@SuppressLint("NewApi") @SuppressWarnings("unchecked") @Override public View getView(int position, View convertView, ViewGroup parent) { MonthView v; HashMap<String, Integer> drawingParams = null; if (convertView != null) { v = (MonthView) convertView; // We store the drawing parameters in the view so it can be recycled drawingParams = (HashMap<String, Integer>) v.getTag(); } else { v = createMonthView(mContext); // Set up the new view LayoutParams params = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); v.setLayoutParams(params); v.setClickable(true); v.setOnDayClickListener(this); if (mAccentColor != -1) { v.setAccentColor(mAccentColor); } } if (drawingParams == null) { drawingParams = new HashMap<String, Integer>(); } drawingParams.clear(); final int month = position % MONTHS_IN_YEAR; final int year = position / MONTHS_IN_YEAR + mController.getMinYear(); int selectedDay = -1; if (isSelectedDayInMonth(year, month)) { selectedDay = mSelectedDay.day; } // Invokes requestLayout() to ensure that the recycled view is set with the appropriate // height/number of weeks before being displayed. v.reuse(); drawingParams.put(MonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay); drawingParams.put(MonthView.VIEW_PARAMS_YEAR, year); drawingParams.put(MonthView.VIEW_PARAMS_MONTH, month); drawingParams.put(MonthView.VIEW_PARAMS_WEEK_START, mController.getFirstDayOfWeek()); v.setMonthParams(drawingParams); v.invalidate(); return v; }
Example #26
Source File: WeatherFragment.java From WayHoo with Apache License 2.0 | 4 votes |
/** * 初始化所有的view * * @param view */ private void initViews(View view, Bundle savedInstanceState) { mSwipeRefreshLayout = (SwipeRefreshLayout) view .findViewById(R.id.swiperefresh); mSwipeRefreshLayout.setOnRefreshListener(this); mListView = (ListView) view.findViewById(R.id.drag_list); mNormalImageView = (ImageView) view .findViewById(R.id.weather_background); mBlurredImageView = (ImageView) view .findViewById(R.id.weather_background_blurred); if (savedInstanceState != null) { float alpha = savedInstanceState.getFloat(ALPHA_KEY); mBlurredImageView.setAlpha(alpha); } else { mBlurredImageView.setAlpha(0f);// 设置默认模糊背景为透明 } mListHeaderView = LayoutInflater.from(getActivity()).inflate( R.layout.weather_current_condition, null); // 获取屏幕高度 int displayHeight = SystemUtils.getDisplayHeight(getActivity()); // HeaderView高度=屏幕高度-标题栏高度 mHeaderHeight = displayHeight - getResources().getDimensionPixelSize( R.dimen.abs__action_bar_default_height); mListHeaderView.setLayoutParams(new LayoutParams( LayoutParams.MATCH_PARENT, mHeaderHeight)); // 计算背景View的高度,适当比屏幕高度多一点, // 之所以多1/8是为了后面滑动ListView时背景能跟随滑动。 // int backgroundHeight = displayHeight + mHeaderHeight / 8; // mNormalImageView.setLayoutParams(new FrameLayout.LayoutParams( // FrameLayout.LayoutParams.MATCH_PARENT, backgroundHeight)); // mBlurredImageView.setLayoutParams(new FrameLayout.LayoutParams( // FrameLayout.LayoutParams.MATCH_PARENT, backgroundHeight)); mListView.addHeaderView(mListHeaderView, null, false);// 给ListView添加HeaderView mWeatherAdapter = new WeatherListAdapter(getActivity()); mListView.setAdapter(mWeatherAdapter); mListView.setOnScrollListener(mOnScrollListener);// 监听滑动 initCurWeatherViews(view); }
Example #27
Source File: MonthAdapter.java From StyleableDateTimePicker with MIT License | 4 votes |
@SuppressLint("NewApi") @SuppressWarnings("unchecked") @Override public View getView(int position, View convertView, ViewGroup parent) { MonthView v; HashMap<String, Integer> drawingParams = null; if (convertView != null) { v = (MonthView) convertView; // We store the drawing parameters in the view so it can be recycled drawingParams = (HashMap<String, Integer>) v.getTag(); } else { v = createMonthView(mContext); // Set up the new view LayoutParams params = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); v.setLayoutParams(params); v.setClickable(true); v.setOnDayClickListener(this); } if (drawingParams == null) { drawingParams = new HashMap<String, Integer>(); } drawingParams.clear(); final int month = position % MONTHS_IN_YEAR; final int year = position / MONTHS_IN_YEAR + mController.getMinYear(); int selectedDay = -1; if (isSelectedDayInMonth(year, month)) { selectedDay = mSelectedDay.day; } // Invokes requestLayout() to ensure that the recycled view is set with the appropriate // height/number of weeks before being displayed. v.reuse(); drawingParams.put(MonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay); drawingParams.put(MonthView.VIEW_PARAMS_YEAR, year); drawingParams.put(MonthView.VIEW_PARAMS_MONTH, month); drawingParams.put(MonthView.VIEW_PARAMS_WEEK_START, mController.getFirstDayOfWeek()); v.setMonthParams(drawingParams); v.invalidate(); return v; }
Example #28
Source File: MonthAdapter.java From AssistantBySDK with Apache License 2.0 | 4 votes |
@SuppressLint("NewApi") @SuppressWarnings("unchecked") @Override public View getView(int position, View convertView, ViewGroup parent) { MonthView v; HashMap<String, Integer> drawingParams = null; if (convertView != null) { v = (MonthView) convertView; // We store the drawing parameters in the view so it can be recycled drawingParams = (HashMap<String, Integer>) v.getTag(); } else { v = createMonthView(mContext); // Set up the new view LayoutParams params = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); v.setLayoutParams(params); v.setClickable(true); v.setOnDayClickListener(this); } if (drawingParams == null) { drawingParams = new HashMap<>(); } drawingParams.clear(); final int month = (position + mController.getStartDate().get(Calendar.MONTH)) % MONTHS_IN_YEAR; final int year = (position + mController.getStartDate().get(Calendar.MONTH)) / MONTHS_IN_YEAR + mController.getMinYear(); int selectedDay = -1; if (isSelectedDayInMonth(year, month)) { selectedDay = mSelectedDay.day; } // Invokes requestLayout() to ensure that the recycled view is set with the appropriate // height/number of weeks before being displayed. v.reuse(); drawingParams.put(MonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay); drawingParams.put(MonthView.VIEW_PARAMS_YEAR, year); drawingParams.put(MonthView.VIEW_PARAMS_MONTH, month); drawingParams.put(MonthView.VIEW_PARAMS_WEEK_START, mController.getFirstDayOfWeek()); v.setMonthParams(drawingParams); v.invalidate(); return v; }
Example #29
Source File: MonthAdapter.java From MaterialDateRangePicker with Apache License 2.0 | 4 votes |
@SuppressLint("NewApi") @SuppressWarnings("unchecked") @Override public View getView(int position, View convertView, ViewGroup parent) { MonthView v; HashMap<String, Integer> drawingParams = null; if (convertView != null) { v = (MonthView) convertView; // We store the drawing parameters in the view so it can be recycled drawingParams = (HashMap<String, Integer>) v.getTag(); } else { v = createMonthView(mContext); // Set up the new view LayoutParams params = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); v.setLayoutParams(params); v.setClickable(true); v.setOnDayClickListener(this); if (mAccentColor != -1) { v.setAccentColor(mAccentColor); } } if (drawingParams == null) { drawingParams = new HashMap<String, Integer>(); } drawingParams.clear(); final int month = position % MONTHS_IN_YEAR; final int year = position / MONTHS_IN_YEAR + mController.getMinYear(); int selectedDay = -1; if (isSelectedDayInMonth(year, month)) { selectedDay = mSelectedDay.day; } // Invokes requestLayout() to ensure that the recycled view is set with the appropriate // height/number of weeks before being displayed. v.reuse(); drawingParams.put(MonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay); drawingParams.put(MonthView.VIEW_PARAMS_YEAR, year); drawingParams.put(MonthView.VIEW_PARAMS_MONTH, month); drawingParams.put(MonthView.VIEW_PARAMS_WEEK_START, mController.getFirstDayOfWeek()); v.setMonthParams(drawingParams); v.invalidate(); return v; }
Example #30
Source File: MonthAdapter.java From AlarmOn with Apache License 2.0 | 4 votes |
@SuppressLint("NewApi") @SuppressWarnings("unchecked") @Override public View getView(int position, View convertView, ViewGroup parent) { MonthView v; HashMap<String, Integer> drawingParams = null; if (convertView != null) { v = (MonthView) convertView; // We store the drawing parameters in the view so it can be recycled drawingParams = (HashMap<String, Integer>) v.getTag(); } else { v = createMonthView(mContext); // Set up the new view LayoutParams params = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); v.setLayoutParams(params); v.setClickable(true); v.setOnDayClickListener(this); } if (drawingParams == null) { drawingParams = new HashMap<>(); } drawingParams.clear(); final int month = (position + mController.getStartDate().get(Calendar.MONTH)) % MONTHS_IN_YEAR; final int year = (position + mController.getStartDate().get(Calendar.MONTH)) / MONTHS_IN_YEAR + mController.getMinYear(); int selectedDay = -1; if (isSelectedDayInMonth(year, month)) { selectedDay = mSelectedDay.day; } // Invokes requestLayout() to ensure that the recycled view is set with the appropriate // height/number of weeks before being displayed. v.reuse(); drawingParams.put(MonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay); drawingParams.put(MonthView.VIEW_PARAMS_YEAR, year); drawingParams.put(MonthView.VIEW_PARAMS_MONTH, month); drawingParams.put(MonthView.VIEW_PARAMS_WEEK_START, mController.getFirstDayOfWeek()); v.setMonthParams(drawingParams); v.invalidate(); return v; }