Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Commit a8dfd21

Browse files
committed
Minor fix
1 parent 3c826a6 commit a8dfd21

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryInfoFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public void onClick(View view) {
124124
@Override
125125
public void onResume() {
126126
super.onResume();
127+
presenter.start();
127128
// Reset map icon color
128129
map.setColorFilter(ContextCompat.getColor(getContext(), R.color.colorAccent));
129130
}

app/src/main/java/com/davidmiguel/gobees/apiary/ApiaryPresenter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.davidmiguel.gobees.data.source.repository.GoBeesRepository;
2929

3030
import java.util.Date;
31+
import java.util.concurrent.atomic.AtomicInteger;
3132

3233
/**
3334
* Listens to user actions from the UI ApiaryHivesFragment, retrieves the data and updates the
@@ -45,6 +46,7 @@ class ApiaryPresenter implements ApiaryContract.Presenter {
4546
private boolean firstLoad = true;
4647
private long apiaryId;
4748
private Apiary apiary;
49+
private AtomicInteger ready;
4850

4951
ApiaryPresenter(GoBeesRepository goBeesRepository,
5052
ApiaryContract.ApiaryHivesView apiaryHivesView,
@@ -55,6 +57,7 @@ class ApiaryPresenter implements ApiaryContract.Presenter {
5557
this.apiaryInfoView = apiaryInfoView;
5658
apiaryInfoView.setPresenter(this);
5759
this.apiaryId = apiaryId;
60+
this.ready = new AtomicInteger(0);
5861
}
5962

6063
@Override
@@ -166,7 +169,10 @@ public void onOpenMapClicked() {
166169

167170
@Override
168171
public void start() {
169-
loadData(false);
172+
int num = ready.incrementAndGet();
173+
if(num >= 2) {
174+
loadData(false);
175+
}
170176
}
171177

172178
/**

app/src/main/java/com/davidmiguel/gobees/hive/HiveInfoFragment.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
7373
return root;
7474
}
7575

76+
@Override
77+
public void onResume() {
78+
super.onResume();
79+
presenter.start();
80+
}
81+
7682
@Override
7783
public void setUserVisibleHint(boolean isVisibleToUser) {
7884
super.setUserVisibleHint(isVisibleToUser);

app/src/main/java/com/davidmiguel/gobees/hive/HivePresenter.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import com.davidmiguel.gobees.data.source.repository.GoBeesRepository;
2929
import com.davidmiguel.gobees.monitoring.MonitoringActivity;
3030

31+
import java.util.concurrent.atomic.AtomicInteger;
32+
3133
/**
3234
* Listens to user actions from the UI HiveRecordingsFragment, retrieves the data and updates the
3335
* UI as required.
@@ -37,6 +39,7 @@ class HivePresenter implements HiveContract.Presenter {
3739
private GoBeesRepository goBeesRepository;
3840
private HiveContract.HiveRecordingsView hiveRecordingsView;
3941
private HiveContract.HiveInfoView hiveInfoView;
42+
private AtomicInteger ready;
4043

4144
/**
4245
* Force update the first time.
@@ -56,6 +59,7 @@ class HivePresenter implements HiveContract.Presenter {
5659
this.hiveInfoView.setPresenter(this);
5760
this.apiaryId = apiaryId;
5861
this.hiveId = hiveId;
62+
this.ready = new AtomicInteger(0);
5963
}
6064

6165
@Override
@@ -181,6 +185,9 @@ public void onFailure() {
181185

182186
@Override
183187
public void start() {
184-
loadData(false);
188+
int num = ready.incrementAndGet();
189+
if(num >= 2) {
190+
loadData(false);
191+
}
185192
}
186193
}

0 commit comments

Comments
 (0)