Logs removed
This commit is contained in:
@@ -39,7 +39,7 @@ public class ModulesList extends HTTPService {
|
||||
private CacheKVVCourse mKVVCache;
|
||||
|
||||
ModulesList(Login login, KVVListener listener, Context context) {
|
||||
super(context, "ModuleList");
|
||||
super(context);
|
||||
this.mLogin = login;
|
||||
this.mListener = listener;
|
||||
restore();
|
||||
|
||||
@@ -43,24 +43,25 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
|
||||
private boolean mBound = false;
|
||||
private boolean mWaitForBound = false;
|
||||
private boolean mWaitForUnbound = false;
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
// We've bound to LocalService, cast the IBinder and get LocalService instance
|
||||
log.d("connected 1", mWaitForBound, mBound);
|
||||
KVV.LocalBinder binder = (KVV.LocalBinder) service;
|
||||
mKVV = binder.getService();
|
||||
mBound = true;
|
||||
if (mWaitForBound) mQueue.next();
|
||||
if (mWaitForBound) {
|
||||
mWaitForBound = false;
|
||||
log.d("connected", mKVV);
|
||||
mQueue.next();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName arg0) {
|
||||
mBound = false;
|
||||
mKVV = null;
|
||||
if (mWaitForUnbound) mQueue.next();
|
||||
mWaitForUnbound = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -103,11 +104,13 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
SyncResult syncResult) {
|
||||
if (!mBound) {
|
||||
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;
|
||||
log.d("connect", mKVV);
|
||||
mQueue.add(() -> {});
|
||||
}
|
||||
mQueue.add(() -> {
|
||||
log.d("kvv", mKVV);
|
||||
mKVV.account().restoreOnlineLogin(bool -> {
|
||||
mQueue.next();
|
||||
});
|
||||
@@ -156,11 +159,11 @@ public class KVVSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
mQueue.next();
|
||||
}, true);
|
||||
});
|
||||
mQueue.add(() -> {
|
||||
mBound = false;
|
||||
mKVV = null;
|
||||
getContext().unbindService(mConnection);
|
||||
if (mBound) {
|
||||
mWaitForUnbound = true;
|
||||
mQueue.add(() -> {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -9,18 +9,11 @@ import de.sebse.fuplanner.tools.network.NetworkErrorCallback;
|
||||
public class NewAsyncQueue {
|
||||
private final LinkedList<AsyncQueueCallback> mQueue = new LinkedList<>();
|
||||
private boolean mIsRunning = false;
|
||||
private Logger log = new Logger(this);
|
||||
public String name = null;
|
||||
|
||||
public NewAsyncQueue(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public NewAsyncQueue() {
|
||||
}
|
||||
|
||||
public void add(AsyncQueueCallback callback) {
|
||||
//if ("ModuleList".equals(name)) log.t("add start", name, mIsRunning, mQueue.size());
|
||||
if (isRunning())
|
||||
getQueue().addLast(callback);
|
||||
else {
|
||||
@@ -30,7 +23,6 @@ public class NewAsyncQueue {
|
||||
}
|
||||
|
||||
public void next() {
|
||||
//if ("ModuleList".equals(name)) log.t("next start", name, mIsRunning, mQueue.size());
|
||||
AsyncQueueCallback callback = getQueue().pollFirst();
|
||||
if (callback == null)
|
||||
setRunning(false);
|
||||
|
||||
@@ -25,7 +25,7 @@ import de.sebse.fuplanner.tools.logging.Logger;
|
||||
|
||||
public class HTTPService {
|
||||
private final Context mContext;
|
||||
private NewAsyncQueue mQueue = new NewAsyncQueue("HTTPService");
|
||||
private NewAsyncQueue mQueue = new NewAsyncQueue();
|
||||
protected final Logger log = new Logger(this);
|
||||
|
||||
private int mRequestCount = 0;
|
||||
@@ -39,7 +39,6 @@ public class HTTPService {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
// 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;
|
||||
mService = binder.getService();
|
||||
mBound = true;
|
||||
@@ -57,7 +56,6 @@ public class HTTPService {
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName arg0) {
|
||||
log.d("disconnected HTTP", HTTPService.this.mQueue.name, mWaitForBound);
|
||||
mBound = false;
|
||||
mService = null;
|
||||
}
|
||||
@@ -67,11 +65,6 @@ public class HTTPService {
|
||||
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) {
|
||||
errorListeners.put(id, listener);
|
||||
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) {
|
||||
log.d("HEAD", url);
|
||||
connect();
|
||||
mQueue.add(() -> {
|
||||
mService.head(url, cookies, response1 -> {
|
||||
log.d("response", url);
|
||||
response.onResponse(response1);
|
||||
disconnect();
|
||||
}, error1 -> {
|
||||
log.d("error", url);
|
||||
error.onErrorResponse(error1);
|
||||
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) {
|
||||
log.d("GET", url);
|
||||
connect();
|
||||
mQueue.add(() -> {
|
||||
mService.get(url, cookies, response1 -> {
|
||||
log.d("response", url);
|
||||
response.onResponse(response1);
|
||||
disconnect();
|
||||
}, error1 -> {
|
||||
log.d("error", url);
|
||||
error.onErrorResponse(error1);
|
||||
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) {
|
||||
log.d("POST", url);
|
||||
connect();
|
||||
mQueue.add(() -> {
|
||||
mService.post(url, cookies, body, response1 -> {
|
||||
log.d("response", url);
|
||||
response.onResponse(response1);
|
||||
disconnect();
|
||||
}, error1 -> {
|
||||
log.d("error", url);
|
||||
error.onErrorResponse(error1);
|
||||
disconnect();
|
||||
});
|
||||
@@ -175,33 +159,16 @@ public class HTTPService {
|
||||
mDisconnectTimer = null;
|
||||
}
|
||||
mRequestCount++;
|
||||
log.d("connect count", HTTPService.this.mQueue.name, mRequestCount);
|
||||
}
|
||||
|
||||
private void disconnect() {
|
||||
mRequestCount--;
|
||||
log.d("disconnect count", HTTPService.this.mQueue.name, mRequestCount);
|
||||
if (mDisconnectTimer == null) {
|
||||
if (mBound && mRequestCount == 0) {
|
||||
mBound = false;
|
||||
mService = null;
|
||||
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;
|
||||
}
|
||||
}
|
||||
};*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user