Skip to content

custom animations added to fragments #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
/captures
.externalNativeBuild
.cxx
/.idea/codeStyles
.idea/gradle.xml
16 changes: 16 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 56 additions & 51 deletions app/src/main/java/com/anant/codingguide/activity/ControlActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.anant.codingguide.activity

//import android.widget.Toolbar

import android.content.DialogInterface
import android.os.Bundle
Expand All @@ -17,6 +16,8 @@ import com.anant.codingguide.R
import com.anant.codingguide.fragment.*
import com.google.android.material.navigation.NavigationView
import androidx.appcompat.app.AlertDialog.Builder
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction


class ControlActivity : AppCompatActivity() {
Expand All @@ -27,7 +28,7 @@ class ControlActivity : AppCompatActivity() {
lateinit var toolbar: Toolbar
lateinit var frameLayout: FrameLayout
lateinit var navigationView: NavigationView
var previousMenuItem:MenuItem?=null
var previousMenuItem: MenuItem? = null


override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -41,69 +42,65 @@ class ControlActivity : AppCompatActivity() {
navigationView = findViewById(R.id.navigationView)

openHome()
supportActionBar?.title="Home"
supportActionBar?.title = "Home"


setUpToolbar()

val actionBarDrawerToggle=ActionBarDrawerToggle(this@ControlActivity,drawerLayout,R.string.open_drawer,R.string.close_drawer)
val actionBarDrawerToggle = ActionBarDrawerToggle(
this@ControlActivity,
drawerLayout,
R.string.open_drawer,
R.string.close_drawer
)
drawerLayout.addDrawerListener(actionBarDrawerToggle)
actionBarDrawerToggle.syncState()

navigationView.setNavigationItemSelectedListener {


if(previousMenuItem != null){
previousMenuItem?.isChecked=false
if (previousMenuItem != null) {
previousMenuItem?.isChecked = false
}
it.isCheckable=true
it.isChecked=true
previousMenuItem=it

when(it.itemId)
{
R.id.home->{
openHome()
it.isCheckable = true
it.isChecked = true
previousMenuItem = it


when (it.itemId) {
R.id.home -> {
openHome()
drawerLayout.closeDrawers()

}

R.id.language->{
supportFragmentManager.beginTransaction().replace(R.id.frame,
LanguagesFragment()
).commit()
supportActionBar?.title="Programming languages"
R.id.language -> {
setUpFragment(LanguagesFragment())
supportActionBar?.title = "Programming languages"
drawerLayout.closeDrawers()
}

R.id.dev->{
supportFragmentManager.beginTransaction().replace(R.id.frame,
DevelopmentFragment()
).commit()
supportActionBar?.title="Software Development"
R.id.dev -> {
setUpFragment(DevelopmentFragment())
supportActionBar?.title = "Software Development"
drawerLayout.closeDrawers()
}

R.id.quest->{
supportFragmentManager.beginTransaction().replace(R.id.frame,
CompetitiveProgrammingFragment()
).commit()
supportActionBar?.title="Competitive programming"
R.id.quest -> {
setUpFragment(CompetitiveProgrammingFragment())
supportActionBar?.title = "Competitive programming"
drawerLayout.closeDrawers()
}



R.id.compiler->{
supportFragmentManager.beginTransaction().replace(R.id.frame,
CompilerFragment()
).commit()
supportActionBar?.title="Test your Code"
R.id.compiler -> {
setUpFragment(CompilerFragment())
supportActionBar?.title = "Test your Code"
drawerLayout.closeDrawers()
}


R.id.exit->{
R.id.exit -> {
val builder: android.app.AlertDialog.Builder =
android.app.AlertDialog.Builder(this@ControlActivity)
builder.setTitle(R.string.app_name)
Expand All @@ -119,7 +116,6 @@ class ControlActivity : AppCompatActivity() {
}



}


Expand All @@ -132,45 +128,54 @@ class ControlActivity : AppCompatActivity() {

}

fun setUpToolbar(){
fun setUpToolbar() {
setSupportActionBar(toolbar)
//supportActionBar?.title="Toolbar Title"
//supportActionBar?.title="Toolbar Title"
supportActionBar?.setHomeButtonEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}

fun setUpFragment(fragment: Fragment){
val manager = supportFragmentManager.beginTransaction()
manager.setCustomAnimations(
R.anim.slide_in,
R.anim.slide_out)

manager.replace(
R.id.frame,
fragment
)
manager.commit()
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
val id=item.itemId
if(id==android.R.id.home)
{
val id = item.itemId
if (id == android.R.id.home) {
drawerLayout.openDrawer(GravityCompat.START)
}
return super.onOptionsItemSelected(item)
}

fun openHome()
{
val fragment=HomeFragment()
val transaction=supportFragmentManager.beginTransaction()
transaction.replace(R.id.frame,fragment)
fun openHome() {
val fragment = HomeFragment()
val transaction = supportFragmentManager.beginTransaction()
transaction.replace(R.id.frame, fragment)
transaction.commit()
supportActionBar?.title="Home"
supportActionBar?.title = "Home"
navigationView.setCheckedItem(R.id.home)
}

override fun onBackPressed() {
val frag = supportFragmentManager.findFragmentById(R.id.frame)

when(frag){
when (frag) {
!is HomeFragment -> openHome()

else -> super.onBackPressed()
}
}




}


7 changes: 7 additions & 0 deletions app/src/main/res/anim/slide_in.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="0%"
android:fromYScale="0%"
android:toXScale="100%"
android:toYScale="100%"/>
7 changes: 7 additions & 0 deletions app/src/main/res/anim/slide_out.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="100%"
android:fromYScale="100%"
android:toXScale="0%"
android:toYScale="0%"/>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/mybutton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
android:shape="rectangle" >

<solid android:color="#20b6d9"/>
<corners android:radius="150dp"/>
<corners android:radius="8dp"/>

</shape>
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:elevation="0dp">


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbdefb"
android:background="@color/blueOcean"
tools:context=".activity.SplashActivity">


Expand Down
11 changes: 7 additions & 4 deletions app/src/main/res/layout/activity_welcome.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.WelcomeActivity"
android:background="#bbdefb">
android:background="@color/blueOcean">


<TextView
Expand All @@ -15,14 +15,16 @@
android:text="@string/welcome_to_coding_guide"
android:layout_centerHorizontal="true"
android:textSize="28sp"
android:textColor="#1a237e"
android:textStyle="bold"
android:textColor="@color/colorPrimaryDark"
android:padding="16dp"
android:layout_marginTop="40dp" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/cod"
android:elevation="4dp"
android:layout_below="@id/txtWelcome"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"/>
Expand All @@ -33,9 +35,10 @@
android:layout_height="wrap_content"
android:layout_below="@id/txtWelcome"
android:layout_centerInParent="true"
android:elevation="4dp"
android:layout_marginTop="300dp"
android:background="@color/colorPrimary"
android:textColor="#000000"
android:background="@drawable/mybutton"
android:textColor="@color/white"
android:text="Get Started"/>


Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/drawer_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
android:layout_below="@id/imgLogo"
android:textSize="38sp"
android:layout_centerInParent="true"
android:textColor="@color/colorPrimaryDark" />
android:textStyle="bold"
android:textColor="@color/white" />

</RelativeLayout>
12 changes: 9 additions & 3 deletions app/src/main/res/layout/fragment_competitiveprogramming.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.CompetitiveProgrammingFragment"
android:background="#bbdefb">
android:background="@color/blueOcean">


<TextView
Expand Down Expand Up @@ -228,4 +232,6 @@



</RelativeLayout>
</RelativeLayout>

</androidx.core.widget.NestedScrollView>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_compiler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.CompilerFragment"
android:background="#bbdefb">
android:background="@color/blueOcean">

<TextView
android:id="@+id/txtReady"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_development.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbdefb">
android:background="@color/blueOcean">

<RelativeLayout
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#bbdefb"
android:background="@color/blueOcean"
tools:context=".fragment.HomeFragment">


Expand Down
Loading