APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:лукистрелы
版本号:4.7.5
包名称:com.itrack.lukistrely492503

MD5 校验值:f251013a2aaff35392a018e97a7e0052

反编译源代码说明

BaseShareActivity.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package com.itrack.mobifitnessdemo.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.fragment.app.FragmentActivity;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.itrack.lukistrely492503.R;
import com.itrack.mobifitnessdemo.application.Config;
import com.itrack.mobifitnessdemo.application.GlideApp;
import com.itrack.mobifitnessdemo.domain.model.entity.ColorPalette;
import com.itrack.mobifitnessdemo.domain.model.entity.DesignId;
import com.itrack.mobifitnessdemo.domain.model.entity.SchemeProperties;
import com.itrack.mobifitnessdemo.domain.model.entity.ScreenInfo;
import com.itrack.mobifitnessdemo.domain.model.utils.ColorStyler;
import com.itrack.mobifitnessdemo.mvp.presenter.SharePresenter;
import com.itrack.mobifitnessdemo.mvp.view.ShareView;
import com.itrack.mobifitnessdemo.utils.ErrorUtils;
import com.itrack.mobifitnessdemo.utils.LogHelper;
import com.itrack.mobifitnessdemo.utils.Utils;
import com.vk.api.sdk.VK;
import com.vk.api.sdk.auth.VKAccessToken;
import com.vk.api.sdk.auth.VKAuthCallback;
import com.vk.api.sdk.auth.VKScope;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import kotlin.collections.CollectionsKt__CollectionsJVMKt;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.SetsKt__SetsKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt__StringsJVMKt;

public final class BaseShareActivity extends BaseMvpActivity<SharePresenter> implements ShareView {
    public static final Companion Companion = new Companion(null);
    private static final String EXTRA_APPLY_DESIGN = "apply_design";
    private static final String EXTRA_IMAGE = "image";
    private static final String EXTRA_MESSAGE = "message";
    private static final String EXTRA_POINTS_CODE = "pointsCode";
    private static final String EXTRA_SEARCH_FOR_POINTS = "EXTRA_SEARCH_FOR_POINTS";
    private static final String EXTRA_TYPE = "type";
    private static final String EXTRA_URL = "url";
    private static final String RESULT_SHOULD_GIVE_POINTS = "RESULT_SHOULD_GIVE_POINTS";
    private static final Set<VKScope> SCOPE;
    private static final String TAG = "ShareActivity";
    private static final int TYPE_TWITTER = 1;
    private static final int TYPE_VK = 0;
    public Map<Integer, View> _$_findViewCache = new LinkedHashMap();
    private MenuItem actionSendMenuItem;
    private Uri imageExtra;
    public ImageView imageView;
    public TextView messageView;
    public SharePresenter mvpPresenter;

    @Override
    public void _$_clearFindViewByIdCache() {
        this._$_findViewCache.clear();
    }

    @Override
    public View _$_findCachedViewById(int i) {
        Map<Integer, View> map = this._$_findViewCache;
        View view = map.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i);
        if (findViewById == null) {
            return null;
        }
        map.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final TextView getMessageView() {
        TextView textView = this.messageView;
        if (textView != null) {
            return textView;
        }
        Intrinsics.throwUninitializedPropertyAccessException("messageView");
        return null;
    }

    public final void setMessageView(TextView textView) {
        Intrinsics.checkNotNullParameter(textView, "<set-?>");
        this.messageView = textView;
    }

    public final ImageView getImageView() {
        ImageView imageView = this.imageView;
        if (imageView != null) {
            return imageView;
        }
        Intrinsics.throwUninitializedPropertyAccessException("imageView");
        return null;
    }

    public final void setImageView(ImageView imageView) {
        Intrinsics.checkNotNullParameter(imageView, "<set-?>");
        this.imageView = imageView;
    }

    public final SharePresenter getMvpPresenter() {
        SharePresenter sharePresenter = this.mvpPresenter;
        if (sharePresenter != null) {
            return sharePresenter;
        }
        Intrinsics.throwUninitializedPropertyAccessException("mvpPresenter");
        return null;
    }

