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
| public class Main { | |
| public static void main(String[] args) { | |
| Printer p = new Printer(); | |
| Thread t1 = new NumberPrinter(p); | |
| Thread t2 = new LetterPrinter(p); | |
| t1.start(); | |
| t2.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
| package suzp1984.github.io.exapidemo.animation | |
| import android.graphics.Camera | |
| import android.view.animation.Animation | |
| import android.view.animation.Transformation | |
| class FlipAnimation(fromDegre: Float, toDegre: Float, centerX : Float, centerY : Float) : Animation() { | |
| var fromDegree : Float = 0.0f | |
| var toDegree : Float = 0.0f |
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 |
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
| <?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
| 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
| # 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
| 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
| 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
| func listenDefaultAudioInputDeviceChanged() { | |
| var audioInputAddress = AudioObjectPropertyAddress( | |
| mSelector: kAudioHardwarePropertyDefaultInputDevice, | |
| mScope: kAudioObjectPropertyScopeGlobal, | |
| mElement: kAudioObjectPropertyElementMaster) | |
| let status = AudioObjectAddPropertyListenerBlock(AudioObjectID(kAudioObjectSystemObject), | |
| &audioInputAddress, DispatchQueue.main) { | |
| inNumberAddress, inAddress in |
OlderNewer