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);
}
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);
}
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);
}
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);
}
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());
}
}
Aggregations