Code Monkey home page Code Monkey logo

andfun-kotlin-guess-it's Introduction

Application Architecture - The UI Layer - Guess It!

This is the toy app for lesson 5 of the Android App Development in Kotlin course on Udacity.

Guess It!

Guess It is a word guessing app you can play with one or more friends. To play, hold the device in landscape, facing away from you with your thumbs on the Skip and Got It buttons. Your friends can then give you clues to help you guess the word.

If you get the word right, press Got It. If you're stuck, press Skip. The game runs for a minute and then shows you your score.

Screenshots

Screenshot 0 Screenshot 1 Screenshot 2

How to use this repo while taking the course

Each code repository in this class has a chain of commits that looks like this:

listofcommits

These commits show every step you'll take to create the app. Each commit contains instructions for completing the step.

Each commit also has a branch associated with it of the same name as the commit message, as seen below:

branches Access all branches from this tab.

listofbranches

branchesdropdown

The branches are also accessible from the drop-down in the "Code" tab.

Working with the Course Code

Here are the basic steps for working with and completing exercises in the repo.

The basic steps are:

  1. Clone the repo.
  2. checkout the branch corresponding to the step you want to attempt.
  3. Find and complete the TODOs.
  4. Optionally commit your code changes.
  5. Compare your code with the solution.
  6. Repeat steps 2-5 until you've gone trough all the steps to complete the toy app.

Step 1: Clone the repo

As you go through the course, you'll be instructed to clone the different exercise repositories, so you don't need to set these up now. You can clone a repository from GitHub in a folder of your choice with the command:

git clone https://github.com/udacity/REPOSITORY_NAME.git

Step 2: Check out the step branch

As you go through different steps in the code, you'll be told which step you're on, as well as given a link to the corresponding branch.

Check out the branch associated with that step. The command to check out a branch is:

git checkout BRANCH_NAME

Step 3: Find and complete the TODOs

Once you've checked out the branch, you'll have the code in the exact state you need. You'll even have TODOs, which are special comments that tell you all the steps you need to complete the exercise. You can navigate to all the TODOs using Android Studio's TODO tool. To open the TODO tool, click the button at the bottom of the screen that says TODO. This will display a list of all comments with TODO in the project.

We've numbered the TODO steps so you can do them in order: todos

Step 4: Commit your code changes

After you've completed the TODOs, you can optionally commit your changes. This will allow you to see the code you wrote whenever you return to the branch. The following git code will add and save all your changes.

git add .
git commit -m "Your commit message"

Step 5: Compare with the solution

Most exercises will have a list of steps for you to check off in the classroom. Once you've checked these off, you'll see a pop up window with a link to the solution code. Note the Diff link after the Solution link:

solutionwindow

The Diff link will take you to a GitHub diff as seen below: diff

All of the code that was added in the solution is in green, and the removed code (which will usually be the TODO comments) is in red.

You can also diff your local copy of the code with the corresponding branch as you are working on it:

git diff BRANCH_NAME

Report Issues

Notice any issues with a repository? Please file a GitHub issue in the repository.

andfun-kotlin-guess-it's People

Contributors

ceruleanotter avatar fangmobile avatar sudkul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

andfun-kotlin-guess-it's Issues

getting error in GameFragmentDirections

Can anybody please tell me why it showing a red error. i have downloaded the zip file from udacity and i didn't change the any code but it's showing error.

Help me!



private fun gameFinished() { val action = GameFragmentDirections.actionGameToScore(score) findNavController(this).navigate(action) }

starter-code branch is totally out of date

The starter-code branch is totally out of date.

The main issue is that it's build.gradle files still has references to the old android.arch.navigation packages instead of the new androidx.navigation ones and thus the app crashes a lot.

I suggest upgrading it with the versions from the master branch.

Starter code built failed

  • Exception is:
    java.lang.NoClassDefFoundError: com/google/common/util/concurrent/SettableFuture
    at com.google.common.cache.LocalCache$LoadingValueReference.(LocalCache.java:3388)
    at com.google.common.cache.LocalCache$LoadingValueReference.(LocalCache.java:3392)

BUG: Crash on Rotation in Game

steps to recreate Bug:

  1. start the game
  2. play and rotate screen
  3. finish to the end
  4. crash happens upon navigating to ScoreFragment


upgrading dependencies to androidx fix it:

// Navigation
// implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0-rc02"
// implementation "android.arch.navigation:navigation-ui-ktx:1.0.0-rc02"
implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
implementation "androidx.navigation:navigation-ui-ktx:2.3.5"

