Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
门心叼龙
android-mvvm-architecture
提交
50dfff59
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,发现更多精彩内容 >>
提交
50dfff59
编写于
7月 09, 2017
作者:
A
amitshekhariitbhu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement show and hide loading for activity
上级
d1b2d2a1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
57 addition
and
12 deletion
+57
-12
app/src/main/java/com/mindorks/framework/mvvm/ui/base/BaseActivity.java
...ava/com/mindorks/framework/mvvm/ui/base/BaseActivity.java
+37
-0
app/src/main/java/com/mindorks/framework/mvvm/ui/login/LoginActivity.java
...a/com/mindorks/framework/mvvm/ui/login/LoginActivity.java
+5
-0
app/src/main/java/com/mindorks/framework/mvvm/ui/login/LoginCallback.java
...a/com/mindorks/framework/mvvm/ui/login/LoginCallback.java
+6
-0
app/src/main/java/com/mindorks/framework/mvvm/ui/login/LoginViewModel.java
.../com/mindorks/framework/mvvm/ui/login/LoginViewModel.java
+8
-12
app/src/main/java/com/mindorks/framework/mvvm/ui/main/MainActivity.java
...ava/com/mindorks/framework/mvvm/ui/main/MainActivity.java
+1
-0
未找到文件。
app/src/main/java/com/mindorks/framework/mvvm/ui/base/BaseActivity.java
浏览文件 @
50dfff59
...
...
@@ -17,17 +17,23 @@
package
com.mindorks.framework.mvvm.ui.base
;
import
android.annotation.TargetApi
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.pm.PackageManager
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
import
android.view.inputmethod.InputMethodManager
;
import
com.mindorks.framework.mvvm.MvvmApp
;
import
com.mindorks.framework.mvvm.di.component.ActivityComponent
;
import
com.mindorks.framework.mvvm.di.component.DaggerActivityComponent
;
import
com.mindorks.framework.mvvm.di.module.ActivityModule
;
import
com.mindorks.framework.mvvm.ui.login.LoginActivity
;
import
com.mindorks.framework.mvvm.utils.CommonUtils
;
import
com.mindorks.framework.mvvm.utils.NetworkUtils
;
import
uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper
;
...
...
@@ -39,6 +45,8 @@ public abstract class BaseActivity extends AppCompatActivity implements BaseFrag
private
ActivityComponent
mActivityComponent
;
private
ProgressDialog
mProgressDialog
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -85,5 +93,34 @@ public abstract class BaseActivity extends AppCompatActivity implements BaseFrag
}
public
void
hideKeyboard
()
{
View
view
=
this
.
getCurrentFocus
();
if
(
view
!=
null
)
{
InputMethodManager
imm
=
(
InputMethodManager
)
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
imm
.
hideSoftInputFromWindow
(
view
.
getWindowToken
(),
0
);
}
}
public
void
openActivityOnTokenExpire
()
{
startActivity
(
LoginActivity
.
getStartIntent
(
this
));
finish
();
}
public
boolean
isNetworkConnected
()
{
return
NetworkUtils
.
isNetworkConnected
(
getApplicationContext
());
}
public
void
showLoading
()
{
hideLoading
();
mProgressDialog
=
CommonUtils
.
showLoadingDialog
(
this
);
}
public
void
hideLoading
()
{
if
(
mProgressDialog
!=
null
&&
mProgressDialog
.
isShowing
())
{
mProgressDialog
.
cancel
();
}
}
}
app/src/main/java/com/mindorks/framework/mvvm/ui/login/LoginActivity.java
浏览文件 @
50dfff59
...
...
@@ -70,4 +70,9 @@ public class LoginActivity extends BaseActivity implements LoginCallback {
startActivity
(
intent
);
finish
();
}
@Override
public
void
handleError
(
Throwable
throwable
)
{
// handle error
}
}
app/src/main/java/com/mindorks/framework/mvvm/ui/login/LoginCallback.java
浏览文件 @
50dfff59
...
...
@@ -24,4 +24,10 @@ public interface LoginCallback {
void
openMainActivity
();
void
showLoading
();
void
hideLoading
();
void
handleError
(
Throwable
throwable
);
}
app/src/main/java/com/mindorks/framework/mvvm/ui/login/LoginViewModel.java
浏览文件 @
50dfff59
...
...
@@ -16,7 +16,6 @@
package
com.mindorks.framework.mvvm.ui.login
;
import
com.androidnetworking.error.ANError
;
import
com.mindorks.framework.mvvm.data.DataManager
;
import
com.mindorks.framework.mvvm.data.model.api.LoginRequest
;
import
com.mindorks.framework.mvvm.data.model.api.LoginResponse
;
...
...
@@ -43,6 +42,7 @@ public class LoginViewModel extends BaseViewModel<LoginCallback> {
}
public
void
onGoogleLoginClick
()
{
getCallback
().
showLoading
();
getCompositeDisposable
().
add
(
getDataManager
()
.
doGoogleLoginApiCall
(
new
LoginRequest
.
GoogleLoginRequest
(
"test1"
,
"test1"
))
.
subscribeOn
(
getSchedulerProvider
().
io
())
...
...
@@ -57,22 +57,20 @@ public class LoginViewModel extends BaseViewModel<LoginCallback> {
response
.
getUserName
(),
response
.
getUserEmail
(),
response
.
getGoogleProfilePicUrl
());
getCallback
().
hideLoading
();
getCallback
().
openMainActivity
();
}
},
new
Consumer
<
Throwable
>()
{
@Override
public
void
accept
(
Throwable
throwable
)
throws
Exception
{
// handle the login error here
if
(
throwable
instanceof
ANError
)
{
ANError
anError
=
(
ANError
)
throwable
;
}
getCallback
().
hideLoading
();
getCallback
().
handleError
(
throwable
);
}
}));
}
public
void
onFbLoginClick
()
{
getCallback
().
showLoading
();
getCompositeDisposable
().
add
(
getDataManager
()
.
doFacebookLoginApiCall
(
new
LoginRequest
.
FacebookLoginRequest
(
"test3"
,
"test4"
))
.
subscribeOn
(
getSchedulerProvider
().
io
())
...
...
@@ -87,16 +85,14 @@ public class LoginViewModel extends BaseViewModel<LoginCallback> {
response
.
getUserName
(),
response
.
getUserEmail
(),
response
.
getGoogleProfilePicUrl
());
getCallback
().
hideLoading
();
getCallback
().
openMainActivity
();
}
},
new
Consumer
<
Throwable
>()
{
@Override
public
void
accept
(
Throwable
throwable
)
throws
Exception
{
// handle the login error here
if
(
throwable
instanceof
ANError
)
{
ANError
anError
=
(
ANError
)
throwable
;
}
getCallback
().
hideLoading
();
getCallback
().
handleError
(
throwable
);
}
}));
}
...
...
app/src/main/java/com/mindorks/framework/mvvm/ui/main/MainActivity.java
浏览文件 @
50dfff59
...
...
@@ -156,6 +156,7 @@ public class MainActivity extends BaseActivity implements MainCallback {
@Override
public
void
onDrawerOpened
(
View
drawerView
)
{
super
.
onDrawerOpened
(
drawerView
);
hideKeyboard
();
}
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录