-
Notifications
You must be signed in to change notification settings - Fork 1
Vh tuan #10
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
hidenobi
wants to merge
23
commits into
master
Choose a base branch
from
VHTuan
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Vh tuan #10
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
00b4615
First commit
hidenobi d7c2ec8
First commit
hidenobi cb75b9a
First commit
hidenobi 13be504
Commit UI
hidenobi fafa385
Commit UI
hidenobi 38311dd
Commit UI
hidenobi 70edbdb
Commit UI
hidenobi e66af95
Commit UI
hidenobi deaa023
Commit UI
hidenobi cb335fd
Commit UI
hidenobi 59cffb1
Merge remote-tracking branch 'origin/VHTuan' into VHTuan
hidenobi 9cba247
Commit UI
hidenobi 683a3a9
Commit UI
hidenobi 73de98f
Đang lỗi
hidenobi 19b5a57
Đang lỗi
hidenobi 178d1dd
Đang lỗi
hidenobi d83efde
None Done
hidenobi 27b437d
None Done
hidenobi 2cdd02c
Lỗi truyền từ Fragment sang Activity
hidenobi 1f28ba4
Lỗi truyền từ Fragment sang Activity
hidenobi 5e6e80a
Chưa xử lý Data
hidenobi 060aae1
Chưa xử lý Data
hidenobi 5ce1e31
Chưa xử lý Data
hidenobi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| package com.sudo.androidd20 | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import android.widget.Toast | ||
| import androidx.fragment.app.Fragment | ||
| import androidx.fragment.app.FragmentResultListener | ||
| import com.sudo.androidd20.databinding.FragmentLoginBinding | ||
|
|
||
| // TODO: Rename parameter arguments, choose names that match | ||
| // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER | ||
| private const val ARG_PARAM1 = "param1" | ||
| private const val ARG_PARAM2 = "param2" | ||
|
|
||
| /** | ||
| * A simple [Fragment] subclass. | ||
| * Use the [LoginFragment.newInstance] factory method to | ||
| * create an instance of this fragment. | ||
| */ | ||
| class LoginFragment : Fragment() { | ||
| // TODO: Rename and change types of parameters | ||
| private var param1: String? = null | ||
| private var param2: String? = null | ||
| private lateinit var binding: FragmentLoginBinding | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| arguments?.let { | ||
| param1 = it.getString(ARG_PARAM1) | ||
| param2 = it.getString(ARG_PARAM2) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View { | ||
| binding = FragmentLoginBinding.inflate(inflater,container,false) | ||
| parentFragmentManager.apply { | ||
| setFragmentResultListener("result_to_fragment_login", | ||
| this@LoginFragment, | ||
| FragmentResultListener{_,bundle-> | ||
| val result = bundle.getSerializable("userName") as User | ||
| binding.username.setText(result.email) | ||
| }) | ||
| } | ||
| // arguments?.let { | ||
| // val result = it.getSerializable("userName") as User | ||
| // } | ||
| binding.tvSignUp.setOnClickListener{ | ||
| changeFragment() | ||
| } | ||
| binding.login.setOnClickListener { | ||
| if(binding.username.text.isNullOrEmpty()||binding.password.text.isNullOrEmpty()){ | ||
| Toast.makeText(context,"Please complete all information", Toast.LENGTH_SHORT).show() | ||
| } | ||
| else{ | ||
|
|
||
| val intent = Intent(context,SecondActivity::class.java) | ||
| val bundle = Bundle() | ||
| bundle.putSerializable("userData",User(binding.username.text.toString(),binding.password.text.toString())) | ||
| intent.putExtras(bundle) | ||
| activity?.finish() | ||
| startActivity(intent) | ||
| Toast.makeText(context,"Logged in successfully", Toast.LENGTH_SHORT).show() | ||
|
|
||
|
|
||
| } | ||
| } | ||
| return binding.root | ||
| } | ||
|
|
||
| private fun changeFragment() { | ||
| parentFragmentManager.beginTransaction().replace(R.id.frame_container,RegisterFragment()).addToBackStack(null).commit() | ||
| } | ||
|
|
||
|
|
||
| companion object { | ||
| /** | ||
| * Use this factory method to create a new instance of | ||
| * this fragment using the provided parameters. | ||
| * | ||
| * @param param1 Parameter 1. | ||
| * @param param2 Parameter 2. | ||
| * @return A new instance of fragment LoginFragment. | ||
| */ | ||
| // TODO: Rename and change types and number of parameters | ||
| @JvmStatic | ||
| fun newInstance(param1: String, param2: String) = | ||
| LoginFragment().apply { | ||
| arguments = Bundle().apply { | ||
| putString(ARG_PARAM1, param1) | ||
| putString(ARG_PARAM2, param2) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,29 @@ | ||
| package com.sudo.androidd20 | ||
|
|
||
| import androidx.appcompat.app.AppCompatActivity | ||
| import android.os.Bundle | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import androidx.fragment.app.FragmentManager | ||
| import androidx.fragment.app.FragmentTransaction | ||
|
|
||
| class MainActivity : AppCompatActivity() { | ||
| private var fragmentManager: FragmentManager? = null | ||
| private var fragmentTransaction: FragmentTransaction? = null | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_main) | ||
| addFragment() | ||
| } | ||
|
|
||
| private fun addFragment() { | ||
| val fragment = LoginFragment() | ||
| fragmentManager = supportFragmentManager | ||
| fragmentTransaction = fragmentManager?.beginTransaction() | ||
| fragmentTransaction?.add( | ||
| R.id.frame_container, | ||
| fragment | ||
| ) | ||
| fragmentTransaction?.commit() | ||
| } | ||
|
|
||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package com.sudo.androidd20 | ||
|
|
||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import android.widget.Toast | ||
| import androidx.fragment.app.Fragment | ||
| import com.sudo.androidd20.databinding.FragmentRegisterBinding | ||
|
|
||
| // TODO: Rename parameter arguments, choose names that match | ||
| // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER | ||
| private const val ARG_PARAM1 = "param1" | ||
| private const val ARG_PARAM2 = "param2" | ||
|
|
||
| /** | ||
| * A simple [Fragment] subclass. | ||
| * Use the [RegisterFragment.newInstance] factory method to | ||
| * create an instance of this fragment. | ||
| */ | ||
| class RegisterFragment : Fragment() { | ||
| // TODO: Rename and change types of parameters | ||
| private var param1: String? = null | ||
| private var param2: String? = null | ||
| private lateinit var binding: FragmentRegisterBinding | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| arguments?.let { | ||
| param1 = it.getString(ARG_PARAM1) | ||
| param2 = it.getString(ARG_PARAM2) | ||
| } | ||
| } | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View { | ||
| // Inflate the layout for this fragment | ||
| binding = FragmentRegisterBinding.inflate(inflater,container,false) | ||
| binding.register.setOnClickListener { | ||
|
|
||
| signup(binding.username.text.toString(),binding.password.text.toString(),binding.confirmedPassword.text.toString()) | ||
| } | ||
| binding.tvSignIn.setOnClickListener { | ||
| parentFragmentManager.popBackStack() | ||
| } | ||
| return binding.root | ||
| } | ||
|
|
||
| private fun signup(username: String?, password: String?, confirmedPassword: String?) { | ||
| if (username.isNullOrEmpty() || password.isNullOrEmpty() || confirmedPassword.isNullOrEmpty() ) { | ||
| Toast.makeText(context,"Please complete all information",Toast.LENGTH_SHORT).show() | ||
| } | ||
| else if(password.compareTo(confirmedPassword)!=0){ | ||
| Toast.makeText(context,"Password does not match",Toast.LENGTH_SHORT).show() | ||
| } | ||
| else{ | ||
| // (activity as MainActivity).updateUsersList(User(username,password)) | ||
| Toast.makeText(context,"Create account success",Toast.LENGTH_SHORT).show() | ||
| parentFragmentManager.apply { | ||
| val bundle = Bundle() | ||
| bundle.putSerializable("userName",User(username,password)) | ||
| setFragmentResult("result_to_fragment_login", bundle) | ||
| popBackStack() | ||
| } | ||
| // val fragmentLogin = LoginFragment() | ||
| // val bundle = Bundle() | ||
| // fragmentLogin.arguments = bundle | ||
| // bundle.putSerializable("userName",User(username,password)) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| /** | ||
| * Use this factory method to create a new instance of | ||
| * this fragment using the provided parameters. | ||
| * | ||
| * @param param1 Parameter 1. | ||
| * @param param2 Parameter 2. | ||
| * @return A new instance of fragment RegisterFragment. | ||
| */ | ||
| // TODO: Rename and change types and number of parameters | ||
| @JvmStatic | ||
| fun newInstance(param1: String, param2: String) = | ||
| RegisterFragment().apply { | ||
| arguments = Bundle().apply { | ||
| putString(ARG_PARAM1, param1) | ||
| putString(ARG_PARAM2, param2) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.sudo.androidd20 | ||
|
|
||
| import androidx.appcompat.app.AppCompatActivity | ||
| import android.os.Bundle | ||
| import com.sudo.androidd20.databinding.ActivitySecondBinding | ||
|
|
||
| class SecondActivity : AppCompatActivity() { | ||
| private lateinit var binding: ActivitySecondBinding | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_second) | ||
| binding = ActivitySecondBinding.inflate(layoutInflater) | ||
| setContentView(binding.root) | ||
| val user = intent?.extras?.get("userData") as User | ||
| binding.username.setText(user.email) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.sudo.androidd20 | ||
|
|
||
| import java.io.Serializable | ||
|
|
||
| data class User( | ||
| var email:String, | ||
| var password:String | ||
| ):Serializable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:shape="rectangle"> | ||
| <corners android:radius="64dp"/> | ||
| <solid android:color="@color/teal_200"/> | ||
|
|
||
|
|
||
| </shape> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"> | ||
| <gradient | ||
| android:angle="90" | ||
| android:endColor="#3cdcf3" | ||
| android:startColor="@color/white" | ||
| /> | ||
|
|
||
| </shape> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Không cần thiết phải tạo 2 biến này vì mạc định activity đã có rồi