Sunday, February 16, 2014

getFinishTime

I just wrote and tested this awesome method for my capstone. It really shows me that those seemingly pointless excecise problems can come in handy.

public String getFinishTime()
    {
        Time now = new Time();
        Time finish = new Time();
        now.setToNow();
       
        int hr, mins, carry = 0, pm = 0;
        hr = now.hour;
        mins = now.minute;
       
        if(hr > 11) {
            pm = 1;
            hr = hr%12;
        }
       
        int task_time = 0;
        int hours, minutes;
        for (int i = 0; i < tasks.size(); i++) {
            task_time += tasks.get(i).getTime();
        }
        hours = (int) task_time / 60;
        minutes = task_time % 60;
        //TODO:time will be lost if hours is over 12

        //hr = Integer.parseInt(now.format("%k"));
        //mins = Integer.parseInt(now.format("%M"));
       
        int fin_min, fin_hr;
       
        if(mins+minutes > 59) {
            carry++;
            fin_min = (mins+minutes)%60;
        } else {
            fin_min = mins+minutes;
        }
        if(hr+hours+carry > 12) {
            if(pm == 1)
                pm =0;
            fin_hr = (hr+hours+carry)%12;
        } else {
            fin_hr = hr+hours+carry;
        }
           
        String am = "";
        if(pm == 1)
            am = "pm";
        if(pm == 0)
            am = "am";
       
        //hr += hours;
        //mins += minutes;

        //return hr+":"+mins+"," + hours+":"+minutes+","+fin_hr+":"+fin_min;
        return fin_hr+":"+ ((fin_min < 10) ? "0"+fin_min : fin_min) + am;
    }

Capstone Development

So working a lot on my bachelors thesis to get the next working version out by tomorrow. The Center for Student Success is having a Time Management workshop tomorrow and I'm going to pitch my project to them to see if there are interested in testing it. I'm really excited.

But what takes me to my blog is remembering that when you have a statement like:

  • final_minutes = temp_minutes + current_minutes % 60
 you might actually be meaning

  • final_minutes = (temp_minutes + current_minutes) % 60
Emphasis added to the parenthesis. Just another moment where you remember a skill learned long ago in a CST 101 course.

Monday, February 10, 2014

First Stackoverflow Answer

So working on my Capstone I had the problem of my app launching to the first screen when I clicked the launcher, after I had navigated away from the app. So after several failed stack overflow answers I turned to the activity documentation on the Android developers sight. And I found the android:alwaysRetainTaskState attribute. Which worked perfectly for me.

The bonus for this was I posted my solution to stackoverflow!!!!

Tuesday, February 4, 2014

Finally have the Android Development Bridge Working

After buying a used laptop with the primary intent to be able to have a separate workstation to do all my developing on, I was thrilled just now when I finally got the ADB to successfully deploy to my S3. I have had problems with this for the last two years using my mac and to finally see that little prompt asking me about an RSA key, made a small tear of joy sleek down my cheek.

So ready to tackle my bachelor's thesis dev now.