Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
warppay-app
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian
warppay-app
Commits
ca78b94a
Commit
ca78b94a
authored
8 years ago
by
Christian Dresen
Browse files
Options
Downloads
Patches
Plain Diff
Auto-Refresh alle 60 Sekunden wenn nicht eingeloggt.
parent
12b6a8f4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
WarpDrinkApp/app/src/main/java/ms/warpzone/warppay/manager/MainManager.java
+37
-3
37 additions, 3 deletions
...rc/main/java/ms/warpzone/warppay/manager/MainManager.java
with
37 additions
and
3 deletions
WarpDrinkApp/app/src/main/java/ms/warpzone/warppay/manager/MainManager.java
+
37
−
3
View file @
ca78b94a
...
@@ -65,6 +65,7 @@ public class MainManager {
...
@@ -65,6 +65,7 @@ public class MainManager {
public
AlertDialog
alertAmount
;
public
AlertDialog
alertAmount
;
private
ProgressDialog
pdRefresh
=
null
;
private
ProgressDialog
pdRefresh
=
null
;
private
NotificationDialog
ndRefreshError
=
null
;
private
NotificationDialog
ndRefreshError
=
null
;
private
Timer
tmrRefresh
;
public
static
MainManager
getInstance
()
{
public
static
MainManager
getInstance
()
{
return
instance
;
return
instance
;
...
@@ -134,11 +135,16 @@ public class MainManager {
...
@@ -134,11 +135,16 @@ public class MainManager {
}
}
public
void
refreshData
()
{
public
void
refreshData
()
{
this
.
refreshData
(
false
);
}
public
void
refreshData
(
boolean
disableDialog
)
{
if
(
this
.
ndRefreshError
!=
null
)
if
(
this
.
ndRefreshError
!=
null
)
this
.
ndRefreshError
.
dismiss
();
this
.
ndRefreshError
.
dismiss
();
this
.
ndRefreshError
=
null
;
this
.
ndRefreshError
=
null
;
this
.
pdRefresh
=
ProgressDialog
.
show
(
this
.
mainActivity
,
"Refreshing..."
,
"Loading..."
);
if
(!
disableDialog
)
this
.
pdRefresh
=
ProgressDialog
.
show
(
this
.
mainActivity
,
"Refreshing..."
,
"Loading..."
);
this
.
restService
.
getAllUser
().
enqueue
(
new
Callback
<
List
<
RestUser
>>()
{
this
.
restService
.
getAllUser
().
enqueue
(
new
Callback
<
List
<
RestUser
>>()
{
...
@@ -148,7 +154,6 @@ public class MainManager {
...
@@ -148,7 +154,6 @@ public class MainManager {
if
(
userList
!=
null
)
{
if
(
userList
!=
null
)
{
MainManager
.
getInstance
().
uiManager
.
refreshUserData
(
userList
);
MainManager
.
getInstance
().
uiManager
.
refreshUserData
(
userList
);
}
}
Toast
.
makeText
(
MainManager
.
getInstance
().
mainActivity
,
"Refresh successful"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
@Override
@Override
...
@@ -182,6 +187,7 @@ public class MainManager {
...
@@ -182,6 +187,7 @@ public class MainManager {
MainManager
.
getInstance
().
uiManager
.
refreshProductData
(
productList
);
MainManager
.
getInstance
().
uiManager
.
refreshProductData
(
productList
);
}
}
MainManager
.
this
.
pdRefresh
.
dismiss
();
MainManager
.
this
.
pdRefresh
.
dismiss
();
MainManager
.
this
.
startRefreshTimer
();
}
}
@Override
@Override
...
@@ -194,8 +200,8 @@ public class MainManager {
...
@@ -194,8 +200,8 @@ public class MainManager {
}
}
private
void
showRefreshError
()
{
private
void
showRefreshError
()
{
if
(
ndRefreshError
==
null
)
{
if
(
ndRefreshError
==
null
)
{
this
.
stopRefreshTimer
();
if
(
pdRefresh
!=
null
)
if
(
pdRefresh
!=
null
)
pdRefresh
.
dismiss
();
pdRefresh
.
dismiss
();
ndRefreshError
=
new
NotificationDialog
(
this
.
mainActivity
,
"WARNING"
,
"Refresh failed. Please retry!"
);
ndRefreshError
=
new
NotificationDialog
(
this
.
mainActivity
,
"WARNING"
,
"Refresh failed. Please retry!"
);
...
@@ -249,6 +255,7 @@ public class MainManager {
...
@@ -249,6 +255,7 @@ public class MainManager {
this
.
dataManager
.
setCurrentUser
(
user
);
this
.
dataManager
.
setCurrentUser
(
user
);
this
.
uiManager
.
setCurrentUser
(
user
);
this
.
uiManager
.
setCurrentUser
(
user
);
this
.
startTimer
();
this
.
startTimer
();
this
.
stopRefreshTimer
();
}
}
}
}
...
@@ -279,6 +286,31 @@ public class MainManager {
...
@@ -279,6 +286,31 @@ public class MainManager {
this
.
timer
.
schedule
(
t
,
60000
);
this
.
timer
.
schedule
(
t
,
60000
);
}
}
public
void
startRefreshTimer
()
{
this
.
tmrRefresh
=
new
Timer
();
TimerTask
t
=
new
TimerTask
()
{
@Override
public
void
run
()
{
Handler
mainHandler
=
new
Handler
(
MainManager
.
getInstance
().
getMainActivity
().
getApplicationContext
().
getMainLooper
());
Runnable
myRunnable
=
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
MainManager
.
getInstance
().
getCurrentUser
()
==
null
)
MainManager
.
getInstance
().
refreshData
(
true
);
}
};
mainHandler
.
post
(
myRunnable
);
}
};
this
.
tmrRefresh
.
schedule
(
t
,
60000
,
60000
);
}
public
void
stopRefreshTimer
()
{
if
(
this
.
tmrRefresh
!=
null
)
{
this
.
tmrRefresh
.
cancel
();
this
.
tmrRefresh
.
purge
();
}
}
public
void
resetScreenSaverTimer
()
{
public
void
resetScreenSaverTimer
()
{
this
.
stopScreenSaverTimer
();
this
.
stopScreenSaverTimer
();
this
.
screenSaverTimer
=
new
Timer
();
this
.
screenSaverTimer
=
new
Timer
();
...
@@ -314,6 +346,8 @@ public class MainManager {
...
@@ -314,6 +346,8 @@ public class MainManager {
this
.
dataManager
.
clearCurrentUser
();
this
.
dataManager
.
clearCurrentUser
();
this
.
uiManager
.
clearCurrentUser
();
this
.
uiManager
.
clearCurrentUser
();
this
.
stopTimer
();
this
.
stopTimer
();
MainManager
.
getInstance
().
refreshData
();
this
.
startRefreshTimer
();
}
}
public
void
addOrder
(
Order
order
)
{
public
void
addOrder
(
Order
order
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment