-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSampleActivity.kt
More file actions
68 lines (59 loc) · 2.41 KB
/
Copy pathSampleActivity.kt
File metadata and controls
68 lines (59 loc) · 2.41 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
package com.banuba.example.videoeditor
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.banuba.example.videoeditor.databinding.ActivitySampleBinding
import com.banuba.example.videoeditor.export.ExportActivity
import com.banuba.example.videoeditor.playback.PlaybackActivity
class SampleActivity : AppCompatActivity() {
private lateinit var binding: ActivitySampleBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySampleBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.exportSampleButton.setOnClickListener {
checkVideoEditorLicenseState {
startActivity(Intent(applicationContext, ExportActivity::class.java))
}
}
binding.playbackSampleButton.setOnClickListener {
checkVideoEditorLicenseState {
startActivity(Intent(applicationContext, PlaybackActivity::class.java))
}
}
}
private fun checkVideoEditorLicenseState(
onActiveLicenseBlock: () -> Unit,
) {
val videoEditor = (application as SampleApp).videoEditor
if (videoEditor == null) {
Log.e(
"BanubaVideoEditor",
"Cannot check license state. Please initialize Video Editor SDK"
)
showLicenseErrorMessage(SampleApp.ERR_SDK_NOT_INITIALIZED)
} else {
// Checking the license might take around 1 sec in the worst case.
// Please optimize use if this method in your application for the best user experience
videoEditor.getLicenseState { isValid ->
if (isValid) {
// ✅ License is active, all good
// You can show button that opens Video Editor or
// Start Video Editor right away
onActiveLicenseBlock()
} else {
// ❌ Use of Video Editor is restricted. License is revoked or expired.
showLicenseErrorMessage(SampleApp.ERR_LICENSE_REVOKED)
}
}
}
}
private fun showLicenseErrorMessage(msg: String) {
binding.licenseErrorMessageView.run {
text = msg
visibility = View.VISIBLE
}
}
}