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 onStart(View view, OnFragmentIsReadyListener listener);
|
||||||
|
|
||||||
void onSemesterChange(int which);
|
void onSemesterChange(int which);
|
||||||
|
|
||||||
|
void onSemesterSwitchActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ public class GradesFragment extends BaseFragment implements GradesContract.View
|
|||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
if (item.getItemId() == R.id.action_filter) {
|
if (item.getItemId() == R.id.action_filter) {
|
||||||
|
presenter.onSemesterSwitchActive();
|
||||||
CharSequence[] items = new CharSequence[]{
|
CharSequence[] items = new CharSequence[]{
|
||||||
getResources().getString(R.string.semester_text, 1),
|
getResources().getString(R.string.semester_text, 1),
|
||||||
getResources().getString(R.string.semester_text, 2),
|
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.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
|
|
||||||
|
import org.threeten.bp.LocalDate;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -57,11 +59,15 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSemesterSwitchActive() {
|
||||||
|
cancelAsyncTasks();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSemesterChange(int which) {
|
public void onSemesterChange(int which) {
|
||||||
semesterName = which + 1;
|
semesterName = which + 1;
|
||||||
getView().setCurrentSemester(which);
|
getView().setCurrentSemester(which);
|
||||||
|
|
||||||
reloadGrades();
|
reloadGrades();
|
||||||
|
|
||||||
Answers.getInstance().logCustom(new CustomEvent("Semester change")
|
Answers.getInstance().logCustom(new CustomEvent("Semester change")
|
||||||
@ -123,7 +129,7 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
|||||||
}
|
}
|
||||||
getView().hideRefreshingBar();
|
getView().hideRefreshingBar();
|
||||||
|
|
||||||
FabricUtils.logRefresh("Grades", result, null);
|
FabricUtils.logRefresh("Grades", result, LocalDate.now().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -165,10 +171,7 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
|||||||
listener.onFragmentIsReady();
|
listener.onFragmentIsReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void cancelAsyncTasks() {
|
||||||
public void onDestroy() {
|
|
||||||
isFirstSight = false;
|
|
||||||
|
|
||||||
if (refreshTask != null) {
|
if (refreshTask != null) {
|
||||||
refreshTask.cancel(true);
|
refreshTask.cancel(true);
|
||||||
refreshTask = null;
|
refreshTask = null;
|
||||||
@ -177,6 +180,12 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
|||||||
loadingTask.cancel(true);
|
loadingTask.cancel(true);
|
||||||
loadingTask = null;
|
loadingTask = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
isFirstSight = false;
|
||||||
|
cancelAsyncTasks();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user