Search in sources :

Example 1 with DownloadRepoMessageEvent

use of com.gradle.java.model.DownloadRepoMessageEvent in project Gradle-demo by Arisono.

the class testUASApi method saveCardLog.

public static void saveCardLog(String dis, String code, String method) {
    //master=USOFTSYS, sessionUser=U0316, sessionId=29DB60DE6E40D859B9169FE5013A8520, caller=CardLog, type=2
    String formStore = "" + "{\"cl_emname\":\"刘杰\"," + "\"cl_distance\":" + dis + "," + "\"cl_time\":" + "2017-05-22 08:22:10" + "," + "\"cl_emcode\":\"U0316\"," + "\"cl_phone\":\"13266699268\"," + "\"cl_code\":\"" + code + "\"," + "\"cl_location\":\"在英唐大厦附近\"," + "\"cl_address\":\"中国广东省深圳市南山区科技南五路5\"}";
    OkhttpUtils.println(formStore);
    String url = baseurl + "mobile/saveCardLog.action";
    RequestBody formBody = new FormBody.Builder().add("master", master).add("caller", "CardLog").add("formStore", formStore).add("sessionId", sessionId).build();
    Request request = new Request.Builder().url(url).header("cookie", "JSESSIONID=" + sessionId).addHeader("sessionUser", emcode).addHeader("content-type", "text/html;charset:utf-8").post(formBody).build();
    OkhttpUtils.client.newCall(request).enqueue(new Callback() {

        @Override
        public void onResponse(Call call, Response response) throws IOException {
            String result = OkhttpUtils.getResponseString(response);
            OkhttpUtils.println(result, OkhttpUtils.typeMiddle, method);
            RxBus.getInstance().send(new DownloadRepoMessageEvent("保存成功!"));
        }

        @Override
        public void onFailure(Call call, IOException e) {
            OkhttpUtils.onFailurePrintln(e);
        }
    });
}
Also used : Response(okhttp3.Response) Call(okhttp3.Call) Callback(okhttp3.Callback) DownloadRepoMessageEvent(com.gradle.java.model.DownloadRepoMessageEvent) FormBody(okhttp3.FormBody) Request(okhttp3.Request) IOException(java.io.IOException) RequestBody(okhttp3.RequestBody)

Example 2 with DownloadRepoMessageEvent

use of com.gradle.java.model.DownloadRepoMessageEvent in project Gradle-demo by Arisono.

the class RxjavaUtils method rxBus.

/**
	 * 测试rxbus
	 */
public static void rxBus() {
    // 注册 ---被观察者
    registerSubscription(RxBus.getInstance().toObservable().filter(o -> o instanceof DownloadRepoMessageEvent).map(o -> (DownloadRepoMessageEvent) o).doOnNext(o -> showMessage(o.getMessage())).subscribe());
    // 发送消息 ---观察者
    RxBus.getInstance().send(new DownloadRepoMessageEvent("我这是利用rxjava技术来发送消息!"));
}
Also used : Subscriber(rx.Subscriber) Date(java.util.Date) StringUtils(com.gradle.java.utils.StringUtils) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) Timer(java.util.Timer) Observer(rx.Observer) Scheduler(rx.Scheduler) Action1(rx.functions.Action1) Executors(java.util.concurrent.Executors) Observable(rx.Observable) CompositeSubscription(rx.subscriptions.CompositeSubscription) OkhttpUtils(com.gradle.android.retrofit.OkhttpUtils) Map(java.util.Map) Schedulers(rx.schedulers.Schedulers) TimerTask(java.util.TimerTask) DownloadRepoMessageEvent(com.gradle.java.model.DownloadRepoMessageEvent) Subscription(rx.Subscription) DownloadRepoMessageEvent(com.gradle.java.model.DownloadRepoMessageEvent)

Example 3 with DownloadRepoMessageEvent

use of com.gradle.java.model.DownloadRepoMessageEvent in project Gradle-demo by Arisono.

the class RxjavaUtils method rxBusMethod.

/**
	 * 测试rxbus
	 */
public static void rxBusMethod() {
    // 注册 ---被观察者
    if (mSubscription != null && !mSubscription.isUnsubscribed()) {
        OkhttpUtils.println("mSubscription:unsubscribe()");
        mSubscription.unsubscribe();
    }
    mSubscription = RxBus.getInstance().toObservable().filter(o -> o instanceof DownloadRepoMessageEvent).map(o -> (DownloadRepoMessageEvent) o).doOnNext(o -> showMessage(o.getMessage())).subscribe();
    OkhttpUtils.println("isUnsubscribed():" + mSubscription.isUnsubscribed());
    // 发送消息 ---观察者
    RxBus.getInstance().send(new DownloadRepoMessageEvent("我这是利用rxjava技术来发送消息!"));
    OkhttpUtils.println("isUnsubscribed():" + mSubscription.isUnsubscribed());
}
Also used : Subscriber(rx.Subscriber) Date(java.util.Date) StringUtils(com.gradle.java.utils.StringUtils) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) Timer(java.util.Timer) Observer(rx.Observer) Scheduler(rx.Scheduler) Action1(rx.functions.Action1) Executors(java.util.concurrent.Executors) Observable(rx.Observable) CompositeSubscription(rx.subscriptions.CompositeSubscription) OkhttpUtils(com.gradle.android.retrofit.OkhttpUtils) Map(java.util.Map) Schedulers(rx.schedulers.Schedulers) TimerTask(java.util.TimerTask) DownloadRepoMessageEvent(com.gradle.java.model.DownloadRepoMessageEvent) Subscription(rx.Subscription) DownloadRepoMessageEvent(com.gradle.java.model.DownloadRepoMessageEvent)

Aggregations

DownloadRepoMessageEvent (com.gradle.java.model.DownloadRepoMessageEvent)3 OkhttpUtils (com.gradle.android.retrofit.OkhttpUtils)2 StringUtils (com.gradle.java.utils.StringUtils)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Timer (java.util.Timer)2 TimerTask (java.util.TimerTask)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Executors (java.util.concurrent.Executors)2 Observable (rx.Observable)2 Observer (rx.Observer)2 Scheduler (rx.Scheduler)2 Subscriber (rx.Subscriber)2 Subscription (rx.Subscription)2 Action1 (rx.functions.Action1)2 Schedulers (rx.schedulers.Schedulers)2 CompositeSubscription (rx.subscriptions.CompositeSubscription)2 IOException (java.io.IOException)1