Skip to content

Commit fde8f06

Browse files
author
Mohamed Ezzat
committed
Multiple quality improvements
1 parent d484849 commit fde8f06

2 files changed

Lines changed: 4 additions & 47 deletions

File tree

app/src/main/java/com/che58/ljb/rxjava/net/interceptor/XgoLogInterceptor.java

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ public Response intercept(Chain chain) throws IOException {
140140

141141
Connection connection = chain.connection();
142142
Protocol protocol = connection != null ? connection.getProtocol() : Protocol.HTTP_1_1;
143-
String requestStartMessage =
144-
"--> " + request.method() + ' ' + request.url() + ' ' + protocol(protocol);
143+
StringBuilder requestStartMessage = new StringBuilder();
144+
requestStartMessage.append("--> " + request.method() + ' ' + request.url() + ' ' + protocol(protocol));
145145
if (!logHeaders && hasRequestBody) {
146-
requestStartMessage += " (" + requestBody.contentLength() + BYTE_BODY;
146+
requestStartMessage.append(" (" + requestBody.contentLength() + BYTE_BODY);
147147
}
148-
logger.log(requestStartMessage);
148+
logger.log(requestStartMessage.toString());
149149

150150
if (logHeaders) {
151151
if (hasRequestBody) {
@@ -241,44 +241,4 @@ private static String protocol(Protocol protocol) {
241241
return protocol == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1";
242242
}
243243

244-
/* @Override
245-
public Response intercept(Chain chain) throws IOException {
246-
Request request = chain.request();
247-
long t1 = System.nanoTime();
248-
String requestLog = "\t" + request.method() + "::" + request.urlString();
249-
250-
if (request.method().compareToIgnoreCase("post") == 0) {
251-
requestLog = "\n" + requestLog + "\n" + bodyToString(request);
252-
}
253-
XgoLog.d("request::\n" + requestLog);
254-
255-
Response response = null;
256-
String bodyString = null;
257-
try {
258-
response = chain.proceed(request);
259-
bodyString = response.body().string();
260-
}catch (Exception e){
261-
e.printStackTrace();
262-
}
263-
264-
long t2 = System.nanoTime();
265-
266-
XgoLog.d("response::" + (t2 - t1) / 1e6d + "ms\n" + bodyString);
267-
268-
269-
return response==null ? null :response.newBuilder()
270-
.body(ResponseBody.create(response.body().contentType(), bodyString))
271-
.build();
272-
}
273-
274-
private static String bodyToString(final Request request) {
275-
try {
276-
final Request copy = request.newBuilder().build();
277-
final Buffer buffer = new Buffer();
278-
copy.body().writeTo(buffer);
279-
return buffer.readUtf8();
280-
} catch (final IOException e) {
281-
return "did not work";
282-
}
283-
}*/
284244
}

app/src/main/java/com/che58/ljb/rxjava/view/ProgressWheel.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public class ProgressWheel extends View {
6767
//Animation
6868
//The amount of degrees per second
6969
private float spinSpeed = 230.0f;
70-
//private float spinSpeed = 120.0f;
7170
// The last time the spinner was animated
7271
private long lastTimeAnimated;
7372

@@ -352,9 +351,7 @@ private void updateBarLength(long deltaTimeInMilliSeconds) {
352351
// We completed a size change cycle
353352
// (growing or shrinking)
354353
timeStartGrowing -= barSpinCycleTime;
355-
//if(barGrowingFromFront) {
356354
pausedTimeWithoutGrowing = 0;
357-
//}
358355
barGrowingFromFront = !barGrowingFromFront;
359356
}
360357

0 commit comments

Comments
 (0)