    public final void setMvpPresenter(SharePresenter sharePresenter) {
        Intrinsics.checkNotNullParameter(sharePresenter, "<set-?>");
        this.mvpPresenter = sharePresenter;
    }

    @Override
    public SharePresenter getPresenter() {
        return getMvpPresenter();
    }

    private final int getMaxMessageLength() {
        int shareType = getShareType();
        if (shareType != 0) {
            return shareType != 1 ? 0 : 140;
        }
        return 10000;
    }

    private final String getMessage() {
        String obj = getMessageView().getText().toString();
        int length = obj.length() - 1;
        int i = 0;
        boolean z = false;
        while (i <= length) {
            boolean z2 = Intrinsics.compare(obj.charAt(!z ? i : length), 32) <= 0;
            if (z) {
                if (!z2) {
                    break;
                }
                length--;
            } else if (z2) {
                i++;
            } else {
                z = true;
            }
        }
        return obj.subSequence(i, length + 1).toString();
    }

    private final List<String> getSearchListForPoints() {
        List listOf;
        ArrayList<String> stringArrayListExtra = getIntent().getStringArrayListExtra(EXTRA_SEARCH_FOR_POINTS);
        if (stringArrayListExtra != null) {
            return stringArrayListExtra;
        }
        String siteUrl = getFranchisePrefs().getSiteUrl();
        if (siteUrl == null) {
            siteUrl = "";
        }
        listOf = CollectionsKt__CollectionsJVMKt.listOf(siteUrl);
        ArrayList arrayList = new ArrayList();
        for (Object obj : listOf) {
            if (((String) obj).length() > 0) {
                arrayList.add(obj);
            }
        }
        return arrayList;
    }

    private final String getUrlExtra() {
        Bundle extras;
        String string;
        Intent intent = getIntent();
        return (intent == null || (extras = intent.getExtras()) == null || (string = extras.getString(EXTRA_URL)) == null) ? getFranchisePrefs().getSiteUrl() : string;
    }

    private final int getShareType() {
        Intent intent = getIntent();
        if (intent != null) {
            return intent.getIntExtra("type", -1);
        }
        return -1;
    }

    @Override
    @SuppressLint({"MissingSuperCall"})
    public void onCreate(Bundle bundle) {
        String str;
        super.onCreate(bundle, R.layout.activity_share, "none", false);
        View findViewById = findViewById(R.id.shareContentMessage);
        Intrinsics.checkNotNullExpressionValue(findViewById, "findViewById(R.id.shareContentMessage)");
        setMessageView((TextView) findViewById);
        View findViewById2 = findViewById(R.id.shareContentImage);
        Intrinsics.checkNotNullExpressionValue(findViewById2, "findViewById(R.id.shareContentImage)");
        setImageView((ImageView) findViewById2);
        Intent intent = getIntent();
        if (intent != null && intent.getBooleanExtra(EXTRA_APPLY_DESIGN, false)) {
            applyPalette();
        }
        getMessageView().addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }

