@@ -4,30 +4,29 @@ import android.content.Intent
4
4
import android.content.pm.PackageManager
5
5
import android.os.Bundle
6
6
import androidx.appcompat.app.AppCompatActivity
7
+ import androidx.appcompat.widget.Toolbar
7
8
import androidx.recyclerview.widget.LinearLayoutManager
9
+ import androidx.recyclerview.widget.RecyclerView
10
+ import com.google.android.material.floatingactionbutton.FloatingActionButton
8
11
import com.google.android.material.snackbar.Snackbar
9
12
import com.zhihu.android.sugaradapter.SugarAdapter
10
13
import home.smart.fly.animations.R
11
14
import home.smart.fly.animations.sugar.viewholder.ActivityListViewHolder
12
15
import home.smart.fly.animations.utils.AppUtils
13
- import kotlinx.android.synthetic.main.activity_all.*
14
- import kotlinx.android.synthetic.main.content_all.*
15
16
import java.util.*
16
17
17
18
class AllActivity : AppCompatActivity () {
18
19
19
20
override fun onCreate (savedInstanceState : Bundle ? ) {
20
21
super .onCreate(savedInstanceState)
21
22
setContentView(R .layout.activity_all)
23
+ val toolbar = findViewById<Toolbar >(R .id.toolbar)
22
24
setSupportActionBar(toolbar)
23
-
25
+ val fab : FloatingActionButton = findViewById( R .id.fab)
24
26
fab.setOnClickListener { view ->
25
- Snackbar .make(view, " Replace with your own action" , Snackbar .LENGTH_LONG )
26
- .setAction(" Action" , null ).show()
27
+ Snackbar .make(view, " Replace with your own action" , Snackbar .LENGTH_LONG ).setAction(" Action" , null ).show()
27
28
}
28
- val adapter = SugarAdapter .Builder .with (getActivities())
29
- .add(ActivityListViewHolder ::class .java)
30
- .build();
29
+ val adapter = SugarAdapter .Builder .with (getActivities()).add(ActivityListViewHolder ::class .java).build();
31
30
adapter.addSugarHolderListener(object : SugarAdapter .SugarHolderListener <ActivityListViewHolder >() {
32
31
override fun onSugarHolderBindData (holder : ActivityListViewHolder ) {
33
32
super .onSugarHolderBindData(holder)
@@ -39,6 +38,7 @@ class AllActivity : AppCompatActivity() {
39
38
}
40
39
}
41
40
})
41
+ val recyclerView: RecyclerView = findViewById(R .id.recyclerView)
42
42
recyclerView.setHasFixedSize(true )
43
43
recyclerView.layoutManager = LinearLayoutManager (this )
44
44
recyclerView.adapter = adapter
@@ -47,8 +47,7 @@ class AllActivity : AppCompatActivity() {
47
47
48
48
private fun getActivities (): List <Pair <String , String >> {
49
49
val results = ArrayList <Pair <String , String >>()
50
- val info = packageManager
51
- .getPackageInfo(AppUtils .getPackageName(this ), PackageManager .GET_ACTIVITIES )
50
+ val info = packageManager.getPackageInfo(AppUtils .getPackageName(this ), PackageManager .GET_ACTIVITIES )
52
51
for (item in info.activities) {
53
52
val fullName = item.name
54
53
val simpleName = fullName.substring(fullName.lastIndexOf(" ." ) + 1 )
0 commit comments