Search in sources :

Example 1 with StringDialogCallback

use of com.lzy.demo.callback.StringDialogCallback in project okhttp-OkGo by jeasonlzy.

the class CookieActivity method addCookie.

@OnClick(R.id.addCookie)
public void addCookie(View view) {
    HttpUrl httpUrl = HttpUrl.parse(Urls.URL_METHOD);
    Cookie.Builder builder = new Cookie.Builder();
    Cookie cookie = builder.name("myCookieKey1").value("myCookieValue1").domain(httpUrl.host()).build();
    CookieStore cookieStore = OkGo.getInstance().getCookieJar().getCookieStore();
    cookieStore.saveCookie(httpUrl, cookie);
    showToast("详细添加cookie的代码,请看demo的代码");
    //
    OkGo.post(Urls.URL_TEXT_UPLOAD).tag(//
    this).execute(new StringDialogCallback(this) {

        @Override
        public void onSuccess(String s, Call call, Response response) {
            handleResponse(s, call, response);
        }

        @Override
        public void onError(Call call, Response response, Exception e) {
            super.onError(call, response, e);
            handleError(call, response);
        }
    });
}
Also used : Cookie(okhttp3.Cookie) StringDialogCallback(com.lzy.demo.callback.StringDialogCallback) Response(okhttp3.Response) CookieStore(com.lzy.okgo.cookie.store.CookieStore) Call(okhttp3.Call) HttpUrl(okhttp3.HttpUrl) OnClick(butterknife.OnClick)

Aggregations

OnClick (butterknife.OnClick)1 StringDialogCallback (com.lzy.demo.callback.StringDialogCallback)1 CookieStore (com.lzy.okgo.cookie.store.CookieStore)1 Call (okhttp3.Call)1 Cookie (okhttp3.Cookie)1 HttpUrl (okhttp3.HttpUrl)1 Response (okhttp3.Response)1