导航菜单

页面标题

页面副标题

SpeedCash v6.5.1482 - ChatActivity.java 源代码

正在查看: SpeedCash v6.5.1482 应用的 ChatActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.bm.sc.bebasbayar.ui.activity.mail;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.CallSuper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bm.sc.bebasbayar.R;
import com.bm.sc.bebasbayar.adapter.BaseAdapter;
import com.bm.sc.bebasbayar.adapter.entity.AttachmentEntity;
import com.bm.sc.bebasbayar.adapter.entity.ChatEntity;
import com.bm.sc.bebasbayar.adapter.list.ChatAdapter;
import com.bm.sc.bebasbayar.handler.FirebaseProcessor;
import com.bm.sc.bebasbayar.handler.MessageComposer;
import com.bm.sc.bebasbayar.handler.MessageSender;
import com.bm.sc.bebasbayar.helper.Affinity;
import com.bm.sc.bebasbayar.helper.MailHelper;
import com.bm.sc.bebasbayar.iface.AdapterInvoker;
import com.bm.sc.bebasbayar.iface.MessageProcess;
import com.bm.sc.bebasbayar.message.BaseMessage;
import com.bm.sc.bebasbayar.message.api.MailMessage;
import com.bm.sc.bebasbayar.service.BBMailSender;
import com.bm.sc.bebasbayar.setting.session.AppSession;
import com.bm.sc.bebasbayar.ui.BaseActivity;
import com.bm.sc.util.android.Imagery;
import com.bm.sc.util.format.DateTime;
import com.bm.sc.util.format.Locales;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Objects;

public class ChatActivity extends BaseActivity implements AdapterInvoker<ChatEntity> {
    public ChatAdapter c;
    public EditText d;
    public TextView e;
    public int f = 0;
    public int g = 0;
    public int h = 0;
    public int i = R.id.mail_inbox;
    public boolean j = false;
    public String k = "0";
    public String l = "SC_CS";
    public String m = "";
    public Uri n = null;
    public RecyclerView o;

    public class a implements MessageProcess {
        public final String a;

        public a(String str) {
            this.a = str;
        }

        @Override
        public void afterProcess(BaseMessage baseMessage) {
            String str;
            MailMessage mailMessage = new MailMessage(baseMessage);
            if (!mailMessage.isOK()) {
                ChatActivity.this.c.setLoadingState(false);
                return;
            }
            ChatEntity chatEntity = new ChatEntity(mailMessage.getData().get(0));
            if (chatEntity.getType() != ChatActivity.this.getResources().getInteger(R.integer.mail_to_member) || ChatActivity.this.i == 2131364768) {
                ChatActivity.this.findViewById(R.id.panel_input).setVisibility(8);
            } else {
                ChatActivity.this.findViewById(R.id.panel_input).setVisibility(0);
                ChatActivity.this.findViewById(R.id.btn_send).setOnClickListener(ChatActivity.this);
                ChatActivity.this.findViewById(R.id.btn_attach).setOnClickListener(ChatActivity.this);
            }
            ChatActivity.this.k = chatEntity.getId();
            ChatActivity.this.m = chatEntity.getSubject().replace("&amp;", "&").replace("&gt;", ">").replace("&lt;", "<");
            if (chatEntity.getFrom().equals(this.a)) {
                ChatActivity.this.l = chatEntity.getTo();
            } else {
                ChatActivity.this.l = chatEntity.getFrom();
            }
            TextView textView = (TextView) ChatActivity.this.findViewById(R.id.mail_client);
            if (ChatActivity.this.l.equals("SC_CS")) {
                str = "CS " + ChatActivity.this.getString(2132017323);
            } else {
                str = ChatActivity.this.l;
            }
            textView.setText(str);
            ((TextView) ChatActivity.this.findViewById(R.id.mail_subject)).setText(ChatActivity.this.m);
            ChatActivity.this.c.appendData(chatEntity, false);
            ChatActivity.this.y(false);
        }

        @Override
        public void backgroundProcess(long j, long j2, boolean z) {
        }

        @Override
        public void preProcess() {
            ChatActivity.this.c.setLoadingState(true);
        }
    }

    public class b implements MessageProcess {
        public b() {
        }

