Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35

以下内容为反编译后的 AddDeviceMainActivity.java 源代码,内容仅作参考


package com.lumiunited.aqara.device.adddevicepage.view;

import a0.i.b;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lumi.external.utils.log.Logs;
import com.lumiunited.aqara.application.base.BaseActivity;
import com.lumiunited.aqara.application.base.BaseDeviceEntity;
import com.lumiunited.aqara.device.adddevicepage.AddDeviceBaseFragment;
import com.lumiunited.aqara.device.adddevicepage.bean.AutoTemplate;
import com.lumiunited.aqara.device.adddevicepage.bean.BindGatewayResult;
import com.lumiunited.aqara.device.adddevicepage.gateway.guide.RecommendedAutoActivity;
import com.lumiunited.aqara.device.adddevicepage.gateway.scan.AddGatewayScanActivity;
import com.lumiunited.aqara.device.adddevicepage.gateway.view.AddGatewayTipsFragment;
import com.lumiunited.aqara.device.adddevicepage.gateway.view.AddGatewayWaitingPageFragment;
import com.lumiunited.aqara.device.adddevicepage.view.AddDeviceChooseGatewayFragment;
import com.lumiunited.aqara.device.adddevicepage.view.AddDeviceMainActivity;
import com.lumiunited.aqara.device.adddevicepage.view.bean.AddDeviceListCategoryEntitiy;
import com.lumiunited.aqara.device.adddevicepage.view.bean.CategoryDeviceItemEntity;
import com.lumiunited.aqara.device.adddevicepage.view.setname.AddDeviceSetNameFragment;
import com.lumiunited.aqara.device.architecture.viewmodel.DeviceCategoryViewModel;
import com.lumiunited.aqara.device.lock.CommonRnLockActivity;
import com.lumiunited.aqara.device.lock.activity.BleLockNetAccessActivity;
import com.lumiunited.aqara.main.MainActivity;
import com.lumiunited.aqara.service.event.IFTTTRefreshEvent;
import com.lumiunited.aqara.statistics.Statistics;
import com.lumiunited.aqara.web.commonpage.SettingWebActivity;
import com.lumiunited.aqarahome.R;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import k.u.c.d.d.l0;
import k.u.c.d.g.d.v0;
import k.u.c.d.j.i0;
import k.u.c.d.j.o;
import k.u.c.d.j.r;
import k.u.c.f.a.q.y0;
import k.u.c.i.i3.r.f0;
import k.u.c.i.j3.z;
import k.u.c.n.o0;
import k.u.c.x.j3;
import p.a.x0.g;
import pub.devrel.easypermissions.EasyPermissions;
public class AddDeviceMainActivity extends BaseActivity implements EasyPermissions.a {
    public static final int N = 0;
    public static final int R = 1;
    public static final int S = 2;
    public static final int T = 3;
    public static final int U = 4;
    public static final int a7 = 5;
    public static final int b7 = 6;
    public static final int c7 = 7;
    public FrameLayout H;
    public FragmentManager I;
    public DeviceCategoryViewModel J;
    public int K;
    public String L;
    public boolean M = false;

    public static class b extends o<String> {
        public final Context a;
        public final List b;

        public b(Context context, List list) {
            this.a = context;
            this.b = list;
        }

        @Override
        public void a(int i2, String str) {
        }

        @Override
        public void a(String str) {
            RecommendedAutoActivity.a(this.a, new ArrayList(this.b));
            x.b.a.c.f().c(new IFTTTRefreshEvent());
        }
    }

    public class c implements Observer<k.u.c.e.f.a<List<AddDeviceListCategoryEntitiy>>> {
        public final d a;

        public c(d dVar) {
            this.a = dVar;
        }

        @Override
        public void onChanged(@Nullable k.u.c.e.f.a<List<AddDeviceListCategoryEntitiy>> aVar) {
            if (aVar.a() == null || aVar.a().isEmpty()) {
                return;
            }
            AddDeviceMainActivity.this.J.c().removeObserver(this);
            this.a.a(aVar.a());
        }
    }

    public interface d<T> {
        void a(T t2);
    }

    public static CategoryDeviceItemEntity D(List list) throws Exception {
        List<CategoryDeviceItemEntity> devicelist;
        if (list == null || list.isEmpty() || (devicelist = ((AddDeviceListCategoryEntitiy) list.get(0)).getDevicelist()) == null || devicelist.isEmpty()) {
            return null;
        }
        return devicelist.get(0);
    }

