Skip to content

Commit

Permalink
RetrofitDemo增加http返回数据Toast提示
Browse files Browse the repository at this point in the history
  • Loading branch information
alidili committed Jun 21, 2017
1 parent 89746d8 commit cef7d81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.google.gson.GsonBuilder;
import com.yl.retrofitdemo.Constant;
import com.yl.retrofitdemo.R;
import com.yl.retrofitdemo.bean.PostInfo;
Expand Down Expand Up @@ -93,7 +93,8 @@ private void baseRequest() {
call.enqueue(new Callback<PostInfo>() {
@Override
public void onResponse(Call<PostInfo> call, Response<PostInfo> response) {
Log.i("http返回:", response.body().toString() + "");
Log.i("http返回:", response.body().toString());
Toast.makeText(MainActivity.this, response.body().toString(), Toast.LENGTH_SHORT).show();
}

@Override
Expand Down Expand Up @@ -132,7 +133,8 @@ public void onError(Throwable e) {

@Override
public void onNext(PostInfo postInfo) {
Log.i("http返回:", postInfo.toString() + "");
Log.i("http返回:", postInfo.toString());
Toast.makeText(MainActivity.this, postInfo.toString(), Toast.LENGTH_SHORT).show();
}
});
}
Expand All @@ -146,7 +148,8 @@ private void encapRequest() {

@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(PostInfo postInfo) {
Log.i("接收消息:", postInfo.toString() + "");
Log.i("接收消息:", postInfo.toString());
Toast.makeText(MainActivity.this, postInfo.toString(), Toast.LENGTH_SHORT).show();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static OkHttpClient getOkHttpClient() {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override
public void log(String message) {
Log.i("Http请求参数:", message);
Log.i("http请求参数:", message);
}
});
loggingInterceptor.setLevel(level);
Expand Down

0 comments on commit cef7d81

Please sign in to comment.