        @Override
        public void afterProcess(BaseMessage baseMessage) {
            MailMessage mailMessage = new MailMessage(baseMessage);
            if (mailMessage.isOK()) {
                Iterator<HashMap<String, Object>> it = mailMessage.getData().iterator();
                boolean z = false;
                while (it.hasNext()) {
                    ChatEntity chatEntity = new ChatEntity(it.next());
                    if (chatEntity.getAttachmentEntity() != null && !z) {
                        z = true;
                    }
                    ChatActivity.this.c.appendData(chatEntity, false);
                }
            }
            ChatActivity.this.c.setLoadingState(false);
            ChatActivity.this.o.scrollToPosition(ChatActivity.this.c.getItemCount() - 1);
        }

        @Override
        public void backgroundProcess(long j, long j2, boolean z) {
        }

        @Override
        public void preProcess() {
            if (ChatActivity.this.c.isLoading()) {
                return;
            }
            ChatActivity.this.c.setLoadingState(true);
        }
    }

    public static Bundle composeBundle(int i, int i2, int i3, int i4) {
        Bundle bundle = new Bundle();
        bundle.putInt("tag:ids", i);
        bundle.putInt("tag:id", i2);
        bundle.putInt("tag:root:id", i3);
        bundle.putInt("tag:tab", i4);
        return bundle;
    }

    @Override
    public String getClassSimpleName() {
        return FirebaseProcessor.TYPE_CHAT;
    }

    @Override
    public Activity getInvokerActivity() {
        return this;
    }

    @Override
    public int getLayoutResource() {
        return R.layout.activity_chat;
    }

    @Override
    public String getWikiNameSpace() {
        return null;
    }

    @Override
    public boolean isEligibleForFavorit() {
        return false;
    }

