最近我升级recyclerview-v7:23
到了recyclerview-v7:24.2.0
.我的应用程序有一个无尽的滚动列表.notifyItemInserted
当我将加载视图添加到RecyclerView
(null对象表示加载,id 0为空,-1表示页面结束)时,错误消息指向该行,并且它之前工作正常(recyclerview-v7:23)但突然我得到错误像这样,不知怎的,我的加载出现两次,然后当它删除一个,有一个加载仍然可见在顶部.
W/RecyclerView: Cannot call this method in a scroll callback. Scroll callbacks might be run during a measure & layout pass where you cannot change the RecyclerView data. Any method call that might change the structure of the RecyclerView or the adapter contents should be postponed to the next frame.java.lang.IllegalStateException:
at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2403)
at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onItemRangeInserted(RecyclerView.java:4631)
at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeInserted(RecyclerView.java:10469)
at android.support.v7.widget.RecyclerView$Adapter.notifyItemInserted(RecyclerView.java:6211)
at com.sketchproject.infogue.fragments.MessageFragment.loadMessages(MessageFragment.java:109)
at com.sketchproject.infogue.fragments.MessageFragment.access$100(MessageFragment.java:42)
at com.sketchproject.infogue.fragments.MessageFragment$1.onLoadMore(MessageFragment.java:87)
at com.sketchproject.infogue.modules.EndlessRecyclerViewScrollListener.onScrolled(EndlessRecyclerViewScrollListener.java:74)
Run Code Online (Sandbox Code Playgroud)
当我删除部分错误(添加加载)它再次正常工作,我不知道为什么,更新版本的recyclerview阻止将数据添加到适配器太快或有回调函数,当"测量和布局"时触发recyclerview完了,这是我的代码
private void loadArticles(final int …
Run Code Online (Sandbox Code Playgroud) I have some issues about my POS database design, supposed I have products
table with column id, product_name, price, and stocks, and then table transactions
, and transaction_details
if someone bought some products I have one transaction record and some transaction detail record, for now I copy value of price from product
table into transaction_details
, so if the product price is changed, they can't affect the transaction history/report, but I consider separate prices into another table, let's say product_prices …
我是Laravel广播的新手,目前正在使用5.4。我要更新帐户仪表板,当其他人创建新帖子时,我正在使用私人渠道,该仪表板按他们的兴趣包含相关帖子。我成功广播了另一个用户在当前登录的用户仪表板中发布的每个新帖子,我需要检查新帖子是否相关,如果不发布则进行广播。
我想我可以在内部BroadcastServiceProvider
编写授权事件中的过滤来实现。
public function boot(){
Broadcast::routes();
Broadcast::channel('discovery.post', function ($user) {
return true;
});
}
Run Code Online (Sandbox Code Playgroud)
我已经阅读了有关可以与通道名称一起传递数据的文档,例如
Broadcast::channel('discovery.post.{postId}', function ($user, $postId) {
// get post category, tags, etc compare with user interest
return $isInterest;
});
Run Code Online (Sandbox Code Playgroud)
但是这种方法也必须在laravel Echo中传递新的帖子ID
window.Echo.private('discovery.post.{how-i-get-this-id?}')
.listen('NewPostDashboard', (data) => {
// add new update to dom
});
Run Code Online (Sandbox Code Playgroud)
我如何解决此问题,我想保留我的频道名称discovery.post
,我只想发送给具有相关兴趣的用户,我需要Post实例来检查登录的用户是否对此帖子感兴趣。
如果我的问题不清楚,请让我投票。谢谢。