    public static void c(Context context, String str, String str2) {
        Logs.d("H5 address:" + str);
        if (str.endsWith(".pdf")) {
            if (k.u.c.r.l.d.l(context)) {
                str = "https://cdn.aqara.com/cdn/app/mainland/h5/index.html#/privacyPolicy_GDPR";
            } else {
                str = "https://cdn.aqara.com/cdn/app/mainland/h5/pdfjs/web/view.html?pdf=" + str;
            }
        }
        SettingWebActivity.b(context, str, str2);
    }

    public static void d(final Context context, final CategoryDeviceItemEntity categoryDeviceItemEntity) {
        BaseDeviceEntity baseDeviceEntity = new BaseDeviceEntity();
        baseDeviceEntity.setDeviceName(categoryDeviceItemEntity.getDeviceName());
        baseDeviceEntity.setModel("lumi.lock.netAccess");
        baseDeviceEntity.setDid("");
        Bundle bundle = new Bundle();
        Bundle bundle2 = new Bundle();
        ArrayList<String> arrayList = new ArrayList<>(categoryDeviceItemEntity.getSupportModels());
        bundle2.putString("pageTitle", categoryDeviceItemEntity.getDeviceName());
        bundle2.putStringArrayList("models", arrayList);
        bundle2.putString("guideImageUrl", categoryDeviceItemEntity.getGuideIcon());
        bundle2.putString("guideTextTitle", categoryDeviceItemEntity.getGuideContent());
        bundle.putBundle(CommonRnLockActivity.I.c(), bundle2);
        f0.a(context, baseDeviceEntity, "", bundle, AddGatewayScanActivity.q7, new b.a() {
            @Override
            public final void a(boolean z2, String str) {
                AddDeviceMainActivity.a(context, categoryDeviceItemEntity, z2, str);
            }
        });
    }

    @SuppressLint({"AutoDispose", "CheckResult"})
    public static void e(final Context context, String str, String str2) {
        v0.b(k.u.c.r.l.d.h(), str, str2).i(new p.a.x0.o() {
            @Override
            public final Object apply(Object obj) {
                return AddDeviceMainActivity.D((List) obj);
            }
        }).subscribe(new g() {
            @Override
            public final void accept(Object obj) {
                AddDeviceMainActivity.c(context, (CategoryDeviceItemEntity) obj);
            }
        }, new g() {
            @Override
            public final void accept(Object obj) {
                AddDeviceMainActivity.a(context, (Throwable) obj);
            }
        });
    }

    public static void f(Context context, String str, String str2) {
        Intent intent = new Intent(context, AddDeviceMainActivity.class);
        intent.putExtra("type", 4);
        intent.putExtra(AddGatewayScanActivity.n7, str);
        intent.putExtra(AddGatewayScanActivity.p7, str2);
        i0.a(context, intent);
    }

    private void g1() {
        this.H = (FrameLayout) findViewById(R.id.layout_container);
        this.I = getSupportFragmentManager();
    }

    private void h1() {
        a(new d() {
            @Override
            public final void a(Object obj) {
                AddDeviceMainActivity.this.f((List) obj);
            }
        });
    }

    @SuppressLint({"AutoDispose"})
    private void i1() {
        this.K = getIntent().getIntExtra("type", 0);
        this.L = getIntent().getStringExtra("model");
        this.M = getIntent().getBooleanExtra("toMainActivity", false);
        switch (this.K) {
            case 0:
                a((AddDeviceBaseFragment) AddDeviceListPageFragment.s1(), true);
                return;
            case 1:
                a(new d() {
                    @Override
                    public final void a(Object obj) {
                        AddDeviceMainActivity.this.z((List) obj);
                    }
                });
                return;
            case 2:
                final String stringExtra = getIntent().getStringExtra("curGatewayModel");
                final String stringExtra2 = getIntent().getStringExtra("gatewayDid");
                a(new d() {
                    @Override
                    public final void a(Object obj) {
                        AddDeviceMainActivity.this.a(stringExtra, stringExtra2, (List) obj);
                    }
                });
                return;
            case 3:
                h1();
                return;
            case 4:
                a((AddDeviceBaseFragment) AddGatewayWaitingPageFragment.b(getIntent().getStringExtra(AddGatewayScanActivity.n7), j3.E().f(), getIntent().getStringExtra(AddGatewayScanActivity.p7)), true);
                return;
            case 5:
                a((AddDeviceBaseFragment) AddDeviceSetNameFragment.d((BaseDeviceEntity) getIntent().getParcelableExtra("entity")), true);
                return;
            case 6:
                CategoryDeviceItemEntity categoryDeviceItemEntity = (CategoryDeviceItemEntity) getIntent().getParcelableExtra("entity");
                FragmentManager supportFragmentManager = getSupportFragmentManager();
                AddDeviceMainFragment addDeviceMainFragment = (AddDeviceMainFragment) supportFragmentManager.findFragmentByTag(AddDeviceMainActivity.class.getSimpleName());
                if (addDeviceMainFragment == null) {
                    addDeviceMainFragment = new AddDeviceMainFragment();
                    supportFragmentManager.beginTransaction().add(addDeviceMainFragment, AddDeviceMainActivity.class.getSimpleName()).commitNow();
                }
                addDeviceMainFragment.a(categoryDeviceItemEntity, categoryDeviceItemEntity.getModel());
                return;
            default:
                return;
        }
    }

