Logs removed

This commit is contained in:
Caesar2011
2019-02-11 00:48:30 +01:00
parent d098093c8a
commit ab77ad4974
4 changed files with 16 additions and 54 deletions

View File

@@ -39,7 +39,7 @@ public class ModulesList extends HTTPService {
private CacheKVVCourse mKVVCache; private CacheKVVCourse mKVVCache;
ModulesList(Login login, KVVListener listener, Context context) { ModulesList(Login login, KVVListener listener, Context context) {
super(context, "ModuleList"); super(context);
this.mLogin = login; this.mLogin = login;
this.mListener = listener; this.mListener = listener;
restore(); restore();

View File

@@ -43,24 +43,25 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
private boolean mBound = false; private boolean mBound = false;
private boolean mWaitForBound = false; private boolean mWaitForBound = false;
private boolean mWaitForUnbound = false;
private ServiceConnection mConnection = new ServiceConnection() { private ServiceConnection mConnection = new ServiceConnection() {
@Override @Override
public void onServiceConnected(ComponentName className, IBinder service) { public void onServiceConnected(ComponentName className, IBinder service) {
// We've bound to LocalService, cast the IBinder and get LocalService instance // We've bound to LocalService, cast the IBinder and get LocalService instance
log.d("connected 1", mWaitForBound, mBound);
KVV.LocalBinder binder = (KVV.LocalBinder) service; KVV.LocalBinder binder = (KVV.LocalBinder) service;
mKVV = binder.getService(); mKVV = binder.getService();
mBound = true; mBound = true;
if (mWaitForBound) mQueue.next(); if (mWaitForBound) {
mWaitForBound = false; mWaitForBound = false;
log.d("connected", mKVV);
mQueue.next();
}
} }
@Override @Override
public void onServiceDisconnected(ComponentName arg0) { public void onServiceDisconnected(ComponentName arg0) {
mBound = false; mBound = false;
mKVV = null; mKVV = null;
if (mWaitForUnbound) mQueue.next();
mWaitForUnbound = false;
} }
}; };
@@ -103,11 +104,13 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
SyncResult syncResult) { SyncResult syncResult) {
if (!mBound) { if (!mBound) {
Intent intent = new Intent(getContext(), KVV.class); Intent intent = new Intent(getContext(), KVV.class);
getContext().bindService(intent, mConnection, Context.BIND_AUTO_CREATE); log.d("connect22222", getContext().bindService(intent, mConnection, Context.BIND_AUTO_CREATE));
mWaitForBound = true; mWaitForBound = true;
log.d("connect", mKVV);
mQueue.add(() -> {}); mQueue.add(() -> {});
} }
mQueue.add(() -> { mQueue.add(() -> {
log.d("kvv", mKVV);
mKVV.account().restoreOnlineLogin(bool -> { mKVV.account().restoreOnlineLogin(bool -> {
mQueue.next(); mQueue.next();
}); });
@@ -156,11 +159,11 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
mQueue.next(); mQueue.next();
}, true); }, true);
}); });
getContext().unbindService(mConnection); mQueue.add(() -> {
if (mBound) { mBound = false;
mWaitForUnbound = true; mKVV = null;
mQueue.add(() -> {}); getContext().unbindService(mConnection);
} });
} }
private <T> void sendNotifications(Iterable<T> oldList, Iterable<T> newList, String title, StringInterface<T> titleInterface, StringInterface<T> idInterface, String moduleId, int modulePart, @StringRes int updateRes, @StringRes int addRes, @StringRes int removeRes) { private <T> void sendNotifications(Iterable<T> oldList, Iterable<T> newList, String title, StringInterface<T> titleInterface, StringInterface<T> idInterface, String moduleId, int modulePart, @StringRes int updateRes, @StringRes int addRes, @StringRes int removeRes) {

View File

@@ -9,18 +9,11 @@ import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
public class NewAsyncQueue { public class NewAsyncQueue {
private final LinkedList<AsyncQueueCallback> mQueue = new LinkedList<>(); private final LinkedList<AsyncQueueCallback> mQueue = new LinkedList<>();
private boolean mIsRunning = false; private boolean mIsRunning = false;
private Logger log = new Logger(this);
public String name = null;
public NewAsyncQueue(String name) {
this.name = name;
}
public NewAsyncQueue() { public NewAsyncQueue() {
} }
public void add(AsyncQueueCallback callback) { public void add(AsyncQueueCallback callback) {
//if ("ModuleList".equals(name)) log.t("add start", name, mIsRunning, mQueue.size());
if (isRunning()) if (isRunning())
getQueue().addLast(callback); getQueue().addLast(callback);
else { else {
@@ -30,7 +23,6 @@ public class NewAsyncQueue {
} }
public void next() { public void next() {
//if ("ModuleList".equals(name)) log.t("next start", name, mIsRunning, mQueue.size());
AsyncQueueCallback callback = getQueue().pollFirst(); AsyncQueueCallback callback = getQueue().pollFirst();
if (callback == null) if (callback == null)
setRunning(false); setRunning(false);

View File

@@ -25,7 +25,7 @@ import de.sebse.fuplanner.tools.logging.Logger;
public class HTTPService { public class HTTPService {
private final Context mContext; private final Context mContext;
private NewAsyncQueue mQueue = new NewAsyncQueue("HTTPService"); private NewAsyncQueue mQueue = new NewAsyncQueue();
protected final Logger log = new Logger(this); protected final Logger log = new Logger(this);
private int mRequestCount = 0; private int mRequestCount = 0;
@@ -39,7 +39,6 @@ public class HTTPService {
@Override @Override
public void onServiceConnected(ComponentName className, IBinder service) { public void onServiceConnected(ComponentName className, IBinder service) {
// We've bound to LocalService, cast the IBinder and get LocalService instance // We've bound to LocalService, cast the IBinder and get LocalService instance
log.d("connected HTTP", HTTPService.this.mQueue.name, mWaitForBound);
HTTPNetwork.LocalBinder binder = (HTTPNetwork.LocalBinder) service; HTTPNetwork.LocalBinder binder = (HTTPNetwork.LocalBinder) service;
mService = binder.getService(); mService = binder.getService();
mBound = true; mBound = true;
@@ -57,7 +56,6 @@ public class HTTPService {
@Override @Override
public void onServiceDisconnected(ComponentName arg0) { public void onServiceDisconnected(ComponentName arg0) {
log.d("disconnected HTTP", HTTPService.this.mQueue.name, mWaitForBound);
mBound = false; mBound = false;
mService = null; mService = null;
} }
@@ -67,11 +65,6 @@ public class HTTPService {
this.mContext = context; this.mContext = context;
} }
public HTTPService(Context context, String name) {
this.mContext = context;
this.mQueue.name = name;
}
public void addErrorListener(String id, EventListener.EventFunction<VolleyError> listener) { public void addErrorListener(String id, EventListener.EventFunction<VolleyError> listener) {
errorListeners.put(id, listener); errorListeners.put(id, listener);
connect(); connect();
@@ -113,15 +106,12 @@ public class HTTPService {
} }
protected void head(String url, @Nullable final HashMap<String, String> cookies, Response.Listener<Result> response, Response.ErrorListener error) { protected void head(String url, @Nullable final HashMap<String, String> cookies, Response.Listener<Result> response, Response.ErrorListener error) {
log.d("HEAD", url);
connect(); connect();
mQueue.add(() -> { mQueue.add(() -> {
mService.head(url, cookies, response1 -> { mService.head(url, cookies, response1 -> {
log.d("response", url);
response.onResponse(response1); response.onResponse(response1);
disconnect(); disconnect();
}, error1 -> { }, error1 -> {
log.d("error", url);
error.onErrorResponse(error1); error.onErrorResponse(error1);
disconnect(); disconnect();
}); });
@@ -130,15 +120,12 @@ public class HTTPService {
} }
protected void get(String url, @Nullable final HashMap<String, String> cookies, Response.Listener<Result> response, Response.ErrorListener error) { protected void get(String url, @Nullable final HashMap<String, String> cookies, Response.Listener<Result> response, Response.ErrorListener error) {
log.d("GET", url);
connect(); connect();
mQueue.add(() -> { mQueue.add(() -> {
mService.get(url, cookies, response1 -> { mService.get(url, cookies, response1 -> {
log.d("response", url);
response.onResponse(response1); response.onResponse(response1);
disconnect(); disconnect();
}, error1 -> { }, error1 -> {
log.d("error", url);
error.onErrorResponse(error1); error.onErrorResponse(error1);
disconnect(); disconnect();
}); });
@@ -147,15 +134,12 @@ public class HTTPService {
} }
protected void post(String url, @Nullable final HashMap<String, String> cookies, @Nullable final HashMap<String, String> body, Response.Listener<Result> response, Response.ErrorListener error) { protected void post(String url, @Nullable final HashMap<String, String> cookies, @Nullable final HashMap<String, String> body, Response.Listener<Result> response, Response.ErrorListener error) {
log.d("POST", url);
connect(); connect();
mQueue.add(() -> { mQueue.add(() -> {
mService.post(url, cookies, body, response1 -> { mService.post(url, cookies, body, response1 -> {
log.d("response", url);
response.onResponse(response1); response.onResponse(response1);
disconnect(); disconnect();
}, error1 -> { }, error1 -> {
log.d("error", url);
error.onErrorResponse(error1); error.onErrorResponse(error1);
disconnect(); disconnect();
}); });
@@ -175,33 +159,16 @@ public class HTTPService {
mDisconnectTimer = null; mDisconnectTimer = null;
} }
mRequestCount++; mRequestCount++;
log.d("connect count", HTTPService.this.mQueue.name, mRequestCount);
} }
private void disconnect() { private void disconnect() {
mRequestCount--; mRequestCount--;
log.d("disconnect count", HTTPService.this.mQueue.name, mRequestCount);
if (mDisconnectTimer == null) { if (mDisconnectTimer == null) {
if (mBound && mRequestCount == 0) { if (mBound && mRequestCount == 0) {
mBound = false; mBound = false;
mService = null; mService = null;
getContext().unbindService(mConnection); getContext().unbindService(mConnection);
} }
/*mDisconnectTimer = new CountDownTimer(60 * 1000, 60 * 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
if (mBound) {
getContext().unbindService(mConnection);
mQueue.add(() -> {});
mWaitForUnbound = true;
}
}
};*/
} }
} }