Skip to content

Commit

Permalink
[ASV-511] refactor: move session persistence implementation inside th…
Browse files Browse the repository at this point in the history
…e Aptoide analytics lib
  • Loading branch information
jdandrade committed Jun 6, 2018
1 parent d323360 commit 5431311
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/cm/aptoide/pt/ApplicationModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import cm.aptoide.analytics.implementation.FacebookEventLogger;
import cm.aptoide.analytics.implementation.FlurryEventLogger;
import cm.aptoide.analytics.implementation.HttpKnockEventLogger;
import cm.aptoide.analytics.implementation.SharedPreferencesSessionPersistence;
import cm.aptoide.pt.account.AccountAnalytics;
import cm.aptoide.pt.account.AccountServiceV3;
import cm.aptoide.pt.account.AccountSettingsBodyInterceptorV7;
Expand All @@ -59,7 +60,6 @@
import cm.aptoide.pt.analytics.analytics.RealmEventMapper;
import cm.aptoide.pt.analytics.analytics.RealmEventPersistence;
import cm.aptoide.pt.analytics.analytics.RetrofitAptoideBiService;
import cm.aptoide.pt.analytics.analytics.SharedPreferencesSessionPersistence;
import cm.aptoide.pt.app.AdsManager;
import cm.aptoide.pt.app.AppViewAnalytics;
import cm.aptoide.pt.app.ReviewsManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cm.aptoide.pt.analytics.analytics;
package cm.aptoide.analytics.implementation;

import android.content.SharedPreferences;
import cm.aptoide.analytics.implementation.SessionPersistence;
import cm.aptoide.pt.preferences.managed.ManagerPreferences;

public class SharedPreferencesSessionPersistence implements SessionPersistence {

Expand All @@ -13,10 +11,12 @@ public SharedPreferencesSessionPersistence(SharedPreferences sharedPreferences)
}

@Override public void saveSessionTimestamp(long timestamp) {
ManagerPreferences.saveSessionTimestamp(timestamp, sharedPreferences);
sharedPreferences.edit()
.putLong("session_timestamp", timestamp)
.apply();
}

@Override public long getTimestamp() {
return ManagerPreferences.getSessionTimestamp(sharedPreferences);
return sharedPreferences.getLong("session_timestamp", 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ public class ManagedKeys {
"notification_campaign_and_social";
public static final String NOT_LOGGED_IN_NUMBER_OF_INSTALL_CLICKS =
"not_logged_in_install_clicks";
public static final String SESSION_TIMESTAMP = "session_timestamp";
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,4 @@ public static boolean isDebug(SharedPreferences sharedPreferences) {
public static String getNotificationType(SharedPreferences sharedPreferences) {
return sharedPreferences.getString(ManagedKeys.NOTIFICATION_TYPE, "");
}

public static long getSessionTimestamp(SharedPreferences sharedPreferences) {
return sharedPreferences.getLong(ManagedKeys.SESSION_TIMESTAMP, 0);
}

public static void saveSessionTimestamp(long value, SharedPreferences sharedPreferences) {
sharedPreferences.edit()
.putLong(ManagedKeys.SESSION_TIMESTAMP, value)
.apply();
}
}

0 comments on commit 5431311

Please sign in to comment.