Update to JDK 17, Gradle 7.3.3 & Android Gradle Plugin 7.1.0
Signed-off-by: psavarmattas <puranjaysavarmattas@gmail.com>
This commit is contained in:
@@ -8,34 +8,41 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.example.chatcom.mainScreens.Chats
|
||||
import com.example.chatcom.mainScreens.Contacts
|
||||
import com.example.chatcom.mainScreens.Settings
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var viewPager2: ViewPager2
|
||||
private lateinit var tabLayout : TabLayout
|
||||
private lateinit var toolbar: androidx.appcompat.widget.Toolbar
|
||||
private lateinit var appPagerAdapter: AppPagerAdapter
|
||||
private var titles = arrayListOf("Chats","Contacts","Settings")
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
toolbar = findViewById(R.id.toolbarMain)
|
||||
tabLayout = findViewById(R.id.tabLayoutMain)
|
||||
viewPager2 = findViewById(R.id.viewPager2Main)
|
||||
toolbar.title = "ChatCom"
|
||||
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
appPagerAdapter = AppPagerAdapter( this)
|
||||
viewPager2.adapter = appPagerAdapter
|
||||
|
||||
TabLayoutMediator(tabLayout,viewPager2){
|
||||
tab,position->
|
||||
tab.text = titles[position]
|
||||
}.attach()
|
||||
|
||||
|
||||
}
|
||||
class AppPagerAdapter(fragmentActivity: FragmentActivity):FragmentStateAdapter(fragmentActivity)
|
||||
{
|
||||
|
||||
class AppPagerAdapter(fragmentActivity: FragmentActivity):FragmentStateAdapter(fragmentActivity) {
|
||||
override fun getItemCount(): Int {
|
||||
return 3
|
||||
}
|
||||
@@ -43,13 +50,12 @@ class MainActivity : AppCompatActivity() {
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return when(position)
|
||||
{
|
||||
0->Chats()
|
||||
2->Contacts()
|
||||
3->Settings()
|
||||
0-> Chats()
|
||||
2-> Contacts()
|
||||
3-> Settings()
|
||||
else -> Chats()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.example.chatcom
|
||||
package com.example.chatcom.mainScreens
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.example.chatcom.R
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.example.chatcom
|
||||
package com.example.chatcom.mainScreens
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.example.chatcom.R
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.example.chatcom
|
||||
package com.example.chatcom.mainScreens
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.example.chatcom.R
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Chats">
|
||||
tools:context=".mainScreens.Chats">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Contacts">
|
||||
tools:context=".mainScreens.Contacts">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Settings">
|
||||
tools:context=".mainScreens.Settings">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
|
||||
Reference in New Issue
Block a user