Skip to content

Commit

Permalink
1.修复index post页加载数据bug
Browse files Browse the repository at this point in the history
2.详情页增加刷新,系统浏览器打开功能
  • Loading branch information
jixiaoyong committed Mar 13, 2018
1 parent 558e471 commit 42ac00e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ package cf.android666.wanandroid.activity

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.view.View
import cf.android666.wanandroid.R
import cf.android666.wanandroid.utils.SuperUtil
import kotlinx.android.synthetic.main.activity_content.*
import cf.android666.wanandroid.base.BaseActivity
import android.content.Intent
import android.net.Uri


/**
Expand All @@ -26,7 +30,27 @@ class ContentActivity : BaseActivity() {

SuperUtil.loadUrl(web_view,intent.getStringExtra("url"))

toolbar.title = web_view.title

}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_content, menu)
return true
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {

when (item!!.itemId) {

R.id.refresh -> web_view.reload()

R.id.open_sys ->
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(intent.getStringExtra("url"))))

}

return super.onOptionsItemSelected(item)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,14 @@ class IndexPostFragment : BaseFragment() {

currentPage = it.data.curPage

view!!.recycler_view.adapter.notifyDataSetChanged()
if (view != null) {

view!!.recycler_view.adapter.notifyDataSetChanged()
childCount = recycler_view.childCount
}

childCount = recycler_view.childCount

view!!.swipe_refresh.isRefreshing = false
view?.swipe_refresh?.isRefreshing = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ class AutoRefreshRecyclerView(context: Context, attributeSet: AttributeSet?, def

MotionEvent.ACTION_UP -> {

Logger.wtf("onTouchEvent e.y is ${e.y}")

checkFoot(e.y - oldY)

}
Expand All @@ -55,11 +53,9 @@ class AutoRefreshRecyclerView(context: Context, attributeSet: AttributeSet?, def

}

Logger.wtf("dy is $dy")

if (dy < 0 && lastPosition > childCount - 2 && onFootListener!=null) {
onFootListener!!.invoke()
Logger.wtf("onFootListener!!.invoke() ")

}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:layout_width="match_parent"
android:layout_height="@dimen/nav_height"
app:titleTextColor="#fff"
android:background="@color/colorBottomNav">
android:background="@color/colorBottomNav"
>

</android.support.v7.widget.Toolbar>

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/menu/menu_content.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">

<item android:title="刷新" android:id="@+id/refresh" app:showAsAction="never"/>
<item android:title="用系统浏览器打开" android:id="@+id/open_sys" app:showAsAction="never"/>

</menu>

0 comments on commit 42ac00e

Please sign in to comment.