android

【RecyclerView优化】

不想你离开。 提交于 2021-02-17 16:22:46
1.局部刷新 ( 1)避免整个列表的数据更新 ,只更新受影响的布局。例如,加载更多时,不使用 notifyDataSetChanged() ,而是使用 notifyItemRangeInserted(rangeStart, rangeEnd) 补充:recyclerView.adapter的刷新: 刷新全部可见的item,notifyDataSetChanged() 刷新指定item,notifyItemChanged(int) position数据发生了改变,那调用这个方法,就会回调对应position的onBindViewHolder()方法了,当然,因为ViewHolder是复用的,所以如果position在当前屏幕以外,也就不会回调了,因为没有意义,下次position滚动会当前屏幕以内的时候同样会调用onBindViewHolder()方法刷新数据了。其他的方法也是同样的道理。 从指定位置开始刷新指定个item,notifyItemRangeChanged(int,int) 顾名思义,可以刷新从positionStart开始itemCount数量的item了(这里的刷新指回调onBindViewHolder()方法)。 插入、移动一个并自动刷新,notifyItemInserted(int)、notifyItemMoved(int)、notifyItemRemoved

Flutter setState of child widget without rebuilding parent

我的未来我决定 提交于 2021-02-17 15:43:10
问题 I have a parent that contain a listView and a floatingActionButton i would like to hide the floatingActionButton when the user starts scrolling i have managed to do this within the parent widget but this requires the list to be rebuilt each time. I have moved the floatingActionButton to a separate class so i can update the state and only rebuild that widget the problem i am having is passing the data from the ScrollController in the parent class to the child this is simple when doing it

Transferring android app with subscription to another account

北战南征 提交于 2021-02-17 15:30:49
问题 I understand that google does not allow the transfer of app ownership with in app-subscription from one developer account to another. I have been waiting for them to enable that feature but till now, it is not available and there is no ETA on it. I have a paid app with in-app-subscription as part of it. A company is looking to acquire my app but the transfer is not possible. So I am thinking about alternatives. Should I create another identifcal app and ask users in my old app to move to this

Android - programmatically change the state of a switch without triggering OnCheckChanged listener

☆樱花仙子☆ 提交于 2021-02-17 15:06:55
问题 I'm looking for a method of programmatically changing the state of an Android Switch widget using switch.setChecked(true); without triggering OnCheckedChangedlistener . My first thought was to swap it out for an OnClickListener but as this only registers clicks and you are able to not only click but also slide a Switch then it's not really fit for purpose as if the user was to slide the Switch from off to on then the Switch would actually do nothing as the user is not clicking... If anyone's

Android - programmatically change the state of a switch without triggering OnCheckChanged listener

怎甘沉沦 提交于 2021-02-17 15:04:40
问题 I'm looking for a method of programmatically changing the state of an Android Switch widget using switch.setChecked(true); without triggering OnCheckedChangedlistener . My first thought was to swap it out for an OnClickListener but as this only registers clicks and you are able to not only click but also slide a Switch then it's not really fit for purpose as if the user was to slide the Switch from off to on then the Switch would actually do nothing as the user is not clicking... If anyone's

Set android datepicker date limits

女生的网名这么多〃 提交于 2021-02-17 14:55:33
问题 I am using datePicker in android to display images based on user selected dates. I need to limit said dates to certain days for instance Jan 1st 2010 to Dec 31st 2010. Simple as that i thought but no where can i find the answer on how to limit these dates. Does anyone know how to limit the dates for Android DatePicker 回答1: You can just set : dateDialog.getDatePicker().setMaxDate(new Date().getTime()); and dateDialog.getDatePicker().setMinDate(new Date().getTime()); where dateDialog is a new

数据调试~~TCP转串口、串口转TCP调试

偶尔善良 提交于 2021-02-17 11:24:55
1 Android socket开发了一个socket客户端,当输入服务器ip以及端口,建立连接之后,Android可以发送数据到电脑接收服务器端。 2 5 如果电脑端没有socket服务器怎么办?方法如下: 6 7 1 、虚拟串口,建立一对虚拟串口COM2 COM3 8 9 2 、打开两个串口助手,分别选择COM2 COM3,打开串口 10 11 3 、打开一个TCP转串口,监听TCP端口之后,选择发送至串口 12 这样Android通过Tcp过来的数据就可以在串口助手中查看,进行调试了 13 【反过来之后,也可以串口至网络进行调试】 来源: oschina 链接: https://my.oschina.net/u/4323904/blog/3937776

