Skip to content

Instantly share code, notes, and snippets.

View Armen101's full-sized avatar
🎯
Focusing

Armen Gevorgyan Armen101

🎯
Focusing
View GitHub Profile
import android.os.Build
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyProperties
import androidx.annotation.RequiresApi
import com.paylican.invoice.models.CipherTextWrapper
import java.lang.Exception
import java.security.KeyStore
import javax.crypto.Cipher
import javax.crypto.KeyGenerator
@Armen101
Armen101 / ReentrantLockDemonstration.kt
Last active August 20, 2020 16:23
ReentrantLock Demonstration
fun demonstrate() {
val commonResource = CommonResource()
val locker = ReentrantLock()
for (i in 1..5) {
val t = Thread(CountThread(commonResource, locker))
t.name = "Thread $i"
t.start()
}
}
@Armen101
Armen101 / AudioRecordViewUpdate.kt
Created January 9, 2020 13:52
Add or update last chunk of AudioRecordView
timer = Timer()
timer?.schedule(object : TimerTask() {
override fun run() {
val currentMaxAmplitude = recorder?.maxAmplitude
audioRecordView.update(currentMaxAmplitude); //redraw view
}
}, 0, 100)
<com.visualizer.amplitude.AudioRecordView
android:id="@+id/audioRecordView"
android:layout_width="256dp"
android:layout_height="64dp"
app:chunkAlignTo="bottom"
app:chunkRoundedCorners="true"
app:chunkSoftTransition="true"
app:chunkColor="#2196F3"
app:chunkSpace="1dp"
app:chunkWidth="2dp"
@Armen101
Armen101 / FindAudioRecordView.kt
Last active January 9, 2020 13:44
AudioRecordView using sample
private lateinit var audioRecordView: AudioRecordView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
audioRecordView = findViewById(R.id.audioRecordView)
}