- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 codelab 之后实现 Jetpack 分页 3 库使用房间数据库作为事实来源和 RemoteMediator。该应用程序查询谷歌图书 api,但由于某种原因,当我执行搜索时,它会多次调用同一页面。例如,当我在不滚动的情况下搜索火时,我在日志中得到了这个:
D/BooksRepository: new search: fire
D/BooksRemoteMediator: title: fire, page: 0
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=0
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=0 (648ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 1
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=1
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=1 (608ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 0
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=0
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=0 (629ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 1
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=1
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=1 (843ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 0
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=0
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=0 (527ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 1
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=1
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=1 (734ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 2
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=2
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=2 (783ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 3
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=3
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=3 (769ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 2
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=2
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=2 (521ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 3
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=3
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=3 (549ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 2
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=2
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=2 (966ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 3
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=3
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=3 (673ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 4
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=4
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=4 (634ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 5
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=5
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=5 (604ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 4
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=4
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=4 (632ms, unknown-length body)
D/BooksRemoteMediator: title: fire, page: 3
I/okhttp.OkHttpClient: --> GET https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=3
I/okhttp.OkHttpClient: <-- 200 https://www.googleapis.com/books/v1/volumes?q=intitle%3Afire&key=AIzaSyBxHmT9nFCp9n2uOHkS3Gcq2OO3zbxaMrw&maxResults=40&startIndex=3 (602ms, unknown-length body)
我的实现是这样的:
class BooksRepository(private val service: BookService, private val database: BooksDatabase) {
companion object {
private const val NETWORK_PAGE_SIZE = 40
}
fun getSearchResultStream(
title: String = "",
author: String = "",
publisher: String = "",
isbn: String = ""
): Flow<PagingData<Book>> {
Timber.d("new search: $title")
val dbQuery = "%${title.replace(' ', '%')}%"
val pagingSourceFactory = { database.bookDao.getBooks(dbQuery, author, publisher)}
return Pager(
config = PagingConfig(
pageSize = NETWORK_PAGE_SIZE,
enablePlaceholders = false
),
remoteMediator = BooksRemoteMediator(title, author, publisher, isbn, apiKey, service, database),
pagingSourceFactory = pagingSourceFactory
).flow
}
}
远程调解员:
private const val BOOKS_STARTING_PAGE_INDEX = 0
@OptIn(ExperimentalPagingApi::class)
class BooksRemoteMediator(
private val title: String?,
private val author: String?,
private val publisher: String?,
private val isbn: String?,
private val key: String,
private val service: BookService,
private val booksDatabase: BooksDatabase
) : RemoteMediator<Int, Book>() {
override suspend fun load(loadType: LoadType, state: PagingState<Int, Book>): MediatorResult {
val page = when (loadType) {
LoadType.REFRESH -> {
val remoteKeys = getRemoteKeyClosestToCurrentPosition(state)
remoteKeys?.nextKey?.minus(1) ?: BOOKS_STARTING_PAGE_INDEX
}
LoadType.PREPEND -> {
val remoteKeys = getRemoteKeyForFirstItem(state)
if (remoteKeys == null) {
// The LoadType is PREPEND so some data was loaded before,
// so we should have been able to get remote keys
// If the remoteKeys are null, then we're an invalid state and we have a bug
throw InvalidObjectException("Remote key and the prevKey should not be null")
}
// If the previous key is null, then we can't request more data
val prevKey = remoteKeys.prevKey
if (prevKey == null) {
return MediatorResult.Success(endOfPaginationReached = true)
}
remoteKeys.prevKey
}
LoadType.APPEND -> {
val remoteKeys = getRemoteKeyForLastItem(state)
if (remoteKeys == null || remoteKeys.nextKey == null) {
throw InvalidObjectException("Remote key should not be null for $loadType")
}
remoteKeys.nextKey
}
}
Timber.d("title: $title, page: $page")
val sb = StringBuilder()
if (!title.isNullOrBlank()) sb.append("$TITLE$title+")
if (!author.isNullOrBlank()) sb.append("$AUTHOR$author+")
if (!publisher.isNullOrBlank()) sb.append("$PUBLISHER$publisher+")
if (!isbn.isNullOrBlank()) sb.append("$ISBN$isbn+")
sb.setLength(sb.length - 1)
val apiQuery = sb.toString()
try {
val apiResponse = service.searchBooks(apiQuery, key, state.config.pageSize, page)
val books = apiResponse.items
val endOfPaginationReached = books.isEmpty()
booksDatabase.withTransaction {
// clear all tables in the database
if (loadType == LoadType.REFRESH) {
booksDatabase.remoteKeysDao.clearRemoteKeys()
booksDatabase.bookDao.clearBooks()
}
val prevKey = if (page == BOOKS_STARTING_PAGE_INDEX) null else page - 1
val nextKey = if (endOfPaginationReached) null else page + 1
val keys = books.map {
RemoteKeys(bookId = it.id, prevKey = prevKey, nextKey = nextKey)
}
booksDatabase.remoteKeysDao.insertAll(keys)
booksDatabase.bookDao.insert(books)
}
return MediatorResult.Success(endOfPaginationReached = endOfPaginationReached)
} catch (exception: IOException) {
return MediatorResult.Error(exception)
} catch (exception: HttpException) {
return MediatorResult.Error(exception)
}
}
private suspend fun getRemoteKeyForLastItem(state: PagingState<Int, Book>): RemoteKeys? {
// Get the last page that was retrieved, that contained items.
// From that last page, get the last item
return state.pages.lastOrNull() { it.data.isNotEmpty() }?.data?.lastOrNull()
?.let { book ->
// Get the remote keys of the last item retrieved
booksDatabase.remoteKeysDao.remoteKeysBookId(book.id)
}
}
private suspend fun getRemoteKeyForFirstItem(state: PagingState<Int, Book>): RemoteKeys? {
// Get the first page that was retrieved, that contained items.
// From that first page, get the first item
return state.pages.firstOrNull { it.data.isNotEmpty() }?.data?.firstOrNull()
?.let { book ->
// Get the remote keys of the first items retrieved
booksDatabase.remoteKeysDao.remoteKeysBookId(book.id)
}
}
private suspend fun getRemoteKeyClosestToCurrentPosition(
state: PagingState<Int, Book>
): RemoteKeys? {
// The paging library is trying to load data after the anchor position
// Get the item closest to the anchor position
return state.anchorPosition?.let { position ->
state.closestItemToPosition(position)?.id?.let { bookId ->
booksDatabase.remoteKeysDao.remoteKeysBookId(bookId)
}
}
}
}
查看型号:
class BookListViewModel(private val repository: BooksRepository) : ViewModel() {
private var currentQueryValue: String? = null
private var currentSearchResult: Flow<PagingData<Book>>? = null
fun searchRepo(queryString: String): Flow<PagingData<Book>> {
val lastResult = currentSearchResult
if (queryString == currentQueryValue && lastResult != null) {
return lastResult
}
currentQueryValue = queryString
val newResult: Flow<PagingData<Book>> = repository.getSearchResultStream(queryString)
.cachedIn(viewModelScope)
currentSearchResult = newResult
return newResult
}
}
fragment :
class BookListFragment : Fragment() {
...
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
setHasOptionsMenu(true)
binding = FragmentBookListBinding.inflate(inflater, container, false).apply {
lifecycleOwner = viewLifecycleOwner
viewModel = bookListViewModel
}
initAdapter()
val queryString = queryArgs.split(",")
val query = savedInstanceState?.getString(LAST_SEARCH_QUERY) ?: DEFAULT_QUERY
search(query)
setHasOptionsMenu(true)
return binding.root
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
binding.retryButton.setOnClickListener { adapter.retry() }
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putString(LAST_SEARCH_QUERY, latest)
}
private fun search(query: String) {
// Make sure we cancel the previous job before creating a new one
searchJob?.cancel()
searchJob = lifecycleScope.launch {
bookListViewModel.searchRepo(query).collectLatest{
adapter.submitData(it)
}
}
}
private fun initAdapter() {
binding.rvBooks.adapter = adapter.withLoadStateHeaderAndFooter(
header = BooksLoadStateAdapter { adapter.retry() },
footer = BooksLoadStateAdapter { adapter.retry() }
)
adapter.addLoadStateListener { loadState ->
// Only show the list if refresh succeeds.
binding.rvBooks.isVisible = loadState.source.refresh is LoadState.NotLoading
// Show loading spinner during initial load or refresh.
binding.pbLoading.isVisible = loadState.source.refresh is LoadState.Loading
// Show the retry state if initial load or refresh fails.
binding.retryButton.isVisible = loadState.source.refresh is LoadState.Error
// Toast on any error, regardless of whether it came from RemoteMediator or PagingSource
val errorState = loadState.source.append as? LoadState.Error
?: loadState.source.prepend as? LoadState.Error
?: loadState.append as? LoadState.Error
?: loadState.prepend as? LoadState.Error
errorState?.let {
Toast.makeText(
context,
"\uD83D\uDE28 Wooops ${it.error}",
Toast.LENGTH_LONG
).show()
}
}
}
private fun initSearch(menu: Menu) {
val searchItem = menu.findItem(R.id.action_search)
val searchView = searchItem.actionView as android.widget.SearchView
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener, android.widget.SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
try {
latest = query!!
updateBookListFromInput(query)
} catch (e: Exception) {
Timber.d(e)
}
return false
}
override fun onQueryTextChange(newText: String?): Boolean {
return false
}
})
lifecycleScope.launch {
adapter.loadStateFlow
// Only emit when REFRESH LoadState changes.
.distinctUntilChangedBy { it.refresh }
// Only react to cases where REFRESH completes i.e., NotLoading.
.filter { it.refresh is LoadState.NotLoading }
.collect { binding.rvBooks.scrollToPosition(0) }
}
}
private fun updateBookListFromInput(query: String?) {
query?.trim().let {
if (!it.isNullOrEmpty()) {
search(it.toString())
}
}
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.book_list_menu, menu)
initSearch(menu)
_menu = menu
val recentList: ArrayList<String> = SpUtil.getQueryList(requireContext())
var recentMenu: MenuItem? = null
for (item in recentList) {
recentMenu = menu.add(Menu.NONE, recentList.indexOf(item), Menu.NONE, item)
}
}
companion object {
private const val LAST_SEARCH_QUERY: String = "last_search_query"
private const val DEFAULT_QUERY = "Fishing"
}
}
道:
@Dao
interface BooksDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(books: List<Book>)
@Query("DELETE FROM books")
suspend fun clearBooks()
@Query("SELECT * FROM books WHERE (title LIKE :title) OR (authors LIKE :author) " +
"OR (publisher LIKE :publisher) ORDER BY title ASC")
fun getBooks(title: String, author: String = "", publisher: String = ""): PagingSource<Int, Book>
}
服务:
interface BookService {
@GET("volumes")
suspend fun searchBooks(
@Query("q") query: String,
@Query("key") apiKey: String,
@Query("maxResults") max: Int,
@Query("startIndex") page: Int
): BookSearchResponse
}
如果有人指出我做错了什么并帮助解决这个问题,那就太好了。
最佳答案
我花了一些时间来解决这个问题,在阅读了 user9694585 和 dunkypie 的答案之后,我能够解决我的问题。就我而言,我使用的是 movieDb API,与 Doilio Matsinhe 完全一样,我发现我不能依赖 API id 有两个原因:
@Entity(tableName = "movie")
data class MovieTable(
@PrimaryKey(autoGenerate = true)
var id: Long = 0,
var remoteId: Long = 0,
...
)
@Dao
interface RemoteKeysDao {
...
@Query("SELECT * FROM remote_keys WHERE movieId = :movieId")
suspend fun remoteKeyId(movieId: Long): RemoteKeyTable?
...
}
我的 RemoteMediator 与 Doilio Matsinhe 非常相似。所以我只留下他回答中没有的方法:
private suspend fun getRemoteKeyForLastItem(state: PagingState<Int, MovieTable>): RemoteKeyTable? {
return state.pages
.lastOrNull {
it.data.isNotEmpty()
}?.data?.lastOrNull()
?.let { movie ->
remoteKeyLocalDataSource.remoteKeyId(movie.remoteId)
}
}
private suspend fun getRemoteKeyForFirstItem(state: PagingState<Int, MovieTable>): RemoteKeyTable? {
return state.pages
.firstOrNull {
it.data.isNotEmpty()
}?.data?.firstOrNull()
?.let { movie ->
remoteKeyLocalDataSource.remoteKeyId(movie.remoteId)
}
}
private suspend fun getRemoteKeyClosestToCurrentPosition(
state: PagingState<Int, MovieTable>
): RemoteKeyTable? {
return state.anchorPosition?.let { position ->
state.closestItemToPosition(position)?.remoteId?.let { id ->
remoteKeyLocalDataSource.remoteKeyId(id)
}
}
}
基本上是我们在 codelab 上使用的那个,但使用 movie.remoteId 来获取 remoteKey.id。
关于android - Jetpack Paging3 库对同一页面进行多次调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63113217/
我喜欢 smartcase,也喜欢 * 和 # 搜索命令。但我更希望 * 和 # 搜索命令区分大小写,而/和 ?搜索命令遵循 smartcase 启发式。 是否有隐藏在某个地方我还没有找到的设置?我宁
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 10年前关闭。 Improve this qu
从以下网站,我找到了执行java AD身份验证的代码。 http://java2db.com/jndi-ldap-programming/solution-to-sslhandshakeexcepti
似乎 melt 会使用 id 列和堆叠的测量变量 reshape 您的数据框,然后通过转换让您执行聚合。 ddply,从 plyr 包看起来非常相似..你给它一个数据框,几个用于分组的列变量和一个聚合
我的问题是关于 memcached。 Facebook 使用 memcached 作为其结构化数据的缓存,以减少用户的延迟。他们在 Linux 上使用 UDP 优化了 memcached 的性能。 h
在 Camel route ,我正在使用 exec 组件通过 grep 进行 curl ,但使用 ${HOSTNAME} 的 grep 无法正常工作,下面是我的 Camel 路线。请在这方面寻求帮助。
我正在尝试执行相当复杂的查询,在其中我可以排除与特定条件集匹配的项目。这是一个 super 简化的模型来解释我的困境: class Thing(models.Model) user = mod
我正在尝试执行相当复杂的查询,我可以在其中排除符合特定条件集的项目。这里有一个 super 简化的模型来解释我的困境: class Thing(models.Model) user = mod
我发现了很多嵌入/内容项目的旧方法,并且我遵循了在这里找到的最新方法(我假设):https://blog.angular-university.io/angular-ng-content/ 我正在尝试
我正在寻找如何使用 fastify-nextjs 启动 fastify-cli 的建议 我曾尝试将代码简单地添加到建议的位置,但它不起作用。 'use strict' const path = req
我正在尝试将振幅 js 与 React 和 Gatsby 集成。做 gatsby developer 时一切看起来都不错,因为它发生在浏览器中,但是当我尝试 gatsby build 时,我收到以下错
我试图避免过度执行空值检查,但同时我想在需要使代码健壮的时候进行空值检查。但有时我觉得它开始变得如此防御,因为我没有实现 API。然后我避免了一些空检查,但是当我开始单元测试时,它开始总是等待运行时异
尝试进行包含一些 NOT 的 Kibana 搜索,但获得包含 NOT 的结果,因此猜测我的语法不正确: "chocolate" AND "milk" AND NOT "cow" AND NOT "tr
我正在使用开源代码共享包在 iOS 中进行 facebook 集成,但收到错误“FT_Load_Glyph failed: glyph 65535: error 6”。我在另一台 mac 机器上尝试了
我正在尝试估计一个标准的 tobit 模型,该模型被审查为零。 变量是 因变量 : 幸福 自变量 : 城市(芝加哥,纽约), 性别(男,女), 就业(0=失业,1=就业), 工作类型(失业,蓝色,白色
我有一个像这样的项目布局 样本/ 一种/ 源/ 主要的/ java / java 资源/ .jpg 乙/ 源/ 主要的/ java / B.java 资源/ B.jpg 构建.gradle 设置.gr
如何循环遍历数组中的多个属性以及如何使用map函数将数组中的多个属性显示到网页 import React, { Component } from 'react'; import './App.css'
我有一个 JavaScript 函数,它进行 AJAX 调用以返回一些数据,该调用是在选择列表更改事件上触发的。 我尝试了多种方法来在等待时显示加载程序,因为它当前暂停了选择列表,从客户的 Angul
可能以前问过,但找不到。 我正在用以下形式写很多语句: if (bar.getFoo() != null) { this.foo = bar.getFoo(); } 我想到了三元运算符,但我认
我有一个表单,在将其发送到 PHP 之前我正在执行一些验证 JavaScript,验证后的 JavaScript 函数会发布用户在 中输入的文本。页面底部的标签;然而,此消息显示短暂,然后消失...
我是一名优秀的程序员,十分优秀!