如何写出无法维护的代码

帅比萌擦擦* 提交于 2021-02-17 10:57:54
对,你没看错,本文就是教你怎么写无法维护的代码。 一、程序命名 容易输入的变量名 。 比如:Fred,asdf 单字母的变量名 。比如:a,b,c, x,y,z(如果不够用,可以考虑a1,a2,a3,a4,….) 有创意地拼写错误 。比如:SetPintleOpening, SetPintalClosing。这样可以让人很难搜索代码。 抽象 。比如:ProcessData, DoIt, GetData… 抽象到就跟什么都没说一样。 缩写 。比如:WTF,RTFSC …… (使用拼音缩写也同样给力,比如:BT,TMD,TJJTDS) 随机大写字母 。比如:gEtnuMbER.. 重用命名 。在内嵌的语句块中使用相同的变量名有奇效。 使用重音字母 。比如:int ínt(第二个 ínt不是int) 使用下划线 。比如:_, __, ___。 使用不同的语言 。比如混用英语,德语,或是中文拼音。 使用字符命名 。比如:slash, asterix, comma… 使用无关的单词 。比如:god, superman, iloveu…. 混淆l和1 。字母l和数字1有时候是看不出来的。 二、伪装欺诈 把注释和代码交织在一起。 for(j=0; j < array_len; j + = 8) { total += array[j+0 ]; total += array[j+1 ]; total

移动端底部fixed固定定位输入框ios下不兼容

情到浓时终转凉″ 提交于 2021-02-17 09:39:26
简短记录下最近开发移动端项目碰到的小坑,产品需求做一个售后对话页面,底部固定输入框,和微信对话差不多,但是在ios下,fixed失效,输入框被虚拟键盘挡住,在安卓下是正常的。 尝试过网上说的很多方法,因为每个页面的需求和布局可能不相同,比如我做的需要下拉刷新消息,上拉加载更多,用的是minit-UI来做,所以都没有效果 后面无奈用了两套代码,用 var u = navigator.userAgent, app = navigator.appVersion; var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 判断是安卓还是ios,安卓的继续底部用固定定位, ios底部也用固定定位,只是content内容主体部分用绝对定位 <div :class="isIOS?'input-bottom1':'input-bottom'"> <form style="width:70%;"> <input class="message-input" @focus="iosScrollT" @blur="iosScrollB" type="text" v-model="sendMess" > </form> <div class="footer-r" @click="postAdvisory">发送</div> </div>

Android 8.0 平台预置第三方apk到Data目录,使其可以卸载并且恢复出厂设置可以还原

﹥>﹥吖頭↗ 提交于 2021-02-17 09:06:28
Mstar 8.0平台预置第三方apk,踩了不少坑,这里做一下笔录。 正常情况预置apk到Data目录很简单,网上一搜很多,这里就不贴代码了,但是这里会遇到一个问题, 1 如果在不改变apk签名的情况下预置到Data目录,编译后可以看到out 目录下确实是有这个apk,但是刷机系统跑起来后会因为签名校验不过(android 7.0之后增加的APK Signature Scheme v2签名方案),导致这个apk自动被系统删除。 2 如果将apk的签名改为系统签名预置到data目录,编译后刷机都可以正常运行,但是一般apk都有在线升级的功能,一旦apk有新版本了会因为apk签名被改变导致升级不了, 经过几次尝试发现如果将apk直接push进data目录 apk可以正常运行,那么这就好办了,我们就通过这种方式将apk内置进去,既可以让apk可以卸载,也能够让apk可以升级,并且恢复出厂设置可以恢复,具体怎么做呢,下面我以预置腾讯视频会议apk为例子 1 首先 准备好要内置的apk,在编译代码的时候将这个apk拷贝到一个位置(位置自己定义即可),ps :如果apk有lib 记得解压出来 PRODUCT_COPY_FILES += \ $(call find-copy-subdir-files,*,$(LOCAL_PATH)/dataApps/TenxunConference,data