xkcd viewer report

4

Click here to load reader

Upload: zx-mys

Post on 21-May-2015

82 views

Category:

Technology


4 download

DESCRIPTION

xkcd viewer report

TRANSCRIPT

Page 1: xkcd viewer report

COMS 6998-7 Celluar Networks and Mobile ComputingFinal Project ReportBocheng Zhou bz2228

1. Motivation

For this final project, I wanted to gain more experience in android development. And

since I'm the only team member of my team, I wanted to implement something

interesting and useful to me. Finally, I decided to implement an xkcd viewer, because

I'm a huge fan of this nerdy and ridiculously profound webcomic, and have always

wanted a convenient app to browse the comics easily. Moreover, I thought I would learn

a lot of new android stuff along the way.

2. Problem statement & proposed solution

First of all, I wanted my app to have the basic functionalities like those on the xkcd

website: when the app boots, it will fetch me the latest xkcd comic. I can browse the

next comic, the previous one, the last one, the first one, and, if I'm feeling lucky, a

random one. Second, there is this awesome website called “explain xkcd”, which, not

surprisingly, explains to you in great detail the actually meaning behind the comics if

you find some of them hard to understand. And it would be great to integrate this into

the app. Third, I want to “favorite” the comics, because some of them(or almost all of

them) are hilarious and enlightening. And I really like the concept of circles in the

google+ app, so I thought it would be neat if I can “circle” the comics(make them

belong to one or more categories) as a way of favoriting them.

To implement those functionalities, the android actionbar will be a natural choice, since

it provides a clean user interface and a bunch of intuitive options. And there will be a tab

Page 2: xkcd viewer report

bar with two tabs, one for displaying the comic and the other displaying the list of

favorited comics.

3. Design and Architecture

One of the essential design issues is that avoid sending http requests as much as

possible. As has mentioned in the lectures, energy bugs contribute significantly to high

battery usage. In terms of power consumption, many components of the phone have very

high tail states even after they stop the service, and wifi/network connection is one of

them. A typical scenario is that the user may want to go back to the previous

comics they've seen, which have already been downloaded, so it is not necessary to

download them again. In other words, I should cache the images. When the user goes

back to a previous comic, the app should just load it from the cache.

The app's main activity is an action-bar activity with two tab bars embedded in it. With

the help of viewpager, the user can swipe back and forth between the 2 tab bars. The 2

tab bars are subclasses of android fragments. The first tab bar contains an image view,

which will display the comic once it is downloaded, and 5 buttons which the user can

press them to wade through all the comics. The second bar is a listview, whose items are

comprised of the titles, connotations and the tags of the favorited comics. The action

bar provide the options like favorite, share and explain.

4. Implementation and testing

There app will use the REST api porvided by xkcd, which will fetch the metadata of the

comics in JSON format. One of the import libraries used in the project is Picasso, which

is a powerful image downloading and caching library for android. I first tried to

implement my own caching of images, but it turned out to be error-prone. Picasso did a

really great job caching the images:when the user go back to previously downloaded

Page 3: xkcd viewer report

comics, it loads instantly, the speedup is very noticeable. Another library used in this

project is PhotoView, which is for image zooming and pinching. The user can pinch to

zoom in or zoom out the comic image smoothly.

For storing the tags across different sessions, I used the Shared Preference, which is the

most suitable storage option for this task.

For testing, the Logcat is the most helpful during the process of doing this project. One

can assign tags to the log messages, and logcat provides filtering based on keywords and

saving the log to a file, which had been very useful for analyzing the behavior of the

program.

5. Lessons learned

1.Start early and join a team. When I started to do the project, it had been over a month

since the last android homework. I basically needed to relearn quite a few things before I

could go on with more advanced stuff. Given the time constraints, I could not implement

a more sophisticated app, which is a shame. I think if I had joined another team instead

of working alone, I could have learned faster and have added more complex

functionalities to the app.

2. Don't reinvent the wheel. Before using the Picasso library, I tried to implement image

caching myself, which is error-prone and time consuming. Using full-fledged libraries

will make the development faster and the app more robust.

3. Make sure to initialize the objects correctly, and always beware of the possibility of

the object being null. Actually many of the bugs can be attributed to null pointer

exception.

Page 4: xkcd viewer report

4. Learn and understand the life cycle of Fragments, Activity, etc. Fully understanding

these things will save you a lot of time which would otherwise be used on unncessary

tial and error.

6. Summary and further work

Although the project doesn't look as sophisticated as those of other teams, but I did learn

a lot about android programming. For further work, I think I can add more advanced

features to the app. I'm actually planning on adding social elements into the app, such as

see how your facebook friends tag the comic you have favorited, try to find the people

who are similar to you based on the tags they given to the comics.

Extra Remarks

Dear Professor Li, Xiao and William, I'm so sorry I missed the presentation which I

should have given. Before the class, I'd only slept for 4 hours in 2 days, so I'm very sleep

deprived. I fell asleep unconsciously and woke up only to find I already missed the

presentation time. But this report is basically the transcript of what I was going to say in

the presentation, and I also included a video to showcase the app.

I know it's totally my fault to miss the presentation and turn in the project late. But I

swear I did it all by myself and did put a lot of time and effort into it. Any grade is

acceptable for me. Please don't fail me!