是否有可能在运行时构造一个查询?
@Query("SELECT * FROM playlist " +
"WHERE playlist_title LIKE '% :playlistTitle %' " +
"GROUP BY playlist_title " +
"ORDER BY playlist_title " +
"LIMIT :limit")
List<IPlaylist> searchPlaylists(String playlistTitle, int limit);
Run Code Online (Sandbox Code Playgroud)
该limit部分是可选的.也就是说,它应该能够在有或没有限制的情况下执行相同的查询.
在前一种情况下,可以使用和不使用限制部分进行两个静态查询,并且每次都可以使用适当的一个.但有时我们可能不得不处理更复杂的情况,例如构建过滤器.
在这种情况下,与前面的示例不同,将有多个可选部分.对于书籍表,我们可能需要根据书籍所属的类别,作者姓名,价格范围,出版日期等进行过滤.使用这些部分的所有组合进行静态查询几乎是不可能的.
Android Studio更新到2.3后,我收到以下错误.
错误:无法加载类'org.gradle.logging.StyledTextOutput'.此意外错误的可能原因包括:
有人得到同样的错误?
有人可以解释这个异常何时发生?
12-18 11:20:07.225 15944-15944/com.test.dev.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dev.debug, PID: 15944
java.lang.IllegalArgumentException: Illegal state argument: 5
at android.support.design.widget.BottomSheetBehavior.startSettlingAnimation(BottomSheetBehavior.java:631)
at android.support.design.widget.BottomSheetBehavior$1.run(BottomSheetBehavior.java:550)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Run Code Online (Sandbox Code Playgroud)
Java类
public class BottomSheetController {
private BottomSheetBehavior<View> bottomSheetBehavior;
private WeakReference<FrameLayout> bottomSheetContainer;
private Slide slide;
public interface Slide {
void onSlide(@NonNull View bottomSheet, float slideOffset);
}
public void bind(FrameLayout bottomSheetContainer) {
this.bottomSheetContainer = new WeakReference<>(bottomSheetContainer);
bottomSheetBehavior = BottomSheetBehavior.from(this.bottomSheetContainer.get());
bottomSheetBehavior.setHideable(true);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
bottomSheetBehavior.setBottomSheetCallback(sheetCallback());
}
public void unbind() …Run Code Online (Sandbox Code Playgroud) 我正在尝试Image从我的Android APP上传到Amazon AWS S3,我需要使用AWS Restful API.
我正在使用Retrofit 2来提出请求.
我的应用程序与Amazon S3成功连接并按预期执行请求,但是当我尝试Image从Bucket查看时,图片无法打开.我下载Image到我的电脑并尝试打开但仍然收到图像已损坏的消息.
让我们看看我的完整代码.
我的Gradle依赖项
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'
compile 'net.danlew:android.joda:2.8.2'
Run Code Online (Sandbox Code Playgroud)
这里创建了一个文件并启动了请求
File file = new File(mCurrentPhotoPath);
RequestBody body = RequestBody.create(MediaType.parse("image/jpeg"), file);
uploadImage(body, "photo_name.jpeg");
Run Code Online (Sandbox Code Playgroud)
改造界面
public interface AwsS3 {
@Multipart
@PUT("/{Key}")
Call<String> upload(@Path("Key") String Key,
@Header("Content-Length") long length,
@Header("Accept") String accept,
@Header("Host") String host,
@Header("Date") String date,
@Header("Content-type") String contentType,
@Header("Authorization") String authorization,
@Part("Body") RequestBody …Run Code Online (Sandbox Code Playgroud) 我需要实现这个屏幕,我想知道是否有人可以帮助我解决一些场景的想法,基本上屏幕将在顶部图像中包含视差效果,整个屏幕必须可滚动,我在设计此屏幕时遇到的问题这是我看到我需要有一个滚动视图和一个tableview的方式,让我遇到让卷轴朝同一方向的麻烦.
我在这里阅读了几篇关于滚动滚动内容的问题,例如:嵌套的UITableView在另一个嵌套表中,我想要的实际上是可以帮助我实现下面屏幕的想法.
我只需要良好实践的建议,没有人需要担心邮政编码,除非有一些lib来帮助解决这个问题.
我感谢任何帮助.

我有一段时间用Dagger测试了一些东西,在监督了这里的一系列文章之后:http://antonioleiva.com/dependency-injection-android-dagger-part-1/,回去了解更多信息,我看到了一些很好的例子,比如这些:https://github.com/adennie/fb-android-dagger,其中大部分集中在注入依赖上Activity,Fragment,Service和相关的.我想和RoboGuice做类似的事情.
在RoboGuice中
public class Utils {
@InjectResource(R.string.hello_world) private String hello;
public void showLog(){
System.out.println("String from injected resource : " + hello);
}
}
Run Code Online (Sandbox Code Playgroud)
在匕首
public class Utils {
@Inject
Resources mResource;
public void showLog() {
System.out.println( "String from injected resource : " + this.mResource.getString( R.string.hello_world ) );
}
}
Run Code Online (Sandbox Code Playgroud)
我在我的应用程序中创建了一个模块
@Module( injects = {Utils.class }, complete = false, library = true )
public class ResourceModule {
Context mContext; …Run Code Online (Sandbox Code Playgroud) android ×5
amazon-s3 ×1
android-room ×1
autolayout ×1
bottom-sheet ×1
dagger ×1
gradle ×1
ios8.3 ×1
rest ×1
retrofit ×1
roboguice ×1
swift ×1
uitableview ×1