解决post过短导致无线加载的问题
This commit is contained in:
@@ -5,7 +5,6 @@ import android.animation.AnimatorListenerAdapter
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
@@ -17,7 +16,7 @@ import com.google.android.material.snackbar.Snackbar
|
||||
import com.lsp.view.bean.Post
|
||||
import com.hentai.yandeview.Retrofit.PostService
|
||||
import com.hentai.yandeview.Retrofit.ServiceCreator
|
||||
import com.lsp.view.Adapter.PostAdapter
|
||||
import com.lsp.view.adapter.PostAdapter
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
@@ -73,20 +72,12 @@ class MainActivity : AppCompatActivity() {
|
||||
return@setOnEditorActionListener false
|
||||
}
|
||||
|
||||
|
||||
|
||||
fbtn.setOnClickListener {
|
||||
if (searchBar.visibility == View.GONE) {
|
||||
showSearchBar()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
swipeRefreshLayout.setOnRefreshListener {
|
||||
Log.e("Refresh", "Is refresh")
|
||||
postList.clear()
|
||||
@@ -133,7 +124,6 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun loadPost(context: Context, source: String?, tags: String?,page:String){
|
||||
nowPosition = postList.size-3
|
||||
|
||||
@@ -160,17 +150,13 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
if (list != null) {
|
||||
for ((i, post) in list.withIndex()) {
|
||||
// if (list[i].rating=="s") {
|
||||
postList.add(post)
|
||||
// }
|
||||
postList.add(post)
|
||||
}
|
||||
} else {
|
||||
Log.e("Post", "Is null")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
val layoutManager = GridLayoutManager(context, 2)
|
||||
val recyclerView =
|
||||
findViewById<androidx.recyclerview.widget.RecyclerView>(R.id.recyclerview)
|
||||
|
||||
@@ -20,10 +20,10 @@ import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.google.android.flexbox.*
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.lsp.view.Adapter.AuthorAdapter
|
||||
import com.lsp.view.Adapter.IdAdapter
|
||||
import com.lsp.view.Adapter.SizeAdapter
|
||||
import com.lsp.view.Adapter.TagAdapter
|
||||
import com.lsp.view.adapter.AuthorAdapter
|
||||
import com.lsp.view.adapter.IdAdapter
|
||||
import com.lsp.view.adapter.SizeAdapter
|
||||
import com.lsp.view.adapter.TagAdapter
|
||||
import com.lsp.view.bean.Author
|
||||
import com.lsp.view.bean.ID
|
||||
import com.lsp.view.bean.Size
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.lsp.view.Adapter
|
||||
package com.lsp.view.adapter
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.lsp.view.Adapter
|
||||
package com.lsp.view.adapter
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.lsp.view.Adapter
|
||||
package com.lsp.view.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -54,7 +54,7 @@ class PostAdapter(val context:Context, private val postList: List<Post>) :Recycl
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val post = postList[position]
|
||||
Glide.with(context).load(post.preview_url).into(holder.picImage)
|
||||
if (position==postList.size-1){
|
||||
if (position==postList.size-1&&postList.size>100){
|
||||
//到达底部
|
||||
mLoadMoreListener.loadMore(position)
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.lsp.view.Adapter
|
||||
package com.lsp.view.adapter
|
||||
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package com.lsp.view.Adapter
|
||||
package com.lsp.view.adapter
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -22,6 +22,7 @@ class TagAdapter(val tagList:List<Tags>):RecyclerView.Adapter<TagAdapter.ViewHol
|
||||
this.mOnItemClickListener = mOnItemClickListener
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.tag_item_layout,parent,false)
|
||||
return ViewHolder(view)
|
||||
+3
-1
@@ -18,4 +18,6 @@ android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official
|
||||
kotlin.code.style=official
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user