forked from github/wulkanowy-mirror
Stop refreshing while semester switching window open (#123)
This commit is contained in:
parent
ffe8511e3f
commit
2288ceffb8
@ -40,5 +40,7 @@ public interface GradesContract {
|
||||
void onStart(View view, OnFragmentIsReadyListener listener);
|
||||
|
||||
void onSemesterChange(int which);
|
||||
|
||||
void onSemesterSwitchActive();
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ public class GradesFragment extends BaseFragment implements GradesContract.View
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.action_filter) {
|
||||
presenter.onSemesterSwitchActive();
|
||||
CharSequence[] items = new CharSequence[]{
|
||||
getResources().getString(R.string.semester_text, 1),
|
||||
getResources().getString(R.string.semester_text, 2),
|
||||
|
@ -3,6 +3,8 @@ package io.github.wulkanowy.ui.main.grades;
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
|
||||
import org.threeten.bp.LocalDate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -57,11 +59,15 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSemesterSwitchActive() {
|
||||
cancelAsyncTasks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSemesterChange(int which) {
|
||||
semesterName = which + 1;
|
||||
getView().setCurrentSemester(which);
|
||||
|
||||
reloadGrades();
|
||||
|
||||
Answers.getInstance().logCustom(new CustomEvent("Semester change")
|
||||
@ -123,7 +129,7 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
||||
}
|
||||
getView().hideRefreshingBar();
|
||||
|
||||
FabricUtils.logRefresh("Grades", result, null);
|
||||
FabricUtils.logRefresh("Grades", result, LocalDate.now().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -165,10 +171,7 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
||||
listener.onFragmentIsReady();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
isFirstSight = false;
|
||||
|
||||
private void cancelAsyncTasks() {
|
||||
if (refreshTask != null) {
|
||||
refreshTask.cancel(true);
|
||||
refreshTask = null;
|
||||
@ -177,6 +180,12 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
||||
loadingTask.cancel(true);
|
||||
loadingTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
isFirstSight = false;
|
||||
cancelAsyncTasks();
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user