Skip to content

Commit

Permalink
Binding
Browse files Browse the repository at this point in the history
  • Loading branch information
whyfoo committed Dec 2, 2021
1 parent 39a369c commit 86e7dc2
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

5 changes: 3 additions & 2 deletions .idea/gradle.xml

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

204 changes: 204 additions & 0 deletions .idea/intellij-javadocs-4.0.1.xml

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

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

9 changes: 3 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
android:name=".ui.profile.ProfileActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
<activity
android:name=".ui.home.HomeFailedActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
android:name=".ui.home.HomeFailedActivity" />
<activity
android:name=".ui.home.HomeSuccessActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
android:name=".ui.home.HomeSuccessActivity" />
<activity
android:name=".ui.home.HomeActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
android:name=".ui.home.HomeActivity" />
<activity
android:name=".ui.signup.SignUpActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/com/trolle/trolleapp/ui/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ package com.trolle.trolleapp.ui.home

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.widget.Toast
import com.trolle.trolleapp.R

class HomeActivity : AppCompatActivity() {

private var backPressed: Boolean = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
Expand All @@ -16,4 +22,16 @@ class HomeActivity : AppCompatActivity() {
setLogo(R.drawable.menglogo)
}
}

override fun onBackPressed() {
if (backPressed) {
super.onBackPressed()
return
}
this.backPressed = true
Toast.makeText(this, "Press back again to exit", Toast.LENGTH_SHORT).show()
Handler(Looper.getMainLooper()).postDelayed({
this.backPressed = false
}, 2000)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,27 @@ import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import com.trolle.trolleapp.R
import com.trolle.trolleapp.databinding.ActivitySignInBinding
import com.trolle.trolleapp.ui.home.HomeActivity
import com.trolle.trolleapp.ui.main.MainActivity
import com.trolle.trolleapp.ui.signup.SignUpActivity

class SignInActivity : AppCompatActivity() {

private lateinit var binding: ActivitySignInBinding
private var backPressed: Boolean = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sign_in)
binding = ActivitySignInBinding.inflate(layoutInflater)
setContentView(binding.root)

val signinButton = findViewById<Button>(R.id.button_sign_in)
signinButton.setOnClickListener {
binding.buttonSignIn.setOnClickListener {
startActivity(Intent(this, HomeActivity::class.java))
finish()
}

val signupButton = findViewById<TextView>(R.id.text_view_then_sign_up)
signupButton.setOnClickListener {
binding.textViewThenSignUp.setOnClickListener{
startActivity(Intent(this, SignUpActivity::class.java))
}
}
Expand Down
19 changes: 7 additions & 12 deletions app/src/main/java/com/trolle/trolleapp/ui/signup/SignUpActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,23 @@ import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.widget.TextView
import android.widget.Toast
import com.trolle.trolleapp.R
import com.trolle.trolleapp.databinding.ActivitySignUpBinding

class SignUpActivity : AppCompatActivity() {

private var backPressed: Boolean = false
private lateinit var binding: ActivitySignUpBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sign_up)
}
binding = ActivitySignUpBinding.inflate(layoutInflater)
setContentView(binding.root)

override fun onBackPressed() {
if (backPressed) {
super.onBackPressed()
return
binding.textViewThenSignIn.setOnClickListener{
finish()
}
this.backPressed = true
Toast.makeText(this, "Press back again to exit", Toast.LENGTH_SHORT).show()
Handler(Looper.getMainLooper()).postDelayed({
this.backPressed = false
}, 2000)
}

}
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string name="connection_failed">Connection Failed</string>
<string name="click_here_to_retry">Click <u>Here</u> to Retry</string>
<string name="sign_up_underline"><u>Sign Up</u></string>
<string name="sign_in_underline"><u>Sign In</u>u></string>
<string name="sign_in_underline"><u>Sign In</u></string>
<string name="username_dummy">johndoe</string>
<string name="email_dummy">[email protected]</string>
<string name="see_shopping_history">See Shopping History</string>
Expand Down

0 comments on commit 86e7dc2

Please sign in to comment.