正在查看: 自健身 v3.3.4 应用的 MessageActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 自健身 v3.3.4 应用的 MessageActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mu.gymtrain.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStoreOwner;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.android.material.tabs.TabLayout;
import com.mu.gymtrain.Adapter.MyMessageListAdapter;
import com.mu.gymtrain.Base.BaseActivityKT;
import com.mu.gymtrain.Bean.MyMessageData;
import com.mu.gymtrain.R;
import com.mu.gymtrain.Utils.FinalTools;
import com.mu.gymtrain.Utils.PreferenceUtils;
import com.mu.gymtrain.Utils.UrlConfig;
import com.mu.gymtrain.viewmodel.MessageViewModel;
import com.tencent.open.SocialConstants;
import java.util.List;
import java.util.Objects;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
@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\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u00012\u00020\u0002B\u0005¢\u0006\u0002\u0010\u0003J\b\u0010\f\u001a\u00020\tH\u0016J\b\u0010\r\u001a\u00020\u000eH\u0016J*\u0010\u000f\u001a\u00020\u000e2\u000e\u0010\u0010\u001a\n\u0012\u0002\b\u0003\u0012\u0002\b\u00030\u00112\b\u0010\u0012\u001a\u0004\u0018\u00010\u00132\u0006\u0010\u0014\u001a\u00020\tH\u0016J\u000e\u0010\u0015\u001a\u00020\u000e2\u0006\u0010\u0016\u001a\u00020\tR\u000e\u0010\u0004\u001a\u00020\u0005X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u0017"}, d2 = {"Lcom/mu/gymtrain/Activity/MessageActivity;", "Lcom/mu/gymtrain/Base/BaseActivityKT;", "Lcom/chad/library/adapter/base/BaseQuickAdapter$OnItemClickListener;", "()V", "listAdapter", "Lcom/mu/gymtrain/Adapter/MyMessageListAdapter;", "model", "Lcom/mu/gymtrain/viewmodel/MessageViewModel;", UrlConfig.Params.PAGE, "", FinalTools.USER_ID, "", "getLayoutRes", "init", "", "onItemClick", "adapter", "Lcom/chad/library/adapter/base/BaseQuickAdapter;", "view", "Landroid/view/View;", "position", "requestList", SocialConstants.PARAM_TYPE, "app_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public final class MessageActivity extends BaseActivityKT implements BaseQuickAdapter.OnItemClickListener {
private MyMessageListAdapter listAdapter;
private MessageViewModel model;
private String userId = "";
private int page = 1;
@Override
public void _$_clearFindViewByIdCache() {
}
@Override
public int getLayoutRes() {
return R.layout.activity_message_layout;
}
public static final void m48init$lambda0(MessageActivity this$0, View view) {
Intrinsics.checkNotNullParameter(this$0, "this$0");
this$0.finish();
}
@Override
public void init() {
((FrameLayout) findViewById(R.id.imgBack)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MessageActivity.m48init$lambda0(MessageActivity.this, view);
}
});
((TextView) findViewById(R.id.tvTitle)).setText("消息列表");
ViewModel viewModel = new ViewModelProvider((ViewModelStoreOwner) this).get(MessageViewModel.class);
Intrinsics.checkNotNullExpressionValue(viewModel, "ViewModelProvider(this)[MessageViewModel::class.java]");
this.model = (MessageViewModel) viewModel;
findViewById(R.id.recyclerView).setLayoutManager(new LinearLayoutManager((Context) this));
this.listAdapter = new MyMessageListAdapter();
RecyclerView findViewById = findViewById(R.id.recyclerView);
RecyclerView.Adapter adapter = this.listAdapter;
if (adapter == null) {
Intrinsics.throwUninitializedPropertyAccessException("listAdapter");
throw null;
}
findViewById.setAdapter(adapter);
String string = PreferenceUtils.getInstance().getString(FinalTools.USER_ID, "");
Intrinsics.checkNotNullExpressionValue(string, "getInstance().getString(FinalTools.USER_ID, \"\")");
this.userId = string;
MyMessageListAdapter myMessageListAdapter = this.listAdapter;
if (myMessageListAdapter == null) {
Intrinsics.throwUninitializedPropertyAccessException("listAdapter");
throw null;
}
myMessageListAdapter.setType(2);
requestList(2);
((TabLayout) findViewById(R.id.tabLayout)).addTab(((TabLayout) findViewById(R.id.tabLayout)).newTab().setText("点赞"));
((TabLayout) findViewById(R.id.tabLayout)).addTab(((TabLayout) findViewById(R.id.tabLayout)).newTab().setText("评论"));
((TabLayout) findViewById(R.id.tabLayout)).addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabSelected(TabLayout.Tab tab) {
MyMessageListAdapter myMessageListAdapter2;
MyMessageListAdapter myMessageListAdapter3;
if (Intrinsics.areEqual(tab == null ? null : tab.getText(), "点赞")) {
myMessageListAdapter3 = MessageActivity.this.listAdapter;
if (myMessageListAdapter3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("listAdapter");
throw null;
}
myMessageListAdapter3.setType(2);
MessageActivity.this.requestList(2);
return;
}
myMessageListAdapter2 = MessageActivity.this.listAdapter;
if (myMessageListAdapter2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("listAdapter");
throw null;
}
myMessageListAdapter2.setType(1);
MessageActivity.this.requestList(1);
}
});
MyMessageListAdapter myMessageListAdapter2 = this.listAdapter;
if (myMessageListAdapter2 != null) {
myMessageListAdapter2.setOnItemClickListener(this);
} else {
Intrinsics.throwUninitializedPropertyAccessException("listAdapter");
throw null;
}
}
public final void requestList(int type) {
MessageViewModel messageViewModel = this.model;
if (messageViewModel != null) {
messageViewModel.requestList(this.page, type, new Function1<List<MyMessageData>, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((List<MyMessageData>) obj);
return Unit.INSTANCE;
}
public final void invoke(List<MyMessageData> it) {
MyMessageListAdapter myMessageListAdapter;
Intrinsics.checkNotNullParameter(it, "it");
myMessageListAdapter = MessageActivity.this.listAdapter;
if (myMessageListAdapter != null) {
myMessageListAdapter.setNewData(it);
} else {
Intrinsics.throwUninitializedPropertyAccessException("listAdapter");
throw null;
}
}
});
} else {
Intrinsics.throwUninitializedPropertyAccessException("model");
throw null;
}
}
public void onItemClick(BaseQuickAdapter<?, ?> adapter, View view, int position) {
Intrinsics.checkNotNullParameter(adapter, "adapter");
Object item = adapter.getItem(position);
Objects.requireNonNull(item, "null cannot be cast to non-null type com.mu.gymtrain.Bean.MyMessageData");
MyMessageData myMessageData = (MyMessageData) item;
MessageViewModel messageViewModel = this.model;
if (messageViewModel == null) {
Intrinsics.throwUninitializedPropertyAccessException("model");
throw null;
}
int id = myMessageData.getId();
MyMessageListAdapter myMessageListAdapter = this.listAdapter;
if (myMessageListAdapter == null) {
Intrinsics.throwUninitializedPropertyAccessException("listAdapter");
throw null;
}
messageViewModel.readMessage(id, myMessageListAdapter.getType());
Intent intent = new Intent((Context) this, (Class<?>) ArticleDetailActivity2.class);
intent.putExtra("id", myMessageData.getArticleId());
intent.putExtra("commandId", myMessageData.getId());
startActivity(intent);
}
}