Skip to content

Commit

Permalink
rework analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
irov committed Oct 3, 2023
1 parent 1571ceb commit 460c187
Show file tree
Hide file tree
Showing 36 changed files with 384 additions and 812 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.List;

public class MengineActivity extends SDLActivity {
public static final String TAG = "MengineActivity";
Expand Down Expand Up @@ -100,34 +101,34 @@ public String getApplicationId() {
return applicationId;
}

protected ArrayList<MenginePlugin> getPlugins() {
protected List<MenginePlugin> getPlugins() {
MengineApplication app = this.getMengineApplication();

ArrayList<MenginePlugin> plugins = app.getPlugins();
List<MenginePlugin> plugins = app.getPlugins();

return plugins;
}

protected ArrayList<MenginePluginKeyListener> getKeyListeners() {
protected List<MenginePluginKeyListener> getKeyListeners() {
MengineApplication app = this.getMengineApplication();

ArrayList<MenginePluginKeyListener> listeners = app.getKeyListeners();
List<MenginePluginKeyListener> listeners = app.getKeyListeners();

return listeners;
}

protected ArrayList<MenginePluginActivityListener> getActivityListeners() {
protected List<MenginePluginActivityListener> getActivityListeners() {
MengineApplication app = this.getMengineApplication();

ArrayList<MenginePluginActivityListener> listeners = app.getActivityListeners();
List<MenginePluginActivityListener> listeners = app.getActivityListeners();

return listeners;
}

protected ArrayList<MenginePluginEngineListener> getEngineListeners() {
protected List<MenginePluginEngineListener> getEngineListeners() {
MengineApplication app = this.getMengineApplication();

ArrayList<MenginePluginEngineListener> listeners = app.getEngineListeners();
List<MenginePluginEngineListener> listeners = app.getEngineListeners();

return listeners;
}
Expand Down Expand Up @@ -260,13 +261,13 @@ protected void onCreate(Bundle savedInstanceState) {

AndroidEnv_setMengineAndroidActivityJNI(this);

ArrayList<MenginePlugin> plugins = this.getPlugins();
List<MenginePlugin> plugins = this.getPlugins();

for (MenginePlugin p : plugins) {
p.setActivity(this);
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
String pluginName = l.getPluginName();
Expand Down Expand Up @@ -335,7 +336,7 @@ public void onMengineInitializeBaseServices() {

MengineLog.logInfo(TAG, "onMengineInitializeBaseServices");

ArrayList<MenginePluginEngineListener> listeners = this.getEngineListeners();
List<MenginePluginEngineListener> listeners = this.getEngineListeners();

for (MenginePluginEngineListener l : listeners) {
l.onMengineInitializeBaseServices(this);
Expand All @@ -345,13 +346,13 @@ public void onMengineInitializeBaseServices() {
public void onMengineCreateApplication() {
MengineLog.logInfo(TAG, "onMengineCreateApplication");

ArrayList<MenginePluginEngineListener> listeners = this.getEngineListeners();
List<MenginePluginEngineListener> listeners = this.getEngineListeners();

for (MenginePluginEngineListener l : listeners) {
l.onMengineCreateApplication(this);
}

ArrayList<MenginePlugin> plugins = this.getPlugins();
List<MenginePlugin> plugins = this.getPlugins();

for (MenginePlugin p : plugins) {
p.onExtensionRun(this);
Expand All @@ -361,7 +362,7 @@ public void onMengineCreateApplication() {
public void onMenginePlatformRun() {
MengineLog.logInfo(TAG, "onMenginePlatformRun");

ArrayList<MenginePluginEngineListener> listeners = this.getEngineListeners();
List<MenginePluginEngineListener> listeners = this.getEngineListeners();

for (MenginePluginEngineListener l : listeners) {
l.onMenginePlatformRun(this);
Expand All @@ -371,7 +372,7 @@ public void onMenginePlatformRun() {
public void onMenginePlatformStop() {
MengineLog.logInfo(TAG, "onMenginePlatformStop");

ArrayList<MenginePluginEngineListener> listeners = this.getEngineListeners();
List<MenginePluginEngineListener> listeners = this.getEngineListeners();

for (MenginePluginEngineListener l : listeners) {
l.onMenginePlatformStop(this);
Expand Down Expand Up @@ -405,7 +406,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
return;
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onActivityResult(this, requestCode, resultCode, data);
Expand All @@ -428,7 +429,7 @@ protected void onStart(){
return;
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onStart(this);
Expand All @@ -455,9 +456,9 @@ protected void onStop() {
return;
}

ArrayList<MenginePlugin> plugins = this.getPlugins();
List<MenginePlugin> plugins = this.getPlugins();

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onStop(this);
Expand All @@ -484,7 +485,7 @@ protected void onPause() {
return;
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onPause(this);
Expand All @@ -511,7 +512,7 @@ protected void onResume() {
return;
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onResume(this);
Expand All @@ -536,7 +537,7 @@ protected void onNewIntent(Intent intent) {
return;
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onNewIntent(this, intent);
Expand All @@ -559,13 +560,13 @@ protected void onDestroy() {

m_destroy = true;

ArrayList<MenginePlugin> plugins = this.getPlugins();
List<MenginePlugin> plugins = this.getPlugins();

for (MenginePlugin p : plugins) {
p.onExtensionFinalize(this);
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onDestroy(this);
Expand Down Expand Up @@ -597,7 +598,7 @@ protected void onRestart() {
return;
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onRestart(this);
Expand Down Expand Up @@ -626,7 +627,7 @@ public void onConfigurationChanged(Configuration newConfig) {
return;
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onConfigurationChanged(this, newConfig);
Expand All @@ -649,7 +650,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
return;
}

ArrayList<MenginePluginActivityListener> listeners = this.getActivityListeners();
List<MenginePluginActivityListener> listeners = this.getActivityListeners();

for (MenginePluginActivityListener l : listeners) {
l.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
Expand All @@ -670,7 +671,7 @@ public boolean dispatchKeyEvent(KeyEvent event) {
return super.dispatchKeyEvent(event);
}

ArrayList<MenginePluginKeyListener> listeners = this.getKeyListeners();
List<MenginePluginKeyListener> listeners = this.getKeyListeners();

for (MenginePluginKeyListener l : listeners) {
if (l.dispatchKeyEvent(this, event) == true) {
Expand Down Expand Up @@ -718,7 +719,7 @@ public void pythonInitializePlugins() {
MengineApplication application = (MengineApplication)this.getApplication();
AndroidNativePython_addPlugin("Application", application);

ArrayList<MenginePlugin> plugins = this.getPlugins();
List<MenginePlugin> plugins = this.getPlugins();

for (MenginePlugin p : plugins) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@
import java.util.Map;

public class MengineAnalytics {
public final static int EAET_CUSTOM = 0;
public final static int EAET_EARN_VIRTUAL_CURRENCY = 1;
public final static int EAET_SPEND_VIRTUAL_CURRENCY = 2;
public final static int EAET_UNLOCK_ACHIEVEMENT = 3;
public final static int EAET_LEVEL_UP = 4;
public final static int EAET_LEVEL_START = 5;
public final static int EAET_LEVEL_END = 6;
public final static int EAET_SELECT_ITEM = 7;
public final static int EAET_TUTORIAL_BEGIN = 8;
public final static int EAET_TUTORIAL_COMPLETE = 9;
public final static int EAET_SCREEN_VIEW = 10;

private static MengineApplication m_application;
private static Map<String, Object> m_context = new HashMap<>();
private static Map<String, Object> m_getter = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public long logAndFlush() {
public long log() {
long timestamp = MengineUtils.getTimestamp();

m_application.onMengineAnalyticsEvent(MengineAnalytics.EAET_CUSTOM, m_name, timestamp, m_bases, m_parameters);
m_application.onMengineAnalyticsEvent(m_name, timestamp, m_bases, m_parameters);

return timestamp;
}
Expand Down
Loading

0 comments on commit 460c187

Please sign in to comment.