Crash

so, when:

  • click play button
  • rotate
  • back
  • rotate
  • click play button again, it going to crash.
    java.lang.IllegalStateException: no current navigation node
    is it ack-ed?

Unresolved reference : ScoreFragmentBinding

Hello,

it seems that I cant' use GameFragmentBinding, ScoreFragmentBinding, and TitleFragmentBinding.
I can't find the packages com.example.android.guesstheword.databinding in the code that I downloaded, neither on github.

How to get this right?

Thank you

Step 08 Solution

@SudKul
Hello, firstly, thank you for writing the solutions. Following each commit has helped me to write cleaner code and understand the pertinent concepts better e.g. encapsulation.

For solution 08 I was wondering the reasoning behind 1) the onPlayAgainComplete() method and 2) storing the score as a LiveData.

  1. It seems, to me, that once we navigate away from the scoreFragment, the scoreViewModel will be cleared anyway so changing the value of _eventPlayAgain to false is not meaningful i.e. the next viewModel being referenced won't be the same viewModel as before.

  2. The score seems neither transient nor live, it is a value that is being passed from the previous fragment. Hence, why is it a good idea to store this value in the viewModel?

If there is a particular reason for this then I would love to be enlightened. If it's good coding practice then I will take it in good faith. Thanks once again for your help so far.

Abrupt termination

Hi,
After the optional lesson's (haptic feedback) code is installed, the application terminates abruptly after "Play" is clicked. No logcat details reported. Please help.
Thanks.
Vasan S T

Application crash when game finished

Hi Team,
the steps are as follows to reproduce the issue,

  1. on finishing all the words, just before pressing GOT IT, change the orientation.
  2. once the orientation is changed, now press GOT IT button .
  3. There is application crash with below logs.
    2020-12-30 09:07:14.599 4328-4328/com.example.android.guesstheword E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.android.guesstheword, PID: 4328
    java.lang.IllegalStateException: no current navigation node
    at androidx.navigation.NavController.navigate(NavController.java:765)
    at androidx.navigation.NavController.navigate(NavController.java:745)
    at androidx.navigation.NavController.navigate(NavController.java:731)
    at androidx.navigation.NavController.navigate(NavController.java:863)
    at com.example.android.guesstheword.screens.game.GameFragment.gameFinished(GameFragment.kt:87)
    at com.example.android.guesstheword.screens.game.GameFragment.access$gameFinished(GameFragment.kt:35)
    at com.example.android.guesstheword.screens.game.GameFragment$onCreateView$3.onChanged(GameFragment.kt:65)
    at com.example.android.guesstheword.screens.game.GameFragment$onCreateView$3.onChanged(GameFragment.kt:35)
    at androidx.lifecycle.LiveData.considerNotify(LiveData.java:131)
    at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:149)
    at androidx.lifecycle.LiveData.setValue(LiveData.java:307)
    at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
    at com.example.android.guesstheword.screens.game.GameViewModel.nextWord(GameViewModel.kt:90)
    at com.example.android.guesstheword.screens.game.GameViewModel.onCorrect(GameViewModel.kt:105)
    at com.example.android.guesstheword.screens.game.GameFragment$onCreateView$4.onClick(GameFragment.kt:71)
    at android.view.View.performClick(View.java:7448)
    at android.view.View.performClickInternal(View.java:7425)
    at android.view.View.access$3600(View.java:810)
    at android.view.View$PerformClick.run(View.java:28305)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7656)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Starter code does not compile

Error message is:

<snip>andfun-kotlin-guess-it-starter-code/app/build/generated/source/kapt/debug/androidx/databinding/library/baseAdapters/BR.java:3: error: package javax.annotation does not exist
import javax.annotation.Generated;
                       ^

I'm using intellij rather than android studio because autocomplete and other functionality works!

IntelliJ IDEA 2021.1.3 (Community Edition)
Build #IC-211.7628.21, built on June 29, 2021
Runtime version: 11.0.11+9-b1341.60 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.13.0-1-default
GC: ParNew, ConcurrentMarkSweep
Memory: 1923M
Cores: 12
Non-Bundled Plugins: Batch Scripts Support (1.0.12), CMD Support (1.0.5), com.intellij.javafx (1.0.3), org.jetbrains.kotlin (211-1.5.10-release-909-IJ7142.45)
Kotlin: 211-1.5.10-release-909-IJ7142.45
Current Desktop: KDE

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.