Merge remote-tracking branch 'origin/master'

This commit is contained in:
BA7LZD 2020-04-21 21:31:32 +08:00
commit 984450858f
5 changed files with 50 additions and 2 deletions

View File

@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="com.yuxihan.sdu.comm.SDUApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"

View File

@ -1,4 +1,4 @@
package com.yuxihan.sdu;
package com.yuxihan.sdu.comm;
public class Constant {
public static final String BASE_URL = "https://www.yuxihan.com/";

View File

@ -0,0 +1,17 @@
package com.yuxihan.sdu.comm;
import android.app.Application;
public class SDUApp extends Application {
@Override
public void onCreate() {
super.onCreate();
initApp();
}
private void initApp() {
}
}

View File

@ -0,0 +1,30 @@
package com.yuxihan.sdu.comm.network;
import android.util.Log;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
class LoggingInterceptor implements Interceptor {
public static final String TAG = "LoggingInterceptor";
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
Request request = chain.request();
long t1 = System.nanoTime();
Log.i(TAG, String.format("Sending request %s on %s%n%s",
request.url(), chain.connection(), request.headers()));
Response response = chain.proceed(request);
long t2 = System.nanoTime();
Log.i(TAG, String.format("Received response for %s in %.1fms%n%s",
response.request().url(), (t2 - t1) / 1e6d, response.headers()));
return response;
}
}

View File

@ -2,7 +2,7 @@ package com.yuxihan.sdu.data;
import android.util.Log;
import com.yuxihan.sdu.Constant;
import com.yuxihan.sdu.comm.Constant;
import com.yuxihan.sdu.data.model.DataBean;
import com.yuxihan.sdu.data.model.LoggedInUser;