我的Android工作室项目有一个依赖于android框架的app模块,我创建了一个名为domain的新模块,它只包含纯java类和一些测试类.
在这个模块的build.gradle文件中,我添加了junit和mockito库用于测试目的,如下所示:
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7
dependencies {
testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-core:1.9.5'
compile project(':common')
compile project(':model')
//test dependencies
}
Run Code Online (Sandbox Code Playgroud)
但是!!! JUnit version 3.8 or later expected每当我尝试执行测试类时,Android Studio都会给我错误消息.
此问题的所有建议解决方案是打开项目结构| 模块| 依赖关系,并将junit-4.7.jar向上移动,以便它在类路径中的Android 1.6 Platform之前出现.
事实上,我试图实现这个解决方案,但问题仍然存在.
有关如何解决此问题的任何想法?
我有以下方法使用otto和发布对UI的响应AsyncTask.
private static void onGetLatestStoryCollectionSuccess(final StoryCollection storyCollection, final Bus bus) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
bus.post(new LatestStoryCollectionResponse(storyCollection));
return null;
}
}.execute();
}
Run Code Online (Sandbox Code Playgroud)
我需要帮助将其转换AsyncTask为RxJava使用RxAndroid库.
我正在使用以下cURL请求localhost运行正常:
curl -u admin:e4d4face52f2e3dc22b43b2145ed7c58ce66e26b384d73592c -d "{\"jsonrpc\": \"2.0\", \"method\": \"feed.list\", \"id\": 1}" http://localhost/minifluxR/jsonrpc.php
Run Code Online (Sandbox Code Playgroud)
但是当我使用Postman而不是cURL发送相同的请求时,我得到:
{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error"}}
Run Code Online (Sandbox Code Playgroud)
在Postman中我使用了一个GET请求并将以下内容作为标题发送:
url:http://localhost/minifluxR/jsonrpc.php
username:admin
api_token:e4d4face52f2e3dc22b43b2145ed7c58ce66e26b384d73592c
method: feed.list
Run Code Online (Sandbox Code Playgroud)
以下是我试图触发的PHP函数:
$server = new Server;
$server->authentication(array(
\Model\Config\get('username') => \Model\Config\get('api_token')
));
// Get all feeds
$server->register('feed.list', function () {
return Model\Feed\get_all();
});
Run Code Online (Sandbox Code Playgroud)
请帮我纠正这些错误.
关于制作透明工具栏有很多问题.但没有一个给定的答案解决了我的问题.
我的问题是,我想制作透明的工具栏,只有当用户向上或向下滚动时才应该有原色背景.但最初它必须是透明的,直到滚动向上/向下事件发生.
因为我有以下主题:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowActionBarOverlay">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
activity_main.xml:
<android.support.v4.widget.DrawerLayout
...
/>
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
.....
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
app_bar_main:
<android.support.design.widget.CoordinatorLayout
....
.... />
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"/>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton
....
....
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
但是我没有获得透明工具栏,而是获得了带有白色背景的工具栏.
你能检查一下我的theme.xml有什么问题吗?
我正在使用设计支持库23.1.1谢谢
我试图通过从autoloader文件加载PHPUnit与PhpSTORM.但是,正如您在下面的屏幕截图中看到的那样,PHPUnit版本:未安装,即使我选择其他两个选项,我也会得到相同的结果.即phpunit.phar的路径和从包含路径(PEAR)加载.
正在检测PhpUnit类和代码自动完成,但PhpStorm编辑器就好了.
让我说我有observable call rest api服务然后将结果存储在数据库中:
public Observable<Boolean> initDB() {
return this.restApi.feedsEntityList()
.flatMap(feedEntityList -> this.mNewsCache.saveFeeds(feedEntityList));
}
Run Code Online (Sandbox Code Playgroud)
save Observable执行数据库保存,如果成功则返回true,如果发生错误则返回false:
public Observable<Boolean> saveFeeds(List<FeedEntity> feedEntity) {
if (feedEntity != null) {
return Observable.create(new Observable.OnSubscribe<Boolean>() {
@Override
public void call(Subscriber<? super Boolean> subscriber) {
try {
Log.d("DB: ", "saving Feed to DB");
for (FeedEntity feeds : feedEntity) {
feeds.save();
}
subscriber.onNext(true);
subscriber.onCompleted();
} catch (Exception exception) {
subscriber.onError(exception);
}
}
});
} else return Observable.empty();
}
Run Code Online (Sandbox Code Playgroud)
在最后一个观察中,我不确定我是否正确地做到了.ie如果成功完成数据库保存操作,则返回true.否则返回false!
还有,我应该返回feedEntity是否为空?
那是对的吗?我应该如何检查observable是否返回true,false或empty Observable?