Lets try with getIdentifier :(

This commit is contained in:
Blatzar 2022-08-18 19:36:26 +02:00
parent ca915ebc7e
commit 2f1774a844
2 changed files with 20 additions and 15 deletions

View File

@ -29,20 +29,25 @@ class NginxSettingsFragment(private val plugin: Plugin, val nginxApi: NginxApi)
return inflater.inflate(layout, container, false)
}
private fun <T : View> View.findView(name: String): T {
val id = plugin.resources!!.getIdentifier(name, "id", "com.lagradost")
return this.findViewById(id)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val infoView = view.findViewWithTag<LinearLayout>("nginx_info")
val infoTextView = view.findViewWithTag<TextView>("info_main_text")
val infoSubTextView = view.findViewWithTag<TextView>("info_sub_text")
val infoImageView = view.findViewWithTag<ImageView>("nginx_info_imageview")
val infoView = view.findView<LinearLayout>("nginx_info")
val infoTextView = view.findView<TextView>("info_main_text")
val infoSubTextView = view.findView<TextView>("info_sub_text")
val infoImageView = view.findView<ImageView>("nginx_info_imageview")
infoTextView.text = getString(nginx_info_title)
infoSubTextView.text = getString(nginx_info_summary)
infoImageView.setImageResource(nginx_question)
val loginView = view.findViewWithTag<LinearLayout>("nginx_login")
val loginTextView = view.findViewWithTag<TextView>("main_text")
val loginImageView = view.findViewWithTag<ImageView>("nginx_login_imageview")
val loginView = view.findView<LinearLayout>("nginx_login")
val loginTextView = view.findView<TextView>("main_text")
val loginImageView = view.findView<ImageView>("nginx_login_imageview")
loginImageView.setImageResource(nginx)
// object : View.OnClickListener is required to make it compile because otherwise it used invoke-customs

View File

@ -2,20 +2,20 @@
<LinearLayout 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:tag="@+id/settings_root"
android:id="@+id/settings_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:tag="@+id/nginx_login"
android:id="@+id/nginx_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="20dp">
<ImageView
android:tag="@+id/nginx_login_imageview"
android:id="@+id/nginx_login_imageview"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="start|center_vertical"
@ -34,7 +34,7 @@
<!-- android:orientation="horizontal">-->
<TextView
android:tag="@+id/main_text"
android:id="@+id/main_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
@ -51,14 +51,14 @@
<LinearLayout
android:tag="@+id/nginx_info"
android:id="@+id/nginx_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="20dp">
<ImageView
android:tag="@+id/nginx_info_imageview"
android:id="@+id/nginx_info_imageview"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="start|center_vertical"
@ -77,14 +77,14 @@
android:orientation="horizontal">
<TextView
android:tag="@+id/info_main_text"
android:id="@+id/info_main_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp" />
</LinearLayout>
<TextView
android:tag="@+id/info_sub_text"
android:id="@+id/info_sub_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp" />