@@ -4,16 +4,18 @@ import android.content.Intent
4
4
import android.net.Uri
5
5
import android.os.Bundle
6
6
import android.util.Log
7
+ import android.view.LayoutInflater
7
8
import androidx.activity.result.contract.ActivityResultContracts
8
9
import androidx.appcompat.app.AlertDialog
9
10
import androidx.appcompat.app.AppCompatActivity
10
11
import androidx.lifecycle.lifecycleScope
12
+ import com.banuba.example.integrationapp.databinding.ActivityMainBinding
11
13
import com.banuba.sdk.cameraui.data.PipConfig
12
14
import com.banuba.sdk.core.ui.ext.visible
13
15
import com.banuba.sdk.export.data.ExportResult
14
16
import com.banuba.sdk.export.utils.EXTRA_EXPORTED_SUCCESS
15
17
import com.banuba.sdk.ve.flow.VideoCreationActivity
16
- import kotlinx.android.synthetic.main.activity_main.*
18
+
17
19
18
20
class MainActivity : AppCompatActivity () {
19
21
@@ -71,15 +73,22 @@ class MainActivity : AppCompatActivity() {
71
73
}
72
74
}
73
75
76
+ private var _binding : ActivityMainBinding ? = null
77
+
78
+ private val binding: ActivityMainBinding
79
+ get() = requireNotNull(_binding )
80
+
74
81
override fun onCreate (savedInstanceState : Bundle ? ) {
75
82
super .onCreate(savedInstanceState)
76
- setContentView(R .layout.activity_main)
83
+ _binding = ActivityMainBinding .inflate(LayoutInflater .from(this ))
84
+
85
+ setContentView(binding.root)
77
86
78
87
// Handle Video Editor license flow
79
88
val videoEditor = (application as SampleApp ).videoEditor
80
89
if (videoEditor == null ) {
81
- licenseStateView.visible()
82
- licenseStateView.text = SampleApp .ERR_SDK_NOT_INITIALIZED
90
+ binding. licenseStateView.visible()
91
+ binding. licenseStateView.text = SampleApp .ERR_SDK_NOT_INITIALIZED
83
92
return
84
93
}
85
94
@@ -90,32 +99,37 @@ class MainActivity : AppCompatActivity() {
90
99
// ✅ License is active, all good
91
100
// You can show button that opens Video Editor or
92
101
// Start Video Editor right away
93
- btnVideoEditor.setOnClickListener {
102
+ binding. btnVideoEditor.setOnClickListener {
94
103
openVideoEditor()
95
104
}
96
- btnPiPVideoEditor.setOnClickListener {
105
+ binding. btnPiPVideoEditor.setOnClickListener {
97
106
requestVideoOpenPIP.launch(" video/*" )
98
107
}
99
- btnDraftsVideoEditor.setOnClickListener {
108
+ binding. btnDraftsVideoEditor.setOnClickListener {
100
109
openVideoEditorDrafts()
101
110
}
102
- btnSlideShowVideoEditorTrimmer.setOnClickListener {
111
+ binding. btnSlideShowVideoEditorTrimmer.setOnClickListener {
103
112
requestImageOpenTrimmer.launch(" image/*" )
104
113
}
105
114
} else {
106
115
// ❌ Use of Video Editor is restricted. License is revoked or expired.
107
- licenseStateView.text = SampleApp .ERR_LICENSE_REVOKED
116
+ binding. licenseStateView.text = SampleApp .ERR_LICENSE_REVOKED
108
117
Log .w(SampleApp .TAG , SampleApp .ERR_LICENSE_REVOKED )
109
118
110
- licenseStateView.visible()
111
- btnVideoEditor.isEnabled = false
112
- btnPiPVideoEditor.isEnabled = false
113
- btnDraftsVideoEditor.isEnabled = false
114
- btnSlideShowVideoEditorTrimmer.isEnabled = false
119
+ binding. licenseStateView.visible()
120
+ binding. btnVideoEditor.isEnabled = false
121
+ binding. btnPiPVideoEditor.isEnabled = false
122
+ binding. btnDraftsVideoEditor.isEnabled = false
123
+ binding. btnSlideShowVideoEditorTrimmer.isEnabled = false
115
124
}
116
125
}
117
126
}
118
127
128
+ override fun onDestroy () {
129
+ super .onDestroy()
130
+ _binding = null
131
+ }
132
+
119
133
private fun openVideoEditor (pipVideo : Uri = Uri .EMPTY ) {
120
134
val videoCreationIntent = VideoCreationActivity .startFromCamera(
121
135
context = this ,
0 commit comments