    @Nullable
    public static CategoryDeviceItemEntity j0(@Nullable String str) {
        JSONObject parseObject = JSON.parseObject(str);
        if (parseObject == null || !parseObject.containsKey("androidAccessLink")) {
            return null;
        }
        JSONArray jSONArray = parseObject.getJSONArray("androidAccessLink");
        for (int i2 = 0; i2 < jSONArray.size(); i2++) {
            if (jSONArray.getJSONObject(i2).containsValue(k.t.j.a.b.f21677j)) {
                CategoryDeviceItemEntity categoryDeviceItemEntity = new CategoryDeviceItemEntity();
                String string = parseObject.getString("deviceName");
                String string2 = parseObject.getString("model");
                String string3 = parseObject.getString("modelId");
                String string4 = parseObject.getString("pId");
                JSONObject jSONObject = parseObject.getJSONObject("guidePage");
                String string5 = jSONObject.getString("imgUrl");
                String string6 = jSONObject.getString("descDeviceState");
                categoryDeviceItemEntity.setGuideIcon("https://cdn.aqara.com/cdn/common/mainland/test/statics/default/" + string5);
                categoryDeviceItemEntity.setGuideContent(string6);
                categoryDeviceItemEntity.setDeviceName(string);
                categoryDeviceItemEntity.setModel(string2);
                categoryDeviceItemEntity.setSupportModels(Arrays.asList(string2));
                categoryDeviceItemEntity.setPids(Arrays.asList(string4, string3));
                categoryDeviceItemEntity.setDependsOnDescription(str);
                return categoryDeviceItemEntity;
            }
        }
        return null;
    }

    public void f1() {
        if (this.M) {
            startActivity(new Intent(this, MainActivity.class));
        } else {
            finish();
        }
    }

    public void g(String str, int i2) {
        AddDeviceBaseFragment addDeviceBaseFragment = (AddDeviceBaseFragment) this.I.findFragmentById(R.id.layout_container);
        this.I.getBackStackEntryCount();
        if (str != null) {
            for (int backStackEntryCount = this.I.getBackStackEntryCount() - 1; backStackEntryCount >= 0; backStackEntryCount--) {
                String name = this.I.getBackStackEntryAt(backStackEntryCount).getName();
                if (name != null && name.equals(str)) {
                    this.I.popBackStack(str, 0);
                    return;
                }
            }
            finish();
        } else if (this.I.getBackStackEntryCount() > 1) {
            this.I.popBackStack();
        } else {
            finish();
        }
    }

    @Override
    public void o(int i2) {
        AddDeviceBaseFragment addDeviceBaseFragment = (AddDeviceBaseFragment) this.I.findFragmentById(R.id.layout_container);
        if (addDeviceBaseFragment == null || !(addDeviceBaseFragment instanceof EasyPermissions.a)) {
            return;
        }
        ((EasyPermissions.a) addDeviceBaseFragment).o(i2);
    }

    @Override
    public void onActivityResult(int i2, int i3, Intent intent) {
        super.onActivityResult(i2, i3, intent);
        AddDeviceBaseFragment addDeviceBaseFragment = (AddDeviceBaseFragment) this.I.findFragmentById(R.id.layout_container);
        if (addDeviceBaseFragment != null) {
            addDeviceBaseFragment.onActivityResult(i2, i3, intent);
        }
    }

