正在查看: Rilo v2.0.21 应用的 ApiLogsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 ApiLogsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package app.callpe.ui;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleOwnerKt;
import androidx.recyclerview.widget.RecyclerView;
import app.callpe.App;
import app.callpe.adapters.ApiLogsBriefAdapter;
import app.callpe.common.utils.Helper;
import app.callpe.common.utils.custom.CustomLinearLayoutManager;
import app.callpe.common.utils.extensions.ActivityExtKt;
import app.callpe.data.model.ApiLogEntryModel;
import app.callpe.databinding.ActivityApiLogsBinding;
import app.callpe.ui.bottomsheet.ApiLogsBottomSheet;
import app.callpe.ui.home.BaseActivity;
import com.google.gson.Gson;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Dispatchers;
import timber.log.Timber;
@Metadata(d1 = {"\u0000:\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0003J\u000e\u0010\u0006\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\tJ\u0010\u0010\n\u001a\u00020\u00022\u0006\u0010\u000b\u001a\u00020\fH\u0016J\b\u0010\r\u001a\u00020\u000eH\u0002J\b\u0010\u000f\u001a\u00020\u000eH\u0002J\u0012\u0010\u0010\u001a\u00020\u000e2\b\u0010\u0011\u001a\u0004\u0018\u00010\u0012H\u0014J\u0010\u0010\u0013\u001a\u00020\u000e2\u0006\u0010\u0014\u001a\u00020\tH\u0002J\b\u0010\u0015\u001a\u00020\u000eH\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082.¢\u0006\u0002\n\u0000¨\u0006\u0016"}, d2 = {"Lapp/callpe/ui/ApiLogsActivity;", "Lapp/callpe/ui/home/BaseActivity;", "Lapp/callpe/databinding/ActivityApiLogsBinding;", "()V", "adapter", "Lapp/callpe/adapters/ApiLogsBriefAdapter;", "generateCurlCommand", "", "logEntry", "Lapp/callpe/data/model/ApiLogEntryModel;", "inflateLayout", "layoutInflater", "Landroid/view/LayoutInflater;", "observeApiLogs", "", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "openRequestResponseBottomSheet", "logModel", "setUpAdapter", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class ApiLogsActivity extends BaseActivity<ActivityApiLogsBinding> {
private ApiLogsBriefAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setUpAdapter();
observeApiLogs();
onClicks();
}
private final void observeApiLogs() {
try {
if (App.Companion.getCurrentOpenActivity().length() > 0) {
BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), Dispatchers.getIO(), (CoroutineStart) null, new ApiLogsActivity$observeApiLogs$1(this, null), 2, (Object) null);
}
} catch (Exception e) {
ActivityExtKt.toast((Activity) this, "Error: " + e);
}
}
private final void onClicks() {
getBinding().clearLogs.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ApiLogsActivity.onClicks$lambda$0(ApiLogsActivity.this, view);
}
});
getBinding().backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ApiLogsActivity.onClicks$lambda$1(ApiLogsActivity.this, view);
}
});
}
public static final void onClicks$lambda$0(ApiLogsActivity apiLogsActivity, View view) {
Intrinsics.checkNotNullParameter(apiLogsActivity, "this$0");
try {
ApiLogsBriefAdapter apiLogsBriefAdapter = apiLogsActivity.adapter;
if (apiLogsBriefAdapter == null) {
Intrinsics.throwUninitializedPropertyAccessException("adapter");
apiLogsBriefAdapter = null;
}
apiLogsBriefAdapter.clear();
((ConcurrentHashMap) App.Companion.getLogsMap().getValue()).clear();
TextView textView = ((ActivityApiLogsBinding) apiLogsActivity.getBinding()).noLogsFound;
Intrinsics.checkNotNullExpressionValue(textView, "binding.noLogsFound");
textView.setVisibility(0);
} catch (Exception e) {
ActivityExtKt.toast((Activity) apiLogsActivity, "Error: " + e);
}
}
public static final void onClicks$lambda$1(ApiLogsActivity apiLogsActivity, View view) {
Intrinsics.checkNotNullParameter(apiLogsActivity, "this$0");
apiLogsActivity.finish();
}
private final void setUpAdapter() {
RecyclerView.LayoutManager customLinearLayoutManager = new CustomLinearLayoutManager((Context) this);
ApiLogsBriefAdapter apiLogsBriefAdapter = null;
this.adapter = new ApiLogsBriefAdapter(null, new ApiLogsBriefAdapter.ItemClickListener() {
@Override
public void onItemClick(ApiLogEntryModel logModel) {
Intrinsics.checkNotNullParameter(logModel, "logModel");
ApiLogsActivity.this.openRequestResponseBottomSheet(logModel);
}
@Override
public void onCopyCURLClick(ApiLogEntryModel logModel) {
Intrinsics.checkNotNullParameter(logModel, "logModel");
Helper.copyToClipboard((Context) ApiLogsActivity.this, ApiLogsActivity.this.generateCurlCommand(logModel));
}
}, 1, null);
((ActivityApiLogsBinding) getBinding()).logRv.setLayoutManager(customLinearLayoutManager);
RecyclerView recyclerView = ((ActivityApiLogsBinding) getBinding()).logRv;
ApiLogsBriefAdapter apiLogsBriefAdapter2 = this.adapter;
if (apiLogsBriefAdapter2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("adapter");
} else {
apiLogsBriefAdapter = apiLogsBriefAdapter2;
}
recyclerView.setAdapter(apiLogsBriefAdapter);
}
public final String generateCurlCommand(ApiLogEntryModel logEntry) {
Intrinsics.checkNotNullParameter(logEntry, "logEntry");
StringBuilder sb = new StringBuilder("curl -X " + logEntry.getMethod() + " \\\n");
for (Map.Entry<String, String> entry : logEntry.getHeaders().entrySet()) {
sb.append("-H \"" + entry.getKey() + ": " + entry.getValue() + "\" \\\n");
}
String requestBody = logEntry.getRequestBody();
if (requestBody != null) {
sb.append("--data '" + requestBody + "' \\\n");
}
sb.append('\"' + logEntry.getUrl() + '\"');
String sb2 = sb.toString();
Intrinsics.checkNotNullExpressionValue(sb2, "curlCmd.toString()");
return sb2;
}
public final void openRequestResponseBottomSheet(ApiLogEntryModel logModel) {
try {
String json = new Gson().toJson(logModel);
ApiLogsBottomSheet.Companion companion = ApiLogsBottomSheet.INSTANCE;
Intrinsics.checkNotNullExpressionValue(json, "logModelJson");
ApiLogsBottomSheet newInstance = companion.newInstance(json);
if (!newInstance.isAdded() && !newInstance.isVisible()) {
newInstance.show(getSupportFragmentManager(), "RequestResponseBottomSheet");
}
} catch (Exception e) {
Timber.e(e);
}
}
@Override
public ActivityApiLogsBinding inflateLayout(LayoutInflater layoutInflater) {
Intrinsics.checkNotNullParameter(layoutInflater, "layoutInflater");
ActivityApiLogsBinding inflate = ActivityApiLogsBinding.inflate(layoutInflater);
Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
return inflate;
}
}