android 登录 + 支付 + GA 通了

This commit is contained in:
LYP
2024-08-06 17:54:36 +08:00
parent 638d34a95d
commit 4e608afc37
4 changed files with 91 additions and 49 deletions

View File

@@ -7,12 +7,12 @@ import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
//import com.barton.log.GASDKFactory;
//import com.barton.log.builder.GAConfiguration;
//import com.barton.log.builder.ParamsBuilder;
//import com.barton.log.ebarton.BaseUrl;
//import com.barton.log.ebarton.EventType;
//import com.barton.log.logapi.IGASDK;
import com.barton.log.GASDKFactory;
import com.barton.log.builder.GAConfiguration;
import com.barton.log.builder.ParamsBuilder;
import com.barton.log.ebarton.BaseUrl;
import com.barton.log.ebarton.EventType;
import com.barton.log.logapi.IGASDK;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.tuyoo.gamesdk.api.SDKAPI;
@@ -36,7 +36,7 @@ import java.util.Map;
public class SDKManager {
private final static Handler handler = new Handler(Looper.getMainLooper());
// private static IGASDK gasdk;
private static IGASDK gasdk;
private static final String TAG = com.unity3d.player.SDKManager.class.getSimpleName();
private static String curType = TuYooClientID.tyGuest;
public static void InitSDK(Activity activity)
@@ -153,6 +153,18 @@ public class SDKManager {
});
}
public static void UnityLogin(String type) {
curType = type;
Log.e(TAG,"UnityLogin : " + type);
SDKLog.i("UnityLogin : " + type);
handler.post(new Runnable() {
@Override
public void run() {
SDKAPI.getIns().loginByType(type, mLogin);
}
});
}
public static void UnityLoginOut() {
// Log.e(TAG,"UnityLoginOut!!!");
SDKLog.i("UnityLoginOut : ");
@@ -247,55 +259,55 @@ public class SDKManager {
});
}
// private static IGASDK GetGameGa(){
// if(gasdk == null){
// GAConfiguration.Builder builder = new GAConfiguration.Builder()
// .withBaseUrl(BaseUrl.INTERNAL)
// .withContext(SDKWrapper.getInstance().getContext())
// .withClientId(ConfigManager.SDK_CLIENTID)
// .withGameId(ConfigManager.SDK_GAMEID)
// .withProjectId(ConfigManager.SDK_PROJECTID);
// gasdk = GASDKFactory.createGASDK(builder.build());
// }
// return gasdk;
// }
private static IGASDK GetGameGa(){
if(gasdk == null){
GAConfiguration.Builder builder = new GAConfiguration.Builder()
.withBaseUrl(BaseUrl.INTERNAL)
.withContext(SDKWrapper.getInstance().getContext())
.withClientId(ConfigManager.SDK_CLIENTID)
.withGameId(ConfigManager.SDK_GAMEID)
.withProjectId(ConfigManager.SDK_PROJECTID);
gasdk = GASDKFactory.createGASDK(builder.build());
}
return gasdk;
}
public static void SetGaUserInfo(String userId)
{
// Log.e(TAG,"SetGaUserInfo : " + userId);
// SDKLog.i("SetGaUserInfo : " + userId);
// GetGameGa().setUserId(userId);
Log.e(TAG,"SetGaUserInfo : " + userId);
SDKLog.i("SetGaUserInfo : " + userId);
GetGameGa().setUserId(userId);
}
public static void SetGaCommonInfo(String SetGaCommonInfo)
{
// Log.e(TAG,"SetGaCommonInfo : " + SetGaCommonInfo);
// SDKLog.i("SetGaCommonInfo : " + SetGaCommonInfo);
// Gson gson = new Gson();
// Map<String, Object> map = gson.fromJson(SetGaCommonInfo, new TypeToken<Map<String, Object>>(){}.getType());
// for (String key : map.keySet()) {
// System.out.println("Key = " + key + ", Value = " + map.get(key));
// if(!TextUtils.isEmpty(key) && map.get(key) != null){
// GetGameGa().addCommonParameter(key, map.get(key).toString());
// }
// }
Log.e(TAG,"SetGaCommonInfo : " + SetGaCommonInfo);
SDKLog.i("SetGaCommonInfo : " + SetGaCommonInfo);
Gson gson = new Gson();
Map<String, Object> map = gson.fromJson(SetGaCommonInfo, new TypeToken<Map<String, Object>>(){}.getType());
for (String key : map.keySet()) {
System.out.println("Key = " + key + ", Value = " + map.get(key));
if(!TextUtils.isEmpty(key) && map.get(key) != null){
GetGameGa().addCommonParameter(key, map.get(key).toString());
}
}
}
public static void GAReportParams(int type, String eventstr, String paramstr)
{
// Log.e(TAG,"GAReportParams : " + type + " \n" + eventstr + " \n" + paramstr);
//
// SDKLog.i("GAReportParams : " + type + " \n" + eventstr + " \n" + paramstr);
// ParamsBuilder paramsBuilder = ParamsBuilder.newInstance();
// Gson gson = new Gson();
// Map<String, Object> map = gson.fromJson(paramstr, new TypeToken<Map<String, Object>>(){}.getType());
// for (String key : map.keySet()) {
// System.out.println("Key = " + key + ", Value = " + map.get(key));
// if(!TextUtils.isEmpty(key) && map.get(key) != null){
// paramsBuilder.append(key, map.get(key).toString());
// }
// }
// GetGameGa().track(EventType.TRACK, eventstr, paramsBuilder);
Log.e(TAG,"GAReportParams : " + type + " \n" + eventstr + " \n" + paramstr);
SDKLog.i("GAReportParams : " + type + " \n" + eventstr + " \n" + paramstr);
ParamsBuilder paramsBuilder = ParamsBuilder.newInstance();
Gson gson = new Gson();
Map<String, Object> map = gson.fromJson(paramstr, new TypeToken<Map<String, Object>>(){}.getType());
for (String key : map.keySet()) {
System.out.println("Key = " + key + ", Value = " + map.get(key));
if(!TextUtils.isEmpty(key) && map.get(key) != null){
paramsBuilder.append(key, map.get(key).toString());
}
}
GetGameGa().track(EventType.TRACK, eventstr, paramsBuilder);
}
}