Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
门心叼龙
android-mvvm-architecture
提交
0962a910
A
android-mvvm-architecture
项目概览
门心叼龙
/
android-mvvm-architecture
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
android-mvvm-architecture
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0962a910
编写于
7月 08, 2017
作者:
A
amitshekhariitbhu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Seeding Functionality
上级
eef5ae37
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
83 addition
and
6 deletion
+83
-6
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+6
-2
app/src/main/java/com/mindorks/framework/mvvm/ui/base/BaseViewModel.java
...va/com/mindorks/framework/mvvm/ui/base/BaseViewModel.java
+2
-2
app/src/main/java/com/mindorks/framework/mvvm/ui/splash/SplashActivity.java
...com/mindorks/framework/mvvm/ui/splash/SplashActivity.java
+19
-1
app/src/main/java/com/mindorks/framework/mvvm/ui/splash/SplashCallback.java
...com/mindorks/framework/mvvm/ui/splash/SplashCallback.java
+27
-0
app/src/main/java/com/mindorks/framework/mvvm/ui/splash/SplashViewModel.java
...om/mindorks/framework/mvvm/ui/splash/SplashViewModel.java
+29
-1
未找到文件。
app/src/main/AndroidManifest.xml
浏览文件 @
0962a910
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
~
~ Licensed under the Apache License, Version 2.0 (the "License");
...
...
@@ -33,6 +32,11 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<activity
android:name=
".ui.main.MainActivity"
android:launchMode=
"singleTop"
android:screenOrientation=
"portrait"
/>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/mindorks/framework/mvvm/ui/base/BaseViewModel.java
浏览文件 @
0962a910
...
...
@@ -41,11 +41,11 @@ public abstract class BaseViewModel<V> {
this
.
mCompositeDisposable
=
compositeDisposable
;
}
public
void
onAttach
(
V
callback
)
{
public
void
setCallback
(
V
callback
)
{
this
.
mCallback
=
callback
;
}
public
void
onDe
tach
()
{
public
void
onDe
stroy
()
{
mCompositeDisposable
.
dispose
();
}
...
...
app/src/main/java/com/mindorks/framework/mvvm/ui/splash/SplashActivity.java
浏览文件 @
0962a910
...
...
@@ -24,6 +24,7 @@ import android.os.Bundle;
import
com.mindorks.framework.mvvm.R
;
import
com.mindorks.framework.mvvm.databinding.ActivitySplashBinding
;
import
com.mindorks.framework.mvvm.ui.base.BaseActivity
;
import
com.mindorks.framework.mvvm.ui.main.MainActivity
;
import
javax.inject.Inject
;
...
...
@@ -33,7 +34,7 @@ import butterknife.ButterKnife;
* Created by amitshekhar on 08/07/17.
*/
public
class
SplashActivity
extends
BaseActivity
{
public
class
SplashActivity
extends
BaseActivity
implements
SplashCallback
{
@Inject
SplashViewModel
mSplashViewModel
;
...
...
@@ -55,5 +56,22 @@ public class SplashActivity extends BaseActivity {
setUnBinder
(
ButterKnife
.
bind
(
this
));
binding
.
setViewmodel
(
mSplashViewModel
);
mSplashViewModel
.
setCallback
(
this
);
mSplashViewModel
.
startSeeding
();
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
mSplashViewModel
.
onDestroy
();
}
@Override
public
void
onSeedingComplete
()
{
Intent
intent
=
MainActivity
.
getStartIntent
(
SplashActivity
.
this
);
startActivity
(
intent
);
finish
();
}
}
app/src/main/java/com/mindorks/framework/mvvm/ui/splash/SplashCallback.java
0 → 100644
浏览文件 @
0962a910
/*
* Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://mindorks.com/license/apache-v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package
com.mindorks.framework.mvvm.ui.splash
;
/**
* Created by amitshekhar on 08/07/17.
*/
public
interface
SplashCallback
{
void
onSeedingComplete
();
}
app/src/main/java/com/mindorks/framework/mvvm/ui/splash/SplashViewModel.java
浏览文件 @
0962a910
...
...
@@ -20,13 +20,16 @@ import com.mindorks.framework.mvvm.data.DataManager;
import
com.mindorks.framework.mvvm.ui.base.BaseViewModel
;
import
com.mindorks.framework.mvvm.utils.rx.SchedulerProvider
;
import
io.reactivex.ObservableSource
;
import
io.reactivex.disposables.CompositeDisposable
;
import
io.reactivex.functions.Consumer
;
import
io.reactivex.functions.Function
;
/**
* Created by amitshekhar on 08/07/17.
*/
public
class
SplashViewModel
extends
BaseViewModel
{
public
class
SplashViewModel
extends
BaseViewModel
<
SplashCallback
>
{
public
SplashViewModel
(
DataManager
dataManager
,
SchedulerProvider
schedulerProvider
,
...
...
@@ -34,4 +37,29 @@ public class SplashViewModel extends BaseViewModel {
super
(
dataManager
,
schedulerProvider
,
compositeDisposable
);
}
public
void
startSeeding
()
{
getCompositeDisposable
().
add
(
getDataManager
()
.
seedDatabaseQuestions
()
.
flatMap
(
new
Function
<
Boolean
,
ObservableSource
<
Boolean
>>()
{
@Override
public
ObservableSource
<
Boolean
>
apply
(
Boolean
aBoolean
)
throws
Exception
{
return
getDataManager
().
seedDatabaseOptions
();
}
})
.
subscribeOn
(
getSchedulerProvider
().
io
())
.
observeOn
(
getSchedulerProvider
().
ui
())
.
subscribe
(
new
Consumer
<
Boolean
>()
{
@Override
public
void
accept
(
Boolean
aBoolean
)
throws
Exception
{
getCallback
().
onSeedingComplete
();
}
},
new
Consumer
<
Throwable
>()
{
@Override
public
void
accept
(
Throwable
throwable
)
throws
Exception
{
getCallback
().
onSeedingComplete
();
}
}));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录