Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-android
Commits
76d0e27e
Commit
76d0e27e
authored
Jan 10, 2017
by
Robert Hitt
Browse files
Fixed crashes on rotation
parent
0aecabaa
Pipeline
#745
passed with stages
in 4 minutes and 46 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/srct/whatsopen/ui/activities/MainActivity.java
View file @
76d0e27e
...
...
@@ -17,6 +17,7 @@ import butterknife.ButterKnife;
import
fr.castorflex.android.circularprogressbar.CircularProgressBar
;
import
io.realm.Realm
;
import
srct.whatsopen.R
;
import
srct.whatsopen.ui.MainView
;
import
srct.whatsopen.ui.presenters.MainPresenter
;
...
...
@@ -25,7 +26,6 @@ import srct.whatsopen.ui.adapters.FacilityListFragmentPagerAdapter;
public
class
MainActivity
extends
AppCompatActivity
implements
MainView
{
@BindView
(
R
.
id
.
progress_bar
)
CircularProgressBar
mProgressBar
;
@BindView
(
R
.
id
.
list_view
)
LinearLayout
mListView
;
private
MainPresenter
mPresenter
;
...
...
@@ -34,14 +34,16 @@ public class MainActivity extends AppCompatActivity implements MainView {
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
// Bind them views
ButterKnife
.
bind
(
this
);
// Set up presenter
mPresenter
=
new
MainPresenter
();
mPresenter
.
attachView
(
this
);
// Get facility data
mPresenter
.
loadFacilities
();
// Get facility data if necessary
if
(
Realm
.
getDefaultInstance
().
isEmpty
())
mPresenter
.
loadFacilities
();
// Configure toolbar
Toolbar
toolbar
=
ButterKnife
.
findById
(
this
,
R
.
id
.
toolbar
);
...
...
app/src/main/java/srct/whatsopen/ui/presenters/MainPresenter.java
View file @
76d0e27e
...
...
@@ -28,9 +28,11 @@ import srct.whatsopen.ui.activities.MainActivity;
public
class
MainPresenter
{
private
MainActivity
mMainView
;
private
SharedPreferences
pref
;
public
void
attachView
(
MainActivity
view
)
{
this
.
mMainView
=
view
;
pref
=
PreferenceManager
.
getDefaultSharedPreferences
(
mMainView
);
}
public
void
detachView
()
{
...
...
@@ -53,11 +55,13 @@ public class MainPresenter {
.
subscribe
(
new
Subscriber
<
List
<
Facility
>>()
{
@Override
public
void
onCompleted
()
{
mMainView
.
dismissProgressBar
();
if
(
mMainView
!=
null
)
mMainView
.
dismissProgressBar
();
}
@Override
public
void
onError
(
Throwable
e
)
{
mMainView
.
dismissProgressBar
();
if
(
mMainView
!=
null
)
mMainView
.
dismissProgressBar
();
// should probably show some error message
}
@Override
...
...
@@ -69,7 +73,6 @@ public class MainPresenter {
// Sets the favorite and open status of each Facility
private
List
<
Facility
>
setStatus
(
List
<
Facility
>
facilities
)
{
final
SharedPreferences
pref
=
PreferenceManager
.
getDefaultSharedPreferences
(
mMainView
);
for
(
Facility
facility
:
facilities
)
{
// Query SharedReferences for each Facility's favorite status. defaults to false
...
...
@@ -87,7 +90,6 @@ public class MainPresenter {
realm
.
close
();
}
// Uses the device time to determine which facilities should be open
public
boolean
getOpenStatus
(
Facility
facility
,
Calendar
now
)
{
RealmList
<
OpenTimes
>
openTimesList
=
facility
.
getMainSchedule
().
getOpenTimesList
();
...
...
app/src/main/res/layout/activity_main.xml
View file @
76d0e27e
...
...
@@ -38,6 +38,7 @@
<fr.castorflex.android.circularprogressbar.CircularProgressBar
android:id=
"@+id/progress_bar"
android:indeterminate=
"true"
android:visibility=
"gone"
android:layout_gravity=
"center"
app:cpb_color=
"@color/colorPrimary"
app:cpb_rotation_speed=
"1.0"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment