Search in sources :

Example 11 with OnClick

use of butterknife.OnClick in project okhttp-OkGo by jeasonlzy.

the class RxCommonActivity method retrofitRequest.

@OnClick(R.id.retrofitRequest)
public void retrofitRequest(View view) {
    Subscription subscription = //
    ServerApi.getServerModel("aaa", "bbb").doOnSubscribe(new Action0() {

        @Override
        public void call() {
            //开始请求前显示对话框
            showLoading();
        }
    }).map(new Func1<LzyResponse<ServerModel>, ServerModel>() {

        @Override
        public ServerModel call(LzyResponse<ServerModel> response) {
            return response.data;
        }
    }).observeOn(//切换到主线程
    AndroidSchedulers.mainThread()).subscribe(new Action1<ServerModel>() {

        @Override
        public void call(ServerModel serverModel) {
            //请求成功
            dismissLoading();
            handleResponse(serverModel, null, null);
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
            //请求失败
            throwable.printStackTrace();
            showToast("请求失败");
            dismissLoading();
            handleError(null, null);
        }
    });
    addSubscribe(subscription);
}
Also used : Action0(rx.functions.Action0) LzyResponse(com.lzy.demo.model.LzyResponse) ServerModel(com.lzy.demo.model.ServerModel) Subscription(rx.Subscription) OnClick(butterknife.OnClick)

Example 12 with OnClick

use of butterknife.OnClick in project okhttp-OkGo by jeasonlzy.

the class RxCommonActivity method commonRequest.

@OnClick(R.id.commonRequest)
public void commonRequest(View view) {
    Subscription subscription = //
    OkGo.post(Urls.URL_METHOD).headers("aaa", //
    "111").params("bbb", //
    "222").getCall(StringConvert.create(), //以上为产生请求事件,请求默认发生在IO线程
    RxAdapter.<String>create()).doOnSubscribe(new Action0() {

        @Override
        public void call() {
            //开始请求前显示对话框
            showLoading();
        }
    }).observeOn(//切换到主线程
    AndroidSchedulers.mainThread()).subscribe(new Action1<String>() {

        @Override
        public void call(String s) {
            //请求成功,关闭对话框
            dismissLoading();
            handleResponse(s, null, null);
        }
    }, new Action1<Throwable>() {

        @Override
        public void call(Throwable throwable) {
            throwable.printStackTrace();
            //请求失败
            dismissLoading();
            showToast("请求失败");
            handleError(null, null);
        }
    });
    addSubscribe(subscription);
}
Also used : Action0(rx.functions.Action0) Subscription(rx.Subscription) OnClick(butterknife.OnClick)

Example 13 with OnClick

use of butterknife.OnClick in project okhttp-OkGo by jeasonlzy.

the class RxFormUploadActivity method selectImage.

@OnClick(R.id.selectImage)
public void selectImage(View view) {
    ImagePicker imagePicker = ImagePicker.getInstance();
    imagePicker.setImageLoader(new GlideImageLoader());
    //多选
    imagePicker.setMultiMode(true);
    //显示拍照按钮
    imagePicker.setShowCamera(true);
    //最多选择9张
    imagePicker.setSelectLimit(9);
    //不进行裁剪
    imagePicker.setCrop(false);
    Intent intent = new Intent(this, ImageGridActivity.class);
    startActivityForResult(intent, 100);
}
Also used : Intent(android.content.Intent) ImagePicker(com.lzy.imagepicker.ImagePicker) GlideImageLoader(com.lzy.demo.utils.GlideImageLoader) OnClick(butterknife.OnClick)

Example 14 with OnClick

use of butterknife.OnClick in project android-oss by kickstarter.

the class DebugPushNotificationsView method simulateProjectLaunchButtonClick.

@OnClick(R.id.simulate_project_launch_button)
public void simulateProjectLaunchButtonClick() {
    final GCM gcm = GCM.builder().title("Want to be the first backer?").alert("Taylor Moore just launched a project!").build();
    final Activity activity = Activity.builder().category(com.kickstarter.models.Activity.CATEGORY_LAUNCH).id(5).projectId(PROJECT_ID).build();
    final PushNotificationEnvelope envelope = PushNotificationEnvelope.builder().activity(activity).gcm(gcm).build();
    pushNotifications.add(envelope);
}
Also used : GCM(com.kickstarter.models.pushdata.GCM) PushNotificationEnvelope(com.kickstarter.services.apiresponses.PushNotificationEnvelope) Activity(com.kickstarter.models.pushdata.Activity) OnClick(butterknife.OnClick)

Example 15 with OnClick

use of butterknife.OnClick in project android-oss by kickstarter.

the class DebugPushNotificationsView method simulateBurstClick.

@OnClick(R.id.simulate_burst_button)
public void simulateBurstClick() {
    final PushNotificationEnvelope baseEnvelope = projectSuccessEnvelope();
    for (int i = 0; i < 100; i++) {
        // Create a different signature for each push notification
        final GCM gcm = baseEnvelope.gcm().toBuilder().alert(Integer.toString(i)).build();
        pushNotifications.add(baseEnvelope.toBuilder().gcm(gcm).build());
    }
}
Also used : GCM(com.kickstarter.models.pushdata.GCM) PushNotificationEnvelope(com.kickstarter.services.apiresponses.PushNotificationEnvelope) OnClick(butterknife.OnClick)

Aggregations

OnClick (butterknife.OnClick)465 Intent (android.content.Intent)206 View (android.view.View)24 AlertDialog (android.support.v7.app.AlertDialog)21 TextView (android.widget.TextView)18 File (java.io.File)18 Bundle (android.os.Bundle)16 BindView (butterknife.BindView)16 DialogInterface (android.content.DialogInterface)15 ArrayList (java.util.ArrayList)15 DialogFragment (com.rey.material.app.DialogFragment)13 SimpleDialog (com.rey.material.app.SimpleDialog)13 Uri (android.net.Uri)11 SimpleDateFormat (java.text.SimpleDateFormat)11 SuppressLint (android.annotation.SuppressLint)10 ImageView (android.widget.ImageView)10 LzyResponse (com.lzy.demo.model.LzyResponse)10 HorizontalChangeHandler (com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler)9 List (java.util.List)9 Animator (android.animation.Animator)8