Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mlykotom committed Jan 31, 2022
1 parent 7e1b0c1 commit 71782ba
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 50 deletions.
4 changes: 2 additions & 2 deletions JankStatsSample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.0'
implementation "androidx.metrics:metrics-performance:$jankstats_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ class JankAggregatorActivity : AppCompatActivity() {
"*** Jank Report ($reason), totalFrames = $totalFrames, " +
"jankFrames = ${jankFrameData.size}"
)
for (frameData in jankFrameData) {

jankFrameData.forEach { frameData ->
Log.v(
"JankStatsSample",
"***** Jank Report: " +
"frame start ${frameData.frameStartNanos}, " +
"duration = ${frameData.frameDurationNanos}, " +
"duration = ${frameData.frameDurationUiNanos}, " +
"jank = ${frameData.isJank}"
)
for (state in frameData.states) {

frameData.states.forEach { state ->
Log.v("JankStatsSample", " ${state.stateName}: ${state.state}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import com.example.jankstats.tools.simulateJank
* This custom view is used to inject an artificial, random delay during drawing, to simulate
* jank on the UI thread.
*/
class MyCustomView @JvmOverloads constructor(
class JankyView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import androidx.navigation.ui.setupActionBarWithNavController
import com.example.jankstats.databinding.ActivityMainBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asExecutor
import java.util.concurrent.Executor
import java.util.concurrent.Executors

/**
* This activity shows the basic usage of JankStats, from creating and enabling it to track
Expand Down Expand Up @@ -69,10 +67,11 @@ class MainActivity : AppCompatActivity() {
"JankStatsSample",
"*** Jank " +
"frame start ${frameData.frameStartNanos}, " +
"duration = ${frameData.frameDurationNanos}, " +
"duration = ${frameData.frameDurationUiNanos}, " +
"jank = ${frameData.isJank}"
)
for (state in frameData.states) {

frameData.states.forEach { state ->
Log.v("JankStatsSample", " ${state.stateName}: ${state.state}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MessageListAdapter(
itemView.setOnClickListener {
val bundle = bundleOf("title" to headerText)
Navigation.findNavController(it).navigate(
R.id.action_MessageList_to_messageContent, bundle
R.id.action_messageList_to_messageContent, bundle
)
}
binding.messageHeader.text = headerText
Expand All @@ -44,7 +44,8 @@ class MessageListAdapter(

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MessageHeaderViewHolder {
val inflater = LayoutInflater.from(parent.context)
return MessageHeaderViewHolder(MessageItemBinding.inflate(inflater, parent, false))
val itemBinding = MessageItemBinding.inflate(inflater, parent, false)
return MessageHeaderViewHolder(itemBinding)
}

override fun onBindViewHolder(holder: MessageHeaderViewHolder, position: Int) {
Expand Down
2 changes: 1 addition & 1 deletion JankStatsSample/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2020 The Android Open Source Project
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2020 The Android Open Source Project
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,4 +41,4 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/messageHeader" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2020 The Android Open Source Project
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
43 changes: 20 additions & 23 deletions JankStatsSample/app/src/main/res/layout/message_item.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2020 The Android Open Source Project
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -14,28 +14,25 @@
limitations under the License.
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground">

<LinearLayout
<TextView
android:id="@+id/messageHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
android:id="@+id/messageHeader"
android:textSize="24sp"
android:textStyle="bold"
android:layout_margin="16dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />

<com.example.jankstats.MyCustomView
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@color/black" />

</LinearLayout>

</FrameLayout>
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:textSize="24sp"
android:textStyle="bold"
tools:text="Message #24" />

<com.example.jankstats.JankyView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:background="@color/black" />

</LinearLayout>
4 changes: 2 additions & 2 deletions JankStatsSample/app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2020 The Android Open Source Project
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -23,4 +23,4 @@
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
</menu>
9 changes: 5 additions & 4 deletions JankStatsSample/app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2020 The Android Open Source Project
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -18,17 +18,18 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/MessageList">
app:startDestination="@id/messageList">

<fragment
android:id="@+id/MessageList"
android:id="@+id/messageList"
android:name="com.example.jankstats.MessageListFragment"
android:label="Message List"
tools:layout="@layout/fragment_message_list">
<action
android:id="@+id/action_MessageList_to_messageContent"
android:id="@+id/action_messageList_to_messageContent"
app:destination="@id/messageContent" />
</fragment>

<fragment
android:id="@+id/messageContent"
android:name="com.example.jankstats.MessageContentFragment"
Expand Down
4 changes: 2 additions & 2 deletions JankStatsSample/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright 2020 The Android Open Source Project
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,4 +27,4 @@
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion JankStatsSample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://androidx.dev/snapshots/builds/8109758/artifacts/repository' }
maven { url 'https://androidx.dev/snapshots/builds/8134407/artifacts/repository' }
}
}

Expand Down

0 comments on commit 71782ba

Please sign in to comment.