mirror of
https://e.coding.net/mcontext/mContext/sdu.git
synced 2024-09-18 02:24:54 +08:00
App
This commit is contained in:
parent
f20d3e1b3b
commit
047f465b4b
@ -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"
|
||||
|
@ -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/";
|
17
app/src/main/java/com/yuxihan/sdu/comm/SDUApp.java
Normal file
17
app/src/main/java/com/yuxihan/sdu/comm/SDUApp.java
Normal 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() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user