正在查看: Biko v2.0.23 应用的 TicketsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Biko v2.0.23 应用的 TicketsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package app.callpe.ui.user;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import androidx.activity.ComponentActivity;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleOwnerKt;
import androidx.lifecycle.ViewModelLazy;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import app.callpe.adapters.MyTicketsAdapter;
import app.callpe.common.utils.custom.CustomLinearLayoutManager;
import app.callpe.common.utils.helper_functions.DialogHelper;
import app.callpe.common.utils.listeners.PaginationListener;
import app.callpe.data.model.MyRaisedTickets;
import app.callpe.databinding.ActivityTicketsBinding;
import app.callpe.ui.SplashActivity;
import app.callpe.ui.bottomsheet.TicketDetailsBottomSheet;
import app.callpe.ui.home.BaseActivity;
import app.callpe.ui.user.games.TicketsViewModel;
import dagger.hilt.android.AndroidEntryPoint;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Job;
import timber.log.Timber;
@Metadata(d1 = {"\u0000h\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\b\b\u0007\u0018\u0000 12\b\u0012\u0004\u0012\u00020\u00020\u0001:\u00011B\u0005¢\u0006\u0002\u0010\u0003J\b\u0010\u0012\u001a\u00020\u0013H\u0002J\u0010\u0010\u0014\u001a\u00020\u00022\u0006\u0010\u0015\u001a\u00020\u0016H\u0016J\b\u0010\u0017\u001a\u00020\u0013H\u0002J\b\u0010\u0018\u001a\u00020\u0019H\u0002J\b\u0010\u001a\u001a\u00020\u0013H\u0016J\b\u0010\u001b\u001a\u00020\u0013H\u0003J\u0012\u0010\u001c\u001a\u00020\u00132\b\u0010\u001d\u001a\u0004\u0018\u00010\u001eH\u0014J\b\u0010\u001f\u001a\u00020\u0013H\u0014J\u0012\u0010 \u001a\u00020\u00132\b\u0010!\u001a\u0004\u0018\u00010\"H\u0015J\u0010\u0010#\u001a\u00020\t2\u0006\u0010$\u001a\u00020%H\u0016J\b\u0010&\u001a\u00020\u0013H\u0014J\b\u0010'\u001a\u00020\u0013H\u0014J\b\u0010(\u001a\u00020\u0013H\u0014J\u0010\u0010)\u001a\u00020\u00132\u0006\u0010$\u001a\u00020*H\u0002J\b\u0010+\u001a\u00020\u0013H\u0002J\b\u0010,\u001a\u00020\u0013H\u0002J\b\u0010-\u001a\u00020\u0013H\u0002J\b\u0010.\u001a\u00020\u0013H\u0002J\b\u0010/\u001a\u00020\u0013H\u0002J\b\u00100\u001a\u00020\u0013H\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082.¢\u0006\u0002\n\u0000R\u001b\u0010\f\u001a\u00020\r8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0010\u0010\u0011\u001a\u0004\b\u000e\u0010\u000f¨\u00062"}, d2 = {"Lapp/callpe/ui/user/TicketsActivity;", "Lapp/callpe/ui/home/BaseActivity;", "Lapp/callpe/databinding/ActivityTicketsBinding;", "()V", "adapter", "Lapp/callpe/adapters/MyTicketsAdapter;", "broadcastReceiver", "Landroid/content/BroadcastReceiver;", "resume", "", "toolbar", "Landroidx/appcompat/widget/Toolbar;", "viewModel", "Lapp/callpe/ui/user/games/TicketsViewModel;", "getViewModel", "()Lapp/callpe/ui/user/games/TicketsViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "getTicketInfo", "", "inflateLayout", "layoutInflater", "Landroid/view/LayoutInflater;", "initViews", "observeEvent", "Lkotlinx/coroutines/Job;", "onBackPressed", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onNewIntent", "intent", "Landroid/content/Intent;", "onOptionsItemSelected", "item", "Landroid/view/MenuItem;", "onResume", "onStart", "onStop", "openTicketDetailsSheet", "Lapp/callpe/data/model/MyRaisedTickets;", "refresh", "registerReceiver", "setUpToolbar", "setupRv", "swipeRefresh", "unRegisterReceiver", "Companion", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class TicketsActivity extends BaseActivity<ActivityTicketsBinding> {
public static final Companion INSTANCE = new Companion(null);
public static final String TICKET_RESOLVED = "TICKET_RESOLVED";
private static boolean refresh;
private MyTicketsAdapter adapter;
private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
TicketsViewModel viewModel;
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(intent, "intent");
Timber.e("Action %s", new Object[]{intent.getAction()});
String action = intent.getAction();
if (action != null && action.hashCode() == -83645493 && action.equals(TicketsActivity.TICKET_RESOLVED)) {
long longExtra = intent.getLongExtra("tickedId", -1L);
if (longExtra != -1) {
viewModel = TicketsActivity.this.getViewModel();
viewModel.setNotificationTickerId(longExtra);
TicketsActivity.this.refresh();
}
}
}
};
private boolean resume;
private Toolbar toolbar;
private final Lazy viewModel;
public TicketsActivity() {
final ComponentActivity componentActivity = (ComponentActivity) this;
final Function0 function0 = null;
this.viewModel = new ViewModelLazy(Reflection.getOrCreateKotlinClass(TicketsViewModel.class), new Function0<ViewModelStore>() {
{
super(0);
}
public final ViewModelStore m2300invoke() {
return componentActivity.getViewModelStore();
}
}, new Function0<ViewModelProvider.Factory>() {
{
super(0);
}
public final ViewModelProvider.Factory m2299invoke() {
return componentActivity.getDefaultViewModelProviderFactory();
}
}, new Function0<CreationExtras>() {
{
super(0);
}
public final CreationExtras m2301invoke() {
CreationExtras creationExtras;
Function0 function02 = function0;
return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? componentActivity.getDefaultViewModelCreationExtras() : creationExtras;
}
});
}
@Override
public ActivityTicketsBinding inflateLayout(LayoutInflater layoutInflater) {
Intrinsics.checkNotNullParameter(layoutInflater, "layoutInflater");
ActivityTicketsBinding inflate = ActivityTicketsBinding.inflate(layoutInflater);
Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
return inflate;
}
public final TicketsViewModel getViewModel() {
return (TicketsViewModel) this.viewModel.getValue();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setStatusBarColor(ContextCompat.getColor((Context) this, 2131100053));
initViews();
setUpToolbar();
onClicks();
swipeRefresh();
observeEvent();
setupRv();
getTicketInfo();
}
private final void setupRv() {
final RecyclerView.LayoutManager customLinearLayoutManager = new CustomLinearLayoutManager((Context) this);
((ActivityTicketsBinding) getBinding()).myTicketsRv.setLayoutManager(customLinearLayoutManager);
this.adapter = new MyTicketsAdapter(null, new MyTicketsAdapter.ItemClickListener() {
@Override
public void onItemClick(MyRaisedTickets item) {
Intrinsics.checkNotNullParameter(item, "item");
TicketsActivity.this.openTicketDetailsSheet(item);
}
@Override
public void onDeleteButtonClick(final long ticketId) {
Context context = (Context) TicketsActivity.this;
final TicketsActivity ticketsActivity = TicketsActivity.this;
DialogHelper.showReasonDialog(context, "", "Are you sure you want to delete this reported problem?", true, new DialogHelper.Listener() {
@Override
public void onNegativeClick() {
}
@Override
public void onPositiveClick() {
TicketsViewModel viewModel;
viewModel = TicketsActivity.this.getViewModel();
viewModel.deleteTicket(ticketId);
}
});
}
}, 1, null);
((ActivityTicketsBinding) getBinding()).myTicketsRv.setAdapter(this.adapter);
((ActivityTicketsBinding) getBinding()).myTicketsRv.addOnScrollListener(new PaginationListener(customLinearLayoutManager, this) {
final TicketsActivity this$0;
@Override
public void isScrolled(int dx, int dy) {
}
{
super(customLinearLayoutManager, 50);
this.this$0 = this;
}
@Override
protected void loadMoreItems() {
TicketsViewModel viewModel;
TicketsViewModel viewModel2;
viewModel = this.this$0.getViewModel();
viewModel.setLoading(true);
viewModel2 = this.this$0.getViewModel();
viewModel2.getMyRaisedTickets();
}
@Override
public boolean isLastPage() {
TicketsViewModel viewModel;
viewModel = this.this$0.getViewModel();
return viewModel.getIsLastPage();
}
@Override
public boolean isLoading() {
TicketsViewModel viewModel;
viewModel = this.this$0.getViewModel();
return viewModel.getIsLoading();
}
});
}
public final void openTicketDetailsSheet(MyRaisedTickets item) {
TicketDetailsBottomSheet.Companion companion = TicketDetailsBottomSheet.INSTANCE;
long id = item.getId();
String topic = item.getTopic();
String description = item.getDescription();
String media = item.getMedia();
String resolution = item.getResolution();
if (resolution == null) {
resolution = "";
}
TicketDetailsBottomSheet newInstance = companion.newInstance(id, topic, description, media, resolution, item.getClosed(), item.getCreatedAt());
newInstance.show(getSupportFragmentManager(), newInstance.getTag());
}
private final Job observeEvent() {
return BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new TicketsActivity$observeEvent$1(this, null), 3, (Object) null);
}
private final void onClicks() {
getBinding().createTicket.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
TicketsActivity.onClicks$lambda$1(TicketsActivity.this, view);
}
});
}
public static final void onClicks$lambda$1(TicketsActivity ticketsActivity, View view) {
Intrinsics.checkNotNullParameter(ticketsActivity, "this$0");
ticketsActivity.startActivity(new Intent((Context) ticketsActivity, (Class<?>) CreateNewTicketActivity.class));
}
private final void swipeRefresh() {
getBinding().swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
public final void onRefresh() {
TicketsActivity.swipeRefresh$lambda$2(TicketsActivity.this);
}
});
}
public static final void swipeRefresh$lambda$2(TicketsActivity ticketsActivity) {
Intrinsics.checkNotNullParameter(ticketsActivity, "this$0");
ticketsActivity.refresh();
ticketsActivity.getBinding().swipeRefresh.setRefreshing(false);
}
public final void refresh() {
getViewModel().setLastPage(false);
getViewModel().setLoading(false);
getViewModel().setPage(0);
getViewModel().getTicketList().clear();
MyTicketsAdapter myTicketsAdapter = this.adapter;
if (myTicketsAdapter != null) {
myTicketsAdapter.clear();
}
getViewModel().getMyRaisedTickets();
}
private final void setUpToolbar() {
try {
Toolbar toolbar = this.toolbar;
if (toolbar == null) {
Intrinsics.throwUninitializedPropertyAccessException("toolbar");
toolbar = null;
}
setSupportActionBar(toolbar);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
} catch (Exception e) {
Timber.e(e, "setUpToolbar: Error ", new Object[0]);
}
}
private final void initViews() {
Toolbar toolbar = getBinding().toolbar;
Intrinsics.checkNotNullExpressionValue(toolbar, "binding.toolbar");
this.toolbar = toolbar;
}
protected void onResume() {
super.onResume();
if (!this.resume || refresh) {
refresh();
refresh = false;
}
this.resume = true;
}
protected void onStop() {
super.onStop();
try {
unRegisterReceiver();
} catch (Exception e) {
Timber.e(e);
}
}
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
getTicketInfo();
}
private final void getTicketInfo() {
getViewModel().setNotificationTickerId(getIntent().getLongExtra("ticketId", -1L));
}
public boolean onOptionsItemSelected(MenuItem item) {
Intrinsics.checkNotNullParameter(item, "item");
if (item.getItemId() != 16908332) {
return true;
}
onBackPressed();
return true;
}
public void onBackPressed() {
if (isTaskRoot()) {
Intent intent = new Intent((Context) this, (Class<?>) SplashActivity.class);
intent.addFlags(67108864);
startActivity(intent);
finish();
return;
}
super.onBackPressed();
}
protected void onDestroy() {
super.onDestroy();
refresh = false;
}
@Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0005\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u001a\u0010\u0005\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0007\u0010\b\"\u0004\b\t\u0010\n¨\u0006\u000b"}, d2 = {"Lapp/callpe/ui/user/TicketsActivity$Companion;", "", "()V", TicketsActivity.TICKET_RESOLVED, "", "refresh", "", "getRefresh", "()Z", "setRefresh", "(Z)V", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final boolean getRefresh() {
return TicketsActivity.refresh;
}
public final void setRefresh(boolean z) {
TicketsActivity.refresh = z;
}
}
@Override
protected void onStart() {
super.onStart();
registerReceiver();
}
private final void registerReceiver() {
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance((Context) this);
Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(this)");
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(TICKET_RESOLVED);
localBroadcastManager.registerReceiver(this.broadcastReceiver, intentFilter);
}
private final void unRegisterReceiver() {
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance((Context) this);
Intrinsics.checkNotNullExpressionValue(localBroadcastManager, "getInstance(this)");
localBroadcastManager.unregisterReceiver(this.broadcastReceiver);
}
}