return nestViews;
}
private final HashSet nestViews;
private final LinkedHashSet childClickViewIds;
private final LinkedHashSet itemChildLongClickViewIds;
private BaseDelegateAdapter adapter;
/**
- use itemView instead
*/
@Deprecated
public View convertView;
/**
- Package private field to retain the associated user object and detect a change
*/
Object associatedObject;
public BaseDelegateViewHolder(final View view) {
super(view);
this.views = new SparseArray<>();
this.childClickViewIds = new LinkedHashSet<>();
this.itemChildLongClickViewIds = new LinkedHashSet<>();
this.nestViews = new HashSet<>();
convertView = view;
}
private int getClickPosition() {
return getLayoutPosition();
}
public HashSet getItemChildLongClickViewIds() {
return itemChildLongClickViewIds;
}
public HashSet getChildClickViewIds() {
return childClickViewIds;
}
/**
-
use itemView instead
-
@return the ViewHolder root view
*/
@Deprecated
public View getConvertView() {
return convertView;
}
/**
-
Will set the text of a TextView.
-
@param viewId The view id.
-
@param value The text to put in the text view.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setText(@IdRes int viewId, CharSequence value) {
TextView view = getView(viewId);
view.setText(value);
return this;
}
public BaseDelegateViewHolder setText(@IdRes int viewId, @StringRes int strId) {
TextView view = getView(viewId);
view.setText(strId);
return this;
}
/**
-
Will set the image of an ImageView from a resource id.
-
@param viewId The view id.
-
@param imageResId The image resource id.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setImageResource(@IdRes int viewId, @DrawableRes int imageResId) {
ImageView view = getView(viewId);
view.setImageResource(imageResId);
return this;
}
/**
-
Will set background color of a view.
-
@param viewId The view id.
-
@param color A color, not a resource id.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setBackgroundColor(@IdRes int viewId, @ColorInt int color) {
View view = getView(viewId);
view.setBackgroundColor(color);
return this;
}
/**
-
Will set background of a view.
-
@param viewId The view id.
-
@param backgroundRes A resource to use as a background.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setBackgroundRes(@IdRes int viewId, @DrawableRes int backgroundRes) {
View view = getView(viewId);
view.setBackgroundResource(backgroundRes);
return this;
}
/**
-
Will set text color of a TextView.
-
@param viewId The view id.
-
@param textColor The text color (not a resource id).
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setTextColor(@IdRes int viewId, @ColorInt int textColor) {
TextView view = getView(viewId);
view.setTextColor(textColor);
return this;
}
/**
-
Will set the image of an ImageView from a drawable.
-
@param viewId The view id.
-
@param drawable The image drawable.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setImageDrawable(@IdRes int viewId, Drawable drawable) {
ImageView view = getView(viewId);
view.setImageDrawable(drawable);
return this;
}
/**
- Add an action to set the image of an image view. Can be called multiple times.
*/
public BaseDelegateViewHolder setImageBitmap(@IdRes int viewId, Bitmap bitmap) {
ImageView view = getView(viewId);
view.setImageBitmap(bitmap);
return this;
}
/**
-
Add an action to set the alpha of a view. Can be called multiple times.
-
Alpha between 0-1.
*/
public BaseDelegateViewHolder setAlpha(@IdRes int viewId, float value) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getView(viewId).setAlpha(value);
} else {
// Pre-honeycomb hack to set Alpha value
AlphaAnimation alpha = new AlphaAnimation(value, value);
alpha.setDuration(0);
alpha.setFillAfter(true);
getView(viewId).startAnimation(alpha);
}
return this;
}
/**
-
Set a view visibility to VISIBLE (true) or GONE (false).
-
@param viewId The view id.
-
@param visible True for VISIBLE, false for GONE.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setGone(@IdRes int viewId, boolean visible) {
View view = getView(viewId);
view.setVisibility(visible ? View.VISIBLE : View.GONE);
return this;
}
/**
-
Set a view visibility to VISIBLE (true) or INVISIBLE (false).
-
@param viewId The view id.
-
@param visible True for VISIBLE, false for INVISIBLE.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setVisible(@IdRes int viewId, boolean visible) {
View view = getView(viewId);
view.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
return this;
}
/**
-
Add links into a TextView.
-
@param viewId The id of the TextView to linkify.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder linkify(@IdRes int viewId) {
TextView view = getView(viewId);
Linkify.addLinks(view, Linkify.ALL);
return this;
}
/**
- Apply the typeface to the given viewId, and enable subpixel rendering.
*/
public BaseDelegateViewHolder setTypeface(@IdRes int viewId, Typeface typeface) {
TextView view = getView(viewId);
view.setTypeface(typeface);
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
return this;
}
/**
- Apply the typeface to all the given viewIds, and enable subpixel rendering.
*/
public BaseDelegateViewHolder setTypeface(Typeface typeface, int… viewIds) {
for (int viewId : viewIds) {
TextView view = getView(viewId);
view.setTypeface(typeface);
view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
return this;
}
/**
-
Sets the progress of a ProgressBar.
-
@param viewId The view id.
-
@param progress The progress.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setProgress(@IdRes int viewId, int progress) {
ProgressBar view = getView(viewId);
view.setProgress(progress);
return this;
}
/**
-
Sets the progress and max of a ProgressBar.
-
@param viewId The view id.
-
@param progress The progress.
-
@param max The max value of a ProgressBar.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setProgress(@IdRes int viewId, int progress, int max) {
ProgressBar view = getView(viewId);
view.setMax(max);
view.setProgress(progress);
return this;
}
/**
-
Sets the range of a ProgressBar to 0…max.
-
@param viewId The view id.
-
@param max The max value of a ProgressBar.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setMax(@IdRes int viewId, int max) {
ProgressBar view = getView(viewId);
view.setMax(max);
return this;
}
/**
-
Sets the rating (the number of stars filled) of a RatingBar.
-
@param viewId The view id.
-
@param rating The rating.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setRating(@IdRes int viewId, float rating) {
RatingBar view = getView(viewId);
view.setRating(rating);
return this;
}
/**
-
Sets the rating (the number of stars filled) and max of a RatingBar.
-
@param viewId The view id.
-
@param rating The rating.
-
@param max The range of the RatingBar to 0…max.
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setRating(@IdRes int viewId, float rating, int max) {
RatingBar view = getView(viewId);
view.setMax(max);
view.setRating(rating);
return this;
}
/**
-
Sets the tag of the view.
-
@param viewId The view id.
-
@param tag The tag;
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setTag(@IdRes int viewId, Object tag) {
View view = getView(viewId);
view.setTag(tag);
return this;
}
/**
-
Sets the tag of the view.
-
@param viewId The view id.
-
@param key The key of tag;
-
@param tag The tag;
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setTag(@IdRes int viewId, int key, Object tag) {
View view = getView(viewId);
view.setTag(key, tag);
return this;
}
/**
-
Sets the checked status of a checkable.
-
@param viewId The view id.
-
@param checked The checked status;
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setChecked(@IdRes int viewId, boolean checked) {
View view = getView(viewId);
// View unable cast to Checkable
if (view instanceof Checkable) {
((Checkable) view).setChecked(checked);
}
return this;
}
/**
-
Set the enabled state of this view.
-
@param viewId The view id.
-
@param enable The checked status;
-
@return The BaseViewHolder for chaining.
*/
public BaseDelegateViewHolder setEnabled(@IdRes int viewId,boolean enable) {
View view = getView(viewId);
view.setEnabled(enable);
return this;
}
@SuppressWarnings(“unchecked”)
public T getView(@IdRes int viewId) {
View view = views.get(viewId);
if (view == null) {
view = itemView.findViewById(viewId);
views.put(viewId, view);
}
return (T) view;
}
/**
- Retrieves the last converted object on this view.
*/
public Object getAssociatedObject() {
return associatedObject;
}
/**
- Should be called during convert
*/
public void setAssociatedObject(Object associatedObject) {
this.associatedObject = associatedObject;
}
}
2.Adapter(包含item的点击事件和长按事件)
public abstract class BaseDelegateAdapter<T, VH extends RecyclerView.ViewHolder> extends DelegateAdapter.Adapter{
private static final String TAG = BaseDelegateAdapter.class.getSimpleName();
public Context mContext;
private LayoutInflater mLayoutInflater;
private int mLayoutResId;
private List mData;
private LayoutHelper mLayoutHelper;
public BaseDelegateAdapter(@LayoutRes int layoutResId, @Nullable List data, LayoutHelper layoutHelper) {
this.mData = data == null ? new ArrayList<>() : data;
if (layoutResId != 0) {
this.mLayoutResId = layoutResId;
}
this.mLayoutHelper = layoutHelper;
}
/**
- 删除一条数据
*/
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
作者2013年从java开发,转做Android开发,在小厂待过,也去过华为,OPPO等大厂待过,18年四月份进了阿里一直到现在。
参与过不少面试,也当面试官 面试过很多人。深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长,不成体系的学习效果低效漫长,而且极易碰到天花板技术停滞不前!
我整理了一份阿里P7级别的最系统的Android开发主流技术,特别适合有3-5年以上经验的小伙伴深入学习提升。
主要包括阿里,以及字节跳动,腾讯,华为,小米,等一线互联网公司主流架构技术。如果你想深入系统学习Android开发,成为一名合格的高级工程师,可以收藏一下这些Android进阶技术选型
我搜集整理过这几年阿里,以及腾讯,字节跳动,华为,小米等公司的面试题,把面试的要求和技术点梳理成一份大而全的“ Android架构师”面试 Xmind(实际上比预期多花了不少精力),包含知识脉络 + 分支细节。
Java语言与原理;
大厂,小厂。Android面试先看你熟不熟悉Java语言
高级UI与自定义view;
自定义view,Android开发的基本功。
性能调优;
数据结构算法,设计模式。都是这里面的关键基础和重点需要熟练的。
NDK开发;
未来的方向,高薪必会。
前沿技术;
组件化,热升级,热修复,框架设计
网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。
我在搭建这些技术框架的时候,还整理了系统的高级进阶教程,会比自己碎片化学习效果强太多,CodeChina上可见;
当然,想要深入学习并掌握这些能力,并不简单。关于如何学习,做程序员这一行什么工作强度大家都懂,但是不管工作多忙,每周也要雷打不动的抽出 2 小时用来学习。
不出半年,你就能看出变化!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
比预期多花了不少精力),包含知识脉络 + 分支细节。
[外链图片转存中…(img-tWwrotTe-1713598402328)]
Java语言与原理;
大厂,小厂。Android面试先看你熟不熟悉Java语言
[外链图片转存中…(img-IJIvveRS-1713598402329)]
高级UI与自定义view;
自定义view,Android开发的基本功。
[外链图片转存中…(img-wDKxCcri-1713598402330)]
性能调优;
数据结构算法,设计模式。都是这里面的关键基础和重点需要熟练的。
[外链图片转存中…(img-YxmniDkj-1713598402331)]
NDK开发;
未来的方向,高薪必会。
[外链图片转存中…(img-on9l0zb3-1713598402331)]
前沿技术;
组件化,热升级,热修复,框架设计
[外链图片转存中…(img-fvouKxbG-1713598402332)]
网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。
我在搭建这些技术框架的时候,还整理了系统的高级进阶教程,会比自己碎片化学习效果强太多,CodeChina上可见;
当然,想要深入学习并掌握这些能力,并不简单。关于如何学习,做程序员这一行什么工作强度大家都懂,但是不管工作多忙,每周也要雷打不动的抽出 2 小时用来学习。
不出半年,你就能看出变化!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!