Skip to content

Commit

Permalink
project ongoing - fragments created
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryUdorji committed May 3, 2021
1 parent 385e9cc commit f0a5490
Show file tree
Hide file tree
Showing 23 changed files with 397 additions and 31 deletions.
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
android:roundIcon="@drawable/ic_app_logo"
android:supportsRtl="true"
android:theme="@style/SplashTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:label=""
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/com/henryudorji/theater/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@ package com.henryudorji.theater
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import com.henryudorji.theater.adapters.ViewpagerAdapter
import com.henryudorji.theater.databinding.ActivityMainBinding
import com.henryudorji.theater.ui.fragments.HomeFragment
import com.henryudorji.theater.ui.fragments.MoviesFragment
import com.henryudorji.theater.ui.fragments.TrendingFragment
import com.henryudorji.theater.ui.fragments.TvSeriesFragment

class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setTheme(R.style.Theme_Theater)
setContentView(R.layout.activity_main)

binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.henryudorji.theater.adapters

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentPagerAdapter
import androidx.viewpager2.adapter.FragmentStateAdapter

//
// Created by hash on 5/2/2021.
//
class ViewpagerAdapter(
fragment: Fragment,
private val fragments: MutableList<Fragment>
): FragmentStateAdapter(fragment) {

override fun getItemCount(): Int {
return fragments.size
}

override fun createFragment(position: Int): Fragment {
return fragments[position]
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.henryudorji.theater.data.remote

//
// Created by hash on 5/2/2021.
//
interface ServiceApi {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.henryudorji.theater.data.remote

//
// Created by hash on 5/2/2021.
//
class ServiceGenerator {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.henryudorji.theater.ui.fragments

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.google.android.material.tabs.TabLayoutMediator
import com.henryudorji.theater.R
import com.henryudorji.theater.adapters.ViewpagerAdapter
import com.henryudorji.theater.databinding.FragmentHomeBinding

//
// Created by hash on 5/2/2021.
//
class HomeFragment: Fragment(R.layout.fragment_home) {
private lateinit var binding: FragmentHomeBinding
private lateinit var viewpagerAdapter: ViewpagerAdapter
private lateinit var fragments: MutableList<Fragment>
private var tabLayoutMediator: TabLayoutMediator? = null

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentHomeBinding.bind(view)

initViews()
}

private fun initViews() {
fragments = mutableListOf(
MoviesFragment(),
TvSeriesFragment(),
TrendingFragment()
)
viewpagerAdapter = ViewpagerAdapter(this, fragments)
binding.viewpager.adapter = viewpagerAdapter

TabLayoutMediator(binding.tabs, binding.viewpager) {tab, position ->
when(position) {
0 -> tab.text = "MOVIES"
1 -> tab.text = "TV SERIES"
2 -> tab.text = "TRENDING"
}
binding.viewpager.currentItem = tab.position
}.attach()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.henryudorji.theater.ui.fragments

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.henryudorji.theater.R
import com.henryudorji.theater.databinding.FragmentHomeBinding
import com.henryudorji.theater.databinding.FragmentMovieDetailBinding

//
// Created by hash on 5/2/2021.
//
class MovieDetailFragment: Fragment(R.layout.fragment_movie_detail) {
private lateinit var binding: FragmentMovieDetailBinding

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentMovieDetailBinding.bind(view)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.henryudorji.theater.ui.fragments

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.henryudorji.theater.R
import com.henryudorji.theater.databinding.FragmentHomeBinding
import com.henryudorji.theater.databinding.FragmentMovieDetailBinding
import com.henryudorji.theater.databinding.FragmentMovieListBinding

//
// Created by hash on 5/2/2021.
//
class MovieListFragment: Fragment(R.layout.fragment_movie_list) {
private lateinit var binding: FragmentMovieListBinding

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentMovieListBinding.bind(view)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.henryudorji.theater.ui.fragments

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.henryudorji.theater.R
import com.henryudorji.theater.databinding.FragmentHomeBinding
import com.henryudorji.theater.databinding.FragmentMovieDetailBinding

//
// Created by hash on 5/2/2021.
//
class MoviesFragment: Fragment(R.layout.fragment_home_detail) {
private lateinit var binding: FragmentMovieDetailBinding

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentMovieDetailBinding.bind(view)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.henryudorji.theater.ui.fragments

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.henryudorji.theater.R
import com.henryudorji.theater.databinding.FragmentHomeBinding
import com.henryudorji.theater.databinding.FragmentMovieDetailBinding

//
// Created by hash on 5/2/2021.
//
class TrendingFragment: Fragment(R.layout.fragment_home_detail) {
private lateinit var binding: FragmentMovieDetailBinding

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentMovieDetailBinding.bind(view)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.henryudorji.theater.ui.fragments

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import com.henryudorji.theater.R
import com.henryudorji.theater.databinding.FragmentHomeBinding
import com.henryudorji.theater.databinding.FragmentMovieDetailBinding

//
// Created by hash on 5/2/2021.
//
class TvSeriesFragment: Fragment(R.layout.fragment_home_detail) {
private lateinit var binding: FragmentMovieDetailBinding

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentMovieDetailBinding.bind(view)
}
}
9 changes: 9 additions & 0 deletions app/src/main/java/com/henryudorji/theater/utils/Resource.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.henryudorji.theater.utils

//
// Created by hash on 5/2/2021.
//
class Resource(

) {
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/edit_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@color/app_background_color"/>
<corners android:radius="@dimen/_5sdp"/>
<stroke android:width="@dimen/_1sdp"
android:color="@color/red"/>

</shape>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="@color/white"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>
28 changes: 19 additions & 9 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<fragment
android:id="@+id/navHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:navGraph="@navigation/nav_graph" />

</FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
59 changes: 59 additions & 0 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/app_background_color"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/app_background_color"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/searchEdit"
android:hint="Search..."
android:inputType="text"
android:fontFamily="@font/raleway_regular"
android:textColorHint="@color/white"
android:textColor="@color/white"
android:padding="@dimen/_10sdp"
android:drawableEnd="@drawable/ic_search"
android:layout_marginTop="@dimen/_10sdp"
android:layout_marginStart="@dimen/_10sdp"
android:layout_marginEnd="@dimen/_10sdp"
android:background="@drawable/edit_bg"/>


<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:tabGravity="start"
app:tabMode="scrollable"
app:tabIndicatorFullWidth="false"
app:tabContentStart="0dp"
app:tabTextAppearance="@style/TabTextStyle"
app:tabIndicatorColor="@color/red"
app:tabTextColor="@color/gray"
app:tabSelectedTextColor="@color/white"
android:background="@color/app_background_color"/>
</com.google.android.material.appbar.AppBarLayout>

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/appBar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_home_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/app_background_color">

<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/genreRecyclerView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit f0a5490

Please sign in to comment.