# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1620206108 0 # Node ID 4ae2b3b77f25dc53402d54174dd582dd80719bd5 # Parent 7b210f156eefc28d9597bf2684accb54b8ef04b8 Android: Get the notebook control functional. Disable recylcing of the views. Even though we are using the RecylerView we don't actually want the views recycled. Attempt to prevent the activity from restarting immediately in the simulator by enabling the required options in the AndroidManifest.xml. This didn't work so I am putting that ugly workaround back in, since in the simulator we get called twice and we want to actually run dwmain() on the second call in the simulator. diff -r 7b210f156eef -r 4ae2b3b77f25 android/AndroidManifest.xml --- a/android/AndroidManifest.xml Wed May 05 01:19:21 2021 +0000 +++ b/android/AndroidManifest.xml Wed May 05 09:15:08 2021 +0000 @@ -10,7 +10,9 @@ android:supportsRtl="true" android:theme="@style/Theme.Dwtest"> + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden" + android:screenOrientation="fullSensor" + android:persistent="true"> diff -r 7b210f156eef -r 4ae2b3b77f25 android/DWindows.kt --- a/android/DWindows.kt Wed May 05 01:19:21 2021 +0000 +++ b/android/DWindows.kt Wed May 05 09:15:08 2021 +0000 @@ -23,7 +23,6 @@ import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.collection.SimpleArrayMap -import androidx.core.view.marginStart import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.tabs.TabLayout @@ -38,43 +37,42 @@ public var currentPageID = 0L override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = - DWEventViewHolder(viewList.get(0)) + DWEventViewHolder(viewList.get(viewType)) override fun getItemCount() = viewList.count() + override fun getItemViewType(position: Int): Int { + return position + } override fun onBindViewHolder(holder: DWEventViewHolder, position: Int) { - //(holder.view as? TextView)?.also{ - // it.text = "Page " + eventList.get(position) - //} + holder.setIsRecyclable(false); } - class DWEventViewHolder(val view: View) : RecyclerView.ViewHolder(view) + class DWEventViewHolder(var view: View) : RecyclerView.ViewHolder(view) } class DWindows : AppCompatActivity() { var firstWindow: Boolean = true + // We only want to call this once when the app starts up + // By default Android will call onCreate for rotation and other + // changes. This is incompatible with Dynamic Windows... + // Make sure the following is in your AndroidManifest.xml + // android:configChanges="orientation|screenSize|screenLayout|keyboardHidden" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Turn on rotation setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR) - // We only want to call this once when the app starts up - // By default Android will call onCreate for rotation and other - // changes. This is incompatible with Dynamic Windows... - // Make sure the following is in your AndroidManifest.xml - // android:configChanges="orientation|screenSize|screenLayout|keyboardHidden" - if(savedInstanceState == null) { - // Get the Android app path - val m = packageManager - var s = packageName - val p = m.getPackageInfo(s!!, 0) - s = p.applicationInfo.dataDir + // Get the Android app path + val m = packageManager + var s = packageName + val p = m.getPackageInfo(s!!, 0) + s = p.applicationInfo.dataDir - // Initialize the Dynamic Windows code... - // This will start a new thread that calls the app's dwmain() - dwindowsInit(s) - } + // Initialize the Dynamic Windows code... + // This will start a new thread that calls the app's dwmain() + dwindowsInit(s) } override fun onConfigurationChanged(newConfig: Configuration) { @@ -399,7 +397,7 @@ pager.id = View.generateViewId() pager.adapter = DWTabViewPagerAdapter() TabLayoutMediator(tabs, pager) { tab, position -> - //tab.text = "OBJECT ${(position + 1)}" + // This code never gets called? }.attach() var params: RelativeLayout.LayoutParams = RelativeLayout.LayoutParams(w, h) diff -r 7b210f156eef -r 4ae2b3b77f25 android/dw.cpp --- a/android/dw.cpp Wed May 05 01:19:21 2021 +0000 +++ b/android/dw.cpp Wed May 05 09:15:08 2021 +0000 @@ -90,7 +90,11 @@ static int runcount = 0; /* Safety check to prevent multiple initializations... */ +#if defined(__arm__) || defined(__aarch64__) if(runcount == 0) +#else + if(runcount == 1) +#endif { char *arg = strdup(env->GetStringUTFChars((jstring) path, NULL));