Skip to content

Commit

Permalink
DroidKaigi#32 記事画面でコメントが一瞬出るのを直しましょう
Browse files Browse the repository at this point in the history
  • Loading branch information
wada811 committed Feb 8, 2019
1 parent e4cbe9f commit 17e6dfa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.ProgressBar
import android.widget.ScrollView
import androidx.recyclerview.widget.RecyclerView
import com.squareup.moshi.Types
import droidkaigi.github.io.challenge2019.data.api.HackerNewsApi
import droidkaigi.github.io.challenge2019.data.api.response.Item
Expand All @@ -29,8 +31,9 @@ class StoryActivity : BaseActivity() {
private const val STATE_COMMENTS = "comments"
}

private lateinit var contentScrollView: ScrollView
private lateinit var webView: WebView
private lateinit var recyclerView: androidx.recyclerview.widget.RecyclerView
private lateinit var recyclerView: RecyclerView
private lateinit var progressView: ProgressBar

private lateinit var commentAdapter: CommentAdapter
Expand All @@ -50,6 +53,7 @@ class StoryActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
contentScrollView = findViewById(R.id.content)
webView = findViewById(R.id.web_view)
recyclerView = findViewById(R.id.comment_recycler)
progressView = findViewById(R.id.progress)
Expand Down Expand Up @@ -83,7 +87,6 @@ class StoryActivity : BaseActivity() {
return
}

progressView.visibility = View.VISIBLE
loadUrlAndComments()
}

Expand All @@ -94,6 +97,12 @@ class StoryActivity : BaseActivity() {

hideProgressTask = @SuppressLint("StaticFieldLeak") object : AsyncTask<Unit, Unit, Unit>() {

override fun onPreExecute() {
super.onPreExecute()
contentScrollView.visibility = View.GONE
progressView.visibility = View.VISIBLE
}

override fun doInBackground(vararg unit: Unit?) {
try {
progressLatch.await()
Expand All @@ -103,7 +112,8 @@ class StoryActivity : BaseActivity() {
}

override fun onPostExecute(result: Unit?) {
progressView.visibility = Util.setVisibility(false)
progressView.visibility = View.GONE
contentScrollView.visibility = View.VISIBLE
}
}

Expand Down Expand Up @@ -163,7 +173,6 @@ class StoryActivity : BaseActivity() {
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
return when (item?.itemId) {
R.id.refresh -> {
progressView.visibility = Util.setVisibility(true)
loadUrlAndComments()
return true
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_story.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
>

<ScrollView
android:id="@+id/content"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down

0 comments on commit 17e6dfa

Please sign in to comment.