├── LICENSE
├── README.md
├── chapter 01
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── gamecodeschool
│ │ └── helloworld
│ │ ├── FirstFragment.java
│ │ ├── MainActivity.java
│ │ └── SecondFragment.java
└── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── content_main.xml
│ ├── fragment_first.xml
│ └── fragment_second.xml
│ ├── menu
│ └── menu_main.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── navigation
│ └── nav_graph.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── chapter 02
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── gamecodeschool
│ │ └── helloworld
│ │ ├── FirstFragment.java
│ │ ├── MainActivity.java
│ │ └── SecondFragment.java
└── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── content_main.xml
│ ├── fragment_first.xml
│ └── fragment_second.xml
│ ├── menu
│ └── menu_main.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── navigation
│ └── nav_graph.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── chapter 03
├── BasicActivityApp
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── gamecodeschool
│ │ │ └── basicactivityapp
│ │ │ ├── FirstFragment.java
│ │ │ ├── MainActivity.java
│ │ │ └── SecondFragment.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── content_main.xml
│ │ ├── fragment_first.xml
│ │ └── fragment_second.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── navigation
│ │ └── nav_graph.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
└── EmptyActivityApp
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── gamecodeschool
│ │ └── emptyactivityapp
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── chapter 04
├── java
│ └── MainActivity.java
└── layout
│ ├── activity_main.xml
│ ├── main_menu.xml
│ └── my_table_layout.xml
├── chapter 05
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── gamecodeschool
│ │ └── cardviewlayout
│ │ └── MainActivity.java
└── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── ic_launcher_background.xml
│ ├── image_1.png
│ ├── image_2.png
│ └── image_3.png
│ ├── layout
│ ├── activity_main.xml
│ ├── card_contents_1.xml
│ ├── card_contents_2.xml
│ ├── card_contents_3.xml
│ └── main_layout.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── chapter 06
└── LifecycleDemo
│ └── java
│ └── MainActivity.java
├── chapter 07
└── Expressing Yourself
│ └── java
│ ├── FirstFragment.java
│ ├── MainActivity.java
│ └── SecondFragment.java
├── chapter 08
├── Loops
│ ├── java
│ │ └── MainActivity.java
│ └── layout
│ │ └── activity_main.xml
└── Switch Demo
│ └── java
│ └── MainActivity.java
├── chapter 09
├── Exploring Method Overloading
│ └── java
│ │ └── MainActivity.java
└── Real World Methods
│ └── java
│ └── MainActivity.java
├── chapter 10
└── Basic Classes
│ └── java
│ ├── MainActivity.java
│ └── Soldier.java
├── chapter 11
├── Access Scope This And Static
│ ├── AlienShip.java
│ └── MainActivity.java
├── Getters And Setters
│ ├── Hospital.java
│ ├── MainActivity.java
│ └── Soldier.java
└── Inheritance Example
│ ├── AlienShip.java
│ ├── Bomber.java
│ ├── Fighter.java
│ └── MainActivity.java
├── chapter 12
└── Java Meet UI
│ ├── java
│ └── MainActivity.java
│ └── layout
│ └── activity_main.xml
├── chapter 13
└── Widget Exploration
│ ├── AndroidManifest.xml
│ ├── java
│ └── MainActivity.java
│ └── layout
│ └── activity_main.xml
├── chapter 14
├── Dialog Demo
│ ├── java
│ │ ├── MainActivity.java
│ │ └── MyDialog.java
│ └── layout
│ │ └── activity_main.xml
└── Note to Self
│ ├── java
│ ├── DialogNewNote.java
│ ├── DialogShowNote.java
│ ├── MainActivity.java
│ └── Note.java
│ ├── layout
│ ├── activity_main.xml
│ ├── content_main.xml
│ ├── dialog_new_note.xml
│ └── dialog_show_note.xml
│ └── values
│ └── strings.xml
├── chapter 15
├── Dynamic array example
│ └── MainActivity.java
├── Multidimensional array example
│ └── MainActivity.java
└── Simple Array Example
│ └── MainActivity.java
├── chapter 16
└── Note to self
│ ├── java
│ ├── DialogNewNote.java
│ ├── DialogShowNote.java
│ ├── MainActivity.java
│ ├── Note.java
│ └── NoteAdapter.java
│ ├── layout
│ ├── activity_main.xml
│ ├── content_main.xml
│ ├── dialog_new_note.xml
│ ├── dialog_show_note.xml
│ └── listitem.xml
│ └── values
│ └── strings.xml
├── chapter 17
└── Note to self
│ ├── AndroidManifest.xml
│ ├── java
│ ├── DialogNewNote.java
│ ├── DialogShowNote.java
│ ├── JSONSerializer.java
│ ├── MainActivity.java
│ ├── Note.java
│ ├── NoteAdapter.java
│ └── SettingsActivity.java
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_settings.xml
│ ├── content_main.xml
│ ├── dialog_new_note.xml
│ ├── dialog_show_note.xml
│ └── listitem.xml
│ └── values
│ └── strings.xml
├── chapter 18
└── Note to self
│ ├── AndroidManifest.xml
│ ├── java
│ ├── DialogNewNote.java
│ ├── DialogShowNote.java
│ ├── JSONSerializer.java
│ ├── MainActivity.java
│ ├── Note.java
│ ├── NoteAdapter.java
│ └── SettingsActivity.java
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_settings.xml
│ ├── content_main.xml
│ ├── dialog_new_note.xml
│ ├── dialog_show_note.xml
│ └── listitem.xml
│ ├── values-de
│ └── strings.xml
│ ├── values-es
│ └── strings.xml
│ └── values
│ └── strings.xml
├── chapter 19
├── anim
│ ├── bounce.xml
│ ├── fade_in.xml
│ ├── fade_in_out.xml
│ ├── fade_out.xml
│ ├── flash.xml
│ ├── left_right.xml
│ ├── right_left.xml
│ ├── rotate_left.xml
│ ├── rotate_right.xml
│ ├── top_bot.xml
│ ├── zoom_in.xml
│ └── zoom_out.xml
├── java
│ └── MainActivity.java
└── layout
│ └── activity_main.xml
├── chapter 20
├── Canvas Demo
│ └── java
│ │ └── MainActivity.java
└── Manipulating Bitmaps
│ ├── drawable
│ └── bob.png
│ └── java
│ └── MainActivity.java
├── chapter 21
├── AndroidManifest.xml
└── java
│ ├── LiveDrawingActivity.java
│ ├── LiveDrawingView.java
│ ├── Particle.java
│ └── ParticleSystem.java
├── chapter 22
├── AndroidManifest.xml
└── java
│ ├── LiveDrawingActivity.java
│ ├── LiveDrawingView.java
│ ├── Particle.java
│ └── ParticleSystem.java
├── chapter 23
├── assets
│ ├── fx1.ogg
│ ├── fx2.ogg
│ └── fx3.ogg
├── java
│ └── MainActivity.java
├── layout
│ └── activity_main.xml
└── values
│ └── strings.xml
├── chapter 24
├── Device Detection
│ ├── java
│ │ └── MainActivity.java
│ ├── layout-land
│ │ └── activity_main.xml
│ └── layout
│ │ └── activity_main.xml
└── Simple Fragment
│ ├── java
│ ├── MainActivity.java
│ └── SimpleFragment.java
│ └── layout
│ ├── activity_main.xml
│ └── fragment_layout.xml
├── chapter 25
└── Image Pager
│ ├── drawable
│ ├── image1.png
│ ├── image2.png
│ ├── image3.png
│ ├── image4.png
│ ├── image5.png
│ └── image6.png
│ ├── java
│ ├── ImagePagerAdapter.java
│ └── MainActivity.java
│ └── layout
│ ├── activity_main.xml
│ └── pager_item.xml
├── chapter 26
├── java
│ ├── DeleteFragment.java
│ ├── InsertFragment.java
│ ├── MainActivity.java
│ ├── README.txt
│ ├── ResultsFragment.java
│ └── SearchFragment.java
├── layout
│ ├── README.txt
│ ├── activity_main.xml
│ ├── app_bar_main.xml
│ ├── content_delete.xml
│ ├── content_insert.xml
│ ├── content_main.xml
│ ├── content_results.xml
│ ├── content_search.xml
│ └── nav_header_main.xml
└── menu
│ ├── README.txt
│ └── activity_main_drawer.xml
└── chapter 27
├── java
├── DataManager.java
├── DeleteFragment.java
├── InsertFragment.java
├── MainActivity.java
├── README.txt
├── ResultsFragment.java
└── SearchFragment.java
├── layout
├── README.txt
├── activity_main.xml
├── app_bar_main.xml
├── content_delete.xml
├── content_insert.xml
├── content_main.xml
├── content_results.xml
├── content_search.xml
└── nav_header_main.xml
└── menu
├── README.txt
└── activity_main_drawer.xml
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Packt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/chapter 01/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/chapter 01/java/com/gamecodeschool/helloworld/FirstFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.helloworld;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.navigation.fragment.NavHostFragment;
11 |
12 | public class FirstFragment extends Fragment {
13 |
14 | @Override
15 | public View onCreateView(
16 | LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState
18 | ) {
19 | // Inflate the layout for this fragment
20 | return inflater.inflate(R.layout.fragment_first, container, false);
21 | }
22 |
23 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
24 | super.onViewCreated(view, savedInstanceState);
25 |
26 | view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | NavHostFragment.findNavController(FirstFragment.this)
30 | .navigate(R.id.action_FirstFragment_to_SecondFragment);
31 | }
32 | });
33 | }
34 | }
--------------------------------------------------------------------------------
/chapter 01/java/com/gamecodeschool/helloworld/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.helloworld;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
6 | import com.google.android.material.snackbar.Snackbar;
7 |
8 | import androidx.appcompat.app.AppCompatActivity;
9 | import androidx.appcompat.widget.Toolbar;
10 |
11 | import android.view.View;
12 |
13 | import android.view.Menu;
14 | import android.view.MenuItem;
15 |
16 | public class MainActivity extends AppCompatActivity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 | Toolbar toolbar = findViewById(R.id.toolbar);
23 | setSupportActionBar(toolbar);
24 |
25 | FloatingActionButton fab = findViewById(R.id.fab);
26 | fab.setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
30 | .setAction("Action", null).show();
31 | }
32 | });
33 | }
34 |
35 | @Override
36 | public boolean onCreateOptionsMenu(Menu menu) {
37 | // Inflate the menu; this adds items to the action bar if it is present.
38 | getMenuInflater().inflate(R.menu.menu_main, menu);
39 | return true;
40 | }
41 |
42 | @Override
43 | public boolean onOptionsItemSelected(MenuItem item) {
44 | // Handle action bar item clicks here. The action bar will
45 | // automatically handle clicks on the Home/Up button, so long
46 | // as you specify a parent activity in AndroidManifest.xml.
47 | int id = item.getItemId();
48 |
49 | //noinspection SimplifiableIfStatement
50 | if (id == R.id.action_settings) {
51 | return true;
52 | }
53 |
54 | return super.onOptionsItemSelected(item);
55 | }
56 | }
--------------------------------------------------------------------------------
/chapter 01/java/com/gamecodeschool/helloworld/SecondFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.helloworld;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.navigation.fragment.NavHostFragment;
11 |
12 | public class SecondFragment extends Fragment {
13 |
14 | @Override
15 | public View onCreateView(
16 | LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState
18 | ) {
19 | // Inflate the layout for this fragment
20 | return inflater.inflate(R.layout.fragment_second, container, false);
21 | }
22 |
23 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
24 | super.onViewCreated(view, savedInstanceState);
25 |
26 | view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | NavHostFragment.findNavController(SecondFragment.this)
30 | .navigate(R.id.action_SecondFragment_to_FirstFragment);
31 | }
32 | });
33 | }
34 | }
--------------------------------------------------------------------------------
/chapter 01/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/chapter 01/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/chapter 01/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
--------------------------------------------------------------------------------
/chapter 01/res/layout/fragment_first.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
28 |
--------------------------------------------------------------------------------
/chapter 01/res/layout/fragment_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
--------------------------------------------------------------------------------
/chapter 01/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 01/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 01/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 01/res/navigation/nav_graph.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
17 |
18 |
23 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/chapter 01/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/chapter 01/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
--------------------------------------------------------------------------------
/chapter 01/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Hello World
3 | Settings
4 |
5 | First Fragment
6 | Second Fragment
7 | Next
8 | Previous
9 |
10 | Hello first fragment
11 | Hello second fragment. Arg: %1$s
12 |
--------------------------------------------------------------------------------
/chapter 01/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/chapter 02/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/chapter 02/java/com/gamecodeschool/helloworld/FirstFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.helloworld;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.navigation.fragment.NavHostFragment;
11 |
12 | public class FirstFragment extends Fragment {
13 |
14 | @Override
15 | public View onCreateView(
16 | LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState
18 | ) {
19 | // Inflate the layout for this fragment
20 | return inflater.inflate(R.layout.fragment_first, container, false);
21 | }
22 |
23 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
24 | super.onViewCreated(view, savedInstanceState);
25 |
26 | view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | NavHostFragment.findNavController(FirstFragment.this)
30 | .navigate(R.id.action_FirstFragment_to_SecondFragment);
31 | }
32 | });
33 | }
34 | }
--------------------------------------------------------------------------------
/chapter 02/java/com/gamecodeschool/helloworld/SecondFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.helloworld;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.navigation.fragment.NavHostFragment;
11 |
12 | public class SecondFragment extends Fragment {
13 |
14 | @Override
15 | public View onCreateView(
16 | LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState
18 | ) {
19 | // Inflate the layout for this fragment
20 | return inflater.inflate(R.layout.fragment_second, container, false);
21 | }
22 |
23 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
24 | super.onViewCreated(view, savedInstanceState);
25 |
26 | view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | NavHostFragment.findNavController(SecondFragment.this)
30 | .navigate(R.id.action_SecondFragment_to_FirstFragment);
31 | }
32 | });
33 | }
34 | }
--------------------------------------------------------------------------------
/chapter 02/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/chapter 02/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/chapter 02/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
--------------------------------------------------------------------------------
/chapter 02/res/layout/fragment_first.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
28 |
29 |
39 |
40 |
41 |
50 |
51 |
--------------------------------------------------------------------------------
/chapter 02/res/layout/fragment_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/chapter 02/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 02/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 02/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 02/res/navigation/nav_graph.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
17 |
18 |
23 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/chapter 02/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/chapter 02/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
--------------------------------------------------------------------------------
/chapter 02/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Hello World
3 | Settings
4 |
5 | First Fragment
6 | Second Fragment
7 | Next
8 | Previous
9 |
10 | Hello first fragment
11 | Hello second fragment. Arg: %1$s
12 |
--------------------------------------------------------------------------------
/chapter 02/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/java/com/gamecodeschool/basicactivityapp/FirstFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.basicactivityapp;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.navigation.fragment.NavHostFragment;
11 |
12 | public class FirstFragment extends Fragment {
13 |
14 | @Override
15 | public View onCreateView(
16 | LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState
18 | ) {
19 | // Inflate the layout for this fragment
20 | return inflater.inflate(R.layout.fragment_first, container, false);
21 | }
22 |
23 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
24 | super.onViewCreated(view, savedInstanceState);
25 |
26 | view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | NavHostFragment.findNavController(FirstFragment.this)
30 | .navigate(R.id.action_FirstFragment_to_SecondFragment);
31 | }
32 | });
33 | }
34 | }
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/java/com/gamecodeschool/basicactivityapp/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.basicactivityapp;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
6 | import com.google.android.material.snackbar.Snackbar;
7 |
8 | import androidx.appcompat.app.AppCompatActivity;
9 | import androidx.appcompat.widget.Toolbar;
10 |
11 | import android.view.View;
12 |
13 | import android.view.Menu;
14 | import android.view.MenuItem;
15 |
16 | public class MainActivity extends AppCompatActivity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 | Toolbar toolbar = findViewById(R.id.toolbar);
23 | setSupportActionBar(toolbar);
24 |
25 | FloatingActionButton fab = findViewById(R.id.fab);
26 | fab.setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
30 | .setAction("Action", null).show();
31 | }
32 | });
33 | }
34 |
35 | @Override
36 | public boolean onCreateOptionsMenu(Menu menu) {
37 | // Inflate the menu; this adds items to the action bar if it is present.
38 | getMenuInflater().inflate(R.menu.menu_main, menu);
39 | return true;
40 | }
41 |
42 | @Override
43 | public boolean onOptionsItemSelected(MenuItem item) {
44 | // Handle action bar item clicks here. The action bar will
45 | // automatically handle clicks on the Home/Up button, so long
46 | // as you specify a parent activity in AndroidManifest.xml.
47 | int id = item.getItemId();
48 |
49 | //noinspection SimplifiableIfStatement
50 | if (id == R.id.action_settings) {
51 | return true;
52 | }
53 |
54 | return super.onOptionsItemSelected(item);
55 | }
56 | }
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/java/com/gamecodeschool/basicactivityapp/SecondFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.basicactivityapp;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.navigation.fragment.NavHostFragment;
11 |
12 | public class SecondFragment extends Fragment {
13 |
14 | @Override
15 | public View onCreateView(
16 | LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState
18 | ) {
19 | // Inflate the layout for this fragment
20 | return inflater.inflate(R.layout.fragment_second, container, false);
21 | }
22 |
23 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
24 | super.onViewCreated(view, savedInstanceState);
25 |
26 | view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | NavHostFragment.findNavController(SecondFragment.this)
30 | .navigate(R.id.action_SecondFragment_to_FirstFragment);
31 | }
32 | });
33 | }
34 | }
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/layout/fragment_first.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
28 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/layout/fragment_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/BasicActivityApp/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/navigation/nav_graph.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
17 |
18 |
23 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Basic Activity App
3 | Settings
4 |
5 | First Fragment
6 | Second Fragment
7 | Next
8 | Previous
9 |
10 | Hello first fragment
11 | Hello second fragment. Arg: %1$s
12 |
--------------------------------------------------------------------------------
/chapter 03/BasicActivityApp/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/java/com/gamecodeschool/emptyactivityapp/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.emptyactivityapp;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_main);
13 | }
14 | }
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 03/EmptyActivityApp/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Empty Activity App
3 |
--------------------------------------------------------------------------------
/chapter 03/EmptyActivityApp/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/chapter 04/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.exploringlayouts;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 |
14 | setContentView(R.layout.main_menu);
15 | }
16 |
17 | public void loadConstraintLayout(View v){
18 | setContentView(R.layout.activity_main);
19 | }
20 |
21 | public void loadTableLayout(View v){
22 | setContentView(R.layout.my_table_layout);
23 | }
24 |
25 | public void loadMenuLayout(View v){
26 | setContentView(R.layout.main_menu);
27 | }
28 | }
--------------------------------------------------------------------------------
/chapter 04/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
31 |
32 |
44 |
--------------------------------------------------------------------------------
/chapter 05/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/chapter 05/java/com/gamecodeschool/cardviewlayout/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.cardviewlayout;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.main_layout);
13 | }
14 | }
--------------------------------------------------------------------------------
/chapter 05/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/chapter 05/res/drawable/image_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/drawable/image_1.png
--------------------------------------------------------------------------------
/chapter 05/res/drawable/image_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/drawable/image_2.png
--------------------------------------------------------------------------------
/chapter 05/res/drawable/image_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/drawable/image_3.png
--------------------------------------------------------------------------------
/chapter 05/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/chapter 05/res/layout/card_contents_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
23 |
24 |
31 |
32 |
40 |
--------------------------------------------------------------------------------
/chapter 05/res/layout/card_contents_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
23 |
24 |
31 |
32 |
40 |
--------------------------------------------------------------------------------
/chapter 05/res/layout/card_contents_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
23 |
24 |
31 |
32 |
40 |
--------------------------------------------------------------------------------
/chapter 05/res/layout/main_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
31 |
32 |
33 |
34 |
35 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/chapter 05/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 05/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/chapter 05/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/chapter 05/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 10dp
5 |
6 |
--------------------------------------------------------------------------------
/chapter 05/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CardView Layout
3 |
--------------------------------------------------------------------------------
/chapter 05/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/chapter 07/Expressing Yourself/java/FirstFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.expressingyourself;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.navigation.fragment.NavHostFragment;
11 |
12 | public class FirstFragment extends Fragment {
13 |
14 | @Override
15 | public View onCreateView(
16 | LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState
18 | ) {
19 | // Inflate the layout for this fragment
20 | return inflater.inflate(R.layout.fragment_first, container, false);
21 | }
22 |
23 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
24 | super.onViewCreated(view, savedInstanceState);
25 |
26 | view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | NavHostFragment.findNavController(FirstFragment.this)
30 | .navigate(R.id.action_FirstFragment_to_SecondFragment);
31 | }
32 | });
33 | }
34 | }
--------------------------------------------------------------------------------
/chapter 07/Expressing Yourself/java/SecondFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.expressingyourself;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.navigation.fragment.NavHostFragment;
11 |
12 | public class SecondFragment extends Fragment {
13 |
14 | @Override
15 | public View onCreateView(
16 | LayoutInflater inflater, ViewGroup container,
17 | Bundle savedInstanceState
18 | ) {
19 | // Inflate the layout for this fragment
20 | return inflater.inflate(R.layout.fragment_second, container, false);
21 | }
22 |
23 | public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
24 | super.onViewCreated(view, savedInstanceState);
25 |
26 | view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() {
27 | @Override
28 | public void onClick(View view) {
29 | NavHostFragment.findNavController(SecondFragment.this)
30 | .navigate(R.id.action_SecondFragment_to_FirstFragment);
31 | }
32 | });
33 | }
34 | }
--------------------------------------------------------------------------------
/chapter 08/Loops/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.loops;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.View;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 | }
16 |
17 | public void countUp(View v){
18 | Log.i("message:","In countUp method");
19 |
20 | int x = 0;
21 |
22 | // Now an apparently infinite while loop
23 | while(true){
24 |
25 | // Add 1 to x each time
26 | x++;
27 | Log.i("x =", "" + x);
28 |
29 | if(x == 3){
30 | // Get me out of here
31 | break;
32 | }
33 | }
34 | }
35 |
36 | public void countDown(View v){
37 | Log.i("message:","In countDown method");
38 |
39 | int x = 4;
40 | // Now an apparently infinite while loop
41 | while(true){
42 |
43 | // Add 1 to x each time
44 | x--;
45 | Log.i("x =", "" + x);
46 |
47 | if(x == 1){
48 | // Get me out of here
49 | break;
50 | }
51 | }
52 | }
53 |
54 | public void nested(View v){
55 | Log.i("message:","In nested method");
56 |
57 | // a nested for loop
58 | for(int i = 0; i < 3; i ++){
59 |
60 | for(int j = 3; j > 0; j --){
61 |
62 | // Output the values of i and j
63 | Log.i("i =" + i,"j=" + j);
64 | }
65 | }
66 | }
67 |
68 |
69 |
70 | }
--------------------------------------------------------------------------------
/chapter 08/Loops/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
31 |
32 |
42 |
--------------------------------------------------------------------------------
/chapter 08/Switch Demo/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.switchdemo;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 |
15 |
16 | // get input from user in a String variable called command
17 | String command = "ofolof";
18 |
19 | switch(command){
20 |
21 | case "go east":
22 | Log.i("Player: ", "Moves to the east");
23 | break;
24 |
25 | case "go west":
26 | Log.i("Player: ", "Moves to the East" );
27 |
28 | break;
29 |
30 | case "go north":
31 | Log.i("Player: ", "Moves to the North" );
32 |
33 | break;
34 |
35 | case "go south":
36 | Log.i("Player: ", "Moves to the South" );
37 |
38 | break;
39 |
40 | case "Take sword":
41 | Log.i("Player: ", "Takes the silver sword" );
42 |
43 | break;
44 |
45 | // more possible cases
46 |
47 | default:
48 | Log.i("Message: ", "Sorry I don't speak Elfish" );
49 | break;
50 |
51 | }
52 |
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/chapter 09/Exploring Method Overloading/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.exploringmethodoverloading;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.Menu;
7 | import android.view.MenuItem;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 |
16 | // Declare and initialize a String and an int
17 | int anInt = 10;
18 | String aString = "I am a string";
19 |
20 | // Now call the different versions of printStuff
21 | // The name stays the same, only the parameters vary
22 | printStuff(anInt);
23 | printStuff(aString);
24 | printStuff(anInt, aString);
25 |
26 | }
27 |
28 | void printStuff(int myInt){
29 | Log.i("info", "This is the int only version");
30 | Log.i("info", "myInt = " + myInt);
31 | }
32 |
33 | void printStuff(String myString){
34 | Log.i("info", "This is the String only version");
35 | Log.i("info", "myString = "+ myString);
36 | }
37 |
38 | void printStuff(int myInt, String myString){
39 | Log.i("info", "This is the combined int and String version");
40 | Log.i("info", "myInt = "+ myInt);
41 | Log.i("info", "myString = "+ myString);
42 | }
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/chapter 09/Real World Methods/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.realworldmethods;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 |
15 |
16 | String joinedString = joinThese("Methods ", "are ", "cool ");
17 | Log.i("joinedString = ","" + joinedString);
18 |
19 | float area = getAreaCircle(5f);
20 | Log.i("area = ","" + area);
21 |
22 | int a = 0;
23 | changeA(a);
24 | Log.i("a = ","" + a);
25 |
26 | }
27 |
28 | String joinThese(String a, String b, String c){
29 | return a + b + c;
30 | }
31 |
32 | float getAreaCircle(float radius){
33 |
34 | return 3.141f * radius * radius;
35 |
36 | }
37 |
38 | void changeA(int a){
39 | a++;
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/chapter 10/Basic Classes/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.basicclasses;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 |
15 | // first we make an object of type soldier
16 | Soldier rambo = new Soldier();
17 | rambo.soldierType = "Green Beret";
18 | rambo.health = 150;
19 | // It takes allot to kill Rambo
20 |
21 | // Now we make another Soldier object
22 | Soldier vassily = new Soldier();
23 | vassily.soldierType = "Sniper";
24 | vassily.health = 50;
25 | // Snipers have less health
26 |
27 | // And one more Soldier object
28 | Soldier wellington = new Soldier();
29 | wellington.soldierType = "Sailor";
30 | wellington.health = 100;
31 | // He's tough but no green beret
32 |
33 | Log.i("Rambo's health = ", "" + rambo.health);
34 | Log.i("Vassily's health = ", "" + vassily.health);
35 | Log.i("Wellington's health = ", "" + wellington.health);
36 |
37 | rambo.shootEnemy();
38 | vassily.shootEnemy();
39 | wellington.shootEnemy();
40 |
41 | }
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/chapter 10/Basic Classes/java/Soldier.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.basicclasses;
2 |
3 | import android.util.Log;
4 |
5 |
6 | public class Soldier {
7 | int health;
8 | String soldierType;
9 |
10 | void shootEnemy(){
11 | //let's print which type of soldier is shooting
12 | Log.i(soldierType, " is shooting");
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/chapter 11/Access Scope This And Static/AlienShip.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.accessscopethisandstatic;
2 |
3 | import android.util.Log;
4 |
5 | public class AlienShip {
6 | private static int numShips;
7 | private int shieldStrength;
8 | public String shipName;
9 |
10 | public AlienShip(){
11 | numShips++;
12 | //Can call private methods from here because I am part
13 | //of the class
14 | //If didn't have "this" then this call might be less clear
15 | //But this "this" isn't strictly necessary
16 | this.setShieldStrength(100);
17 | //Because of "this" I am sure I am setting the correct shieldStrength
18 | }
19 |
20 | public static int getNumShips(){
21 | return numShips;
22 |
23 | }
24 |
25 | private void setShieldStrength(int shieldStrength){
26 | //"this" distinguishes between the member variable shieldStrength
27 | //And the local variable/paramater of the same name
28 | this.shieldStrength = shieldStrength;
29 | }
30 |
31 |
32 | public int getShieldStrength(){
33 | return this.shieldStrength;
34 | }
35 |
36 | public void hitDetected(){
37 |
38 | shieldStrength -=25;
39 | Log.i("Incomiming: ","Bam!!");
40 | if (shieldStrength == 0){
41 | destroyShip();
42 | }
43 |
44 | }
45 |
46 | private void destroyShip(){
47 | numShips--;
48 | Log.i("Explosion: ", ""+this.shipName + " destroyed");
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/chapter 11/Access Scope This And Static/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.accessscopethisandstatic;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_main);
13 |
14 | //every time we do this the constructor runs
15 | AlienShip girlShip = new AlienShip();
16 | AlienShip boyShip = new AlienShip();
17 |
18 | //Look no objects but using the static method
19 | Log.i("numShips: ", "" + AlienShip.getNumShips());
20 |
21 | //This works because shipName is public
22 | girlShip.shipName = "Corrine Yu";
23 | boyShip.shipName = "Andre LaMothe";
24 |
25 | //This won't work because shieldStrenth is private
26 | //girlship.shieldStrength = 999;
27 |
28 | //But we have a public getter
29 | Log.i("girlShip shields: ", "" + girlShip.getShieldStrength());
30 | Log.i("boyShip shields: ", "" + boyShip.getShieldStrength());
31 |
32 | //But we can't do this because it's private
33 | //boyship.setShieldStrength(1000000);
34 |
35 | //lets shoot some ships
36 | girlShip.hitDetected();
37 | Log.i("girlShip shields: ", "" + girlShip.getShieldStrength());
38 | Log.i("boyShip shields: ", "" + boyShip.getShieldStrength());
39 | boyShip.hitDetected();
40 | boyShip.hitDetected();
41 | boyShip.hitDetected();
42 | Log.i("girlShip shields: ", "" + girlShip.getShieldStrength());
43 | Log.i("boyShip shields: ", "" + boyShip.getShieldStrength());
44 | boyShip.hitDetected();//ahhh
45 | Log.i("girlShip shields: ", "" + girlShip.getShieldStrength());
46 | Log.i("boyShip shields: ", "" + boyShip.getShieldStrength());
47 | Log.i("numShips: ", "" + AlienShip.getNumShips());
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/chapter 11/Getters And Setters/Hospital.java:
--------------------------------------------------------------------------------
1 | package com.packtpub.gettersandsetters.app;
2 |
3 | import android.util.Log;
4 |
5 |
6 | class Hospital{
7 | protected void healSoldier(Soldier soldierToHeal){
8 | Log.i("Just arrived at healSoldier method = ", "" + soldierToHeal.getHealth());
9 | int health = soldierToHeal.getHealth();
10 | health = health + 10;
11 | soldierToHeal.setHealth(health);
12 | Log.i("Just finnishing heal soldier method = ", "" + soldierToHeal.getHealth());
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/chapter 11/Getters And Setters/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.packtpub.gettersandsetters.app;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 |
15 | Soldier mySoldier = new Soldier();
16 | //mySoldier.health = 100;//Doesn't work private
17 | //we can use the public getter setHealth()
18 | mySoldier.setHealth(100);//That's better
19 | Log.i("Just set health to 100 = ", ""+mySoldier.getHealth());
20 |
21 |
22 | Hospital militaryHospital = new Hospital();
23 |
24 | //Oh no mySoldier has been wounded
25 | mySoldier.setHealth(10);
26 | Log.i("Just got wounded to 10 = ", ""+mySoldier.getHealth());
27 |
28 | //Take him to the hospital
29 | //But my health variable is private
30 | //And Hospital won't be able to access it
31 | //I'm doomed - tell Laura I love her
32 |
33 | //No wait- what about my public getters and setters?
34 | //We can use the public getters and setters from another method
35 |
36 | militaryHospital.healSoldier(mySoldier);
37 | Log.i("Back from the militaryHospital = ", ""+mySoldier.getHealth());
38 | //mySoldiers private variable health has been increased by 10
39 | //I'm feeling much better thanks!
40 |
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/chapter 11/Getters And Setters/Soldier.java:
--------------------------------------------------------------------------------
1 | package com.packtpub.gettersandsetters.app;
2 |
3 | public class Soldier{
4 | private int health;
5 | public int getHealth(){
6 | return health;
7 | }
8 |
9 | public void setHealth(int newHealth){
10 | health = newHealth;
11 | }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/chapter 11/Inheritance Example/AlienShip.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.inheritanceexample.app;
2 |
3 | import android.util.Log;
4 |
5 | public abstract class AlienShip {
6 | private static int numShips;
7 | private int shieldStrength;
8 | public String shipName;
9 |
10 | public AlienShip(int shieldStrength){
11 | Log.i("Location: ", "AlienShip constructor");
12 | numShips++;
13 | setShieldStrength(shieldStrength);
14 | }
15 |
16 | public abstract void fireWeapon();//Ahh my body
17 |
18 | public static int getNumShips(){
19 | return numShips;
20 | }
21 |
22 | private void setShieldStrength(int shieldStrength){
23 | this.shieldStrength = shieldStrength;
24 | }
25 |
26 |
27 | public int getShieldStrength(){
28 | return this.shieldStrength;
29 | }
30 |
31 | public void hitDetected(){
32 | shieldStrength -=25;
33 | Log.i("Incomiming: ", "Bam!!");
34 | if (shieldStrength == 0){
35 | destroyShip();
36 | }
37 |
38 | }
39 |
40 | private void destroyShip(){
41 | numShips--;
42 | Log.i("Explosion: ", ""+this.shipName + " destroyed");
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/chapter 11/Inheritance Example/Bomber.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.inheritanceexample.app;
2 |
3 | import android.util.Log;
4 |
5 | public class Bomber extends AlienShip {
6 |
7 | public Bomber(){
8 | super(100);
9 | //Weak shields for a bomber
10 | Log.i("Location: ", "Bomber constructor");
11 | }
12 |
13 | public void fireWeapon(){
14 | Log.i("Firing weapon: ", "bombs away");
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/chapter 11/Inheritance Example/Fighter.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.inheritanceexample.app;
2 |
3 | import android.util.Log;
4 |
5 | public class Fighter extends AlienShip{
6 |
7 | public Fighter(){
8 | super(400);
9 | //Strong shields for a fighter
10 | Log.i("Location: ", "Fighter constructor");
11 | }
12 |
13 | public void fireWeapon(){
14 | Log.i("Firing weapon: ", "lasers firing");
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/chapter 11/Inheritance Example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.inheritanceexample.app;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_main);
13 |
14 | Fighter aFighter = new Fighter();
15 | Bomber aBomber = new Bomber();
16 |
17 | //Can't do this AlienShip is abstract -
18 | //Literally speaking as well as in code
19 | //AlienShip alienShip = new AlienShip(500);
20 |
21 | //But our objects of the subclasses can still do
22 | //everything the AlienShip is meant to do
23 | aBomber.shipName = "Newell Bomber";
24 | aFighter.shipName = "Meier Fighter";
25 |
26 | //And because of the overiden constructor
27 | //That still calls the super constructor
28 | //They have unique properties
29 | Log.i("aFighter Shield:", ""+ aFighter.getShieldStrength());
30 | Log.i("aBomber Shield:", ""+ aBomber.getShieldStrength());
31 |
32 | //As well as certain things in certain ways
33 | //That are unique to the subclass
34 | aBomber.fireWeapon();
35 | aFighter.fireWeapon();
36 |
37 | //Take down those alien ships
38 | //Focus on the bomber it has a weaker shield
39 | aBomber.hitDetected();
40 | aBomber.hitDetected();
41 | aBomber.hitDetected();
42 | aBomber.hitDetected();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/chapter 13/Widget Exploration/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/chapter 14/Dialog Demo/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.dialogdemo;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 |
16 | Button button = (Button) findViewById(R.id.button);
17 |
18 | button.setOnClickListener(
19 | new View.OnClickListener() {
20 |
21 | @Override
22 | public void onClick(View v) {
23 | // We only handle one button
24 | // So no switching required
25 | MyDialog myDialog = new MyDialog();
26 | myDialog.show(getSupportFragmentManager(), "123");
27 | // This calls onCreateDialog
28 | // Don't worry about the strange looking 123
29 | // We will find out about this in chapter 18
30 | }
31 | }
32 | );
33 |
34 | }
35 | }
--------------------------------------------------------------------------------
/chapter 14/Dialog Demo/java/MyDialog.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.dialogdemo;
2 |
3 | import androidx.fragment.app.DialogFragment;
4 | import android.app.Dialog;
5 | import android.content.DialogInterface;
6 | import android.os.Bundle;
7 |
8 | import androidx.appcompat.app.AlertDialog;
9 |
10 |
11 | public class MyDialog extends DialogFragment {
12 |
13 | @Override
14 | public Dialog onCreateDialog(Bundle savedInstanceState) {
15 |
16 | // Use the Builder class because this dialog
17 | // has a simple UI
18 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
19 |
20 | // Dialog will have "Make a selection" as the title
21 | builder.setMessage("Make a selection")
22 |
23 | // An OK button that does nothing
24 | .setPositiveButton("OK", new DialogInterface.OnClickListener() {
25 | public void onClick(DialogInterface dialog, int id) {
26 | // Nothing happening here
27 | }
28 | })
29 |
30 | // A "Cancel" button that does nothing
31 | .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
32 | public void onClick(DialogInterface dialog, int id) {
33 | // Nothing happening here either
34 | }
35 | });
36 |
37 | // Create the object and return it
38 | return builder.create();
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/chapter 14/Dialog Demo/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
28 |
29 |
--------------------------------------------------------------------------------
/chapter 14/Note to Self/java/Note.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.notetoself;
2 |
3 | public class Note {
4 | private String mTitle;
5 | private String mDescription;
6 | private boolean mIdea;
7 | private boolean mTodo;
8 | private boolean mImportant;
9 |
10 | public String getTitle() {
11 | return mTitle;
12 | }
13 |
14 | public void setTitle(String mTitle) {
15 | this.mTitle = mTitle;
16 | }
17 |
18 | public String getDescription() {
19 | return mDescription;
20 | }
21 |
22 | public void setDescription(String mDescription) {
23 | this.mDescription = mDescription;
24 | }
25 |
26 | public boolean isIdea() {
27 | return mIdea;
28 | }
29 |
30 | public void setIdea(boolean mIdea) {
31 | this.mIdea = mIdea;
32 | }
33 |
34 | public boolean isTodo() {
35 | return mTodo;
36 | }
37 |
38 | public void setTodo(boolean mTodo) {
39 | this.mTodo = mTodo;
40 | }
41 |
42 | public boolean isImportant() {
43 | return mImportant;
44 | }
45 |
46 | public void setImportant(boolean mImportant) {
47 | this.mImportant = mImportant;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/chapter 14/Note to Self/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/chapter 14/Note to Self/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
--------------------------------------------------------------------------------
/chapter 14/Note to Self/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Note to Self
3 | Settings
4 |
5 | First Fragment
6 | Second Fragment
7 | Next
8 | Previous
9 |
10 | Hello first fragment
11 | Hello second fragment. Arg: %1$s
12 |
13 | add
14 | Title
15 | Description
16 | Idea
17 | Important
18 | To do
19 | Cancel
20 | OK
21 |
22 | Settings
23 | Theme
24 | Light
25 | Dark
26 |
27 |
--------------------------------------------------------------------------------
/chapter 15/Dynamic array example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.dynamicarrayexample;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 |
15 | //Declaring and allocating in one step
16 | int[] ourArray = new int[1000];
17 |
18 | //Let's initialize ourArray using a for loop
19 | //Because more than a few variables is allot of typing!
20 | for(int i = 0; i < 1000; i++){
21 | //Put the value of ourValue into our array
22 | //At the position determined by i.
23 | ourArray[i] = i*5;
24 |
25 | //Output what is going on
26 | Log.i("info", "i = " + i);
27 | Log.i("info", "ourArray[i] = " + ourArray[i]);
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/chapter 15/Simple Array Example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.packtpub.simplearrayexample.simplearrayexample;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 |
8 | public class MainActivity extends AppCompatActivity {
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 |
15 | //Declaring an array
16 | int[] ourArray;
17 |
18 | //Allocate memory for a maximum size of 5 elements
19 | ourArray = new int[5];
20 |
21 | //Initialize ourArray with values
22 | //The values are arbitrary as long as they are int
23 | //The indexes are not arbitrary 0 through 4 or crash!
24 | ourArray[0] = 25;
25 | ourArray[1] = 50;
26 | ourArray[2] = 125;
27 | ourArray[3] = 68;
28 | ourArray[4] = 47;
29 |
30 | //Output all the stored values
31 | Log.i("info", "Here is ourArray:");
32 | Log.i("info", "[0] = "+ourArray[0]);
33 | Log.i("info", "[1] = "+ourArray[1]);
34 | Log.i("info", "[2] = "+ourArray[2]);
35 | Log.i("info", "[3] = "+ourArray[3]);
36 | Log.i("info", "[4] = "+ourArray[4]);
37 |
38 | //We can do any calculation with an array element
39 | //As long as it is appropriate to the contained type
40 | //Like this:
41 | int answer = ourArray[0] +
42 | ourArray[1] +
43 | ourArray[2] +
44 | ourArray[3] +
45 | ourArray[4];
46 |
47 | Log.i("info", "Answer = "+answer);
48 | }
49 |
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/chapter 16/Note to self/java/Note.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.notetoself;
2 |
3 | public class Note {
4 | private String mTitle;
5 | private String mDescription;
6 | private boolean mIdea;
7 | private boolean mTodo;
8 | private boolean mImportant;
9 |
10 | public String getTitle() {
11 | return mTitle;
12 | }
13 |
14 | public void setTitle(String mTitle) {
15 | this.mTitle = mTitle;
16 | }
17 |
18 | public String getDescription() {
19 | return mDescription;
20 | }
21 |
22 | public void setDescription(String mDescription) {
23 | this.mDescription = mDescription;
24 | }
25 |
26 | public boolean isIdea() {
27 | return mIdea;
28 | }
29 |
30 | public void setIdea(boolean mIdea) {
31 | this.mIdea = mIdea;
32 | }
33 |
34 | public boolean isTodo() {
35 | return mTodo;
36 | }
37 |
38 | public void setTodo(boolean mTodo) {
39 | this.mTodo = mTodo;
40 | }
41 |
42 | public boolean isImportant() {
43 | return mImportant;
44 | }
45 |
46 | public void setImportant(boolean mImportant) {
47 | this.mImportant = mImportant;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/chapter 16/Note to self/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/chapter 16/Note to self/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
--------------------------------------------------------------------------------
/chapter 16/Note to self/layout/listitem.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
22 |
23 |
28 |
--------------------------------------------------------------------------------
/chapter 16/Note to self/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Note to Self
3 | Settings
4 |
5 | First Fragment
6 | Second Fragment
7 | Next
8 | Previous
9 |
10 | Hello first fragment
11 | Hello second fragment. Arg: %1$s
12 |
13 | add
14 | Title
15 | Description
16 | Idea
17 | Important
18 | To do
19 | Cancel
20 | OK
21 |
22 | Settings
23 | Theme
24 | Light
25 | Dark
26 |
27 |
--------------------------------------------------------------------------------
/chapter 17/Note to self/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/chapter 17/Note to self/java/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.notetoself;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.widget.CompoundButton;
8 | import android.widget.Switch;
9 |
10 | public class SettingsActivity extends AppCompatActivity {
11 |
12 | private SharedPreferences mPrefs;
13 | private SharedPreferences.Editor mEditor;
14 |
15 | private boolean mShowDividers;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_settings);
21 |
22 | mPrefs = getSharedPreferences("Note to self", MODE_PRIVATE);
23 | mEditor = mPrefs.edit();
24 |
25 | mShowDividers = mPrefs.getBoolean("dividers", true);
26 |
27 | Switch switch1 = findViewById(R.id.switch1);
28 | // Set the switch on or off as appropriate
29 | switch1.setChecked(mShowDividers);
30 |
31 | switch1.setOnCheckedChangeListener(
32 | new CompoundButton.OnCheckedChangeListener() {
33 |
34 | public void onCheckedChanged(
35 | CompoundButton buttonView,
36 | boolean isChecked) {
37 |
38 | if(isChecked){
39 | mEditor.putBoolean(
40 | "dividers", true);
41 |
42 | mShowDividers = true;
43 |
44 | }else{
45 | mEditor.putBoolean(
46 | "dividers", false);
47 |
48 | mShowDividers = false;
49 | }
50 | }
51 | }
52 | );
53 | }
54 |
55 | @Override
56 | protected void onPause() {
57 | super.onPause();
58 |
59 | // Save the settings here
60 | mEditor.commit();
61 | }
62 |
63 | }
--------------------------------------------------------------------------------
/chapter 17/Note to self/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/chapter 17/Note to self/layout/activity_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
--------------------------------------------------------------------------------
/chapter 17/Note to self/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
--------------------------------------------------------------------------------
/chapter 17/Note to self/layout/listitem.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
22 |
23 |
28 |
--------------------------------------------------------------------------------
/chapter 17/Note to self/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Note to Self
3 | Settings
4 |
5 | First Fragment
6 | Second Fragment
7 | Next
8 | Previous
9 |
10 | Hello first fragment
11 | Hello second fragment. Arg: %1$s
12 |
13 | add
14 | Title
15 | Description
16 | Idea
17 | Important
18 | To do
19 | Cancel
20 | OK
21 |
22 | Settings
23 | Theme
24 | Light
25 | Dark
26 |
27 |
--------------------------------------------------------------------------------
/chapter 18/Note to self/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/chapter 18/Note to self/java/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.notetoself;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.widget.CompoundButton;
8 | import android.widget.Switch;
9 |
10 | public class SettingsActivity extends AppCompatActivity {
11 |
12 | private SharedPreferences mPrefs;
13 | private SharedPreferences.Editor mEditor;
14 |
15 | private boolean mShowDividers;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_settings);
21 |
22 | mPrefs = getSharedPreferences("Note to self", MODE_PRIVATE);
23 | mEditor = mPrefs.edit();
24 |
25 | mShowDividers = mPrefs.getBoolean("dividers", true);
26 |
27 | Switch switch1 = (Switch) findViewById(R.id.switch1);
28 | // Set the switch on or off as appropriate
29 | switch1.setChecked(mShowDividers);
30 |
31 | switch1.setOnCheckedChangeListener(
32 | new CompoundButton.OnCheckedChangeListener() {
33 |
34 | public void onCheckedChanged(
35 | CompoundButton buttonView,
36 | boolean isChecked) {
37 |
38 | if(isChecked){
39 | mEditor.putBoolean(
40 | "dividers", true);
41 |
42 | mShowDividers = true;
43 |
44 | }else{
45 | mEditor.putBoolean(
46 | "dividers", false);
47 |
48 | mShowDividers = false;
49 | }
50 | }
51 | }
52 | );
53 | }
54 |
55 | @Override
56 | protected void onPause() {
57 | super.onPause();
58 |
59 | // Save the settings here
60 | mEditor.commit();
61 | }
62 |
63 | }
--------------------------------------------------------------------------------
/chapter 18/Note to self/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/chapter 18/Note to self/layout/activity_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
--------------------------------------------------------------------------------
/chapter 18/Note to self/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
--------------------------------------------------------------------------------
/chapter 18/Note to self/layout/listitem.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
22 |
23 |
28 |
--------------------------------------------------------------------------------
/chapter 18/Note to self/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Hinweis auf selbst
5 | Einstellungen
6 |
7 | add
8 | Titel
9 | Beschreibung
10 | Idee
11 | Wichtig
12 | zu tun
13 | Abbrechen
14 | Okay
15 |
16 | Einstellungen
17 |
18 | Eine neue Note hinzufügen
19 | Ihre Notiz
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/chapter 18/Note to self/values-es/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Nota a sí mismo
6 | Configuración
7 |
8 | add
9 | Título
10 | Descripción
11 | Idea
12 | Importante
13 | Que hacer
14 | Cancelar
15 | Vale
16 |
17 | Configuración
18 |
19 | Agregar una nueva nota
20 | Su nota
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/chapter 18/Note to self/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Note to Self
3 | Settings
4 |
5 | First Fragment
6 | Second Fragment
7 | Next
8 | Previous
9 |
10 | Hello first fragment
11 | Hello second fragment. Arg: %1$s
12 |
13 | add
14 | Title
15 | Description
16 | Idea
17 | Important
18 | To do
19 | Cancel
20 | OK
21 |
22 | Settings
23 | Theme
24 | Light
25 | Dark
26 |
27 | Add a new note
28 | Your note
29 |
30 |
31 |
--------------------------------------------------------------------------------
/chapter 19/anim/bounce.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter 19/anim/fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter 19/anim/fade_in_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/chapter 19/anim/fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/chapter 19/anim/flash.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/chapter 19/anim/left_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/chapter 19/anim/right_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/chapter 19/anim/rotate_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/chapter 19/anim/rotate_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/chapter 19/anim/top_bot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/chapter 19/anim/zoom_in.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/chapter 19/anim/zoom_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/chapter 20/Canvas Demo/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.canvasdemo;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.os.Bundle;
9 | import android.widget.ImageView;
10 |
11 | public class MainActivity extends Activity {
12 |
13 | // Here are all the objects(instances)
14 | // of classes that we need to do some drawing
15 | ImageView myImageView;
16 | Bitmap myBlankBitmap;
17 | Canvas myCanvas;
18 | Paint myPaint;
19 |
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 |
25 | // Initialize all the objects ready for drawing
26 | // We will do this inside the onCreate method
27 | int widthInPixels = 800;
28 | int heightInPixels = 600;
29 |
30 | // Create a new Bitmap
31 | myBlankBitmap = Bitmap.createBitmap(widthInPixels,
32 | heightInPixels,
33 | Bitmap.Config.ARGB_8888);
34 |
35 | // Initialize the Canvas and associate it
36 | // with the Bitmap to draw on
37 | myCanvas = new Canvas(myBlankBitmap);
38 |
39 | // Initialize the ImageView and the Paint
40 | myImageView = new ImageView(this);
41 | myPaint = new Paint();
42 |
43 | // Draw on the Bitmap
44 | // Wipe the Bitmap with a blue color
45 | myCanvas.drawColor(Color.argb(255, 0, 0, 255));
46 |
47 | // Re-size the text
48 | myPaint.setTextSize(100);
49 | // Change the paint to white
50 | myPaint.setColor(Color.argb(255, 255, 255, 255));
51 | // Draw some text
52 | myCanvas.drawText("Hello World!",100, 100, myPaint);
53 |
54 | // Change the paint to yellow
55 | myPaint.setColor(Color.argb(255, 212, 207, 62));
56 | // Draw a circle
57 | myCanvas.drawCircle(400,250, 100, myPaint);
58 | // Associate the drawn upon Bitmap with the ImageView
59 | myImageView.setImageBitmap(myBlankBitmap);
60 | // Tell Android to set our drawing
61 | // as the view for this app
62 | // via the ImageView
63 | setContentView(myImageView);
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/chapter 20/Manipulating Bitmaps/drawable/bob.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 20/Manipulating Bitmaps/drawable/bob.png
--------------------------------------------------------------------------------
/chapter 21/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/chapter 21/java/LiveDrawingActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.livedrawing;
2 |
3 | import android.os.Bundle;
4 |
5 | import android.app.Activity;
6 | import android.graphics.Point;
7 | import android.os.Bundle;
8 | import android.view.Display;
9 | import android.view.Window;
10 |
11 | public class LiveDrawingActivity extends Activity {
12 |
13 | private LiveDrawingView mLiveDrawingView;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | requestWindowFeature(Window.FEATURE_NO_TITLE);
19 |
20 | Display display = getWindowManager().getDefaultDisplay();
21 | Point size = new Point();
22 | display.getSize(size);
23 |
24 | mLiveDrawingView = new LiveDrawingView(
25 | this, size.x, size.y);
26 | setContentView(mLiveDrawingView);
27 | }
28 |
29 |
30 | @Override
31 | protected void onResume() {
32 | super.onResume();
33 |
34 | // More code here later in the chapter
35 | mLiveDrawingView.resume();
36 | }
37 |
38 | @Override
39 | protected void onPause() {
40 | super.onPause();
41 |
42 | // More code here later in the chapter
43 | mLiveDrawingView.pause();
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/chapter 21/java/Particle.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.livedrawing;
2 |
3 | public class Particle {
4 | }
5 |
--------------------------------------------------------------------------------
/chapter 21/java/ParticleSystem.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.livedrawing;
2 |
3 | public class ParticleSystem {
4 | }
5 |
--------------------------------------------------------------------------------
/chapter 22/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/chapter 22/java/LiveDrawingActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.livedrawing;
2 |
3 | import android.os.Bundle;
4 |
5 | import android.app.Activity;
6 | import android.graphics.Point;
7 | import android.os.Bundle;
8 | import android.view.Display;
9 | import android.view.Window;
10 |
11 | public class LiveDrawingActivity extends Activity {
12 |
13 | private LiveDrawingView mLiveDrawingView;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | requestWindowFeature(Window.FEATURE_NO_TITLE);
19 |
20 | Display display = getWindowManager().getDefaultDisplay();
21 | Point size = new Point();
22 | display.getSize(size);
23 |
24 | mLiveDrawingView = new LiveDrawingView(
25 | this, size.x, size.y);
26 | setContentView(mLiveDrawingView);
27 | }
28 |
29 |
30 | @Override
31 | protected void onResume() {
32 | super.onResume();
33 |
34 | // More code here later in the chapter
35 | mLiveDrawingView.resume();
36 | }
37 |
38 | @Override
39 | protected void onPause() {
40 | super.onPause();
41 |
42 | // More code here later in the chapter
43 | mLiveDrawingView.pause();
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/chapter 22/java/Particle.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.livedrawing;
2 |
3 | import android.graphics.PointF;
4 |
5 | class Particle {
6 |
7 | PointF mVelocity;
8 | PointF mPosition;
9 |
10 | Particle(PointF direction)
11 | {
12 | mVelocity = new PointF();
13 | mPosition = new PointF();
14 |
15 | // Determine the direction
16 | mVelocity.x = direction.x;
17 | mVelocity.y = direction.y;
18 | }
19 |
20 | void update(float fps)
21 | {
22 | // Move the particle
23 | mPosition.x += mVelocity.x;
24 | mPosition.y += mVelocity.y;
25 | }
26 |
27 | void setPosition(PointF position)
28 | {
29 | mPosition.x = position.x;
30 | mPosition.y = position.y;
31 | }
32 |
33 | PointF getPosition()
34 | {
35 | return mPosition;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/chapter 23/assets/fx1.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 23/assets/fx1.ogg
--------------------------------------------------------------------------------
/chapter 23/assets/fx2.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 23/assets/fx2.ogg
--------------------------------------------------------------------------------
/chapter 23/assets/fx3.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 23/assets/fx3.ogg
--------------------------------------------------------------------------------
/chapter 23/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Sound Demo
3 | Settings
4 |
5 |
6 | - 0
7 | - 1
8 | - 3
9 | - 5
10 | - 10
11 |
12 |
13 |
--------------------------------------------------------------------------------
/chapter 24/Device Detection/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.devicedetection;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 | import android.widget.TextView;
7 | import android.graphics.Point;
8 | import android.view.Display;
9 | import android.view.View;
10 |
11 |
12 | public class MainActivity extends AppCompatActivity {
13 | private TextView txtOrientation;
14 | private TextView txtResolution;
15 |
16 |
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.activity_main);
22 |
23 | // Get a reference to our TextView widgets
24 | txtOrientation = findViewById(R.id.txtOrientation);
25 | txtResolution = findViewById(R.id.txtResolution);
26 |
27 | }
28 |
29 | public void detectDevice(View v){
30 |
31 | // What is the orientation?
32 | Display display = getWindowManager().getDefaultDisplay();
33 | txtOrientation.setText("" + display.getRotation());
34 |
35 | // What is the resolution?
36 | Point xy = new Point();
37 | display.getSize(xy);
38 | txtResolution.setText("x = " + xy.x + " y = " + xy.y);
39 |
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/chapter 24/Device Detection/layout-land/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
31 |
32 |
42 |
--------------------------------------------------------------------------------
/chapter 24/Device Detection/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
32 |
33 |
43 |
--------------------------------------------------------------------------------
/chapter 24/Simple Fragment/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.simplefragment;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import androidx.fragment.app.Fragment;
6 | import androidx.fragment.app.FragmentManager;
7 | import android.os.Bundle;
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 |
16 | // Get a fragment manager
17 | FragmentManager fManager = getSupportFragmentManager();
18 |
19 | // Create a new fragment using the manager
20 | // Passing in the id of the layout to hold it
21 | Fragment frag = fManager.findFragmentById(R.id.fragmentHolder);
22 |
23 | // Check the fragment has not already been initialized
24 | if(frag == null){
25 |
26 | // Initialize the fragment based on our SimpleFragment
27 | frag = new SimpleFragment();
28 | fManager.beginTransaction()
29 | .add(R.id.fragmentHolder, frag)
30 | .commit();
31 |
32 | }
33 |
34 | }
35 | }
--------------------------------------------------------------------------------
/chapter 24/Simple Fragment/java/SimpleFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.simplefragment;
2 |
3 |
4 | import androidx.fragment.app.Fragment;
5 | import android.os.Bundle;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.Button;
10 | import android.widget.Toast;
11 |
12 |
13 | public class SimpleFragment extends Fragment {
14 |
15 | // member variables accessible from anywhere in this fragment
16 | String myString;
17 | Button myButton;
18 |
19 | @Override
20 | public void onCreate(Bundle savedInstanceState){
21 | super.onCreate(savedInstanceState);
22 |
23 | myString = "Hello from SimpleFragment";
24 | }
25 |
26 | @Override
27 | public View onCreateView(LayoutInflater inflater, ViewGroup
28 | container, Bundle savedInstanceState) {
29 |
30 | View view = inflater.inflate(R.layout.fragment_layout,
31 | container, false);
32 |
33 | myButton = view.findViewById(R.id.button);
34 |
35 | myButton.setOnClickListener(
36 | new View.OnClickListener() {
37 |
38 | @Override
39 | public void onClick(View v) {
40 |
41 | Toast.makeText(getActivity(),
42 | myString ,
43 | Toast.LENGTH_SHORT).
44 | show();
45 | }
46 | });
47 |
48 |
49 |
50 | return view;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/chapter 24/Simple Fragment/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/chapter 24/Simple Fragment/layout/fragment_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
--------------------------------------------------------------------------------
/chapter 25/Image Pager/drawable/image1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 25/Image Pager/drawable/image1.png
--------------------------------------------------------------------------------
/chapter 25/Image Pager/drawable/image2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 25/Image Pager/drawable/image2.png
--------------------------------------------------------------------------------
/chapter 25/Image Pager/drawable/image3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 25/Image Pager/drawable/image3.png
--------------------------------------------------------------------------------
/chapter 25/Image Pager/drawable/image4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 25/Image Pager/drawable/image4.png
--------------------------------------------------------------------------------
/chapter 25/Image Pager/drawable/image5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 25/Image Pager/drawable/image5.png
--------------------------------------------------------------------------------
/chapter 25/Image Pager/drawable/image6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Android-Programming-for-Beginners-Third-Edition/cee9d229d49531e262a21abf6eba1a4f400101e4/chapter 25/Image Pager/drawable/image6.png
--------------------------------------------------------------------------------
/chapter 25/Image Pager/java/ImagePagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.imagepager;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 | import android.widget.RelativeLayout;
9 |
10 | import androidx.viewpager.widget.PagerAdapter;
11 | import androidx.viewpager.widget.ViewPager;
12 |
13 | public class ImagePagerAdapter extends PagerAdapter {
14 |
15 | Context context;
16 |
17 | int[] images;
18 | LayoutInflater inflater;
19 |
20 | public ImagePagerAdapter(Context context, int[] images) {
21 | this.context = context;
22 |
23 | this.images = images;
24 | }
25 |
26 | @Override
27 | public int getCount() {
28 |
29 | return images.length;
30 | }
31 |
32 | @Override
33 | public boolean isViewFromObject(View view, Object object) {
34 | return view == object;
35 | }
36 |
37 | @Override
38 | public Object instantiateItem(ViewGroup container, int position) {
39 |
40 | ImageView image;
41 |
42 | inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
43 | View itemView = inflater.inflate(R.layout.pager_item, container,false);
44 |
45 | // get reference to imageView in pager_item layout
46 | image = itemView.findViewById(R.id.imageView);
47 |
48 | // Set an image to the ImageView
49 | image.setImageResource(images[position]);
50 |
51 | // Add pager_item layout as the current page to the ViewPager
52 | ((ViewPager) container).addView(itemView);
53 |
54 | return itemView;
55 | }
56 |
57 | @Override
58 | public void destroyItem(ViewGroup container, int position, Object object) {
59 | // Remove pager_item layout from ViewPager
60 | container.removeView((RelativeLayout) object);
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/chapter 25/Image Pager/java/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.imagepager;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.view.Menu;
6 | import android.view.MenuItem;
7 |
8 | import androidx.appcompat.app.AppCompatActivity;
9 | import androidx.viewpager.widget.PagerAdapter;
10 | import androidx.viewpager.widget.ViewPager;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | ViewPager viewPager;
15 | PagerAdapter adapter;
16 |
17 | int[] images;
18 |
19 | @Override
20 | public void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 |
23 | setContentView(R.layout.activity_main);
24 |
25 | // Grab all the images and stuff them in our array
26 | images = new int[] { R.drawable.image1,
27 | R.drawable.image2,
28 | R.drawable.image3,
29 | R.drawable.image4,
30 | R.drawable.image5,
31 | R.drawable.image6 };
32 |
33 | // get a reference to the ViewPager in the layout
34 | viewPager = (ViewPager) findViewById(R.id.pager);
35 |
36 | // Initialize our adapter
37 | adapter = new ImagePagerAdapter(MainActivity.this, images);
38 |
39 | // Binds the Adapter to the ViewPager
40 | viewPager.setAdapter(adapter);
41 |
42 | }
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/chapter 25/Image Pager/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/chapter 25/Image Pager/layout/pager_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/chapter 26/java/DeleteFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.agedatabase;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.Button;
8 | import android.widget.EditText;
9 | import android.widget.TextView;
10 |
11 | import androidx.fragment.app.Fragment;
12 |
13 | public class DeleteFragment extends Fragment {
14 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
15 | View v = inflater.inflate(R.layout.content_delete, container, false);
16 |
17 |
18 |
19 | return v;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/chapter 26/java/InsertFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.agedatabase;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.Button;
8 | import android.widget.EditText;
9 |
10 | import androidx.fragment.app.Fragment;
11 |
12 | public class InsertFragment extends Fragment {
13 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
14 | View v = inflater.inflate(R.layout.content_insert, container, false);
15 |
16 |
17 |
18 | return v;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/chapter 26/java/README.txt:
--------------------------------------------------------------------------------
1 | There are more files in the project that were auto-generated but are not required at all/not required to be edited
--------------------------------------------------------------------------------
/chapter 26/java/ResultsFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.agedatabase;
2 |
3 | import android.database.Cursor;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import androidx.fragment.app.Fragment;
12 |
13 | public class ResultsFragment extends Fragment {
14 |
15 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
16 | View v = inflater.inflate(R.layout.content_results, container, false);
17 |
18 |
19 |
20 | return v;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/chapter 26/java/SearchFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.agedatabase;
2 |
3 | import android.database.Cursor;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.TextView;
11 |
12 | import androidx.fragment.app.Fragment;
13 |
14 | public class SearchFragment extends Fragment {
15 |
16 |
17 |
18 |
19 |
20 | @Override
21 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
22 | View v = inflater.inflate(R.layout.content_search,container,false);
23 |
24 | return v;
25 |
26 |
27 | }
28 |
29 |
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/chapter 26/layout/README.txt:
--------------------------------------------------------------------------------
1 | There are more files in the project that were auto-generated but are not required at all/not required to be edited
--------------------------------------------------------------------------------
/chapter 26/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
24 |
--------------------------------------------------------------------------------
/chapter 26/layout/app_bar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/chapter 26/layout/content_delete.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
19 |
--------------------------------------------------------------------------------
/chapter 26/layout/content_insert.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
21 |
22 |
27 |
--------------------------------------------------------------------------------
/chapter 26/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/chapter 26/layout/content_results.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
--------------------------------------------------------------------------------
/chapter 26/layout/content_search.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
19 |
20 |
25 |
--------------------------------------------------------------------------------
/chapter 26/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
22 |
23 |
29 |
30 |
35 |
--------------------------------------------------------------------------------
/chapter 26/menu/README.txt:
--------------------------------------------------------------------------------
1 | There are more files in the project that were auto-generated but are not required at all/not required to be edited
--------------------------------------------------------------------------------
/chapter 26/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/chapter 27/java/DeleteFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.agedatabase;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.Button;
8 | import android.widget.EditText;
9 | import android.widget.TextView;
10 |
11 | import androidx.fragment.app.Fragment;
12 |
13 | public class DeleteFragment extends Fragment {
14 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
15 | View v = inflater.inflate(R.layout.content_delete, container, false);
16 |
17 | final DataManager dm = new DataManager(getActivity());
18 |
19 | Button btnDelete = v.findViewById(R.id.btnDelete);
20 | final EditText editDelete = v.findViewById(R.id.editDelete);
21 |
22 | btnDelete.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View v) {
25 | dm.delete(editDelete.getText().toString());
26 | }
27 | });
28 |
29 | return v;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/chapter 27/java/InsertFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.agedatabase;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.Button;
8 | import android.widget.EditText;
9 |
10 | import androidx.fragment.app.Fragment;
11 |
12 | public class InsertFragment extends Fragment {
13 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
14 | View v = inflater.inflate(R.layout.content_insert, container, false);
15 |
16 | final DataManager dm = new DataManager(getActivity());
17 |
18 | Button btnInsert = v.findViewById(R.id.btnInsert);
19 | final EditText editName = v.findViewById(R.id.editName);
20 | final EditText editAge = v.findViewById(R.id.editAge);
21 |
22 | btnInsert.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View v) {
25 | dm.insert(editName.getText().toString(),
26 | editAge.getText().toString());
27 | }
28 | });
29 |
30 |
31 | return v;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/chapter 27/java/README.txt:
--------------------------------------------------------------------------------
1 | There are more files in the project that were auto-generated but are not required at all/not required to be edited
--------------------------------------------------------------------------------
/chapter 27/java/ResultsFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.agedatabase;
2 |
3 | import android.database.Cursor;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import androidx.fragment.app.Fragment;
12 |
13 | public class ResultsFragment extends Fragment {
14 |
15 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
16 | View v = inflater.inflate(R.layout.content_results, container, false);
17 |
18 | // Create an instance of our DataManager
19 | DataManager dm = new DataManager(getActivity());
20 |
21 | // Get a reference to the TextView to show the results in
22 | TextView textResults = v.findViewById(R.id.textResults);
23 |
24 | // Create and initialize a Cursor with all the results in
25 | Cursor c = dm.selectAll();
26 |
27 | // A String to hold all the text
28 | String list = "";
29 |
30 | // Loop through the results in the Cursor
31 | while (c.moveToNext()){
32 | // Add the results to the String
33 | // with a little formatting
34 | list+=(c.getString(1) + " - " + c.getString(2) + "\n");
35 | }
36 |
37 | // Display the String in the TextView
38 | textResults.setText(list);
39 |
40 |
41 | return v;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/chapter 27/java/SearchFragment.java:
--------------------------------------------------------------------------------
1 | package com.gamecodeschool.agedatabase;
2 |
3 | import android.database.Cursor;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.TextView;
11 |
12 | import androidx.fragment.app.Fragment;
13 |
14 | public class SearchFragment extends Fragment {
15 |
16 |
17 | @Override
18 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
19 | View v = inflater.inflate(R.layout.content_search,container,false);
20 |
21 | Button btnSearch = v.findViewById(R.id.btnSearch);
22 | final EditText editSearch = v.findViewById(R.id.editSearch);
23 | final TextView textResult = v.findViewById(R.id.textResult);
24 |
25 | // This is our DataManager instance
26 | final DataManager dm = new DataManager(getActivity());
27 |
28 | btnSearch.setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View v) {
31 |
32 | Cursor c = dm.searchName(editSearch.getText().toString());
33 |
34 | // Make sure a result was found before using the Cursor
35 | if(c.getCount() > 0) {
36 | c.moveToNext();
37 | textResult.setText("Result = " + c.getString(1) + " - " + c.getString(2));
38 | }
39 |
40 | }
41 | });
42 |
43 | return v;
44 | }
45 |
46 |
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/chapter 27/layout/README.txt:
--------------------------------------------------------------------------------
1 | There are more files in the project that were auto-generated but are not required at all/not required to be edited
--------------------------------------------------------------------------------
/chapter 27/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
24 |
--------------------------------------------------------------------------------
/chapter 27/layout/app_bar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
--------------------------------------------------------------------------------
/chapter 27/layout/content_delete.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
19 |
--------------------------------------------------------------------------------
/chapter 27/layout/content_insert.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
21 |
22 |
27 |
--------------------------------------------------------------------------------
/chapter 27/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/chapter 27/layout/content_results.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
--------------------------------------------------------------------------------
/chapter 27/layout/content_search.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
19 |
20 |
25 |
--------------------------------------------------------------------------------
/chapter 27/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
22 |
23 |
29 |
30 |
35 |
--------------------------------------------------------------------------------
/chapter 27/menu/README.txt:
--------------------------------------------------------------------------------
1 | There are more files in the project that were auto-generated but are not required at all/not required to be edited
--------------------------------------------------------------------------------
/chapter 27/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------