Skip to content
Snippets Groups Projects
Commit e9a9c186 authored by Jennifer Mankoff's avatar Jennifer Mankoff
Browse files

Merge remote-tracking branch 'upstream/master'

parents 236a5d27 b7143f91
No related branches found
No related tags found
No related merge requests found
Showing
with 922 additions and 62 deletions
...@@ -326,6 +326,7 @@ Accommodations must be requested within the first two weeks of this course using ...@@ -326,6 +326,7 @@ Accommodations must be requested within the first two weeks of this course using
[Religious Accommodations Request](https://registrar.washington.edu/students/religious-accommodations-request/) [Religious Accommodations Request](https://registrar.washington.edu/students/religious-accommodations-request/)
form on UW's site. form on UW's site.
# Other relevant classes to know about # Other relevant classes to know about
There are a number of classes on campus that teach related concepts There are a number of classes on campus that teach related concepts
...@@ -377,65 +378,3 @@ here are the ones we are aware of: ...@@ -377,65 +378,3 @@ here are the ones we are aware of:
only and focuses on prototyping techniques, not implementation. It only and focuses on prototyping techniques, not implementation. It
covers everything from paper prototyping to physical interfaces to 3D covers everything from paper prototyping to physical interfaces to 3D
printing. printing.
<!-- | head1 | head two | three | -->
<!-- |:-------------|:------------------|:------| -->
<!-- | OK | good swedish fish | nice | -->
<!-- | out of stock | good and plenty | nice | -->
<!-- | ok | good `oreos` | hmm | -->
<!-- | ok | good `zoute` drop | yumm | -->
<!-- ### There's a horizontal rule below this. -->
<!-- * * * -->
<!-- ### Here is an unordered list: -->
<!-- * Item foo -->
<!-- * Item bar -->
<!-- * Item baz -->
<!-- * Item zip -->
<!-- ### And an ordered list: -->
<!-- 1. Item one -->
<!-- 1. Item two -->
<!-- 1. Item three -->
<!-- 1. Item four -->
<!-- ### And a nested list: -->
<!-- - level 1 item -->
<!-- - level 2 item -->
<!-- - level 2 item -->
<!-- - level 3 item -->
<!-- - level 3 item -->
<!-- - level 1 item -->
<!-- - level 2 item -->
<!-- - level 2 item -->
<!-- - level 2 item -->
<!-- - level 1 item -->
<!-- - level 2 item -->
<!-- - level 2 item -->
<!-- - level 1 item -->
<!-- ### Definition lists can be used with HTML syntax. -->
<!-- <dl> -->
<!-- <dt>Name</dt> -->
<!-- <dd>Godzilla</dd> -->
<!-- <dt>Born</dt> -->
<!-- <dd>1952</dd> -->
<!-- <dt>Birthplace</dt> -->
<!-- <dd>Japan</dd> -->
<!-- <dt>Color</dt> -->
<!-- <dd>Green</dd> -->
<!-- </dl> -->
<!-- ``` -->
<!-- Long, single-line code blocks should not wrap. They should horizontally scroll if they are too long. This line should be long enough to demonstrate this. -->
<!-- ``` -->
<!-- ``` -->
<!-- The final element. -->
<!-- ``` -->
---
layout: presentation
title: Introduction to Doodle Assignment
description: Introduction to Doodle Assignment
class: middle, center, inverse
---
# CSE 340 Lab 1: Doodle (Spring 2020)
## Introduction to Doodle
.title-slide-logo[
![:img Android Logo](img/android-logo.png)
]
---
.left-column[
## **Library** (and Inheritance Hierarchy)
<br>
<br>
<br>
<div class="mermaid">
graph LR
Activity[Activity]
Activity -->|...| Doodler[Doodler]
Doodler --> Part1[Part1]
Part1 --> Part1Activity[Part1Activity]
Part1 --> Part2Activity[Part2Activity]
classDef yellow font-size:19px,text-align:center
classDef green font-size:19px,text-align:center
class Part1,Part1Activity,Part2Activity yellow
class Activity,Doodler green
</div>
]
.right-column[
## Android Classes we are using in Doodle and how they relate
- Doodler (which you don't edit) *extends* [Activity](https://developer.android.com/reference/android/app/Activity)
- Part1 *extends* Doodler. It implements *helper methods* for Part1Activity and
Part2Activity.
- Part1Activity and Part2Activity both extend Part1
]
---
layout:none
.title[Running Sample Code]
.body[
When you accept the assignment on GitGrade, a repository containing the starter code is generated for you on CSE
GitLab. You **MUST** work within this assignment, as it will be turned in via GitGrade when it is due.
Please clone and use the repository and commit and push your work regularly.
Not only will doing so protect your code, but it will also allow course staff
to look at your code and it will allow you to easily pull any changes we make
to the assignment source.You can find instructions on setting up and maintaining
a forked repository [here](https://help.github.com/en/articles/working-with-forks).
]
---
## Cloning Doodle
.left-column[
You can find your unique repo by the notification email or by going to [GitLab](https://gitlab.cs.washington.edu) or via
the [GitGrade](https://gitgrade.cs.washington.edu) interface.
]
.right-column[
![:img Android Studio splash screen, 30%](img/doodle-clone-1.png)
![:img Android Studio clone dialog, 30%](img/doodle-clone-2.png)
]
---
.title[Open project in Android Studio]
.body[
- Run configurations should be automatically imported from Gradle
- If not, `build` should trigger an import
- Run with ►
- Connect an android device by USB or create a new virtual device
- If by USB, debugging must be enabled on the device
]
---
.title[Implementing `addImage`]
.body[
```java
private ImageView addImage(FrameLayout doodleView, String imageName, Float x, Float y, int size);
```
### Params:
- `doodleView`: Canvas in which to render the image.
- `imageName`: Filename of image to draw in `res/drawable`.
]
--
.body[
- `x`: Horizontal distance from top-left corner of canvas to top-left of image.
- `y`: Veritcal distance from top-left corner of canvas to top-left of image.
- `size`: Width and height of rendered image, in pixels.
]
---
.title[Implementing `addImage`]
.body[
### Returns:
- An `ImageView` which has been added to the canvas.
]
---
.title[Implementing `addImage`]
--
.body[
Break down into component steps, look up documentation, and implement
1) Create `ImageView`
]
--
.body[
2) Add new view to canvas
]
--
.body[
3) Position and set view size
]
--
.body[
4) Set view contents
]
---
.title[Implementing `addImage`]
.body[
```java
private ImageView addImage(FrameLayout doodleView, String imageName, Float x, Float y, int size) {
// Create ImageView and add it to doodleView.
ImageView image = new ImageView(this);
// Add image to doodleView
// Set image size and position
// Set image contents using filename
return image;
}
```
]
---
.title[Implementing `addImage`]
.body[
```java
private ImageView addImage(FrameLayout doodleView, String imageName, Float x, Float y, int size) {
// Create ImageView and add it to doodleView.
ImageView image = new ImageView(this);
// Add image to doodleView
doodleView.addView(image);
// Set image size and position
// Set image contents using filename
return image;
}
```
]
---
.title[Implementing `addImage`]
.body[
```java
private ImageView addImage(FrameLayout doodleView, String imageName, Float x, Float y, int size) {
// Create ImageView and add it to doodleView.
ImageView image = new ImageView(this);
// Add image to doodleView
doodleView.addView(image);
// Set image size
image.getLayoutParams().height = size;
image.getLayoutParams().width = size;
// Set image position ?
// Set image contents using filename
return image;
}
```
]
---
.title[Breakout Room Discussion]
.body[
<iframe src="https://embed.polleverywhere.com/multiple_choice_polls/d8jYLjVJq9Lp6MlCMl0XZ?controls=none&short_poll=true" width="800" height="600" frameBorder="0"></iframe>
]
<!--
.title[Implementing `addImage`]
.body[
```java
private ImageView addImage(FrameLayout doodleView, String imageName, Float x, Float y, int size) {
// Create ImageView and add it to doodleView.
ImageView image = new ImageView(this);
doodleView.addView(image);
image.getLayoutParams().height = size;
image.getLayoutParams().width = size;
image.setX(x);
image.setY(y);
// Set image contents using filename
return image;
}
```
]
-->
---
.title[Implementing `addImage`]
.body[
```java
private ImageView addImage(FrameLayout doodleView, String imageName, Float x, Float y, int size) {
// Create ImageView and add it to doodleView.
ImageView image = new ImageView(this);
// Add image to doodleView
doodleView.addView(image);
// Set image size
image.getLayoutParams().height = size;
image.getLayoutParams().width = size;
// Set image position ?
// Set image contents using filename
int resID = getResources().getIdentifier(imageName, "drawable", getPackage());
image.setImageResource(resID);
return image;
}
```
]
---
.title[Android Debugging Tips]
.body[
Resource: [https://developer.android.com/studio/debug](https://developer.android.com/studio/debug)
]
<!---
## `ValueAnimator`
- Keeps track of the animation's timing (how long its been running and current value of property)
- Contains a `TimeInterpolator` that defines the type of interpolation for the value over time
- Contains a `TypeEvaluator` that figures out how to calculate values for the property being animated
```java
ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f);
animation.setDuration(1000);
// Starts the animation
animation.start();
// TODO: need to listen for updates to get the returned value
```
-->
<!--
.title[How do we use pacing functions for this?]
.body[
![:img Picture of a curve transforming motion over time to create a pacing
effect, 40%](img/pacing.png)
- Time normalized with respect to animation interval (0...1)
- Normalized time is transformed by pacing function (0…1)
- Paced value is then fed to curve function to get final value
] -->
<!--
.title[XML shown in class]
.body[
```xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator android:propertyName="x" android:valueTo="100" />
</set>
```
]
-->
<!--
```java
package com.example.myapplication;
//imports...
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ImageView view = new ImageView(this);
setContentView(view);
Bitmap bitmap = Bitmap.createBitmap(100,100, Bitmap.Config.ARGB_8888);
view.setImageBitmap(bitmap);
Canvas c = new Canvas(bitmap);
Paint p = new Paint();
c.drawCircle(10,10,5,p);
ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
anim.setDuration(2000);
anim.start();
Animator anim2 = (Animator) AnimatorInflater.loadAnimator(this,
R.animator.sample);
anim2.setTarget(view);
anim2.setDuration(2000);
anim2.start();
}
}
```
-->
\ No newline at end of file
---
layout: presentation
title: Lab 1 GitGrade Slides
description: Introduction to GitGrade and accepting the first assignment
class: middle, center, inverse
---
# CSE 340 Lab 1: GitGrade (Spring 2020)
## Introduction to course infastructure
![:img GitGrade Logo, 20%](img/gitgrade_square.png)
---
## What is GitGrade?
GitGrade is the software we use to manage and grade programming assignments.
## Why is it relevant to you?
Because you will use GitGrade to `accept` the assignment, in order to generate a GitLab repository with starter code.
You will also `turn-in` the assignment using GitGrade by registering a commit as your submission.
---
## What are we doing with it today?
We're going to `accept` the first assignment (`as1-doodle`) and clone the generated repository.
Start by navigating to
[https://gitgrade.cs.washington.edu/student/assignment/116](https://gitgrade.cs.washington.edu/student/assignment/116).
This link is available on the course website, on the `Doodle` assignment page.
You will need to login with your CSE GitLab credentials.
---
## Accepting the assignment
Accept the assignment, and navigate to the generated GitLab repository of the name
`cse340-20wi-students/as1-doodle-NETID`
![:img screenshot of GitLab accept assignmet page with a large button labeled "Accept Assignment",
90%](img/accept-screencap.png)
---
## Turning in the assignment
- Through GitGrade, link on the Doodle page on the course website (accept link + `/turnin`)
- Recommended to visit the turnin page ahead of time to read the **nuances and details**
- Late Day Policy: 3 late days, no partial usage. Applied whenever something is turned in late until you run out.
- If something is late, and you have no late days: `score -= (10% * unexcused days late)`
\ No newline at end of file
---
layout: presentation
title: Lab 1 Slides
description: Lab project--Hello World--
class: middle, center, inverse
---
# CSE 340 Lab 1 (Spring 2020)
## Week 1: Getting Started With Android Development
.title-slide-logo[
![Android Logo](img/android-logo.png)
]
---
## Course Objectives
- Practical applications for learnings in lecture
- Understand design considerations when making mobile apps
- Design and implement basic Android applications
- Debugging in Java and for Android
---
## Lab 1 Objectives
- Introduce the building blocks of Android applications
<!-- - Obtain the course repository -->
- Explore an Android project folder
- Getting the first part of the Doodle started
- Show some basic Android debugging techniques
---
## Android Applications
__Components__
- Activity
- Service
- Broadcast Receiver
- Content Providers
__Intents__
- Launch components (and provide them with data)
- Not limited to components of the same app
- Meaning: your components can be started by intents from other applications
---
## Activity
[`android.app.Activity`](https://developer.android.com/reference/android/app/Activity)
- Represents a single interface
- Example: Activities for Gmail App
- Inbox, Message Compose, Spam Folder, etc.
- Activities can be started by other applications, if desired
- E.g., sharing a photo by email starts Gmail's Message Compose activity
---
## Activity
.center[
![:img Activity Lifecycle, 40%](img/activity_lifecycle.png)
]
---
## Service
[`android.app.Service`](https://developer.android.com/reference/android/app/Service)
- Entry point for background processes
- Example: Spotify's player activity uses a service to play music
- Could be done by activity alone
- Use of a service allows music to continue when player activity is no longer in the foreground
- Services may be killed and restarted as required by the OS
- A persistent service such as music playback may use a persistent notification to prevent this
---
## Broadcast Receivers
[`android.content.BroadcastReceiver`](https://developer.android.com/reference/android/content/BroadcastReceiver.html)
- Entry point for events outside of regular userflow
- Example: Alarms
- Application schedules callback with OS in 10 minutes
- In the meantime, the application can be killed
- 10 minutes later, the OS broadcasts the callback event to the app
- App begins playing sound; vibrating
---
## Content Providers
[`android.content.ContentProvider`](https://developer.android.com/reference/android/content/ContentProvider)
- Persistent storage of data
- Supports multiple backends, depending on app permissions
- Local filesystem, web, SQLite DB, etc.
- Can permit access to other applications
- Contacts can be read and written to by other apps, depending on permissions
<!---
## Obtaining the Course repository
- After [accepting the assignment](https://courses.cs.washington.edu/courses/cse340/20sp/slides/l01/gitgrade.html#1), go to Gitlab
- If you do not have SSH set up with Gitlab, just download the zip for now
- Later: ['Set up an SSH key with
Gitlab'](https://gitlab.cs.washington.edu/help/ssh/README#generating-a-new-ssh-key-pair)
- Once you have SSH set up, clone the repository -- will show after section -->
---
## Android Project Structure
.center[
![:img Android Project Structure, 30%](img/android_project_structure.png)
]
---
## Android Project Structure
`app/src/main/AndroidManifest.xml`
- Describes application at a high level for both compilation and running
- Includes app package, components, permissions, and hardware features
`app/src/main/java/com.example.myapp/MainActivity.java`
- The main activity activated when application launches
`app/build.gradle`
- Android build tool configuration file
- Includes target and min SDK versions and dependencies
`app/src/main/res/layout/activity_main.xml`
- Declares the views and layout of the main activity
---
## Android Project Structure
`drawable-<density>/`
- Images at various pixel densities to accommodate various display resolutions
- Keep filenames consistent between folders
`layout/`
- Layout XML description files for application activities
`mipmap/`
- Launcher icons for your application at various sizes and shapes
`values/`
- A good place to store constants
- Density-independent pixel values (sizes)
- Color
- Good for string localization as well
- Storing strings here makes it much easier to add additional languages in the future!
---
## Resources
- Vogella Tutorials -
- Android Animation - http://www.vogella.com/tutorials/AndroidAnimation/article.html
- Android Developer
- View Animation - https://developer.android.com/guide/topics/graphics/view-animation.html
- Property Animation - https://developer.android.com/guide/topics/graphics/prop-animation.html
- Relevant supplemental material is provided on the course website
- Listed in the schedule
- This week's supplemental material reviews Java, covers Android animation
\ No newline at end of file
slides/l01/img/accept-screencap.png

107 KiB

slides/l01/img/activity_lifecycle.png

44.6 KiB

slides/l01/img/android-logo.png

7.69 KiB

slides/l01/img/android-versions-oct2018.png

153 KiB

slides/l01/img/android_project_structure.png

121 KiB

slides/l01/img/doodle-clone-1.png

115 KiB

slides/l01/img/doodle-clone-2.png

90.1 KiB

slides/l01/img/gitgrade_square.png

96.5 KiB

slides/l01/img/instagram-example.png

808 KiB

slides/l01/img/mvp-design-pattern.png

11.1 KiB

slides/l01/img/pacing.png

123 KiB

Introduction - 2 minutes
- Welcome to CSE 340
- Over the duration of this course, you will be applying your learnings from
lecture in a very practical way
- This means
- not only understanding what to consider when building mobile apps
- but also designing and implementing your own Android apps
- With that goal in mind, we will use our time in lab today to start exploring
Android app development
- I will introduce you to the building blocks of Android applications
- After obtaining the course repository
- we will explore the android project folder
- I will show some basic Android debugging techniques
Android Application Components - 7 minutes
- Applications are comprised of a variety of components.
- These components are activities, services, broadcast receivers, and content providers
- Components are activated with objects called intents
- These intents provide the components with data.
- Intents are not limited to components of the same application,
so your components can actually be activated by intents from other applications.
- Personal example: for an internship I was kicking off a workflow
on an Amazon Echo where we would play a series of audio pieces, record them,
and then analyze them. For that, I defined the intent in the Android manifest,
and then supplied the intent over a command line with arguments like which audio
files to play, how long to record for, etc.
- Activities represent single screens with a user interface
- Gmail has different activities for composing your message, looking at your inbox,
accessing your settings, etc.
- <Walk through example workflow>
- This diagram is a toolkit architecture.
- Services are components that perform operations in the background that don't provide
a user interface.
- For example, Spotify's player activity is where you select what music to play,
but its player service is what actually places the music. This is why you can
navigate your phone freely when you use Spotify.
- In my project, the Intent kicked off a service that would fetch audio from the cloud,
play it, and calibrate it. There was no user interface because the device was an Amazon Echo.
- Of course, it's the OS's prerogative to impact the life of a service instance.
- Broadcast Receivers are entry points for events outside of the regular user workflow.
- Registers system or application events using the publish-subscribe model.
- When an interesting event happens, a broadcast is sent.
- Individual apps can register to receive specific broadcasts.
- For example, an alarm app can register a callback with the OS for x time. Then,
when the time comes, the OS sends a broadcast to the alarm app to wake it up, and the
alarm starts ringing.
- Think of it as a messaging system between apps outside of the user workflow.
- Content Providers are the interfaces for managing persistent data.
- For example you could have a Content Provider manage writing data to the local filesystem
or the cloud.
- You can manage other applications' interactions with your data.
- For example, the messenger app interacts with a content provider to look at your
contacts list on your phone if you give it permission.
Obtaining the Course Repository - Give them 5 minutes to obtain and peruse
the repository
- Make it private
Ask two people if they noticed any files that stood out in particular
and why those files stood out - 3 minutes
Move through important files together - 5 minutes
- The Android Manifest describes the application at a high level.
- Identifies the name of the application package
- Describes all the components of the app.
- Lists any permissions the application would need, as well
as any hardware or software the app depends on to compile and run
- For example, if the app needs permission to write to the disk,
that information would be here
- Notice that the Part1Activity activity is described here as accepting
intent for the Main action with category Launcher. This means that this
activity is the main activity that is activated when launching the app.
- The MainActivity java file sets the behavior of the main acitivity of the
application. For us, the Main activity is Part1Activity.java
- Here in Doodler we see the OnCreate method, which is run whenever an Activity
is launched.
- Our OnCreate calls other methods, like addText, addLine, and addImage, that you
will implement.
- The build.gradle file configures the build for the application
- Describes the minimum SDK versions and technical dependencies the project will depend on.
- The resources folder contains additional files and static content that the code will use.
- Things like images, static data files, and even activity layouts and global
constants can be described here.
- One interesting thing about Android development is that depending on your needs
you can implement functionality either in your code files or in your resources folder.
- The activity_main.xml file declares the views and the layout of the main activity.
- Layouts in Android are in XML.
- If you've ever done HTML development, this should
be familiar to you.
- Components in your view are structured like a tree, where each
component is described relative its parent.
- In Doodle, we see that right now our outermost container is ConstraintLayout,
and inside that is a FrameLayout whose height and width are set to match the parent.
- The drawable folders contain the images for the application.
- The different folders are for accomodating various display resolutions.
- The layout folder holds the XML files describing the layouts of the different
activities in the program.
- In our application, there's only the main activity's xml layout, but additional
layouts can go here as well.
- The mipmap folders contain the launcher icons for the application for a variety
of screen sizes and shapes.
- The values folder is a good place to store global static constant values
- e.g. strings
- Go over debugging - 5 minutes
- Breakpoints, the android studio debugger
- Logging
- 22 minutes - work on Doodle
- Working on Doodle addImage
Discussion in general:
- Learning a toolkit is hard - need to explore
\ No newline at end of file
TODO:
- update assignment accept link in gitgrade slides
- add assignment accept and turn-in links to assignment page
Issues:
- not sure how doable the addImage without handholding the entire thing / showing them the code
total structured time: 37min
total unstructured time: 23min
Introduction - 10 minutes
- Welcome to CSE 340
- Introduce ourselves!
- notes on how section works, teachers changing
- Talk about nametags, hand out nametags
- Plug Java Refresher Lab 5.30 @ CSE1 403
- Over the duration of this course, you will be applying your learnings from
lecture in a very practical way
- This means
- not only understanding what to consider when building mobile apps
- but also designing and implementing Android apps
- With that goal in mind, we will use our time in lab today to start exploring
Android app development
- We'll accept the first assignment, Doodle
- Clone the repository to our local devices
- Explore the structure and pieces of an Android project
- Complete the first part of the assignment
Android apps happen on phones, if you want to get a phone instead here are our recommendations
(Sophie, 7min)
GitLab Intro (using the GitLab deck) - 10min
Intro to Doodle
- open the assignment spec and walk through it quickly: 5min
- open the repo in Android Studio and talk through important files: 5min
- activities
- layouts
- talk through the addImage line: 5min
- let students work on Doodle for remaining time
---
layout: presentation
title: Lab 2 Slides
description: Lab project--Doodle--
---
# CSE 340 Lab 2 (Spring 2020)
## Week 2: Get Help with Doodle
.title-slide-logo[
![Android Logo](img/android-logo.png)
]
---
# Doodle Timeline
- Doodle Due: Thursday, April 9 @ 10:00pm (**Today!**)
- Lock: Saturday, April 11 @ 10:00pm (If you are using late days)
- Peer Eval: Sunday, April 12 - Tuesday, April 14 @ 10:00pm
- Reflection: Wednesday, April 15 @ 10:00pm
---
# Lab 2 Objectives
- Go through peer evaluation and reflection
- How to debug in Android
- Android Animation
---
# Lab 2 After Implementation
- Peer evaluation - fill the survey that we send out
- The best ones will show off in class
- Part 3: Turn in reflection on Gradescope after peer evaluation
---
# Peer Evaluation
- Why?
- Chance to externalize your work
- Get user feedback (the user experience is after all the point of HCI)
- What to expect
- Your grade won't be determined by peer evaluating alone
- You get credit for **doing** the peer evaluation
- Questions about spec requirements -- no room for interpretation
- Questions that prompt about subjective feedback
- Provide constructive feedback
- Anonymous to your peers (but not to the teaching staff)
- Your feedback on the exercise! (be honest)
---
# Peer Evaluation Practice
- Download the apk file: https://tinyurl.com/wdgjkcu
- Google form: https://tinyurl.com/DoodleTestEval (Please use your UW Net ID)
---
# Peer Evaluation Instructions
.right-column-staff[
- You will be assigned to peer grade 3 assignments via email
- If you have an Android phone
- Click on the download link to install the app on your phone
- If you don't have a phone
- Download the APK files
- Open the APK file in Android Studio and run the app in the emulator
- Fill out the google form for each APK file
]
.left-column-staff[
<img src="./img/wizard.png" alt="screenshot of Android Studio Wizard" width="40%" height="50%"/>
]
---
# Android Debugging
- Select a device to debug your app on
- Set breakpoints in your Java, Kotlin, and C/C++ code
- Examine variables and evaluate expressions at runtime
- How to use Debugger: https://developer.android.com/studio/debug#java
- Helpful tool (Logcat): https://developer.android.com/studio/debug/am-logcat#java
---
# Animation on Android
- _Property Animation_ - preferred method; more flexible
- _View Animation_ - simple setup; the old way (but you have to deal with xml...)
- _Drawable Animation_ - load `Drawable` resources and display them one frame after the other (it is like a gif)
---
# Property Animation
- Define an animate that changes on object's _property_ (a field in an object) over _a length of time_
## `ValueAnimator`
- Keeps track of the animation's timing (how long its been running and current value of property)
```java
ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f);
animation.setDuration(1000);
// Starts the animation
animation.start();
// TODO: need to listen for updates to get the returned value
```
---
# `ObjectAnimator` (the one you need in this assignment)
- Rather than listening for a value, we can simply directly animate a property on an object
- **However**: the property that you are animating must have a setter function (in camel case) in the form of set<propertyName>() for this to work (_setDuration()_)
```java
ObjectAnimator anim = ObjectAnimator.ofFloat(textView, "alpha", 0f, 1f);
anim.setDuration(1000);
anim.start();
```
---
# Resources
- Vogella Tutorials - http://www.vogella.com/tutorials/AndroidAnimation/article.html
- Android Developer
- View Animation - https://developer.android.com/guide/topics/graphics/view-animation.html
- Property Animation - https://developer.android.com/guide/topics/graphics/prop-animation.html
- Relevant supplemental material is provided on the course website
- Listed in the Doodle assignment
- Don't stress out :) this isn't required
File added
slides/l02/img/activity_lifecycle.png

80.7 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment