Fixed crashes in FeedItemlist
This commit is contained in:
parent
4d50903182
commit
0b0ea77df1
|
@ -49,6 +49,8 @@ public class FeedItemlistActivity extends ActionBarActivity {
|
||||||
private ItemlistFragment filf;
|
private ItemlistFragment filf;
|
||||||
private ExternalPlayerFragment externalPlayerFragment;
|
private ExternalPlayerFragment externalPlayerFragment;
|
||||||
|
|
||||||
|
private AsyncTask<?, ?, ?> currentLoadTask;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
setTheme(UserPreferences.getTheme());
|
setTheme(UserPreferences.getTheme());
|
||||||
|
@ -70,7 +72,10 @@ public class FeedItemlistActivity extends ActionBarActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadData(long id) {
|
private synchronized void loadData(long id) {
|
||||||
|
if (currentLoadTask != null) {
|
||||||
|
currentLoadTask.cancel(true);
|
||||||
|
}
|
||||||
AsyncTask<Long, Void, Feed> loadTask = new AsyncTask<Long, Void, Feed>() {
|
AsyncTask<Long, Void, Feed> loadTask = new AsyncTask<Long, Void, Feed>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,6 +85,12 @@ public class FeedItemlistActivity extends ActionBarActivity {
|
||||||
return DBReader.getFeed(FeedItemlistActivity.this, longs[0]);
|
return DBReader.getFeed(FeedItemlistActivity.this, longs[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCancelled(Feed feed) {
|
||||||
|
super.onCancelled(feed);
|
||||||
|
if (AppConfig.DEBUG) Log.d(TAG, "load task was cancelled");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Feed result) {
|
protected void onPostExecute(Feed result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
|
@ -103,6 +114,7 @@ public class FeedItemlistActivity extends ActionBarActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
currentLoadTask = loadTask;
|
||||||
loadTask.execute(id);
|
loadTask.execute(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +124,14 @@ public class FeedItemlistActivity extends ActionBarActivity {
|
||||||
StorageUtils.checkStorageAvailability(this);
|
StorageUtils.checkStorageAvailability(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
if (currentLoadTask != null) {
|
||||||
|
currentLoadTask.cancel(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
|
|
|
@ -125,21 +125,24 @@ public class ItemlistFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onStop() {
|
||||||
super.onDestroyView();
|
super.onStop();
|
||||||
EventDistributor.getInstance().unregister(contentUpdate);
|
EventDistributor.getInstance().unregister(contentUpdate);
|
||||||
if (currentLoadTask != null) {
|
if (currentLoadTask != null) {
|
||||||
currentLoadTask.cancel(true);
|
currentLoadTask.cancel(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadData() {
|
protected synchronized void loadData() {
|
||||||
final long feedId;
|
final long feedId;
|
||||||
if (feed == null) {
|
if (feed == null) {
|
||||||
feedId = getArguments().getLong(ARGUMENT_FEED_ID);
|
feedId = getArguments().getLong(ARGUMENT_FEED_ID);
|
||||||
} else {
|
} else {
|
||||||
feedId = feed.getId();
|
feedId = feed.getId();
|
||||||
}
|
}
|
||||||
|
if (currentLoadTask != null) {
|
||||||
|
currentLoadTask.cancel(true);
|
||||||
|
}
|
||||||
AsyncTask<Long, Void, Feed> loadTask = new AsyncTask<Long, Void, Feed>(){
|
AsyncTask<Long, Void, Feed> loadTask = new AsyncTask<Long, Void, Feed>(){
|
||||||
private volatile List<Long> queueRef;
|
private volatile List<Long> queueRef;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue