forked from github/wulkanowy-mirror
Add some fabric answers (#120)
This commit is contained in:
parent
34205e4a8b
commit
ffe8511e3f
@ -3,6 +3,7 @@ package io.github.wulkanowy;
|
||||
import android.app.Application;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.core.CrashlyticsCore;
|
||||
import com.jakewharton.threetenabp.AndroidThreeTen;
|
||||
|
||||
@ -61,9 +62,12 @@ public class WulkanowyApp extends Application {
|
||||
|
||||
private void initializeFabric() {
|
||||
Fabric.with(new Fabric.Builder(this)
|
||||
.kits(new Crashlytics.Builder()
|
||||
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
|
||||
.build())
|
||||
.kits(
|
||||
new Crashlytics.Builder()
|
||||
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
|
||||
.build(),
|
||||
new Answers()
|
||||
)
|
||||
.debuggable(BuildConfig.DEBUG)
|
||||
.build());
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.data.db.dao.entities.Grade;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Subject;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Symbol;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Week;
|
||||
|
||||
public interface DbContract {
|
||||
@ -20,6 +21,8 @@ public interface DbContract {
|
||||
|
||||
long getCurrentSymbolId();
|
||||
|
||||
Symbol getCurrentSymbol();
|
||||
|
||||
long getCurrentDiaryId();
|
||||
|
||||
long getSemesterId(int name);
|
||||
|
@ -12,6 +12,7 @@ import io.github.wulkanowy.data.db.dao.entities.Semester;
|
||||
import io.github.wulkanowy.data.db.dao.entities.SemesterDao;
|
||||
import io.github.wulkanowy.data.db.dao.entities.StudentDao;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Subject;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Symbol;
|
||||
import io.github.wulkanowy.data.db.dao.entities.SymbolDao;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Week;
|
||||
import io.github.wulkanowy.data.db.dao.entities.WeekDao;
|
||||
@ -57,10 +58,15 @@ public class DbRepository implements DbContract {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCurrentSymbolId() {
|
||||
public Symbol getCurrentSymbol() {
|
||||
return daoSession.getSymbolDao().queryBuilder().where(
|
||||
SymbolDao.Properties.UserId.eq(sharedPref.getCurrentUserId())
|
||||
).unique().getId();
|
||||
).unique();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCurrentSymbolId() {
|
||||
return getCurrentSymbol().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,6 +11,7 @@ import io.github.wulkanowy.api.login.BadCredentialsException;
|
||||
import io.github.wulkanowy.data.RepositoryContract;
|
||||
import io.github.wulkanowy.ui.base.BasePresenter;
|
||||
import io.github.wulkanowy.utils.AppConstant;
|
||||
import io.github.wulkanowy.utils.FabricUtils;
|
||||
|
||||
public class LoginPresenter extends BasePresenter<LoginContract.View>
|
||||
implements LoginContract.Presenter {
|
||||
@ -84,6 +85,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.View>
|
||||
@Override
|
||||
public void onEndAsync(boolean success, Exception exception) {
|
||||
if (success) {
|
||||
FabricUtils.logRegister(true, getRepository().getDbRepo().getCurrentSymbol().getSymbol());
|
||||
getView().openMainActivity();
|
||||
return;
|
||||
} else if (exception instanceof BadCredentialsException) {
|
||||
@ -93,6 +95,7 @@ public class LoginPresenter extends BasePresenter<LoginContract.View>
|
||||
getView().setErrorSymbolRequired();
|
||||
getView().showSoftInput();
|
||||
} else {
|
||||
FabricUtils.logRegister(false, symbol);
|
||||
getView().onError(getRepository().getResRepo().getErrorLoginMessage(exception));
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import io.github.wulkanowy.data.db.dao.entities.AttendanceLesson;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Day;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Week;
|
||||
import io.github.wulkanowy.ui.base.BasePresenter;
|
||||
import io.github.wulkanowy.utils.FabricUtils;
|
||||
import io.github.wulkanowy.utils.async.AbstractTask;
|
||||
import io.github.wulkanowy.utils.async.AsyncListeners;
|
||||
|
||||
@ -88,6 +89,8 @@ public class AttendanceTabPresenter extends BasePresenter<AttendanceTabContract.
|
||||
getView().onError(getRepository().getResRepo().getErrorLoginMessage(exception));
|
||||
}
|
||||
getView().hideRefreshingBar();
|
||||
|
||||
FabricUtils.logRefresh("Attendance", result, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import io.github.wulkanowy.data.db.dao.entities.Day;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Exam;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Week;
|
||||
import io.github.wulkanowy.ui.base.BasePresenter;
|
||||
import io.github.wulkanowy.utils.FabricUtils;
|
||||
import io.github.wulkanowy.utils.async.AbstractTask;
|
||||
import io.github.wulkanowy.utils.async.AsyncListeners;
|
||||
|
||||
@ -93,6 +94,8 @@ public class ExamsTabPresenter extends BasePresenter<ExamsTabContract.View>
|
||||
getView().onError(getRepository().getResRepo().getErrorLoginMessage(exception));
|
||||
}
|
||||
getView().hideRefreshingBar();
|
||||
|
||||
FabricUtils.logRefresh("Exams", result, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,8 @@
|
||||
package io.github.wulkanowy.ui.main.grades;
|
||||
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -10,6 +13,7 @@ import io.github.wulkanowy.data.db.dao.entities.Grade;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Subject;
|
||||
import io.github.wulkanowy.ui.base.BasePresenter;
|
||||
import io.github.wulkanowy.ui.main.OnFragmentIsReadyListener;
|
||||
import io.github.wulkanowy.utils.FabricUtils;
|
||||
import io.github.wulkanowy.utils.async.AbstractTask;
|
||||
import io.github.wulkanowy.utils.async.AsyncListeners;
|
||||
|
||||
@ -59,6 +63,9 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
||||
getView().setCurrentSemester(which);
|
||||
|
||||
reloadGrades();
|
||||
|
||||
Answers.getInstance().logCustom(new CustomEvent("Semester change")
|
||||
.putCustomAttribute("Name", semesterName));
|
||||
}
|
||||
|
||||
private void reloadGrades() {
|
||||
@ -100,8 +107,8 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEndRefreshAsync(boolean success, Exception exception) {
|
||||
if (success) {
|
||||
public void onEndRefreshAsync(boolean result, Exception exception) {
|
||||
if (result) {
|
||||
reloadGrades();
|
||||
|
||||
int numberOfNewGrades = getRepository().getDbRepo().getNewGrades(semesterName).size();
|
||||
@ -115,6 +122,8 @@ public class GradesPresenter extends BasePresenter<GradesContract.View>
|
||||
getView().onError(getRepository().getResRepo().getErrorLoginMessage(exception));
|
||||
}
|
||||
getView().hideRefreshingBar();
|
||||
|
||||
FabricUtils.logRefresh("Grades", result, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.github.wulkanowy.ui.main.timetable;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -11,6 +10,7 @@ import io.github.wulkanowy.data.db.dao.entities.Day;
|
||||
import io.github.wulkanowy.data.db.dao.entities.TimetableLesson;
|
||||
import io.github.wulkanowy.data.db.dao.entities.Week;
|
||||
import io.github.wulkanowy.ui.base.BasePresenter;
|
||||
import io.github.wulkanowy.utils.FabricUtils;
|
||||
import io.github.wulkanowy.utils.async.AbstractTask;
|
||||
import io.github.wulkanowy.utils.async.AsyncListeners;
|
||||
|
||||
@ -91,6 +91,8 @@ public class TimetableTabPresenter extends BasePresenter<TimetableTabContract.Vi
|
||||
getView().onError(getRepository().getResRepo().getErrorLoginMessage(exception));
|
||||
}
|
||||
getView().hideRefreshingBar();
|
||||
|
||||
FabricUtils.logRefresh("Timetable", result, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
27
app/src/main/java/io/github/wulkanowy/utils/FabricUtils.java
Normal file
27
app/src/main/java/io/github/wulkanowy/utils/FabricUtils.java
Normal file
@ -0,0 +1,27 @@
|
||||
package io.github.wulkanowy.utils;
|
||||
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.crashlytics.android.answers.SignUpEvent;
|
||||
|
||||
public final class FabricUtils {
|
||||
|
||||
private FabricUtils() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static void logRegister(boolean result, String symbol) {
|
||||
Answers.getInstance().logSignUp(new SignUpEvent()
|
||||
.putMethod("Login activity")
|
||||
.putSuccess(result)
|
||||
.putCustomAttribute("symbol", symbol));
|
||||
}
|
||||
|
||||
public static void logRefresh(String name, boolean result, String date) {
|
||||
Answers.getInstance().logCustom(
|
||||
new CustomEvent(name + " refresh")
|
||||
.putCustomAttribute("Success", result ? 1 : 0)
|
||||
.putCustomAttribute("Date", date)
|
||||
);
|
||||
}
|
||||
}
|
@ -47,7 +47,7 @@ ext {
|
||||
dagger2 = "2.16"
|
||||
ahbottom = "2.2.0"
|
||||
jsoup = "1.11.3"
|
||||
gson = "2.8.4"
|
||||
gson = "2.8.5"
|
||||
ossLicenses = "15.0.1"
|
||||
|
||||
debugDb = "1.0.3"
|
||||
@ -57,8 +57,8 @@ ext {
|
||||
mockito = "2.18.3"
|
||||
testRunner = "1.0.2"
|
||||
|
||||
fabricGradle = "1.25.3"
|
||||
crashlyticsSdk = "2.9.2"
|
||||
fabricGradle = "1.25.4"
|
||||
crashlyticsSdk = "2.9.3"
|
||||
crashlyticsAnswers = "1.4.1"
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user