mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
trying to extract loadmanager parts
This commit is contained in:
1 parent
30925b4ff1
commit
8729ab34df
3 files changed
+57
-5
No files matched your search
+2
-1
@@ -85,7 +85,7 @@ public class OnlineDataManager extends DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
protected void reloadEvents(LoadClient<Collection<EventBase>> client) {
|
||||
protected DataLoader<Collection<EventBase>> reloadEvents(LoadClient<Collection<EventBase>> client) {
|
||||
SharedDomainFactory domainFactory = DomainFactoryImpl.INSTANCE;
|
||||
DataParser<Collection<EventBase>> parser = new EventsDataParser(new EventBaseJsonDeserializer(
|
||||
new VenueJsonDeserializer(new CourseAreaJsonDeserializer(domainFactory))));
|
||||
@@ -99,6 +99,7 @@ public class OnlineDataManager extends DataManager {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void loadCourseAreas(final Serializable parentEventId, final LoadClient<Collection<CourseArea>> client) {
|
||||
|
||||
+2
-2
@@ -68,13 +68,13 @@ public class DataLoader<T> extends AsyncTaskLoader<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public void deliverResult(T data) {
|
||||
if (data == null) {
|
||||
dataHandler.onFailed(lastException);
|
||||
} else {
|
||||
dataHandler.onLoaded(data);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
+53
-2
@@ -1,13 +1,34 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.fragments.lists;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.LoaderManager.LoaderCallbacks;
|
||||
import android.content.Loader;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.sap.sailing.domain.base.EventBase;
|
||||
import com.sap.sailing.racecommittee.app.AppPreferences;
|
||||
import com.sap.sailing.racecommittee.app.R;
|
||||
import com.sap.sailing.racecommittee.app.data.ReadonlyDataManager;
|
||||
import com.sap.sailing.racecommittee.app.data.handlers.DataHandler;
|
||||
import com.sap.sailing.racecommittee.app.data.handlers.EventsDataHandler;
|
||||
import com.sap.sailing.racecommittee.app.data.loaders.DataLoader;
|
||||
import com.sap.sailing.racecommittee.app.data.parsers.DataParser;
|
||||
import com.sap.sailing.racecommittee.app.data.parsers.EventsDataParser;
|
||||
import com.sap.sailing.racecommittee.app.domain.impl.DomainFactoryImpl;
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.lists.selection.EventSelectedListenerHost;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.lists.selection.ItemSelectedListener;
|
||||
import com.sap.sailing.server.gateway.deserialization.impl.CourseAreaJsonDeserializer;
|
||||
import com.sap.sailing.server.gateway.deserialization.impl.EventBaseJsonDeserializer;
|
||||
import com.sap.sailing.server.gateway.deserialization.impl.VenueJsonDeserializer;
|
||||
|
||||
public class EventListFragment extends NamedListFragment<EventBase> {
|
||||
public class EventListFragment extends NamedListFragment<EventBase> implements LoaderCallbacks<Collection<EventBase>> {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
@@ -33,7 +54,37 @@ public class EventListFragment extends NamedListFragment<EventBase> {
|
||||
|
||||
@Override
|
||||
protected void loadItems(ReadonlyDataManager manager) {
|
||||
manager.loadEvents(this);
|
||||
/*manager.loadEvents(this);*/
|
||||
getLoaderManager().initLoader(0, null, this).forceLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<Collection<EventBase>> onCreateLoader(int id, Bundle args) {
|
||||
DataParser<Collection<EventBase>> parser = new EventsDataParser(new EventBaseJsonDeserializer(
|
||||
new VenueJsonDeserializer(new CourseAreaJsonDeserializer(DomainFactoryImpl.INSTANCE))));
|
||||
try {
|
||||
return new DataLoader<Collection<EventBase>>(
|
||||
getActivity(),
|
||||
URI.create(AppPreferences.getServerBaseURL(getActivity()) + "/sailingserver/events"),
|
||||
parser,
|
||||
null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Collection<EventBase>> arg0, Collection<EventBase> arg1) {
|
||||
if (arg1 == null)
|
||||
ExLog.w("BLUB", "NULL");
|
||||
else
|
||||
super.onLoadSucceded(arg1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Collection<EventBase>> arg0) {
|
||||
super.onLoadSucceded(Collections.<EventBase>emptyList());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user