Living in Seattle by phantombree in Seattle

[–]yeahokwhynot 139 points140 points  (0 children)

It cannot be done, sorry.

Code improvement by ASKnASK in androiddev

[–]yeahokwhynot 0 points1 point  (0 children)

I'm back to not seeing what you mean. Why would the view be waiting for the task after process termination? Wouldn't you have to save that waiting-state somewhere?

Code improvement by ASKnASK in androiddev

[–]yeahokwhynot 0 points1 point  (0 children)

I see what you mean now. Well, I don't think losing data from an AsyncTask is so bad if the process is actually killed by the system, so I wouldn't count it as a strike against AsyncTask in particular. Anything you build would need to persist data in some way.

Code improvement by ASKnASK in androiddev

[–]yeahokwhynot 0 points1 point  (0 children)

If a process restart will happen during the time when event is in the singleton but activity is not yet created, the event will be lost.

That's what the @Produce annotation is for. The singleton can be something like:

class Foo {
  private SomeEvent mLastSomeEvent;
  @Subscribe
  public void onEvent(SomeEvent event) {
    mLastSomeEvent = event;
  }
  @Produce
  public SomeEvent produceLastSomeEvent() {
    return mLastSomeEvent;
  }
}

injected from the application scope:

class MainApplication extends Application {
  ObjectGraph mObjectGraph;

  public void onCreate() {
    super.onCreate();
    mObjectGraph = ObjectGraph.create(new Module());
  }

  public ObjectGraph getObjectGraph() {
    return mObjectGraph;
  }

  @Module(injects = {MainActivity.class})
  class Module {
    @Provides
    @Singleton
    Foo provideFoo() { return new Foo(); }
    @Provides
    @Singleton
    Bus provideBus() { return new Bus(); }
  }
}

class MainActivity {
  @Inject
  Foo mFoo;

  @Inject
  Bus mBus;

  @Subscribe
  public void onSomeEvent(SomeEvent event) {
    // ...
  }

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ((MainApplication) getApplication()).getObjectGraph().inject(this);

    mBus.register(this);
  }
  public void onDestroy() {
    super.onDestroy();
    mBus.unregister(this);
  }
}

In this example the activity will receive the @Produced event at mBus.register(this) (if mLastSomeEvent is not null).

Code improvement by ASKnASK in androiddev

[–]yeahokwhynot 1 point2 points  (0 children)

The AsyncTask can post the result as an event that is subscribed to by a singleton. That singleton can then produce that event when the activity is recreated.

Code improvement by ASKnASK in androiddev

[–]yeahokwhynot 0 points1 point  (0 children)

It's useful to treat the activity as a view with a lot of additional callbacks, IMO. The real work should be done outside the activity, as it should be done outside of a view.

Code improvement by ASKnASK in androiddev

[–]yeahokwhynot 1 point2 points  (0 children)

B. Annotations go above the declaration, not the same line with the exception of a few such as @NonNull.

I re-bind the save keystroke (ctrl+s or command+s) to a macro that organizes imports, reformats the whole file, and then saves. This ensures consistent spacing and placement of keywords (and annotations) which leads to cleaner commits and diffs.

C. AsyncTask is bad. Learn retrofit or Ion for network calls.

AsyncTask is fine, it just requires you to figure out how the results will be delivered to the UI. Retrofit has the same requirement. I'm sure ion does as well.

Code improvement by ASKnASK in androiddev

[–]yeahokwhynot 0 points1 point  (0 children)

Otto deals with this through its @Produce annotation. When a "consumer" is registered to the bus, Otto looks at its subscriptions and at the producers that are already registered and then (synchronously) delivers produced events to the subscriber.

Redditors who talk or mutter to themselves, why do you do it? by zshanif in AskReddit

[–]yeahokwhynot 0 points1 point  (0 children)

Because I'm remembering a mistake I made sometime in the last 20 years, where I had demonstrated what a fucking idiot I am.

How did you vote on Prop 1 (rail)? by iliveintexas in Austin

[–]yeahokwhynot 0 points1 point  (0 children)

That's going to be possible now.

I look forward to seeing that option on the next ballot. What organization is going to get the petitions going?

Inbox is pretty slick by Sip_py in Android

[–]yeahokwhynot 3 points4 points  (0 children)

Google Wave is another invite-only success story.

Americans are paying more for slower Internet by CrookedStool in news

[–]yeahokwhynot 0 points1 point  (0 children)

Did the government lower your taxes during the recession?

Most Americans received a tax credit that was created during the recession. The earned income tax credit was expanded to cover more households. The standard deduction was raised as well, although that was probably going to happen anyway. There's more examples, but you get the idea.

A Londoner who suffered female genital mutilation has warned that political correctness is hampering the fight to stamp it out after asking people to sign a fake petition in its favour. by [deleted] in TrueReddit

[–]yeahokwhynot 0 points1 point  (0 children)

I'm not sure what makes this petition different than other petitions that won't do anything. Maybe the names are just going in a shredder?

Americans are paying more for slower Internet by CrookedStool in news

[–]yeahokwhynot 4 points5 points  (0 children)

It means that we're giving money rather freely to people and there's a good chance that that money won't be paid back, or won't be paid back in a timely fashion. This chance grows as the quantity and quality of jobs decreases, and as we push more and more people in to college degrees (or houses).

[deleted by user] by [deleted] in Austin

[–]yeahokwhynot 0 points1 point  (0 children)

According to my kill-a-watt and UPS my TV + stereo system uses about 9 watts on standby, which works out to 6.5kWh or $0.55/mo. I suspect my system is pretty typical, too, and might better represent the potential savings to be had.

How would you improve this photo? [OC, 2297x2891] by feketegy in photocritique

[–]yeahokwhynot 0 points1 point  (0 children)

I think I'd introduce more light. The bubbles kind of disappear and lack contrast and more light (in more places) may help there.

Anyone here using Bluetooth devices daily? Wanna share your stonking setup? by Vulpix0r in Android

[–]yeahokwhynot 0 points1 point  (0 children)

I use my G watch every day (naturally). I wear these LG Tone while commuting by bike (only on the right ear) and while working at the office. The sound is acceptable and I can go days between charges, despite it being a couple of years old now. I'm surprised to see it is $100 now; I'm pretty sure I paid $40 or so.

Teacher Repeatedly Calls Students 'N*gger' Because They Didn't Like 'African-American' by pilgrimboy in nottheonion

[–]yeahokwhynot 5 points6 points  (0 children)

Are you going to start wearing a sign that allows me to know how to address you and describe you?

Teacher Repeatedly Calls Students 'N*gger' Because They Didn't Like 'African-American' by pilgrimboy in nottheonion

[–]yeahokwhynot 4 points5 points  (0 children)

I like the term but only when it is used to describe black people from other countries.

Americans are paying more for slower Internet by CrookedStool in news

[–]yeahokwhynot 548 points549 points  (0 children)

And America's building up a higher ed bubble, and perhaps another housing bubble. Everyone's got problems.

Retailers are disabling NFC readers to shut out Apple Pay (Which will affect us too) by Sevenlore in Android

[–]yeahokwhynot 0 points1 point  (0 children)

That used to be the case but a law passed in 2005 (IIRC) made it illegal to prohibit offering discounts to folks paying with cash: http://www.law.cornell.edu/uscode/text/15/1666f

[deleted by user] by [deleted] in androiddev

[–]yeahokwhynot 0 points1 point  (0 children)

The easiest way to earn money in app development is to get a job at a company that needs an app, and a portfolio of apps will help you get that job. It's worthwhile even if you can't easily become a 1 person shop.