    @Override
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i2 != -1) {
            this.e.setVisibility(8);
            return;
        }
        if (i == 21241) {
            Uri data = intent.getData();
            this.n = data;
            String realPathFromURI = Imagery.getRealPathFromURI(this, data);
            if (realPathFromURI == null) {
                realPathFromURI = this.n.getPath();
            }
            Objects.requireNonNull(realPathFromURI);
            long length = new File(realPathFromURI).length();
            if (length > 0 && length <= 2000000) {
                this.e.setText(realPathFromURI.substring(realPathFromURI.lastIndexOf("/") + 1));
                this.e.setVisibility(0);
                return;
            }
            Affinity.info(this, false, "Maksimum ukuran file yang diperbolehkan adalah " + Locales.humanReadableByteCount(2000000L, true));
            this.n = null;
        }
    }

    @Override
    public void onBackPressed() {
        setResult(this.j ? -1 : 0);
        super.onBackPressed();
    }

    @Override
    @CallSuper
    public void onClick(View view) {
        String str;
        if (view.getId() != 2131362416) {
            if (view.getId() != 2131362276) {
                super.onClick(view);
                return;
            }
            Intent intent = new Intent();
            intent.setType("*/*");
            intent.setAction("android.intent.action.GET_CONTENT");
            startActivityForResult(Intent.createChooser(intent, "Pilih cara ambil file:"), 21241);
            return;
        }
        String obj = this.d.getText().toString();
        if (obj.isEmpty()) {
            Affinity.toast(this, getString(R.string.error_required_field, "Isi pesan"));
            return;
        }
        Uri uri = this.n;
        if (uri != null) {
            String realPathFromURI = Imagery.getRealPathFromURI(this, uri);
            if (realPathFromURI == null) {
                realPathFromURI = this.n.getPath();
            }
            this.n = null;
            str = realPathFromURI;
        } else {
            str = null;
        }
        int integer = getResources().getInteger(R.integer.mail_to_member);
        ChatEntity chatEntity = new ChatEntity("SPEEDCASH", integer);
        chatEntity.setCreated(DateTime.format(new Date(), "HH:mm"));
        chatEntity.setContent(obj);
        chatEntity.setIs_sent(false);
        chatEntity.setFrom(this.appSession.retrieve(AppSession.PROPERTY_MERCHANT_ID));
        chatEntity.setTo(this.l);
        if (str != null) {
            AttachmentEntity attachmentEntity = new AttachmentEntity("SPEEDCASH");
            attachmentEntity.setAttachment(1);
            attachmentEntity.setLocal_location(str);
            attachmentEntity.setName_attachment(str.substring(str.lastIndexOf("/") + 1));
            chatEntity.setAttachmentEntity(attachmentEntity);
        }
        this.c.appendData(chatEntity, true);
        int itemCount = this.c.getItemCount() - 1;
        this.o.scrollToPosition(itemCount);
        this.d.setText("");
        this.e.setText("");
        this.e.setVisibility(8);
        this.j = true;
        Intent intent2 = new Intent((Context) this, (Class<?>) BBMailSender.class);
        intent2.putExtras(BBMailSender.getSendBundle(this.appSession.retrieve(AppSession.PROPERTY_MERCHANT_ID), this.l, integer, this.k, this.m, obj, str, itemCount));
        startService(intent2);
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (bundle != null) {
            this.g = bundle.getInt("tag:ids", 0);
            this.f = bundle.getInt("tag:id", 0);
            this.h = bundle.getInt("tag:root:id", 0);
            this.i = bundle.getInt("tag:tab", R.id.mail_inbox);
            this.j = bundle.getBoolean("tag:dataset:changed", false);
        } else {
            Bundle extras = getIntent().getExtras();
            if (extras != null) {
                this.g = extras.getInt("tag:ids", 0);
                this.f = extras.getInt("tag:id", 0);
                this.h = extras.getInt("tag:root:id", 0);
                this.i = extras.getInt("tag:tab", R.id.mail_inbox);
                this.j = extras.getBoolean("tag:dataset:changed", false);
            }
        }
        this.c = new ChatAdapter(this);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, 1, false);
        linearLayoutManager.setStackFromEnd(true);
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.mail_recycler_container);
        this.o = recyclerView;
        recyclerView.setLayoutManager(linearLayoutManager);
        this.o.setAdapter(this.c);
        this.d = (EditText) findViewById(R.id.input_content);
        this.e = (TextView) findViewById(R.id.label_attach);
        y(true);
    }

    public void onSaveInstanceState(Bundle bundle) {
        bundle.putInt("tag:ids", this.g);
        bundle.putInt("tag:id", this.f);
        bundle.putInt("tag:root:id", this.h);
        bundle.putInt("tag:tab", this.i);
        super/*androidx.activity.ComponentActivity*/.onSaveInstanceState(bundle);
    }

    public final void y(boolean z) {
        String retrieve = this.appSession.retrieve(AppSession.PROPERTY_MERCHANT_ID);
        MailMessage mailMessage = new MailMessage(retrieve);
        MessageComposer messageComposer = new MessageComposer(2, mailMessage.getPath());
        messageComposer.setRequest_method(MessageComposer.GET);
        messageComposer.setData_type(2);
        messageComposer.setIs_credential(true);
        messageComposer.setShowProgressRegular(false);
        if (z) {
            mailMessage.setSort("created", true);
            StringBuilder sb = new StringBuilder();
            sb.append("is_from=1,id=");
            int i = this.h;
            if (i == 0) {
                i = this.f;
            }
            sb.append(i);
            mailMessage.setFilter(sb.toString());
            messageComposer.setMessageProcess(new a(retrieve));
        } else {
            mailMessage.setSort("id", true);
            StringBuilder sb2 = new StringBuilder();
            sb2.append("author=");
            sb2.append(retrieve);
            sb2.append(",rootId=");
            int i2 = this.h;
            if (i2 == 0) {
                i2 = this.f;
            }
            sb2.append(i2);
            mailMessage.setFilter(sb2.toString());
            messageComposer.setMessageProcess(new b());
        }
        MessageSender messageSender = new MessageSender(this, messageComposer);
        messageSender.setRequestMessage(mailMessage);
        messageSender.execute();
    }

    @Override
    public void adapterResult(BaseAdapter baseAdapter, ChatEntity chatEntity, int i) {
        if (chatEntity.getAttachmentEntity() != null) {
            AttachmentEntity attachmentEntity = chatEntity.getAttachmentEntity();
            if (!attachmentEntity.getId_attachment().equals("SPEEDCASH") || attachmentEntity.getLocal_location() == null) {
                MailHelper.download_attachment(this, chatEntity.getId(), attachmentEntity.getId_attachment(), false);
            } else {
                MailHelper.writeFileToStorage(this, new File(attachmentEntity.getLocal_location()));
            }
        }
    }
}