-
Notifications
You must be signed in to change notification settings - Fork 56
DzBasicActivity #54
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
Gimasteev
wants to merge
4
commits into
Otus-Android:master
Choose a base branch
from
Gimasteev:master
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
DzBasicActivity #54
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9a2da4c
Создал активити, лейауты к ним и сделал переключение с активити А на …
Gimasteev 709181a
Сделал переходы между всеми окнами
Gimasteev c67ccf5
Finish
Gimasteev f01390a
Спасибо большое за комментарии. Поправил все недочеты. Вопросы остали…
Gimasteev 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
45 changes: 45 additions & 0 deletions
45
app/src/main/java/otus/gpb/homework/activities/Activity_A.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,45 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.annotation.SuppressLint | ||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.util.Log | ||
| import android.view.View | ||
| import android.widget.Button | ||
| import androidx.appcompat.app.AppCompatActivity | ||
|
|
||
|
|
||
| class Activity_A : AppCompatActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_a) | ||
| val button = findViewById<Button>(R.id.buttonA_to_B) | ||
| Log.d("Debug", "onCreateA") | ||
| } | ||
|
|
||
| fun onClickListener(view: View){ // создаем функцию и указываем переменную view типа View (!) | ||
| if (view is Button) { | ||
| // Создаем Intent для открытия другого Activity | ||
| val intent = Intent(this, Activity_B::class.java) | ||
| // Задание 2.1: Создаем FLAG_ACTIVITY_NEW_TASK для singleTop и добавляем флаг FLAG_ACTIVITY_MULTIPLE_TASK для открытия в новом таске | ||
| intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK | ||
| // Начинаем новое Activity | ||
| startActivity(intent) | ||
| } | ||
|
|
||
| } | ||
| // override fun onNewIntent(intent: Intent?) { | ||
| // super.onNewIntent(intent) | ||
| // } | ||
| // override fun onRestart() { | ||
| // super.onRestart() | ||
| // Log.d("Debug", "onRestart") | ||
| // val intent = Intent(this, Activity_A::class.java) | ||
| // intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP | ||
| // startActivity(intent) | ||
| // Log.d("Debug", "onNewIntent") | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| } |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/otus/gpb/homework/activities/Activity_B.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,32 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.util.Log | ||
| import android.view.View | ||
| import android.widget.Button | ||
| import androidx.appcompat.app.AppCompatActivity | ||
|
|
||
|
|
||
| class Activity_B : AppCompatActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_b) | ||
| val button = findViewById<Button>(R.id.buttonB_to_C) | ||
| Log.d("Debug", "onCreateB") | ||
| } | ||
|
|
||
| override fun onDestroy() { | ||
| super.onDestroy() | ||
| Log.d("Debug", "onDestroyB") | ||
| } | ||
| fun onClickListener(view: View){ // создаем функцию и указываем переменную view типа View (!) | ||
| if (view is Button) { | ||
| Log.d("Debug", "openB") | ||
| // // Задание 2.2: Создаем Intent для открытия другого Activity | ||
| val intent = Intent(this, Activity_C::class.java) | ||
| // Начинаем новое Activity | ||
| startActivity(intent) | ||
| } | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/otus/gpb/homework/activities/Activity_C.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,59 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.util.Log | ||
| import android.view.View | ||
| import android.widget.Button | ||
| import androidx.appcompat.app.AppCompatActivity | ||
|
|
||
|
|
||
| class Activity_C : AppCompatActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_c) | ||
| val button = findViewById<Button>(R.id.buttonC_to_A) | ||
| Log.d("Debug", "onCreateC") | ||
| } | ||
|
|
||
| override fun onResume() { | ||
| super.onResume() | ||
| Log.d("Debug", "onResumeC") | ||
| } | ||
| override fun onDestroy() { | ||
| super.onDestroy() | ||
| Log.d("Debug", "onDestroyC") | ||
| } | ||
| fun onClickListenerOpenAfromC(view: View) { // создаем функцию и указываем переменную view типа View (!) | ||
| if (view is Button) { | ||
| // Создаем Intent для открытия другого Activity | ||
| val intent = Intent(this, Activity_A::class.java) | ||
| // Начинаем новое Activity | ||
| startActivity(intent) | ||
| } | ||
| } | ||
|
|
||
| fun onClickListenerOpenDfromC(view: View){ | ||
| val intent = Intent(this, Activity_D::class.java) | ||
| // Задание 2.4: Создаю новый активти и чищу весь стек. Вроде как сделано задание. Нажимаю назад и закрывается текущий таск, НО потом открываю трей и вижу, что оно есть)))) | ||
| intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK | ||
| startActivity(intent) | ||
| } | ||
|
|
||
| fun onClickListenerCloseCAndGoBack(view: View){ | ||
| val intent = Intent(this, Activity_B::class.java) | ||
| // Задание 2.5: Финиширую активити С | ||
| finish() | ||
| //intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP | ||
| //startActivity(intent) | ||
| } | ||
|
|
||
| fun onClickListenerCloseStackAndGoA(view: View){ | ||
| val intent = Intent(this, Activity_A::class.java) | ||
|
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. @Gimasteev, еще обратите внимание на функцию finishAffinity |
||
| // Задание 2.5: Финиширую через функцию finishAffinity(), но опять-таки вижу в трее что висит активити С | ||
| finishAffinity() | ||
| //intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK | ||
| //startActivity(intent) | ||
| } | ||
|
|
||
| } | ||
20 changes: 20 additions & 0 deletions
20
app/src/main/java/otus/gpb/homework/activities/Activity_D.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,20 @@ | ||
| package otus.gpb.homework.activities | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.view.View | ||
| import android.widget.Button | ||
| import androidx.appcompat.app.AppCompatActivity | ||
|
|
||
|
|
||
| class Activity_D : AppCompatActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_d) | ||
|
|
||
|
|
||
| } | ||
| fun onClickListener(view: View){ // создаем функцию и указываем переменную view типа View (!) | ||
|
|
||
| } | ||
| } |
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:id="@+id/layoutActivityA" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:background="#f44336" | ||
| android:onClick="onClickListener" | ||
| tools:context=".Activity_A"> | ||
|
|
||
| <Button | ||
| android:id="@+id/buttonA_to_B" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:onClick="onClickListener" | ||
| android:text="Open ActivityB" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" /> | ||
| </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,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:id="@+id/layoutActivityB" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:background="#4caf50" | ||
| android:onClick="onClickListener" | ||
| tools:context=".Activity_B"> | ||
|
|
||
| <Button | ||
| android:id="@+id/buttonB_to_C" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:onClick="onClickListener" | ||
| android:text="Open ActivityC" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" /> | ||
| </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,62 @@ | ||
| <?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:id="@+id/layoutActivityB" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:background="#2196f3" | ||
| tools:context=".Activity_C"> | ||
|
|
||
| <Button | ||
| android:id="@+id/buttonC_to_A" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="184dp" | ||
| android:onClick="onClickListenerOpenAfromC" | ||
| android:text="Open ActivityA" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintHorizontal_bias="0.498" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" | ||
| tools:ignore="MissingConstraints" /> | ||
|
|
||
| <Button | ||
| android:id="@+id/buttonC_to_D" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="292dp" | ||
| android:onClick="onClickListenerOpenDfromC" | ||
| android:text="Open ActivityD" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintHorizontal_bias="0.498" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" | ||
| tools:ignore="MissingConstraints" /> | ||
|
|
||
| <Button | ||
| android:id="@+id/buttonC_close_C" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="388dp" | ||
| android:onClick="onClickListenerCloseCAndGoBack" | ||
| android:text="Close ActivityC" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintHorizontal_bias="0.483" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" | ||
| tools:ignore="MissingConstraints" /> | ||
|
|
||
| <Button | ||
| android:id="@+id/buttonC_close_stack" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="492dp" | ||
| android:onClick="onClickListenerCloseStackAndGoA" | ||
| android:text="Close Stack" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintHorizontal_bias="0.498" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" | ||
| tools:ignore="MissingConstraints" /> | ||
| </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,11 @@ | ||
| <?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:id="@+id/layoutActivityB" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:background="#ffeb3b" | ||
| tools:context=".Activity_D"> | ||
|
|
||
| </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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| <resources> | ||
| <string name="app_name">Activities</string> | ||
| <string name="app_name">Roman_Activities</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
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.
@Gimasteev, не выполняется задание 3.2. Оставил комментарий выше. Возможно, можно добиться того же эффекта с флагом FLAG_ACTIVITY_CLEAR_TOP