我们使用spring framework 5和spring boot 2.0.0.M6,我们也WebClient用于反应式编程.我们为我们的反应式休息端点创建了测试方法,因此我查找了一些关于如何操作的示例.我发现这个或者这个以及许多其他的都是一样的.他们只是自动装配一个WebTestClient.所以我尝试了同样的事情:
@Log
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class MyControllerTest {
@Autowired
private WebTestClient webClient;
@Test
public void getItems() throws Exception {
log.info("Test: '/items/get'");
Parameters params = new Parameters("#s23lkjslökjh12", "2015-09-20/2015-09-27");
this.webClient.post().uri("/items/get")
.accept(MediaType.APPLICATION_STREAM_JSON)
.contentType(MediaType.APPLICATION_STREAM_JSON)
.body(BodyInserters.fromPublisher(Mono.just(params), Parameters.class))
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_STREAM_JSON)
.expectBody(Basket.class);
}
}
Run Code Online (Sandbox Code Playgroud)
我无法运行,因为我收到错误:
Could not autowire. No beans of 'WebTestClient' type found.
Run Code Online (Sandbox Code Playgroud)
因此,似乎不存在自动配置.我使用的是错误版本还是这里有什么问题?
我有以下撰写文件:
version: "3"
services:
zookeeper:
image: docker-dev.art.intern/wurstmeister/zookeeper:latest
ports:
- 2181:2181
kafka:
image: docker-dev.art.intern/wurstmeister/kafka:latest
ports:
- 9092:9092
environment:
- KAFKA_LISTENERS=PLAINTEXT://:9092
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
- KAFKA_ADVERTISED_HOST_NAME=kafka
- KAFKA_ADVERTISED_PORT=9092
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
depends_on:
- zookeeper
app:
build:
context: ./
dockerfile: app/Dockerfile
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4020/actuator/health"]
interval: 30s
timeout: 10s
retries: 5
depends_on:
- kafka
- zookeeper
app-test:
build:
context: ./
dockerfile: test/Dockerfile
depends_on:
app:
condition: service_healthy
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在为应用程序实施运行状况检查,并且我使用service_healthy条件。但这会导致错误:
The Compose file '.\docker-compose.yml' is invalid because:
services.app-test.depends_on contains an invalid type, it should …Run Code Online (Sandbox Code Playgroud) 使用Chart.js可以创建折线图,为此您必须使用标签和数据集.例如:
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(75,192,192,0.4)",
borderColor: "rgba(75,192,192,1)",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "rgba(75,192,192,1)",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "rgba(75,192,192,1)",
pointHoverBorderColor: "rgba(220,220,220,1)",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
data: [65, 59, 80, 81, 56, 55, 40],
}
]
};
Run Code Online (Sandbox Code Playgroud)
这里的问题是你有一定数量的标签(在这种情况下为7),你还需要为每个数据集提供7个数据条目.现在如果您有不明数量的标签和数据条目怎么办?
如果一个数据条目包含数字和时间,该怎么办:
Entry {
number: 127
time: 10:00
}
Run Code Online (Sandbox Code Playgroud)
如果要在X轴上显示所有时间,在Y轴上显示所有数字,请按X轴上的时间排序,该怎么办?Chart.js有可能吗?
我写了一个UICropperViewController,它在横向模式下完美地适用于图像.纵向模式下的图像存在很大问题.下图显示了带有黄色裁剪框的简单图片:
裁剪结果是:
现在谈到肖像图像我们得到了这种情况:
结果如下:
那么这里发生了什么?原始图像自动向左旋转.
我研究了很多,基本上找到了两个建议:
建议1
在裁剪之前保存图像方向并恢复它.
func didTapCropButton(sender: AnyObject) {
let originalOrientation = self.imageView.image?.imageOrientation;
// raw value of originalOrientation is `3` so its rotated to the right
let croppedCGImage = self.imageView.image?.cgImage?.cropping(to: self.cropArea);
// create a cropped cgImage
let croppedImage = UIImage(cgImage: croppedCGImage!, scale: (self.imageView.image?.scale)!, orientation: (originalOrientation)!);
// create the UIImage with the result from cgImage cropping and original orientation
if (self.callback != nil) {
self.callback.croppingDone(image: croppedImage);
}
self.dismiss(animated: true, completion: nil);
}
Run Code Online (Sandbox Code Playgroud)
但结果现在是:
显然这个建议不起作用,因为它只是简单地旋转已经裁剪的图像.
建议2
定位修复.我找到了以下代码,并承诺会修复错误: …
我想用相机拍照.我只是暂时需要它们,所以我做了以下事情:
private void takePicture() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(this.getActivity().getPackageManager()) != null) {
try {
this.imageFile = File.createTempFile("CROP_SHOT", ".jpg", this.getActivity().getCacheDir());
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(this.imageFile));
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
this.startActivityForResult(intent, Globals.REQUEST_TAKE_PHOTO);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的RESULT_CANCELED是我的结果代码onActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.v("PictureEdit", "onActivityResult");
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == Activity.RESULT_OK) {
if(requestCode == Globals.REQUEST_TAKE_PHOTO) {
Log.v("PictureEdit", "onActivityResult take photo");
this.startCropImage(Uri.fromFile(this.imageFile));
} else if (requestCode == Globals.REQUEST_PICK_PHOTO) {
Log.v("PictureEdit", "onActivityResult pick photo"); …Run Code Online (Sandbox Code Playgroud) 是什么区别onScroll(),并onFling()在GestureDetector界面?当我打印出事件时,他们会显示完全相同的事情.至少是最后一个onScroll()和onFling().
我注意到的唯一真正的区别是,onScroll()更频繁地调用,总是只有一次.
我有这个图标:
当我在列表视图中按下我的项目时,我希望它旋转180°.当我再次点击时,我希望它再旋转180°,这样就可以达到它的原始位置.
首先我试过:
view.animate().rotation(180).setDuration(500).start();
Run Code Online (Sandbox Code Playgroud)
但它只发射一次.之后我尝试了:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:fillEnabled="true">
<rotate
android:duration="500"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="180" />
</set>
Run Code Online (Sandbox Code Playgroud)
但是,即使箭头已经显示在顶部,动画始终以箭头显示到按钮并旋转到顶部开始.
那我怎么能让它工作呢?
我想创建一个截图,UIScrollView其中应包含滚动视图的整个内容,甚至包含当前用户不可见的内容.为此,我尝试了以下两种方法:
func snapShot(view:UIView) -> UIImage {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, true, 0);
view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true);
let image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
func snapShotScrollView(scrollView:UIScrollView) -> UIImage {
let bounds = scrollView.bounds;
scrollView.bounds.size = scrollView.contentSize;
let image = snapShot(scrollView);
scrollView.bounds = bounds;
return image;
}
Run Code Online (Sandbox Code Playgroud)
但是生成的图像仍然只显示滚动视图中当前对用户可见的那些视图元素.但我希望看到所有观点.
我怎样才能做到这一点?
编辑
我也尝试过:
func snapshot() -> UIImage? {
var image: UIImage?
UIGraphicsBeginImageContext(scrollView.contentSize)
let savedContentOffset = scrollView.contentOffset
let savedFrame = scrollView.frame;
scrollView.contentOffset = CGPoint.zero;
scrollView.frame = CGRect(x: 0, y: 0, width: scrollView.contentSize.width, height: scrollView.contentSize.height);
scrollView.layer.render(in: UIGraphicsGetCurrentContext()!) …Run Code Online (Sandbox Code Playgroud) 我有一个带有以下视图的CardView:
- RelativeLayout (view_1)
- TextView
- TextView
- RelativeLayout (view_2)
- ImageView
- ImageView
Run Code Online (Sandbox Code Playgroud)
当我打开我的ListViewview_2设置为Visible.GONE所以你无法看到它.现在,我使用的ExpandAnimation从这个博客.在这里你有代码:
/**
*
*/
public class ExpandAnimation extends Animation {
/**
*
*/
private AnimationCallback callback = null;
/**
*
*/
private View viewToAnimate = null;
/**
*
*/
private RelativeLayout.LayoutParams viewToAnimateLayoutParams = null;
/**
*
*/
private int marginStart = 0;
/**
*
*/
private int marginEnd = 0;
/**
*
*/
private boolean isVisibleAfter = …Run Code Online (Sandbox Code Playgroud) 我有一个RecyclerView以下适配器:
public class DataTransferMeasureListAdapter extends DataTransferBaseListAdapter<DataTransferMeasureListAdapter.ViewHolder> {
private Context context = null;
private List<DataTransferListEntry> entries = null;
public DataTransferMeasureListAdapter(Context context, List<DataTransferListEntry> entries) {
super(context);
this.context = context;
this.entries = entries;
}
@Override
public DataTransferMeasureListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(context).inflate(R.layout.fragment_datatransfer_measure_list_row, parent, false);
return new DataTransferMeasureListAdapter.ViewHolder(this.context, itemView);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final DataTransferMeasureListEntry entry = (DataTransferMeasureListEntry) entries.get(position);
final ViewHolder viewHolder = (ViewHolder) holder;
String time = Helper.getDateTimePattern(this.context, entry.getDate());
String value = …Run Code Online (Sandbox Code Playgroud) android ×5
ios ×2
swift ×2
android-view ×1
animation ×1
cgimage ×1
chart.js ×1
charts ×1
docker ×1
javascript ×1
onclick ×1
screenshot ×1
spring ×1
spring-boot ×1
swift3 ×1
uiimage ×1
uiimageview ×1
uiscrollview ×1
visibility ×1
yaml ×1