            @Override
            public void afterTextChanged(Editable editable) {
                BaseShareActivity.this.updateSendButtonState();
            }
        });
        getMessageView().setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(getMaxMessageLength())});
        TextView messageView = getMessageView();
        Intent intent2 = getIntent();
        if (intent2 == null || (str = intent2.getStringExtra("message")) == null) {
            str = null;
        } else if (str.length() > getMaxMessageLength()) {
            str = str.substring(0, getMaxMessageLength());
            Intrinsics.checkNotNullExpressionValue(str, "this as java.lang.String…ing(startIndex, endIndex)");
        }
        messageView.setText(str);
        Intent intent3 = getIntent();
        Uri uri = intent3 != null ? (Uri) intent3.getParcelableExtra("image") : null;
        this.imageExtra = uri;
        if (uri != null) {
            GlideApp.with((FragmentActivity) this).mo32load(this.imageExtra).skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE).into(getImageView());
        } else {
            getImageView().setVisibility(8);
        }
        if (!checkAuth()) {
            onAuthRequired();
        }
        attachToPresenter();
    }

    private final void applyPalette() {
        SchemeProperties schemeProperties = getFranchisePrefs().getSchemeProperties();
        ScreenInfo screenInfo = getFranchisePrefs().getScreenInfo(DesignId.SCREEN_ID_START);
        if (screenInfo == null) {
            return;
        }
        ColorPalette colorPalette = getFranchisePrefs().getColorPalette(screenInfo.getDesign());
        getWindow().getDecorView().setBackgroundColor(colorPalette.getBackground());
        if (Config.hasLollipop()) {
            getWindow().setStatusBarColor(colorPalette.getPrimaryDark());
        }
        ColorStyler colorStyler = ColorStyler.INSTANCE;
        View findViewById = findViewById(R.id.shadowViewContainer);
        Intrinsics.checkNotNullExpressionValue(findViewById, "findViewById(R.id.shadowViewContainer)");
        colorStyler.apply(findViewById, colorPalette, schemeProperties);
    }

    private final boolean checkAuth() {
        if (getShareType() == 0) {
            return VK.isLoggedIn();
        }
        finish();
        return true;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        Intrinsics.checkNotNullParameter(menu, "menu");
        getMenuInflater().inflate(R.menu.share_activity_menu, menu);
        this.actionSendMenuItem = menu.findItem(R.id.menu_send);
        updateSendButtonState();
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        Intrinsics.checkNotNullParameter(item, "item");
        if (item.getItemId() == R.id.menu_send) {
            sendMessage();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public final void updateSendButtonState() {
        MenuItem menuItem = this.actionSendMenuItem;
        if (menuItem == null) {
            return;
        }
        menuItem.setEnabled(getMessage().length() > 0);
    }

    private final void sendMessage() {
        int shareType = getShareType();
        if (shareType == 0) {
            SharePresenter presenter = getPresenter();
            String message = getMessage();
            Uri uri = this.imageExtra;
            presenter.postVk(message, uri != null ? uri.toString() : null, getUrlExtra());
            return;
        }
        if (shareType != 1) {
            return;
        }
        SharePresenter presenter2 = getPresenter();
        String message2 = getMessage();
        Uri uri2 = this.imageExtra;
        presenter2.postTwitter(message2, uri2 != null ? uri2.toString() : null);
    }

    @Override
    public void onAuthRequired() {
        int shareType = getShareType();
        if (shareType == 0) {
            VK.login(this, SCOPE);
        } else {
            if (shareType != 1) {
                return;
            }
            LogHelper.i(TAG, "session is null, logging in");
        }
    }

    @Override
    public void onShareSuccess() {
        Bundle extras;
        Intent putExtra = new Intent().putExtra(RESULT_SHOULD_GIVE_POINTS, Utils.INSTANCE.shouldGivePoints(getMessage(), getSearchListForPoints()));
        Intent intent = getIntent();
        Intent putExtra2 = putExtra.putExtra(EXTRA_POINTS_CODE, (intent == null || (extras = intent.getExtras()) == null) ? null : extras.getString(EXTRA_POINTS_CODE));
        Intrinsics.checkNotNullExpressionValue(putExtra2, "Intent()\n            .pu…tring(EXTRA_POINTS_CODE))");
        setResult(-1, putExtra2);
        finish();
    }

    @Override
    public void onAuthFailure() {
        finish();
    }

    @Override
    public void onShareFailure(Exception e) {
        String message;
        boolean isBlank;
        Intrinsics.checkNotNullParameter(e, "e");
        LogHelper.i(TAG, "Share post failure " + e);
        int shareType = getShareType();
        if (shareType != 0) {
            message = shareType != 1 ? null : ErrorUtils.getErrorMessageText(e, getSpellingResHelper());
        } else {
            message = e.getMessage();
        }
        if (message == null) {
            message = getString(R.string.share_error_message);
            Intrinsics.checkNotNullExpressionValue(message, "getString(R.string.share_error_message)");
        }
        isBlank = StringsKt__StringsJVMKt.isBlank(message);
        if (!isBlank) {
            showSnackbarWithDescription(message, message);
        }
    }

    @Override
    public void onActivityResult(int i, int i2, Intent intent) {
        if (intent != null && VK.onActivityResult(i, i2, intent, new VKAuthCallback() {
            @Override
            public void onLogin(VKAccessToken token) {
                Intrinsics.checkNotNullParameter(token, "token");
            }

            @Override
            public void onLoginFailed(int i3) {
                LogHelper.e("ShareActivity", "login failure " + i3);
                BaseShareActivity.this.finish();
            }
        })) {
            return;
        }
        super.onActivityResult(i, i2, intent);
    }

    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }

        public static Bundle getIntentExtras$default(Companion companion, String str, String str2, Uri uri, String str3, String[] strArr, int i, Object obj) {
            if ((i & 8) != 0) {
                str3 = null;
            }
            return companion.getIntentExtras(str, str2, uri, str3, strArr);
        }

        private final Bundle getIntentExtras(String str, String str2, Uri uri, String str3, String... strArr) {
            List listOf;
            Bundle bundle = new Bundle();
            bundle.putString("message", str);
            bundle.putParcelable("image", uri);
            bundle.putString(BaseShareActivity.EXTRA_URL, str2);
            bundle.putString(BaseShareActivity.EXTRA_POINTS_CODE, str3);
            if (!(strArr.length == 0)) {
                listOf = CollectionsKt__CollectionsKt.listOf(Arrays.copyOf(strArr, strArr.length));
                bundle.putStringArrayList(BaseShareActivity.EXTRA_SEARCH_FOR_POINTS, new ArrayList<>(listOf));
            }
            return bundle;
        }

        public static Bundle getTwitterIntentExtras$default(Companion companion, String str, String str2, Uri uri, String str3, String[] strArr, int i, Object obj) {
            if ((i & 8) != 0) {
                str3 = null;
            }
            return companion.getTwitterIntentExtras(str, str2, uri, str3, strArr);
        }

        public final Bundle getTwitterIntentExtras(String str, String str2, Uri uri, String str3, String... searchForPointsString) {
            Intrinsics.checkNotNullParameter(searchForPointsString, "searchForPointsString");
            Bundle intentExtras = getIntentExtras(str, str2, uri, str3, (String[]) Arrays.copyOf(searchForPointsString, searchForPointsString.length));
            intentExtras.putInt("type", 1);
            return intentExtras;
        }

        public static Bundle getVkIntentExtras$default(Companion companion, String str, String str2, Uri uri, String str3, String[] strArr, int i, Object obj) {
            if ((i & 8) != 0) {
                str3 = null;
            }
            return companion.getVkIntentExtras(str, str2, uri, str3, strArr);
        }

        public final Bundle getVkIntentExtras(String str, String str2, Uri uri, String str3, String... searchForPointsString) {
            Intrinsics.checkNotNullParameter(searchForPointsString, "searchForPointsString");
            Bundle intentExtras = getIntentExtras(str, str2, uri, str3, (String[]) Arrays.copyOf(searchForPointsString, searchForPointsString.length));
            intentExtras.putInt("type", 0);
            return intentExtras;
        }

        public final Bundle applyDesign(Bundle b) {
            Intrinsics.checkNotNullParameter(b, "b");
            b.putBoolean(BaseShareActivity.EXTRA_APPLY_DESIGN, true);
            return b;
        }

        public final boolean shouldGivePoints(Intent intent) {
            Bundle extras;
            return (intent == null || (extras = intent.getExtras()) == null || !extras.getBoolean(BaseShareActivity.RESULT_SHOULD_GIVE_POINTS)) ? false : true;
        }

        public final String getResultPointsCode(Intent intent) {
            Bundle extras;
            if (intent == null || (extras = intent.getExtras()) == null) {
                return null;
            }
            return extras.getString(BaseShareActivity.EXTRA_POINTS_CODE);
        }
    }

    static {
        Set<VKScope> of;
        of = SetsKt__SetsKt.setOf((Object[]) new VKScope[]{VKScope.WALL, VKScope.PHOTOS});
        SCOPE = of;
    }
}