    @Override
    public void onBackPressed() {
        AddDeviceBaseFragment addDeviceBaseFragment = (AddDeviceBaseFragment) this.I.findFragmentById(R.id.layout_container);
        if (addDeviceBaseFragment != null) {
            k.d.a.d("onBackPressed Fragment name #", addDeviceBaseFragment.getClass().getName());
        }
        if (addDeviceBaseFragment == null || !addDeviceBaseFragment.m1()) {
            f(false, (String) null);
        }
    }

    @Override
    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_fragment_no_title_bar);
        Statistics.trackEvent("HomePage$Add_device$Click");
        getWindow().setSoftInputMode(16);
        g1();
        i1();
    }

    @Override
    public void onDestroy() {
        b0();
        super.onDestroy();
    }

    @Override
    public void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        if (intent.getIntExtra("type", -1) == 0) {
            if (this.K == 0) {
                g(AddDeviceListPageFragment.class.getName(), 0);
            } else {
                finish();
            }
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        x.b.a.c.f().c(new k.u.c.i.g3.a(2));
    }

    @Override
    public void onRequestPermissionsResult(int i2, @NonNull String[] strArr, @NonNull int[] iArr) {
        super.onRequestPermissionsResult(i2, strArr, iArr);
        AddDeviceBaseFragment addDeviceBaseFragment = (AddDeviceBaseFragment) this.I.findFragmentById(R.id.layout_container);
        if (addDeviceBaseFragment != null) {
            EasyPermissions.a(i2, strArr, iArr, addDeviceBaseFragment);
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        x.b.a.c.f().c(new k.u.c.i.g3.a(3));
    }

    @Override
    @SuppressLint({"MissingSuperCall"})
    public void onSaveInstanceState(Bundle bundle) {
    }

    @Override
    public void t(int i2) {
    }

    public void z(List list) {
        Iterator it = list.iterator();
        while (it.hasNext()) {
            for (CategoryDeviceItemEntity categoryDeviceItemEntity : ((AddDeviceListCategoryEntitiy) it.next()).getDevicelist()) {
                String str = this.L;
                if (str != null && str.contains(categoryDeviceItemEntity.getModel())) {
                    AddDeviceChooseGatewayFragment.ChooseGatewayInfo chooseGatewayInfo = new AddDeviceChooseGatewayFragment.ChooseGatewayInfo(categoryDeviceItemEntity, true, false);
                    chooseGatewayInfo.setGatewayCategoryEntityList(c(list, categoryDeviceItemEntity.getDependsOn()));
                    a((AddDeviceBaseFragment) AddDeviceChooseGatewayFragment.a(chooseGatewayInfo), true);
                    return;
                }
            }
        }
    }

    public static void b(Context context) {
        Intent intent = new Intent(context, AddDeviceMainActivity.class);
        intent.putExtra("type", 0);
        intent.putExtra("toMainActivity", true);
        i0.a(context, intent);
    }

    public static void a(final Context context) {
        HashMap<String, String> f2 = l0.f();
        k.t.i.i.c cVar = new k.t.i.i.c();
        cVar.a(k.t.i.i.c.c, k.u.c.d.g.c.a());
        cVar.a(k.t.i.i.c.f20656f, k.u.c.r.l.d.h());
        cVar.a(k.t.i.i.c.b, "https://cdn.aqara.com/cdn/common/mainland/test/statics/default");
        cVar.a(k.t.i.i.c.f20658h, f2.get("Appkey"));
        cVar.a(k.t.i.i.c.f20657g, f2.get("Appid"));
        cVar.a(k.t.i.i.c.f20655e, f2.get("Lang"));
        cVar.a(k.t.i.i.c.f20660j, f2.get("Userid"));
        cVar.a(k.t.i.i.c.f20659i, f2.get("Token"));
        cVar.a(k.t.i.i.c.f20661k, String.valueOf(false));
        k.t.i.i.d.f20663e.b().a(context, cVar, new k.u.c.a0.d());
        k.t.j.a.d b2 = k.t.j.a.d.c.b();
        b2.a(context, j3.E().b().getValue(), k.u.c.r.l.d.g(), new a(context));
        b2.a(new k.t.j.a.f.a() {
            @Override
            public final void a(String str, String str2) {
                AddDeviceMainActivity.c(context, str, str2);
            }
        });
    }

    public static class a implements k.t.j.a.f.b {
        public final Context a;

        public a(Context context) {
            this.a = context;
        }

        @Override
        public void a(@Nullable String str) {
            Logs.d("入网成功:" + str);
            BaseDeviceEntity baseDeviceEntity = (BaseDeviceEntity) JSON.parseObject(str, BaseDeviceEntity.class);
            AddDeviceMainActivity.a(this.a, baseDeviceEntity);
            AddDeviceMainActivity.b(this.a, str, baseDeviceEntity.getDid());
        }

        @Override
        @SuppressLint({"CheckResult"})
        public void a(@Nullable Integer num, @Nullable String str) {
            Logs.d("入网失败:" + str);
            if (num != null && 10011 == num.intValue()) {
                CategoryDeviceItemEntity j0 = AddDeviceMainActivity.j0(str);
                if (j0 != null) {
                    AddDeviceMainActivity.d(this.a, j0);
                    return;
                }
                String string = JSON.parseObject(str).getString("model");
                AddDeviceMainActivity.e(this.a, string, TextUtils.isEmpty(string) ? JSON.parseObject(str).getString("pid") : "");
                return;
            }
            r.r(str);
        }
    }

    public static void b(Context context, String str, String str2) {
        List<AutoTemplate> templateIds;
        BindGatewayResult bindGatewayResult = (BindGatewayResult) JSON.parseObject(str, BindGatewayResult.class);
        if (bindGatewayResult == null || (templateIds = bindGatewayResult.getTemplateIds()) == null || templateIds.isEmpty()) {
            return;
        }
        String homeId = j3.E().j() == null ? j3.E().c().getHomeId() : j3.E().j().getRoomId();
        if (TextUtils.isEmpty(homeId)) {
            homeId = j3.E().f();
        }
        o0.a().a(templateIds, homeId, str2, new b(context, templateIds));
    }

    public static void c(Context context, CategoryDeviceItemEntity categoryDeviceItemEntity) {
        Intent intent = new Intent(context, AddDeviceMainActivity.class);
        intent.putExtra("type", 6);
        intent.putExtra("entity", categoryDeviceItemEntity);
        i0.a(context, intent);
    }

    public void f(List list) {
        Iterator it = list.iterator();
        while (it.hasNext()) {
            for (CategoryDeviceItemEntity categoryDeviceItemEntity : ((AddDeviceListCategoryEntitiy) it.next()).getDevicelist()) {
                String str = this.L;
                if (str != null && str.contains(categoryDeviceItemEntity.getModel())) {
                    a((AddDeviceBaseFragment) AddGatewayTipsFragment.a(z.e(this.L), categoryDeviceItemEntity), true);
                    return;
                }
            }
        }
    }

    private List<CategoryDeviceItemEntity> c(List<AddDeviceListCategoryEntitiy> list, List<String> list2) {
        ArrayList arrayList = new ArrayList(list2);
        ArrayList arrayList2 = new ArrayList();
        for (AddDeviceListCategoryEntitiy addDeviceListCategoryEntitiy : list) {
            for (CategoryDeviceItemEntity categoryDeviceItemEntity : addDeviceListCategoryEntitiy.getDevicelist()) {
                if (categoryDeviceItemEntity.getDependsOn().size() == 0) {
                    Iterator it = arrayList.iterator();
                    if (!it.hasNext()) {
                        return arrayList2;
                    }
                    do {
                        if (categoryDeviceItemEntity.getModel().equals((String) it.next())) {
                            it.remove();
                            arrayList2.add(categoryDeviceItemEntity);
                        }
                    } while (it.hasNext());
                }
            }
        }
        return arrayList2;
    }

    public void f(boolean z2, String str) {
        if (z2) {
            finish();
        } else if (str != null) {
            k.d.a.d("manager fragments size:" + this.I.getBackStackEntryCount());
            for (int backStackEntryCount = this.I.getBackStackEntryCount() - 1; backStackEntryCount >= 0; backStackEntryCount--) {
                String name = this.I.getBackStackEntryAt(backStackEntryCount).getName();
                if (name != null && name.equals(str)) {
                    this.I.popBackStack(str, 0);
                    return;
                }
            }
            finish();
        } else if (this.I.getBackStackEntryCount() > 1) {
            this.I.popBackStack();
        } else {
            finish();
        }
    }

    public static void d(Context context, String str, String str2) {
        Intent intent = new Intent(context, AddDeviceMainActivity.class);
        intent.putExtra("type", 1);
        intent.putExtra("model", str);
        intent.putExtra("title", str2);
        i0.a(context, intent);
    }

    public static void a(Context context, CategoryDeviceItemEntity categoryDeviceItemEntity, boolean z2, String str) {
        if (z2) {
            return;
        }
        Intent intent = new Intent(context, BleLockNetAccessActivity.class);
        intent.putExtra("entity", categoryDeviceItemEntity);
        if (context instanceof Activity) {
            ((Activity) context).startActivityForResult(intent, AddGatewayScanActivity.q7);
        }
    }

    public static void a(Context context, Throwable th) throws Exception {
        th.printStackTrace();
        new y0.c(k.t.b.f.e.g.j().g()).d(context.getString(R.string.not_supprot_device_hint)).b(context.getString(R.string.i_know), null).a().show();
    }

    public static void a(Context context, String str) {
        Intent intent = new Intent(context, AddDeviceMainActivity.class);
        intent.putExtra("type", 1);
        intent.putExtra("model", str);
        i0.a(context, intent);
    }

    public static void a(Context context, String str, String str2, String str3) {
        Intent intent = new Intent(context, AddDeviceMainActivity.class);
        intent.putExtra("type", 2);
        intent.putExtra("curGatewayModel", str);
        intent.putExtra("gatewayDid", str2);
        intent.putExtra("model", str3);
        i0.a(context, intent);
    }

    public static void a(Context context, BaseDeviceEntity baseDeviceEntity) {
        Intent intent = new Intent(context, AddDeviceMainActivity.class);
        intent.putExtra("type", 5);
        intent.putExtra("entity", baseDeviceEntity);
        i0.a(context, intent);
    }

    public void a(String str, String str2, List list) {
        Iterator it = list.iterator();
        CategoryDeviceItemEntity categoryDeviceItemEntity = null;
        CategoryDeviceItemEntity categoryDeviceItemEntity2 = null;
        while (it.hasNext()) {
            Iterator<CategoryDeviceItemEntity> it2 = ((AddDeviceListCategoryEntitiy) it.next()).getDevicelist().iterator();
            while (true) {
                if (!it2.hasNext()) {
                    break;
                }
                CategoryDeviceItemEntity next = it2.next();
                String str3 = this.L;
                if (str3 != null && str3.contains(next.getModel())) {
                    categoryDeviceItemEntity2 = next;
                    break;
                } else if (str != null && str.equals(next.getModel())) {
                    categoryDeviceItemEntity = next;
                    break;
                }
            }
            if (categoryDeviceItemEntity2 != null && categoryDeviceItemEntity != null) {
                break;
            }
        }
        a((AddDeviceBaseFragment) AddDeviceWaitingFragment.a(categoryDeviceItemEntity2, str2, categoryDeviceItemEntity == null ? 30 : categoryDeviceItemEntity.getOvertimeValue(), (String) null), true);
    }

    private void a(d<List<AddDeviceListCategoryEntitiy>> dVar) {
        if (this.J == null) {
            DeviceCategoryViewModel deviceCategoryViewModel = (DeviceCategoryViewModel) ViewModelProviders.of(this).get(DeviceCategoryViewModel.class);
            this.J = deviceCategoryViewModel;
            deviceCategoryViewModel.c().observe(this, new c(dVar));
        }
        if (this.L != null) {
            this.J.b();
        }
    }

    public void a(AddDeviceBaseFragment addDeviceBaseFragment, boolean z2) {
        a(addDeviceBaseFragment, z2, false);
    }

    public void a(AddDeviceBaseFragment addDeviceBaseFragment, boolean z2, boolean z3) {
        FragmentTransaction beginTransaction = this.I.beginTransaction();
        k.d.a.d("Fragment name # " + addDeviceBaseFragment.getClass().getName());
        if (this.I.getBackStackEntryCount() > 0) {
            int i2 = R.anim.fragment_left_enter;
            int i3 = z3 ? R.anim.fragment_left_enter : R.anim.fragment_right_enter;
            int i4 = R.anim.fragment_right_exit;
            int i5 = z3 ? R.anim.fragment_right_exit : R.anim.fragment_left_exit;
            if (z3) {
                i2 = R.anim.fragment_right_enter;
            }
            if (z3) {
                i4 = R.anim.fragment_left_exit;
            }
            beginTransaction.setCustomAnimations(i3, i5, i2, i4);
        }
        beginTransaction.replace(R.id.layout_container, addDeviceBaseFragment, addDeviceBaseFragment.getClass().getName());
        if (z2) {
            beginTransaction.addToBackStack(addDeviceBaseFragment.getClass().getName());
        } else {
            beginTransaction.addToBackStack(null);
        }
        beginTransaction.commitAllowingStateLoss();
    }
}