-
Notifications
You must be signed in to change notification settings - Fork 56
Activities 01 #35
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
Serovatova
wants to merge
5
commits into
Otus-Android:master
Choose a base branch
from
Serovatova:activities_01
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
Activities 01 #35
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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
28 changes: 28 additions & 0 deletions
28
app/src/main/java/otus/gpb/homework/activities/MainActivityA.kt
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,28 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.util.Log | ||
| import android.widget.Button | ||
| import androidx.appcompat.app.AppCompatActivity | ||
|
|
||
| private const val TAG = "onNewIntent" | ||
|
|
||
| class MainActivityA : AppCompatActivity(R.layout.activity_main_a) { | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| val button = findViewById<Button>(R.id.button_activity_B) | ||
| button.setOnClickListener { | ||
| val intent = Intent(this, MainActivityB::class.java).apply { | ||
| flags = Intent.FLAG_ACTIVITY_MULTIPLE_TASK or Intent.FLAG_ACTIVITY_NEW_TASK | ||
| } | ||
| startActivity(intent) | ||
| } | ||
| } | ||
|
|
||
| override fun onNewIntent(intent: Intent?) { | ||
| Log.d(TAG,"call newIntent activity A") | ||
| super.onNewIntent(intent) | ||
| } | ||
| } | ||
26 changes: 26 additions & 0 deletions
26
app/src/main/java/otus/gpb/homework/activities/MainActivityB.kt
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,26 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.widget.Button | ||
| import androidx.appcompat.app.AppCompatActivity | ||
|
|
||
| class MainActivityB : AppCompatActivity(R.layout.activity_main_b) { | ||
|
|
||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_main_b) | ||
|
|
||
| val button = findViewById<Button>(R.id.button_activity_C) | ||
|
|
||
| button.setOnClickListener { | ||
| val intent = Intent(this, MainActivityC::class.java) | ||
| startActivity(intent) | ||
| } | ||
| } | ||
|
|
||
| override fun onNewIntent(intent: Intent?) { | ||
| super.onNewIntent(intent) | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
app/src/main/java/otus/gpb/homework/activities/MainActivityC.kt
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,40 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.widget.Button | ||
| import androidx.appcompat.app.AppCompatActivity | ||
|
|
||
| class MainActivityC : AppCompatActivity() { | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_main_c) | ||
|
|
||
| val button = findViewById<Button>(R.id.button_open_activity_A_from_C) | ||
| val button2 = findViewById<Button>(R.id.button_open_activity_D_from_C) | ||
| val button3 = findViewById<Button>(R.id.button_close_activity_C_from_C) | ||
| val button4 = findViewById<Button>(R.id.button_close_Stacks) | ||
|
|
||
| button.setOnClickListener { | ||
| val intent = Intent(this, MainActivityA::class.java) | ||
| startActivity(intent) | ||
| } | ||
|
|
||
| button2.setOnClickListener { | ||
| val intent = Intent(this, MainActivityD::class.java).apply { | ||
| flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK | ||
| } | ||
| startActivity(intent) | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Отсутствует преход на активити А с закрытием стека |
||
|
|
||
| button3.setOnClickListener { | ||
| finish() | ||
| } | ||
|
|
||
| button4.setOnClickListener { | ||
| finishAffinity() | ||
| } | ||
| } | ||
|
|
||
| } | ||
11 changes: 11 additions & 0 deletions
11
app/src/main/java/otus/gpb/homework/activities/MainActivityD.kt
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,11 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.os.Bundle | ||
| import androidx.appcompat.app.AppCompatActivity | ||
|
|
||
| class MainActivityD : AppCompatActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_main_d) | ||
| } | ||
| } |
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,22 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <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" | ||
| android:background="#f44336" | ||
| tools:context=".MainActivityA"> | ||
|
|
||
| <Button | ||
| android:id="@+id/button_activity_B" | ||
| android:layout_width="250dp" | ||
| android:layout_height="70dp" | ||
| android:layout_marginBottom="50dp" | ||
| android:text="@string/open_activity_b" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent"> | ||
| </Button> | ||
|
|
||
| </androidx.constraintlayout.widget.ConstraintLayout> |
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,21 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <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" | ||
| android:background="#4caf50" | ||
| tools:context=".MainActivityB"> | ||
|
|
||
| <Button | ||
| android:id="@+id/button_activity_C" | ||
| android:layout_width="250dp" | ||
| android:layout_height="70dp" | ||
| android:layout_marginBottom="50dp" | ||
| android:text="@string/open_activity_c" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent"> | ||
| </Button> | ||
|
|
||
| </androidx.constraintlayout.widget.ConstraintLayout> |
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,58 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <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" | ||
| android:background="#2196f3" | ||
| tools:context=".MainActivityC"> | ||
|
|
||
| <Button | ||
| android:id="@+id/button_open_activity_A_from_C" | ||
| android:layout_width="250dp" | ||
| android:layout_height="70dp" | ||
| android:text="@string/open_activity_a" | ||
| android:layout_margin="50dp" | ||
| app:layout_constraintBottom_toTopOf="@+id/button_open_activity_D_from_C" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent"> | ||
|
|
||
| </Button> | ||
|
|
||
| <Button | ||
| android:id="@+id/button_open_activity_D_from_C" | ||
| android:layout_width="250dp" | ||
| android:layout_height="70dp" | ||
| android:text="@string/open_activity_d" | ||
| android:layout_margin="50dp" | ||
| app:layout_constraintBottom_toTopOf="@+id/button_close_activity_C_from_C" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent"> | ||
|
|
||
| </Button> | ||
|
|
||
| <Button | ||
| android:id="@+id/button_close_activity_C_from_C" | ||
| android:layout_width="250dp" | ||
| android:layout_height="70dp" | ||
| android:text="@string/close_activity_c" | ||
| android:layout_margin="50dp" | ||
| app:layout_constraintBottom_toTopOf="@+id/button_close_Stacks" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent"> | ||
|
|
||
| </Button> | ||
|
|
||
| <Button | ||
| android:id="@+id/button_close_Stacks" | ||
| android:layout_width="250dp" | ||
| android:layout_height="70dp" | ||
| android:layout_marginBottom="50dp" | ||
| android:text="@string/close_stack" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent"> | ||
|
|
||
| </Button> | ||
|
|
||
| </androidx.constraintlayout.widget.ConstraintLayout> |
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"?> | ||
| <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" | ||
| android:background="#ffeb3b" | ||
| tools:context=".MainActivityD"> | ||
|
|
||
| </androidx.constraintlayout.widget.ConstraintLayout> |
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 |
|---|---|---|
| @@ -1,3 +1,51 @@ | ||
| <resources> | ||
| <string name="app_name">Activities</string> | ||
| <!-- Strings used for fragments for navigation --> | ||
| <string name="first_fragment_label">First Fragment</string> | ||
| <string name="second_fragment_label">Second Fragment</string> | ||
| <string name="next">Next</string> | ||
| <string name="previous">Previous</string> | ||
|
|
||
| <string name="lorem_ipsum"> | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam in scelerisque sem. Mauris | ||
| volutpat, dolor id interdum ullamcorper, risus dolor egestas lectus, sit amet mattis purus | ||
| dui nec risus. Maecenas non sodales nisi, vel dictum dolor. Class aptent taciti sociosqu ad | ||
| litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse blandit eleifend | ||
| diam, vel rutrum tellus vulputate quis. Aliquam eget libero aliquet, imperdiet nisl a, | ||
| ornare ex. Sed rhoncus est ut libero porta lobortis. Fusce in dictum tellus.\n\n | ||
| Suspendisse interdum ornare ante. Aliquam nec cursus lorem. Morbi id magna felis. Vivamus | ||
| egestas, est a condimentum egestas, turpis nisl iaculis ipsum, in dictum tellus dolor sed | ||
| neque. Morbi tellus erat, dapibus ut sem a, iaculis tincidunt dui. Interdum et malesuada | ||
| fames ac ante ipsum primis in faucibus. Curabitur et eros porttitor, ultricies urna vitae, | ||
| molestie nibh. Phasellus at commodo eros, non aliquet metus. Sed maximus nisl nec dolor | ||
| bibendum, vel congue leo egestas.\n\n | ||
| Sed interdum tortor nibh, in sagittis risus mollis quis. Curabitur mi odio, condimentum sit | ||
| amet auctor at, mollis non turpis. Nullam pretium libero vestibulum, finibus orci vel, | ||
| molestie quam. Fusce blandit tincidunt nulla, quis sollicitudin libero facilisis et. Integer | ||
| interdum nunc ligula, et fermentum metus hendrerit id. Vestibulum lectus felis, dictum at | ||
| lacinia sit amet, tristique id quam. Cras eu consequat dui. Suspendisse sodales nunc ligula, | ||
| in lobortis sem porta sed. Integer id ultrices magna, in luctus elit. Sed a pellentesque | ||
| est.\n\n | ||
| Aenean nunc velit, lacinia sed dolor sed, ultrices viverra nulla. Etiam a venenatis nibh. | ||
| Morbi laoreet, tortor sed facilisis varius, nibh orci rhoncus nulla, id elementum leo dui | ||
| non lorem. Nam mollis ipsum quis auctor varius. Quisque elementum eu libero sed commodo. In | ||
| eros nisl, imperdiet vel imperdiet et, scelerisque a mauris. Pellentesque varius ex nunc, | ||
| quis imperdiet eros placerat ac. Duis finibus orci et est auctor tincidunt. Sed non viverra | ||
| ipsum. Nunc quis augue egestas, cursus lorem at, molestie sem. Morbi a consectetur ipsum, a | ||
| placerat diam. Etiam vulputate dignissim convallis. Integer faucibus mauris sit amet finibus | ||
| convallis.\n\n | ||
| Phasellus in aliquet mi. Pellentesque habitant morbi tristique senectus et netus et | ||
| malesuada fames ac turpis egestas. In volutpat arcu ut felis sagittis, in finibus massa | ||
| gravida. Pellentesque id tellus orci. Integer dictum, lorem sed efficitur ullamcorper, | ||
| libero justo consectetur ipsum, in mollis nisl ex sed nisl. Donec maximus ullamcorper | ||
| sodales. Praesent bibendum rhoncus tellus nec feugiat. In a ornare nulla. Donec rhoncus | ||
| libero vel nunc consequat, quis tincidunt nisl eleifend. Cras bibendum enim a justo luctus | ||
| vestibulum. Fusce dictum libero quis erat maximus, vitae volutpat diam dignissim. | ||
| </string> | ||
| <string name="open_activity_b">Open activity B</string> | ||
| <string name="open_activity_c">Open activity C</string> | ||
| <string name="open_activity_a">Open activity A</string> | ||
| <string name="open_activity_d">Open activity D</string> | ||
| <string name="close_activity_c">Close activity C</string> | ||
| <string name="close_stack">Close Stack</string> | ||
| </resources> |
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.
Я б тут советовал завести метод
onNewIntent, чтобы легче было проверить третье задание