Mercurial > dwindows
comparison android/DWindows.kt @ 2499:ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
Seems like my dream of having a single C entrypoint for events
is dead, passing any NULL objects for unused parameters results
in a sementation violation. Leaving the general purpose function
in the code for now, but eventually it will go away.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 05 May 2021 19:53:33 +0000 |
parents | 4ae2b3b77f25 |
children | ac0b7e579229 |
comparison
equal
deleted
inserted
replaced
2498:4ae2b3b77f25 | 2499:ff3310fa6d72 |
---|---|
22 import android.widget.SeekBar.OnSeekBarChangeListener | 22 import android.widget.SeekBar.OnSeekBarChangeListener |
23 import androidx.appcompat.app.AlertDialog | 23 import androidx.appcompat.app.AlertDialog |
24 import androidx.appcompat.app.AppCompatActivity | 24 import androidx.appcompat.app.AppCompatActivity |
25 import androidx.collection.SimpleArrayMap | 25 import androidx.collection.SimpleArrayMap |
26 import androidx.recyclerview.widget.RecyclerView | 26 import androidx.recyclerview.widget.RecyclerView |
27 import androidx.viewpager.widget.ViewPager | |
27 import androidx.viewpager2.widget.ViewPager2 | 28 import androidx.viewpager2.widget.ViewPager2 |
28 import com.google.android.material.tabs.TabLayout | 29 import com.google.android.material.tabs.TabLayout |
29 import com.google.android.material.tabs.TabLayout.OnTabSelectedListener | 30 import com.google.android.material.tabs.TabLayout.OnTabSelectedListener |
30 import com.google.android.material.tabs.TabLayoutMediator | 31 import com.google.android.material.tabs.TabLayoutMediator |
31 import java.util.* | 32 import java.util.* |
50 class DWEventViewHolder(var view: View) : RecyclerView.ViewHolder(view) | 51 class DWEventViewHolder(var view: View) : RecyclerView.ViewHolder(view) |
51 } | 52 } |
52 | 53 |
53 class DWindows : AppCompatActivity() { | 54 class DWindows : AppCompatActivity() { |
54 var firstWindow: Boolean = true | 55 var firstWindow: Boolean = true |
56 var windowLayout: LinearLayout? = null | |
55 | 57 |
56 // We only want to call this once when the app starts up | 58 // We only want to call this once when the app starts up |
57 // By default Android will call onCreate for rotation and other | 59 // By default Android will call onCreate for rotation and other |
58 // changes. This is incompatible with Dynamic Windows... | 60 // changes. This is incompatible with Dynamic Windows... |
59 // Make sure the following is in your AndroidManifest.xml | 61 // Make sure the following is in your AndroidManifest.xml |
76 } | 78 } |
77 | 79 |
78 override fun onConfigurationChanged(newConfig: Configuration) { | 80 override fun onConfigurationChanged(newConfig: Configuration) { |
79 super.onConfigurationChanged(newConfig) | 81 super.onConfigurationChanged(newConfig) |
80 | 82 |
81 // Checks the orientation of the screen | 83 // Send a DW_SIGNAL_CONFIGURE on orientation change |
82 if (newConfig.orientation === Configuration.ORIENTATION_LANDSCAPE) { | 84 if(windowLayout != null) { |
83 Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show() | 85 var width: Int = windowLayout!!.width |
84 } else if (newConfig.orientation === Configuration.ORIENTATION_PORTRAIT) { | 86 var height: Int = windowLayout!!.height |
85 Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show() | 87 |
88 eventHandlerInt(windowLayout as View, 1, width, height, 0, 0) | |
86 } | 89 } |
87 } | 90 } |
88 | 91 |
89 /* | 92 /* |
90 * These are the Android calls to actually create the UI... | 93 * These are the Android calls to actually create the UI... |
91 * forwarded from the C Dynamic Windows API | 94 * forwarded from the C Dynamic Windows API |
92 */ | 95 */ |
93 fun windowNew(title: String, style: Int): LinearLayout? { | 96 fun windowNew(title: String, style: Int): LinearLayout? { |
94 if (firstWindow) { | 97 if (firstWindow) { |
95 var windowLayout: LinearLayout = LinearLayout(this) | |
96 var dataArrayMap = SimpleArrayMap<String, Long>() | 98 var dataArrayMap = SimpleArrayMap<String, Long>() |
97 | 99 windowLayout = LinearLayout(this) |
98 windowLayout.tag = dataArrayMap | 100 |
101 windowLayout!!.tag = dataArrayMap | |
99 setContentView(windowLayout) | 102 setContentView(windowLayout) |
100 this.title = title | 103 this.title = title |
101 // For now we just return our DWindows' main activity layout... | 104 // For now we just return our DWindows' main activity layout... |
102 // in the future, later calls should create new activities | 105 // in the future, later calls should create new activities |
103 firstWindow = false | 106 firstWindow = false |
737 * Native methods that are implemented by the 'dwindows' native library, | 740 * Native methods that are implemented by the 'dwindows' native library, |
738 * which is packaged with this application. | 741 * which is packaged with this application. |
739 */ | 742 */ |
740 external fun dwindowsInit(dataDir: String) | 743 external fun dwindowsInit(dataDir: String) |
741 external fun eventHandler( | 744 external fun eventHandler( |
742 obj1: View, | 745 obj1: View?, |
743 obj2: View?, | 746 obj2: View?, |
744 message: Int, | 747 message: Int, |
745 str1: String?, | 748 str1: String?, |
746 str2: String?, | 749 str2: String?, |
747 int1: Int, | 750 inta: Int, |
748 int2: Int, | 751 intb: Int, |
749 int3: Int, | 752 intc: Int, |
750 int4: Int | 753 intd: Int |
751 ): Int | 754 ): Int |
755 external fun eventHandlerInt( | |
756 obj1: View, | |
757 message: Int, | |
758 inta: Int, | |
759 intb: Int, | |
760 intc: Int, | |
761 intd: Int | |
762 ) | |
752 external fun eventHandlerSimple(obj1: View, message: Int) | 763 external fun eventHandlerSimple(obj1: View, message: Int) |
753 external fun eventHandlerNotebook(obj1: View, message: Int, pageID: Long) | 764 external fun eventHandlerNotebook(obj1: View, message: Int, pageID: Long) |
754 external fun eventHandlerTimer(sigfunc: Long, data: Long): Int | 765 external fun eventHandlerTimer(sigfunc: Long, data: Long): Int |
755 | 766 |
756 companion object | 767 companion object |