|
@@ -6,7 +6,6 @@ import android.util.Log
|
6
|
6
|
import android.view.LayoutInflater
|
7
|
7
|
import android.view.View
|
8
|
8
|
import android.view.ViewGroup
|
9
|
|
-import android.view.WindowManager
|
10
|
9
|
import android.webkit.WebView
|
11
|
10
|
import androidx.fragment.app.Fragment
|
12
|
11
|
import androidx.lifecycle.ViewModelProviders
|
|
@@ -26,24 +25,20 @@ class NewsFragment : Fragment() {
|
26
|
25
|
container: ViewGroup?,
|
27
|
26
|
savedInstanceState: Bundle?
|
28
|
27
|
): View? {
|
29
|
|
- var root = inflater.inflate(R.layout.fragment_news, container, false) as View
|
30
|
28
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT)
|
31
|
29
|
{
|
32
|
|
- root = inflater.inflate(R.layout.fragment_news, container, false) as androidx.coordinatorlayout.widget.CoordinatorLayout
|
33
|
|
- activity?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
|
34
|
|
- val webView = WebView(context)
|
35
|
|
-
|
36
|
30
|
newsViewModel =
|
37
|
|
- ViewModelProviders.of(this).get(NewsViewModel::class.java)
|
|
31
|
+ ViewModelProviders.of(this).get(NewsViewModel::class.java)
|
38
|
32
|
|
39
|
33
|
if (!newsViewModel.isWebViewLoaded)
|
40
|
34
|
{
|
41
|
35
|
try {
|
42
|
|
- val webViewS = root.findViewById<WebView>(R.id.news_webview)
|
43
|
|
- val webViewChat = WebViewNews(webViewS as WebView)
|
44
|
|
- webViewChat.start()
|
|
36
|
+ newsViewModel.root = inflater.inflate(R.layout.fragment_chat, container, false)
|
|
37
|
+ newsViewModel.webView = newsViewModel.root.findViewById(R.id.news_webview)
|
|
38
|
+ newsViewModel.webViewNews = WebViewNews(newsViewModel.webView as WebView)
|
|
39
|
+ newsViewModel.webViewNews!!.start()
|
45
|
40
|
} catch (e: Exception) {
|
46
|
|
- root = inflater.inflate(R.layout.fragment_error_chat, container, false)
|
|
41
|
+ newsViewModel.root = inflater.inflate(R.layout.fragment_error_chat, container, false)
|
47
|
42
|
}
|
48
|
43
|
|
49
|
44
|
newsViewModel.isWebViewLoaded = true
|
|
@@ -52,13 +47,13 @@ class NewsFragment : Fragment() {
|
52
|
47
|
Log.d(tag, "webview already created!?")
|
53
|
48
|
}
|
54
|
49
|
|
55
|
|
- return root
|
|
50
|
+ return newsViewModel.root
|
56
|
51
|
}
|
57
|
52
|
|
58
|
53
|
newsViewModel =
|
59
|
54
|
ViewModelProviders.of(this).get(NewsViewModel::class.java)
|
60
|
55
|
|
61
|
|
- root = inflater.inflate(R.layout.fragment_news, container, false) as androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|
56
|
+ val root = inflater.inflate(R.layout.fragment_news, container, false) as androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
62
|
57
|
|
63
|
58
|
viewManager = LinearLayoutManager(context)
|
64
|
59
|
viewAdapter = NewsAdapter(newsViewModel.newsArray, context!!)
|