This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private lazy var audioInputVolumeListener: AudioObjectPropertyListenerBlock = { | |
| return { _, _ in | |
| // report self.getDefaultAudioInputVolume() | |
| } | |
| }() | |
| private func listenDefaultAudioInputVolume() { | |
| var audioVolumeAddr = AudioObjectPropertyAddress( | |
| mSelector: kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, | |
| mScope: kAudioObjectPropertyScopeInput, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func getDefaultAudioInputVolume() -> Float32? { | |
| var audioVolumeAddr = AudioObjectPropertyAddress( | |
| mSelector: kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, | |
| mScope: kAudioObjectPropertyScopeInput, | |
| mElement: kAudioObjectPropertyElementMaster | |
| ) | |
| guard let audioInputDevice = getDefaultAudioInputDevice() else { | |
| return nil | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func listenDefaultAudioInputDeviceChanged() { | |
| var audioInputAddress = AudioObjectPropertyAddress( | |
| mSelector: kAudioHardwarePropertyDefaultInputDevice, | |
| mScope: kAudioObjectPropertyScopeGlobal, | |
| mElement: kAudioObjectPropertyElementMaster) | |
| let status = AudioObjectAddPropertyListenerBlock(AudioObjectID(kAudioObjectSystemObject), | |
| &audioInputAddress, DispatchQueue.main) { | |
| inNumberAddress, inAddress in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func getDefaultAudioInputDevice() -> AudioDeviceID? { | |
| var audioInputDevice: AudioDeviceID = 0 | |
| var audioInputAddress = AudioObjectPropertyAddress( | |
| mSelector: kAudioHardwarePropertyDefaultInputDevice, | |
| mScope: kAudioObjectPropertyScopeGlobal, | |
| mElement: kAudioObjectPropertyElementMaster) | |
| var propertySize = UInt32(MemoryLayout.size(ofValue: audioInputDevice)) | |
| if AudioObjectGetPropertyData(AudioObjectID(kAudioObjectSystemObject), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| buildscript { | |
| repositories { | |
| jcenter() | |
| google() | |
| } | |
| dependencies { | |
| classpath 'com.android.tools.build:gradle:3.0.1' | |
| // NOTE: Do not place your application dependencies here; they belong | |
| // in the individual module build.gradle files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Tip 1: Use the lastes Android Gradle plugin | |
| buildscript { | |
| repositories { | |
| jcenter() | |
| maven { url 'http://maven.google.com' } | |
| } | |
| dependencies { | |
| classpath 'com.android.tools.build:gradle:3.0.0-alpha1' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| val box1 = findViewById(R.id.checkbox1) | |
| val box1Parent = findViewById(R.id.checkbox1_container) | |
| val box2 = findViewById(R.id.checkbox2) | |
| val box2Parent = findViewById(R.id.checkbox2_container) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:context="io.github.suzp1984.delegatetouchdemo.MainActivity"> | |
| <android.support.v7.widget.CardView | |
| android:id="@+id/box_container" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| flipCardView.pivotX = 0.0f | |
| flipCardView.pivotY = flipCardView.height / 2.0f | |
| val animator = ObjectAnimator.ofFloat(flipCardView, "rotationY", startDeg, endDeg) | |
| animator.setDuration(1000); | |
| animator.interpolator = AccelerateInterpolator() | |
| animator.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val animation = FlipAnimation(startAngor, endAngor, 0.0f, flipCardView.height / 2.0f) | |
| animation.duration = 1000 | |
| animation.interpolator = AccelerateInterpolator() | |
| animation.fillAfter = true | |
| animation.setAnimationListener(object : Animation.AnimationListener { | |
| override fun onAnimationRepeat(animation: Animation?) { | |
| } | |
| override fun onAnimationEnd(animation: Animation?) { | |
| // flipCardView.rotationY = endAngor |