全部 文章 问答 分享 共找到2个相关内容
[文章] oauth2.0的配置信息AuthorizationServerConfigurerAdapter
publicAuthorizationServerTokenServicestokenService(){//jwt令牌内容增强TokenEnhancerChainenhancerChain=newTokenEnhancerChain();List<TokenEnhancer>delegates
2020-12-08 11:59 · oauth2.0
[文章] Kotlin 中 Delegates 的妙用
常规代码实现项目中有一个RecyclerView列表的单选功能,于是我们可以凭借经验写出下面的代码:privatevarlastPos=0privatevarcurrentPos=0funsetCurrentSelected(position:Int){if(currentPos!=position){lastPos=currentPoscurrentPos=positionnotifyItemChanged(lastPos)notifyItemChanged(currentPos)}}然后我们使用的时候这样调用:setCurrentSelected(1)使用kotlin语法糖我们都知道kotlin是一门现代、简洁、安全的编程语言。那么,我们有没有更简洁的写法呢?当然有,只需要像下面这样写即可:privatevarselectedPositionbyDelegates.observable(0){_,oldPos,newPos->if(oldPos!=newPos){notifyItemChanged(oldPos)notifyItemChanged(newPos)}}使用的时候像下面这样调用即可:selectedPosition=position可以看到,比原有的代码简洁了不少~如果对你有帮助的话,欢迎一键三连+关注哦~
2023-07-22 18:02 · Kotlin / Delegates / RecyclerView / 单选
  • 1