-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathNavigationBaseFragment.kt
More file actions
78 lines (59 loc) · 1.55 KB
/
NavigationBaseFragment.kt
File metadata and controls
78 lines (59 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.newline.screencast.base
import android.content.Context
import android.net.ConnectivityManager
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment
/**
* @name
* @author Realmo
* @email momo.weiye@gmail.com
* @version 1.0.0
* @time 2019/10/11 9:08
* @describe
*/
abstract class NavigationBaseFragment : Fragment() {
private var rootLayout:View?=null
private var needInitView = true
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initData()
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
if(rootLayout ==null){
rootLayout = inflater.inflate(getLayoutId(),container,false)
}
return rootLayout
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
//因为用了navigation 框架是用的回退操作用的是replace
if(needInitView){
needInitView = false
initView(view)
}
}
override fun onDestroy() {
super.onDestroy()
}
/**
* 初始化数据
*/
abstract fun initData()
/**
* 加载布局
*/
@LayoutRes
abstract fun getLayoutId():Int
/**
* 初始化 View
*/
abstract fun initView(view : View)
}