Create "My Location" and "Live now" tabs
This commit is contained in:
parent
0619c13f24
commit
7827509e7a
6 changed files with 103 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
android:scrollbars="vertical"/>
|
android:scrollbars="vertical"/>
|
||||||
|
|
||||||
<net.osmand.telegram.ui.views.LockableViewPager
|
<net.osmand.telegram.ui.views.LockableViewPager
|
||||||
android:id="@+id/pager"
|
android:id="@+id/view_pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
@ -39,9 +40,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:itemBackground="?attr/bg_color"
|
app:itemBackground="?attr/bg_color"
|
||||||
app:menu="@menu/bottom_navigation_menu"
|
app:menu="@menu/bottom_navigation_menu"/>
|
||||||
tools:itemIconTint="@color/ctrl_active_color_light"
|
|
||||||
tools:itemTextColor="@color/ctrl_active_color_light"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
14
OsmAnd-telegram/res/layout/fragment_live_now_tab.xml
Normal file
14
OsmAnd-telegram/res/layout/fragment_live_now_tab.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Live Now"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
14
OsmAnd-telegram/res/layout/fragment_my_location_tab.xml
Normal file
14
OsmAnd-telegram/res/layout/fragment_my_location_tab.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="My Location"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -0,0 +1,16 @@
|
||||||
|
package net.osmand.telegram.ui
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v4.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import net.osmand.telegram.R
|
||||||
|
|
||||||
|
class LiveNowTabFragment : Fragment() {
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
val mainView = inflater.inflate(R.layout.fragment_live_now_tab, container, false)
|
||||||
|
return mainView
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,8 +8,11 @@ import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.support.design.widget.BottomNavigationView
|
||||||
import android.support.v4.app.ActivityCompat
|
import android.support.v4.app.ActivityCompat
|
||||||
import android.support.v4.app.DialogFragment
|
import android.support.v4.app.DialogFragment
|
||||||
|
import android.support.v4.app.FragmentManager
|
||||||
|
import android.support.v4.app.FragmentPagerAdapter
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.support.v7.widget.*
|
import android.support.v7.widget.*
|
||||||
|
@ -21,6 +24,7 @@ import net.osmand.telegram.TelegramApplication
|
||||||
import net.osmand.telegram.helpers.TelegramHelper
|
import net.osmand.telegram.helpers.TelegramHelper
|
||||||
import net.osmand.telegram.helpers.TelegramHelper.*
|
import net.osmand.telegram.helpers.TelegramHelper.*
|
||||||
import net.osmand.telegram.ui.LoginDialogFragment.LoginDialogType
|
import net.osmand.telegram.ui.LoginDialogFragment.LoginDialogType
|
||||||
|
import net.osmand.telegram.ui.views.LockableViewPager
|
||||||
import net.osmand.telegram.utils.AndroidUtils
|
import net.osmand.telegram.utils.AndroidUtils
|
||||||
import org.drinkless.td.libcore.telegram.TdApi
|
import org.drinkless.td.libcore.telegram.TdApi
|
||||||
|
|
||||||
|
@ -33,6 +37,9 @@ class MainActivity : AppCompatActivity(), TelegramListener {
|
||||||
private const val LOGIN_MENU_ID = 0
|
private const val LOGIN_MENU_ID = 0
|
||||||
private const val LOGOUT_MENU_ID = 1
|
private const val LOGOUT_MENU_ID = 1
|
||||||
private const val PROGRESS_MENU_ID = 2
|
private const val PROGRESS_MENU_ID = 2
|
||||||
|
|
||||||
|
private const val MY_LOCATION_TAB_POS = 0
|
||||||
|
private const val LIVE_NOW_TAB_POS = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
private val log = PlatformUtil.getLog(TelegramHelper::class.java)
|
private val log = PlatformUtil.getLog(TelegramHelper::class.java)
|
||||||
|
@ -70,6 +77,25 @@ class MainActivity : AppCompatActivity(), TelegramListener {
|
||||||
adapter = chatViewAdapter
|
adapter = chatViewAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val viewPager = findViewById<LockableViewPager>(R.id.view_pager).apply {
|
||||||
|
swipeLocked = true
|
||||||
|
offscreenPageLimit = 2
|
||||||
|
adapter = ViewPagerAdapter(supportFragmentManager)
|
||||||
|
}
|
||||||
|
|
||||||
|
findViewById<BottomNavigationView>(R.id.bottom_navigation).setOnNavigationItemSelectedListener {
|
||||||
|
var pos = -1
|
||||||
|
when (it.itemId) {
|
||||||
|
R.id.action_my_location -> pos = MY_LOCATION_TAB_POS
|
||||||
|
R.id.action_live_now -> pos = LIVE_NOW_TAB_POS
|
||||||
|
}
|
||||||
|
if (pos != -1 && pos != viewPager.currentItem) {
|
||||||
|
viewPager.currentItem = pos
|
||||||
|
return@setOnNavigationItemSelectedListener true
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
if (!LoginDialogFragment.welcomeDialogShown) {
|
if (!LoginDialogFragment.welcomeDialogShown) {
|
||||||
LoginDialogFragment.showWelcomeDialog(supportFragmentManager)
|
LoginDialogFragment.showWelcomeDialog(supportFragmentManager)
|
||||||
}
|
}
|
||||||
|
@ -373,6 +399,15 @@ class MainActivity : AppCompatActivity(), TelegramListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ViewPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) {
|
||||||
|
|
||||||
|
private val fragments = listOf(MyLocationTabFragment(), LiveNowTabFragment())
|
||||||
|
|
||||||
|
override fun getItem(position: Int) = fragments[position]
|
||||||
|
|
||||||
|
override fun getCount() = fragments.size
|
||||||
|
}
|
||||||
|
|
||||||
inner class ChatsAdapter :
|
inner class ChatsAdapter :
|
||||||
RecyclerView.Adapter<ChatsAdapter.ViewHolder>() {
|
RecyclerView.Adapter<ChatsAdapter.ViewHolder>() {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package net.osmand.telegram.ui
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v4.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import net.osmand.telegram.R
|
||||||
|
|
||||||
|
class MyLocationTabFragment : Fragment() {
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
val mainView = inflater.inflate(R.layout.fragment_my_location_tab, container, false)
|
||||||
|
return mainView
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue