android / architecture-components-samples

Samples for Android Architecture Components.
https://d.android.com/arch
Apache License 2.0
23.42k stars 8.29k forks source link

[Question] How to cancel data loading? #9

Open wafer-li opened 7 years ago

wafer-li commented 7 years ago

There is always the case: the user could not torrent the slow data loading process, and want to cancel it.

But in the sample project, I cannot find there is any method to meet that demand.

So, is there any way to achieve that goal?

The cancel data loading means: When the user perform the cancel action, such as onBackPressed, the NetworkBoundResource need to cancel the ongoing db loading transaction and the network request

JoseAlcerreca commented 7 years ago

wafer-li: could you please open another bug for the crash and keep this issue about your question?

wafer-li commented 7 years ago

@JoseAlcerreca I just thought the reason of that bug might relate to the limitation(cannot cancel data-loading).

I will do it right away

codeparams commented 5 years ago

I made a sample app that includes canceling (also my 1st github project). Check it out: github and blog. It's similar to github browser sample but doesn't use NetworkBoundResource and LiveDataCallAdapterFactory.