package com.forum;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.FirstActivity;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.Feature;
import com.common.pictureselector.FullyGridLayoutManager;
import com.common.pictureselector.GlideEngine;
import com.common.pictureselector.adapter.GridImageAdapter;
import com.example.linechartlibrary.SharedPreferencesKey;
import com.forum.bean.UploadUrlBean;
import com.forum.login.LogInActivity;
import com.home.base.LedBleActivity;
import com.home.constant.Constant;
import com.home.http.ResponseBean;
import com.home.utils.ImageUtils;
import com.home.utils.Utils;
import com.home.widget.effects.Effectstype;
import com.home.widget.effects.NiftyDialogBuilder;
import com.ledlamp.R;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.broadcast.BroadcastAction;
import com.luck.picture.lib.broadcast.BroadcastManager;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.permissions.PermissionChecker;
import com.luck.picture.lib.style.PictureCropParameterStyle;
import com.luck.picture.lib.style.PictureParameterStyle;
import com.luck.picture.lib.tools.PictureFileUtils;
import com.luck.picture.lib.tools.SdkVersionUtils;
import com.luck.picture.lib.tools.ToastUtils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONException;
import org.json.JSONObject;

/* loaded from: classes.dex */
public class ReleseCharacterActivity extends LedBleActivity implements View.OnClickListener {
    private static final String READ_EXTERNAL_STORAGE = "READ_EXTERNAL_STORAGE_ReleseCharacterActivity";
    private static final String TAG = "ReleseCharacterActivity";
    private GridImageAdapter adapter;
    Button btn_Publish1;
    TextView clear1;
    EditText et_Content;
    EditText et_Title;
    private StringBuilder fileIdList;
    private Handler handler;
    ImageView iv_Back;
    private int language;
    private PictureCropParameterStyle mCropParameterStyle;
    private PictureParameterStyle mPictureParameterStyle;
    private String parameters;
    private Map<String, String> params;
    private RecyclerView recyclerView;
    private String replyId;
    private String replyType;
    private Effectstype requestExternalStorageEffect;
    private SharedPreferences requestExternalStorageSP;
    private Runnable runnable;
    private String target;
    private int themeId;
    TextView tv_Title;
    private String url;
    private Map<String, File> files = new HashMap();
    private List<File> fileList = new ArrayList();
    private int index = 0;
    private int maxSelectNum = 9;
    private List<LocalMedia> selectList = new ArrayList();
    private List<String> imageNameList = new ArrayList();
    private int chooseMode = PictureMimeType.ofImage();
    private GridImageAdapter.onAddPicClickListener onAddPicClickListener = new GridImageAdapter.onAddPicClickListener() { // from class: com.forum.ReleseCharacterActivity.8
        @Override // com.common.pictureselector.adapter.GridImageAdapter.onAddPicClickListener
        public void onAddPicClick() {
            PictureSelector.create(ReleseCharacterActivity.this).openGallery(ReleseCharacterActivity.this.chooseMode).loadImageEngine(GlideEngine.createGlideEngine()).theme(ReleseCharacterActivity.this.themeId).setPictureStyle(ReleseCharacterActivity.this.mPictureParameterStyle).setPictureCropStyle(ReleseCharacterActivity.this.mCropParameterStyle).maxSelectNum(ReleseCharacterActivity.this.maxSelectNum).minSelectNum(1).imageSpanCount(4).cameraFileName("").selectionMode(2).isSingleDirectReturn(false).previewImage(true).previewVideo(true).enablePreviewAudio(true).isCamera(true).isZoomAnim(true).enableCrop(false).compress(false).compressQuality(0).synOrAsy(true).isGif(false).openClickSound(false).selectionMedia(ReleseCharacterActivity.this.selectList).cutOutQuality(90).minimumCompressSize(1).forResult(PictureConfig.CHOOSE_REQUEST);
        }
    };
    private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { // from class: com.forum.ReleseCharacterActivity.9
        @Override // android.content.BroadcastReceiver
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            action.hashCode();
            if (action.equals(BroadcastAction.ACTION_DELETE_PREVIEW_POSITION)) {
                int i = intent.getExtras().getInt("position");
                ToastUtils.s(context, "delete image index:" + i);
                if (i < ReleseCharacterActivity.this.adapter.getItemCount()) {
                    ReleseCharacterActivity.this.selectList.remove(i);
                    ReleseCharacterActivity.this.imageNameList.remove(i);
                    ReleseCharacterActivity.this.adapter.notifyItemRemoved(i);
                }
            }
        }
    };

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // com.home.base.LedBleActivity, me.imid.swipebacklayout.lib.app.SwipeBackActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_relese_character);
        Window window = getWindow();
        window.addFlags(Integer.MIN_VALUE);
        window.setStatusBarColor(getResources().getColor(R.color.blue));
        init();
    }

    public void init() {
        this.et_Content = (EditText) findViewById(R.id.et_Content);
        this.et_Title = (EditText) findViewById(R.id.et_Title);
        this.btn_Publish1 = (Button) findViewById(R.id.btn_Publish1);
        this.iv_Back = (ImageView) findViewById(R.id.iv_Back);
        this.tv_Title = (TextView) findViewById(R.id.tv_Title);
        TextView textView = (TextView) findViewById(R.id.clear1);
        this.clear1 = textView;
        textView.setOnClickListener(this);
        this.btn_Publish1.setOnClickListener(this);
        this.iv_Back.setOnClickListener(this);
        this.params = new HashMap();
        getDefaultStyle();
        this.themeId = 2131821091;
        this.recyclerView = (RecyclerView) findViewById(R.id.recycler);
        this.recyclerView.setLayoutManager(new FullyGridLayoutManager(this, 4, 1, false));
        GridImageAdapter gridImageAdapter = new GridImageAdapter(this, this.onAddPicClickListener);
        this.adapter = gridImageAdapter;
        gridImageAdapter.setList(this.selectList);
        this.adapter.setSelectMax(this.maxSelectNum);
        this.recyclerView.setAdapter(this.adapter);
        this.adapter.setOnItemClickListener(new GridImageAdapter.OnItemClickListener() { // from class: com.forum.ReleseCharacterActivity$$ExternalSyntheticLambda0
            @Override // com.common.pictureselector.adapter.GridImageAdapter.OnItemClickListener
            public final void onItemClick(int i, View view) {
                ReleseCharacterActivity.this.lambda$init$0(i, view);
            }
        });
        BroadcastManager.getInstance(this).registerReceiver(this.broadcastReceiver, BroadcastAction.ACTION_DELETE_PREVIEW_POSITION);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            this.replyId = extras.getString("replyId");
            this.replyType = extras.getString("replyType");
            this.target = extras.getString("target");
            this.parameters = extras.getString("ReplyActivity");
            if (!TextUtils.isEmpty(this.replyId)) {
                this.et_Title.setVisibility(8);
            }
            if (this.replyType.equals("reply")) {
                this.recyclerView.setVisibility(8);
                this.tv_Title.setText(R.string.reply);
            } else {
                this.recyclerView.setVisibility(8);
                this.tv_Title.setText(R.string.comment);
            }
        }
        requestExternalStoragePermission();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public /* synthetic */ void lambda$init$0(int i, View view) {
        if (this.selectList.size() > 0) {
            LocalMedia localMedia = this.selectList.get(i);
            int mimeType = PictureMimeType.getMimeType(localMedia.getMimeType());
            if (mimeType == 2) {
                if (SdkVersionUtils.checkedAndroid_Q()) {
                    PictureSelector.create(this).externalPictureVideo(localMedia.getAndroidQToPath());
                    return;
                } else {
                    PictureSelector.create(this).externalPictureVideo(localMedia.getPath());
                    return;
                }
            }
            if (mimeType == 3) {
                if (SdkVersionUtils.checkedAndroid_Q()) {
                    PictureSelector.create(this).externalPictureAudio(localMedia.getAndroidQToPath());
                    return;
                } else {
                    PictureSelector.create(this).externalPictureAudio(localMedia.getPath());
                    return;
                }
            }
            PictureSelector.create(this).setPictureStyle(this.mPictureParameterStyle).isNotPreviewDownload(true).loadImageEngine(GlideEngine.createGlideEngine()).openExternalPreview(i, this.selectList);
        }
    }

    @Override // android.view.View.OnClickListener
    public void onClick(View view) {
        int id = view.getId();
        if (id != R.id.btn_Publish1) {
            if (id != R.id.clear1) {
                if (id != R.id.iv_Back) {
                    return;
                }
                finish();
                return;
            } else {
                this.et_Title.setText("");
                this.et_Content.setText("");
                this.fileList.clear();
                this.params.clear();
                return;
            }
        }
        if (LedBleActivity.getBaseApp().getUserToken().equals("")) {
            startActivity(new Intent(getApplicationContext(), (Class<?>) LogInActivity.class));
            return;
        }
        if (!TextUtils.isEmpty(this.replyId)) {
            replyContent();
            return;
        }
        Log.e(TAG, "btn_Publish1......");
        if (this.et_Title.getText().toString() == null || this.et_Title.getText().toString().equalsIgnoreCase("")) {
            Toast.makeText(getApplicationContext(), R.string.tiele, 0).show();
            return;
        }
        if (this.et_Content.getText().toString() == null || this.et_Content.getText().toString().equalsIgnoreCase("")) {
            Toast.makeText(getApplicationContext(), R.string.text, 0).show();
            return;
        }
        showDialog();
        publishContent1();
        this.btn_Publish1.setEnabled(false);
    }

    private void requestExternalStoragePermission() {
        if (this.requestExternalStorageEffect == null) {
            final NiftyDialogBuilder niftyDialogBuilder = new NiftyDialogBuilder(this, R.style.dialog_user_agreement_and_privacy_policy);
            this.requestExternalStorageEffect = Effectstype.SlideBottom;
            niftyDialogBuilder.setCancelable(false);
            niftyDialogBuilder.withTitle(getResources().getString(R.string.access_request)).withTitleColor("#000000").withDividerColor("#11000000").isCancelableOnTouchOutside(false).withDuration(200).withEffect(this.requestExternalStorageEffect).withButton1Text(getResources().getString(R.string.cancel)).withButton2Text(getResources().getString(R.string.agree));
            niftyDialogBuilder.setCustomView(R.layout.activity_spannable, this);
            TextView textView = (TextView) niftyDialogBuilder.getContentView().findViewById(R.id.span_builder);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
            textView.setHighlightColor(getResources().getColor(android.R.color.transparent));
            textView.setText(getResources().getString(R.string.access_media_images_request_description));
            niftyDialogBuilder.setButton1Click(new View.OnClickListener() { // from class: com.forum.ReleseCharacterActivity.2
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    ReleseCharacterActivity.this.requestExternalStorageSP.edit().putBoolean(ReleseCharacterActivity.READ_EXTERNAL_STORAGE, true).commit();
                    if (niftyDialogBuilder.isShowing()) {
                        niftyDialogBuilder.dismiss();
                        ReleseCharacterActivity.this.requestExternalStorageEffect = null;
                    }
                }
            }).setButton2Click(new View.OnClickListener() { // from class: com.forum.ReleseCharacterActivity.1
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    ReleseCharacterActivity.this.requestExternalStorageSP.edit().putBoolean(ReleseCharacterActivity.READ_EXTERNAL_STORAGE, true).commit();
                    if (niftyDialogBuilder.isShowing()) {
                        niftyDialogBuilder.dismiss();
                        ReleseCharacterActivity.this.requestExternalStorageEffect = null;
                    }
                    if (Build.VERSION.SDK_INT <= 32) {
                        if (PermissionChecker.checkSelfPermission(ReleseCharacterActivity.this, "android.permission.WRITE_EXTERNAL_STORAGE")) {
                            PictureFileUtils.deleteCacheDirFile(ReleseCharacterActivity.this, PictureMimeType.ofImage());
                            return;
                        } else {
                            PermissionChecker.requestPermissions(ReleseCharacterActivity.this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 1);
                            return;
                        }
                    }
                    if (Build.VERSION.SDK_INT >= 33) {
                        if (ContextCompat.checkSelfPermission(ReleseCharacterActivity.this.getApplicationContext(), "android.permission.READ_MEDIA_IMAGES") != 0) {
                            PermissionChecker.requestPermissions(ReleseCharacterActivity.this, new String[]{"android.permission.READ_MEDIA_IMAGES"}, 1);
                        } else {
                            PictureFileUtils.deleteCacheDirFile(ReleseCharacterActivity.this, PictureMimeType.ofImage());
                        }
                    }
                }
            });
            SharedPreferences sharedPreferences = getSharedPreferences(READ_EXTERNAL_STORAGE, 0);
            this.requestExternalStorageSP = sharedPreferences;
            if (Boolean.valueOf(sharedPreferences.getBoolean(READ_EXTERNAL_STORAGE, false)).booleanValue() || isFinishing()) {
                return;
            }
            niftyDialogBuilder.show();
        }
    }

    public void replyContent() {
        if (TextUtils.isEmpty(this.et_Content.getText())) {
            Toast.makeText(this, R.string.text, 0).show();
            return;
        }
        this.url = Constant.publishReplyByApp;
        this.params.put("replyId", this.replyId);
        this.params.put("replyType", this.replyType);
        this.params.put("target", this.target);
        this.params.put(SharedPreferencesKey.SP_KEY_TOKEN, LedBleActivity.getBaseApp().getUserToken());
        this.params.put(Utils.RESPONSE_CONTENT, this.et_Content.getText().toString());
        this.files.clear();
        for (int i = 0; i < this.fileList.size(); i++) {
            File file = this.fileList.get(i);
            this.files.put(file.getName(), file);
        }
        uploading();
    }

    public void publishContent() throws JSONException {
        String str;
        if (getResources().getString(R.string.home).equalsIgnoreCase("首页")) {
            str = "cn";
        } else if (getResources().getString(R.string.home).equalsIgnoreCase("Home")) {
            str = "en";
        } else {
            str = "other";
        }
        StringBuilder sb = this.fileIdList;
        new OkHttpClient().newCall(new Request.Builder().url(Constant.publishCommentByApp).post(new FormBody.Builder().add("title", this.et_Title.getText().toString()).add(Utils.RESPONSE_CONTENT, this.et_Content.getText().toString()).add("language", str).add("fileIdList", (sb == null || sb.length() <= 0) ? "" : this.fileIdList.substring(1)).add(SharedPreferencesKey.SP_KEY_TOKEN, LedBleActivity.getBaseApp().getUserToken()).build()).build()).enqueue(new Callback() { // from class: com.forum.ReleseCharacterActivity.3
            @Override // okhttp3.Callback
            public void onFailure(Call call, IOException iOException) {
                new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.forum.ReleseCharacterActivity.3.1
                    @Override // java.lang.Runnable
                    public void run() {
                        ReleseCharacterActivity.this.hideDialog();
                        ReleseCharacterActivity.this.btn_Publish1.setEnabled(true);
                        Toast.makeText(ReleseCharacterActivity.this.getApplicationContext(), R.string.request_failed, 0).show();
                    }
                });
            }

            @Override // okhttp3.Callback
            public void onResponse(Call call, Response response) throws IOException {
                if (response.isSuccessful()) {
                    ResponseBean responseBean = (ResponseBean) JSON.parseObject(response.body().string(), new TypeReference<ResponseBean<String>>() { // from class: com.forum.ReleseCharacterActivity.3.2
                    }, new Feature[0]);
                    if (responseBean == null || !Constant.SUCCESS_CODE.equals(responseBean.getReturnCode())) {
                        return;
                    }
                    new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.forum.ReleseCharacterActivity.3.3
                        @Override // java.lang.Runnable
                        public void run() {
                            ReleseCharacterActivity.this.btn_Publish1.setEnabled(true);
                            Toast.makeText(ReleseCharacterActivity.this.getApplicationContext(), R.string.comment_publish_success, 0).show();
                        }
                    });
                    ReleseCharacterActivity.this.setResult(FirstActivity.RESULT222);
                    ReleseCharacterActivity.this.finish();
                    return;
                }
                new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.forum.ReleseCharacterActivity.3.4
                    @Override // java.lang.Runnable
                    public void run() {
                        ReleseCharacterActivity.this.hideDialog();
                        ReleseCharacterActivity.this.btn_Publish1.setEnabled(true);
                        Toast.makeText(ReleseCharacterActivity.this.getApplicationContext(), R.string.request_failed, 0).show();
                    }
                });
            }
        });
    }

    public void publishContent1() {
        this.fileIdList = new StringBuilder();
        if (this.handler == null) {
            this.handler = new Handler();
            this.runnable = new Runnable() { // from class: com.forum.ReleseCharacterActivity.4
                @Override // java.lang.Runnable
                public void run() {
                    if (ReleseCharacterActivity.this.index >= ReleseCharacterActivity.this.imageNameList.size()) {
                        try {
                            ReleseCharacterActivity.this.publishContent();
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        ReleseCharacterActivity.this.index = 0;
                        ReleseCharacterActivity.this.fileIdList = null;
                        ReleseCharacterActivity.this.handler.removeCallbacks(ReleseCharacterActivity.this.runnable);
                        ReleseCharacterActivity.this.handler = null;
                        return;
                    }
                    try {
                        ReleseCharacterActivity releseCharacterActivity = ReleseCharacterActivity.this;
                        releseCharacterActivity.getUpLoadUrl((String) releseCharacterActivity.imageNameList.get(ReleseCharacterActivity.this.index));
                    } catch (JSONException e2) {
                        e2.printStackTrace();
                    }
                }
            };
        }
        this.handler.postDelayed(this.runnable, 1L);
    }

    public void getUpLoadUrl(String str) throws JSONException {
        OkHttpClient build = new OkHttpClient.Builder().connectTimeout(1000L, TimeUnit.SECONDS).readTimeout(1000L, TimeUnit.SECONDS).build();
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("filename", str);
        jSONObject.put("isOpen", "true");
        build.newCall(new Request.Builder().addHeader("Content-Type", "application/json;charset=utf-8").addHeader("Authorization", "Bearer " + LedBleActivity.getBaseApp().getUserToken()).post(RequestBody.create(jSONObject.toString(), MediaType.parse("application/json;charset=utf-8"))).url("http://test.appv2.ac.ledspi.com/app/file/signUploadUrl").build()).enqueue(new Callback() { // from class: com.forum.ReleseCharacterActivity.5
            @Override // okhttp3.Callback
            public void onFailure(Call call, IOException iOException) {
                Log.e(ReleseCharacterActivity.TAG, String.valueOf(iOException));
                iOException.printStackTrace();
                new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.forum.ReleseCharacterActivity.5.1
                    @Override // java.lang.Runnable
                    public void run() {
                        ReleseCharacterActivity.this.hideDialog();
                        ReleseCharacterActivity.this.btn_Publish1.setEnabled(true);
                        Toast.makeText(ReleseCharacterActivity.this.getApplicationContext(), R.string.request_failed, 0).show();
                    }
                });
            }

            @Override // okhttp3.Callback
            public void onResponse(Call call, Response response) throws IOException {
                UploadUrlBean uploadUrlBean;
                if (response.isSuccessful()) {
                    String string = response.body().string();
                    if (string == null || (uploadUrlBean = (UploadUrlBean) JSON.parseObject(string, new TypeReference<UploadUrlBean>() { // from class: com.forum.ReleseCharacterActivity.5.2
                    }, new Feature[0])) == null) {
                        return;
                    }
                    ReleseCharacterActivity.this.fileIdList.append("," + uploadUrlBean.getData().getId());
                    Log.e(ReleseCharacterActivity.TAG, "fileIdList = " + ((Object) ReleseCharacterActivity.this.fileIdList));
                    if (SdkVersionUtils.checkedAndroid_Q()) {
                        ReleseCharacterActivity releseCharacterActivity = ReleseCharacterActivity.this;
                        releseCharacterActivity.uploadImageToAli(((LocalMedia) releseCharacterActivity.selectList.get(ReleseCharacterActivity.this.index)).getAndroidQToPath(), uploadUrlBean.getData().getUploadurl());
                        return;
                    } else {
                        ReleseCharacterActivity releseCharacterActivity2 = ReleseCharacterActivity.this;
                        releseCharacterActivity2.uploadImageToAli(((LocalMedia) releseCharacterActivity2.selectList.get(ReleseCharacterActivity.this.index)).getPath(), uploadUrlBean.getData().getUploadurl());
                        return;
                    }
                }
                new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.forum.ReleseCharacterActivity.5.3
                    @Override // java.lang.Runnable
                    public void run() {
                        ReleseCharacterActivity.this.hideDialog();
                        ReleseCharacterActivity.this.btn_Publish1.setEnabled(true);
                        Toast.makeText(ReleseCharacterActivity.this.getApplicationContext(), R.string.request_failed, 0).show();
                    }
                });
            }
        });
    }

    public void uploadImageToAli(String str, String str2) throws IOException {
        String[] split = str2.split("://");
        if (split.length > 0) {
            str2 = "http://" + split[split.length - 1];
        }
        new OkHttpClient().newCall(new Request.Builder().url(str2).put(RequestBody.create(new File(str), (MediaType) null)).build()).enqueue(new Callback() { // from class: com.forum.ReleseCharacterActivity.6
            @Override // okhttp3.Callback
            public void onFailure(Call call, IOException iOException) {
                Log.e(ReleseCharacterActivity.TAG, "上传失败");
                Log.e(ReleseCharacterActivity.TAG, String.valueOf(iOException));
                new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.forum.ReleseCharacterActivity.6.1
                    @Override // java.lang.Runnable
                    public void run() {
                        ReleseCharacterActivity.this.hideDialog();
                        ReleseCharacterActivity.this.btn_Publish1.setEnabled(true);
                        Toast.makeText(ReleseCharacterActivity.this.getApplicationContext(), R.string.request_failed, 0).show();
                    }
                });
            }

            @Override // okhttp3.Callback
            public void onResponse(Call call, Response response) throws IOException {
                ReleseCharacterActivity.this.hideDialog();
                if (ReleseCharacterActivity.this.handler != null) {
                    ReleseCharacterActivity.this.index++;
                    ReleseCharacterActivity.this.handler.postDelayed(ReleseCharacterActivity.this.runnable, 50L);
                }
            }
        });
    }

    public void uploading() {
        new OkHttpClient().newCall(new Request.Builder().url(Constant.publishReplyByApp).post(new FormBody.Builder().add("replyId", this.replyId).add("replyType", this.replyType).add("target", this.target).add(Utils.RESPONSE_CONTENT, this.et_Content.getText().toString()).add(SharedPreferencesKey.SP_KEY_TOKEN, LedBleActivity.getBaseApp().getUserToken()).build()).build()).enqueue(new Callback() { // from class: com.forum.ReleseCharacterActivity.7
            @Override // okhttp3.Callback
            public void onFailure(Call call, IOException iOException) {
                new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.forum.ReleseCharacterActivity.7.1
                    @Override // java.lang.Runnable
                    public void run() {
                        ReleseCharacterActivity.this.hideDialog();
                        ReleseCharacterActivity.this.btn_Publish1.setEnabled(true);
                        Toast.makeText(ReleseCharacterActivity.this.getApplicationContext(), R.string.request_failed, 0).show();
                    }
                });
            }

            @Override // okhttp3.Callback
            public void onResponse(Call call, Response response) throws IOException {
                if (response.isSuccessful()) {
                    ResponseBean responseBean = (ResponseBean) JSON.parseObject(response.body().string(), new TypeReference<ResponseBean<String>>() { // from class: com.forum.ReleseCharacterActivity.7.2
                    }, new Feature[0]);
                    if (responseBean == null || !Constant.SUCCESS_CODE.equals(responseBean.getReturnCode())) {
                        return;
                    }
                    new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.forum.ReleseCharacterActivity.7.3
                        @Override // java.lang.Runnable
                        public void run() {
                            ReleseCharacterActivity.this.btn_Publish1.setEnabled(true);
                            Toast.makeText(ReleseCharacterActivity.this.getApplicationContext(), R.string.comment_publish_success, 0).show();
                        }
                    });
                    ReleseCharacterActivity.this.setResult(FirstActivity.RESULT222);
                    ReleseCharacterActivity.this.finish();
                    return;
                }
                new Handler(Looper.getMainLooper()).post(new Runnable() { // from class: com.forum.ReleseCharacterActivity.7.4
                    @Override // java.lang.Runnable
                    public void run() {
                        ReleseCharacterActivity.this.hideDialog();
                        ReleseCharacterActivity.this.btn_Publish1.setEnabled(true);
                        Toast.makeText(ReleseCharacterActivity.this.getApplicationContext(), R.string.request_failed, 0).show();
                    }
                });
            }
        });
    }

    @Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i == 4) {
            finish();
            return true;
        }
        return super.onKeyDown(i, keyEvent);
    }

    private void getDefaultStyle() {
        PictureParameterStyle pictureParameterStyle = new PictureParameterStyle();
        this.mPictureParameterStyle = pictureParameterStyle;
        pictureParameterStyle.isChangeStatusBarFontColor = false;
        this.mPictureParameterStyle.isOpenCompletedNumStyle = false;
        this.mPictureParameterStyle.isOpenCheckNumStyle = false;
        this.mPictureParameterStyle.pictureStatusBarColor = Color.parseColor("#393a3e");
        this.mPictureParameterStyle.pictureTitleBarBackgroundColor = Color.parseColor("#393a3e");
        this.mPictureParameterStyle.pictureTitleUpResId = R.drawable.picture_icon_arrow_up;
        this.mPictureParameterStyle.pictureTitleDownResId = R.drawable.picture_icon_arrow_down;
        this.mPictureParameterStyle.pictureFolderCheckedDotStyle = R.drawable.picture_orange_oval;
        this.mPictureParameterStyle.pictureLeftBackIcon = R.drawable.picture_icon_back;
        this.mPictureParameterStyle.pictureTitleTextColor = ContextCompat.getColor(this, R.color.picture_color_white);
        this.mPictureParameterStyle.pictureCancelTextColor = ContextCompat.getColor(this, R.color.picture_color_white);
        this.mPictureParameterStyle.pictureCheckedStyle = R.drawable.picture_checkbox_selector;
        this.mPictureParameterStyle.pictureBottomBgColor = ContextCompat.getColor(this, R.color.picture_color_fa);
        this.mPictureParameterStyle.pictureCheckNumBgStyle = R.drawable.picture_num_oval;
        this.mPictureParameterStyle.picturePreviewTextColor = ContextCompat.getColor(this, R.color.picture_color_fa632d);
        this.mPictureParameterStyle.pictureUnPreviewTextColor = ContextCompat.getColor(this, R.color.picture_color_9b);
        this.mPictureParameterStyle.pictureCompleteTextColor = ContextCompat.getColor(this, R.color.picture_color_fa632d);
        this.mPictureParameterStyle.pictureUnCompleteTextColor = ContextCompat.getColor(this, R.color.picture_color_9b);
        this.mPictureParameterStyle.picturePreviewBottomBgColor = ContextCompat.getColor(this, R.color.picture_color_grey_3e);
        this.mPictureParameterStyle.pictureExternalPreviewDeleteStyle = R.drawable.picture_icon_delete;
        this.mPictureParameterStyle.pictureExternalPreviewGonePreviewDelete = true;
        this.mPictureParameterStyle.pictureNavBarColor = Color.parseColor("#393a3e");
        this.mCropParameterStyle = new PictureCropParameterStyle(ContextCompat.getColor(this, R.color.app_color_grey), ContextCompat.getColor(this, R.color.app_color_grey), Color.parseColor("#393a3e"), ContextCompat.getColor(this, R.color.app_color_white), this.mPictureParameterStyle.isChangeStatusBarFontColor);
    }

    @Override // com.home.base.LedBleActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i != 188) {
            return;
        }
        this.selectList = PictureSelector.obtainMultipleResult(intent);
        this.imageNameList.clear();
        for (int i3 = 0; i3 < this.selectList.size(); i3++) {
            if (SdkVersionUtils.checkedAndroid_Q()) {
                compressPhoto(this.selectList.get(i3).getAndroidQToPath());
            } else {
                compressPhoto(this.selectList.get(i3).getPath());
            }
        }
        Iterator<LocalMedia> it = this.selectList.iterator();
        while (it.hasNext()) {
            String[] split = it.next().getAndroidQToPath().split("/");
            if (split.length > 0) {
                this.imageNameList.add(split[split.length - 1]);
            }
        }
        this.adapter.setList(this.selectList);
        this.adapter.notifyDataSetChanged();
    }

    private void compressPhoto(String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        new ScalPhotoTask(str).execute("");
    }

    /* loaded from: classes.dex */
    public class ScalPhotoTask extends AsyncTask<String, Void, File> {
        private String picturePath;

        public ScalPhotoTask(String str) {
            this.picturePath = str;
        }

        @Override // android.os.AsyncTask
        protected void onPreExecute() {
            super.onPreExecute();
        }

        /* JADX INFO: Access modifiers changed from: protected */
        @Override // android.os.AsyncTask
        public File doInBackground(String... strArr) {
            File file = new File(this.picturePath);
            return ImageUtils.scalFile(file, file.getName());
        }

        /* JADX INFO: Access modifiers changed from: protected */
        @Override // android.os.AsyncTask
        public void onPostExecute(File file) {
            super.onPostExecute((ScalPhotoTask) file);
            if (file != null) {
                ReleseCharacterActivity.this.fileList.add(ReleseCharacterActivity.this.index, file);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // com.home.base.LedBleActivity, me.imid.swipebacklayout.lib.app.SwipeBackActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
    public void onDestroy() {
        super.onDestroy();
        if (this.broadcastReceiver != null) {
            BroadcastManager.getInstance(this).unregisterReceiver(this.broadcastReceiver, BroadcastAction.ACTION_DELETE_PREVIEW_POSITION);
        }
    }
}
