我正在使用 Dio 进行调用,使用 map 构造函数发送一些查询参数
response = await Dio().get(url, queryParameters: {
"apikey": publicKey,
"hash": hash,
"ts": timestamp,
"nameStartsWith": searchTerm
});
Run Code Online (Sandbox Code Playgroud)
一切正常,但是当尝试发送 int 值时,Dio 抛出错误
response = await Dio().get(url, queryParameters: {
"apikey": publicKey,
"hash": hash,
"ts": timestamp,
"nameStartsWith": searchTerm,
"page" : 10
});
Run Code Online (Sandbox Code Playgroud)
'int' 类型不是 'Iterable < dynamic > '#0 类型的子类型
而且我不能只是将 int 值转换为字符串,因为 api 正在使用 int 类型。
有什么帮助吗?
如何在不使用的情况下检查回收器视图是否滚动到其顶部(列表的开头)findFirstCompletelyVisibleItemPosition?
说明:我不能使用这个方法,因为上面的项目RecyclerView很大,有时永远不会“完全可见”,所以该方法会返回-1( RecyclerView.NO_POSITION)
我需要知道这一点才能仅在回收站视图到达其顶部时才触发操作。
val manager = timelineRecyclerView?.layoutManager as StaggeredGridLayoutManager
val visibles = manager.findFirstCompletelyVisibleItemPositions(null)
Run Code Online (Sandbox Code Playgroud)
已解决:包括一些帮助代码
timelineRecyclerView.addOnScrollListener(object:RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView:RecyclerView,
newState:Int) {
super.onScrollStateChanged(recyclerView, newState)
}
override fun onScrolled(recyclerView:RecyclerView, dx:Int, dy:Int) {
super.onScrolled(recyclerView, dx, dy)
currentTimelinePosition += dy
Log.wtf("position", currentTimelinePosition.toString())
//if the timeline position is on its start, allow swipe and refresh
swipeLayout.isEnabled = currentTimelinePosition == 0
}
})
Run Code Online (Sandbox Code Playgroud) 我试图更改活动转换的默认动画,但我遇到了一个问题。
我可以更改正常活动的动画,但是当我将launchMode 更改为singleInstance 时,第一次打开活动时,动画带有默认值。然后,每次我再次调用它时,它都会带有正确的自定义动画。
我尝试使用 window.attributes.windowAnimations,仅使用样式/主题和 overridePendingTransition(),结果始终相同。
我看到一些人有同样的问题,但我找不到有效的解决方案。