导航菜单

页面标题

页面副标题

BodyTech v7.6.4 - d.java 源代码

正在查看: BodyTech v7.6.4 应用的 d.java JAVA 源代码文件

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


package qf;

import android.util.SparseArray;
import androidx.collection.ArrayMap;
import androidx.collection.LongSparseArray;
import androidx.collection.SparseArrayCompat;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.fitnessmobileapps.fma.Application;
import com.fitnessmobileapps.fma.model.GetClientReferralTypesResponse;
import com.fitnessmobileapps.fma.model.GetRequiredClientFieldsResponse;
import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.stmt.Where;
import com.mindbodyonline.data.sqlcontracts.DatabaseHelper;
import com.mindbodyonline.domain.LiabilityRelease;
import com.mindbodyonline.domain.Location;
import com.mindbodyonline.domain.Rating;
import com.mindbodyonline.domain.UserSite;
import com.mindbodyonline.domain.WorldRegionCountry;
import com.mindbodyonline.domain.WorldRegionProvince;
import com.mindbodyonline.domain.dataModels.GiftCard;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.WeakHashMap;
import java.util.concurrent.TimeUnit;
import n6.l;

public class d {
    private static final String j = "d";
    private static final d k = new d();
    private static final long l = TimeUnit.DAYS.toMillis(30);
    private static final long m;
    private static final long n;
    private static final long o;
    private static DatabaseHelper p;
    private final SparseArray<Location> a = new SparseArray<>();
    private final SparseArray<SparseArray<Location>> b = new SparseArray<>();
    private final LongSparseArray<Rating> c = new LongSparseArray<>();
    private final SparseArrayCompat<SparseArray<List<GiftCard>>> d = new SparseArrayCompat<>();
    private final ArrayMap<String, List<WorldRegionProvince>> e = new ArrayMap<>();
    private final ArrayList<WorldRegionCountry> f = new ArrayList<>();
    private final WeakHashMap<Integer, LiabilityRelease> g = new WeakHashMap<>();
    private final WeakHashMap<Integer, GetRequiredClientFieldsResponse> h = new WeakHashMap<>();
    private final WeakHashMap<Integer, GetClientReferralTypesResponse> i = new WeakHashMap<>();

    class a implements Response.Listener<WorldRegionProvince[]> {
        final WorldRegionCountry c;
        final Response.Listener d;

        a(WorldRegionCountry worldRegionCountry, Response.Listener listener) {
            this.c = worldRegionCountry;
            this.d = listener;
        }

        public void onResponse(WorldRegionProvince[] worldRegionProvinceArr) {
            List asList = Arrays.asList(worldRegionProvinceArr);
            d.this.T(this.c, asList);
            Response.Listener listener = this.d;
            if (listener != null) {
                listener.onResponse(asList);
            }
        }
    }

    class b implements Response.Listener<LiabilityRelease> {
        final Integer c;
        final Response.Listener d;

        b(Integer num, Response.Listener listener) {
            this.c = num;
            this.d = listener;
        }

        public void onResponse(LiabilityRelease liabilityRelease) {
            d.this.h(this.c, liabilityRelease);
            Response.Listener listener = this.d;
            if (listener != null) {
                listener.onResponse(liabilityRelease);
            }
        }
    }

    class c implements Response.ErrorListener {
        final Response.ErrorListener c;

        c(Response.ErrorListener errorListener) {
            this.c = errorListener;
        }

        public void onErrorResponse(VolleyError volleyError) {
            Response.ErrorListener errorListener = this.c;
            if (errorListener != null) {
                errorListener.onErrorResponse(volleyError);
            }
        }
    }

    class C0142d implements Response.ErrorListener {
        final Response.ErrorListener c;

        C0142d(Response.ErrorListener errorListener) {
            this.c = errorListener;
        }

        public void onErrorResponse(VolleyError volleyError) {
            Response.ErrorListener errorListener = this.c;
            if (errorListener != null) {
                errorListener.onErrorResponse(volleyError);
            }
        }
    }

    class e implements Response.Listener<GetRequiredClientFieldsResponse> {
        final Integer c;
        final Response.Listener d;

        e(Integer num, Response.Listener listener) {
            this.c = num;
            this.d = listener;
        }

        public void onResponse(GetRequiredClientFieldsResponse getRequiredClientFieldsResponse) {
            d.this.k(this.c, getRequiredClientFieldsResponse);
            Response.Listener listener = this.d;
            if (listener != null) {
                listener.onResponse(getRequiredClientFieldsResponse);
            }
        }
    }

    class f implements Response.ErrorListener {
        final Response.ErrorListener c;

        f(Response.ErrorListener errorListener) {
            this.c = errorListener;
        }

        public void onErrorResponse(VolleyError volleyError) {
            Response.ErrorListener errorListener = this.c;
            if (errorListener != null) {
                errorListener.onErrorResponse(volleyError);
            }
        }
    }

    class g implements Response.Listener<GetClientReferralTypesResponse> {
        final Integer c;
        final Response.Listener d;

        g(Integer num, Response.Listener listener) {
            this.c = num;
            this.d = listener;
        }

        public void onResponse(GetClientReferralTypesResponse getClientReferralTypesResponse) {
            d.this.f(this.c, getClientReferralTypesResponse);
            Response.Listener listener = this.d;
            if (listener != null) {
                listener.onResponse(getClientReferralTypesResponse);
            }
        }
    }

    static {
        TimeUnit timeUnit = TimeUnit.HOURS;
        m = timeUnit.toMillis(1L);
        n = timeUnit.toMillis(1L);
        o = timeUnit.toMillis(1L);
    }

    private d() {
    }

    public static int A(List<WorldRegionCountry> list) {
        String str;
        String str2;
        boolean z;
        int i;
        h1.a c2 = Application.d().c();
        if (c2.n() != null) {
            str = c2.n().getLocationCountryCode();
            str2 = c2.n().getStudioCountryCode();
        } else {
            str = null;
            str2 = null;
        }
        if (str != null && !str.isEmpty()) {
            str2 = str;
        } else if (str2 == null || str2.isEmpty()) {
            str2 = Locale.getDefault().getCountry();
        }
        if (!str2.isEmpty()) {
            Iterator<WorldRegionCountry> it = list.iterator();
            i = 0;
            while (true) {
                if (!it.hasNext()) {
                    z = false;
                    break;
                }
                if (str2.equals(it.next().getCode())) {
                    z = true;
                    break;
                }
                i++;
            }
        } else {
            z = false;
            i = 0;
        }
        if (z) {
            return i;
        }
        return 0;
    }

    private List<GiftCard> C(int i, t2.a aVar) {
        try {
            Dao<GiftCard, Integer> giftCardsDao = p.getGiftCardsDao();
            QueryBuilder<GiftCard, Integer> queryBuilder = giftCardsDao.queryBuilder();
            Where<GiftCard, Integer> where = queryBuilder.where();
            where.eq(GiftCard.SITE_ID_FIELD_NAME, Integer.valueOf(i));
            where.and();
            where.eq("userId", Integer.valueOf(aVar.g()));
            return giftCardsDao.query(queryBuilder.prepare());
        } catch (SQLException e2) {
            jf.a.c(j, "Unable to get giftcards from disk", e2);
            return null;
        }
    }

    private List<GiftCard> D(int i, t2.a aVar) {
        SparseArray sparseArray = (SparseArray) this.d.get(aVar.g());
        if (sparseArray != null) {
            return (List) sparseArray.get(i);
        }
        return null;
    }

    public static d E() {
        if (p == null) {
            p = (DatabaseHelper) OpenHelperManager.getHelper(Application.d(), DatabaseHelper.class);
        }
        return k;
    }

    private void L(String str) {
        Application.d().getSharedPreferences("FMAPref", 0).edit().putLong(str, 0L).apply();
    }

    private boolean M(long j2, long j3) {
        return j2 + j3 < new Date().getTime();
    }

    public void N(Response.Listener listener, WorldRegionCountry[] worldRegionCountryArr) {
        List<WorldRegionCountry> asList = worldRegionCountryArr != null ? Arrays.asList(worldRegionCountryArr) : Collections.EMPTY_LIST;
        S(asList);
        listener.onResponse(asList);
    }

    private void O(final Response.Listener<List<WorldRegionCountry>> listener, Response.ErrorListener errorListener) {
        qf.f.n().s().d(new Response.Listener() {
            public final void onResponse(Object obj) {
                d.this.N(listener, (WorldRegionCountry[]) obj);
            }
        }, errorListener);
    }

    private void Q(String str) {
        Application.d().getSharedPreferences("FMAPref", 0).edit().putLong(str, new Date().getTime()).apply();
    }

    public void T(WorldRegionCountry worldRegionCountry, List<WorldRegionProvince> list) {
        if (worldRegionCountry != null) {
            this.e.put(worldRegionCountry.getCode(), list);
        }
    }

    public void f(Integer num, GetClientReferralTypesResponse getClientReferralTypesResponse) {
        Q("referral_cache_date");
        this.i.put(num, getClientReferralTypesResponse);
    }

    private void g(List<WorldRegionCountry> list) {
        try {
            Dao<WorldRegionCountry, Integer> countriesDao = p.getCountriesDao();
            if (list != null) {
                Iterator<WorldRegionCountry> it = list.iterator();
                while (it.hasNext()) {
                    countriesDao.createIfNotExists(it.next());
                }
            }
            Q("country_cache_date");
        } catch (Exception e2) {
            jf.a.c(j, "DB Error adding countries to cache", e2);
        }
    }

    public void h(Integer num, LiabilityRelease liabilityRelease) {
        Q("liability_release_cache_date");
        this.g.put(num, liabilityRelease);
    }

    public void k(Integer num, GetRequiredClientFieldsResponse getRequiredClientFieldsResponse) {
        Q("required_fields_cache_date");
        this.h.put(num, getRequiredClientFieldsResponse);
    }

    private boolean m(GiftCard giftCard) {
        try {
            Dao.CreateOrUpdateStatus createOrUpdate = p.getGiftCardsDao().createOrUpdate(giftCard);
            if (!createOrUpdate.isCreated()) {
                if (!createOrUpdate.isUpdated()) {
                    return false;
                }
            }
            return true;
        } catch (SQLException e2) {
            jf.a.c(j, "Unable to add or update giftcard from disk", e2);
            return false;
        }
    }

    private boolean n(GiftCard giftCard) {
        SparseArray sparseArray = (SparseArray) this.d.get(giftCard.getUserId());
        if (sparseArray == null) {
            SparseArray sparseArray2 = new SparseArray();
            ArrayList arrayList = new ArrayList();
            arrayList.add(giftCard);
            sparseArray2.append(giftCard.getSiteID(), arrayList);
            this.d.append(giftCard.getUserId(), sparseArray2);
            return true;
        }
        List list = (List) sparseArray.get(giftCard.getSiteID());
        if (list != null) {
            if (list.contains(giftCard)) {
                return false;
            }
            list.add(giftCard);
            return true;
        }
        ArrayList arrayList2 = new ArrayList();
        arrayList2.add(giftCard);
        sparseArray.append(giftCard.getSiteID(), arrayList2);
        return true;
    }

    private void o() {
        try {
            Dao<WorldRegionCountry, Integer> countriesDao = p.getCountriesDao();
            countriesDao.delete(countriesDao.queryForAll());
            L("country_cache_date");
        } catch (Exception e2) {
            jf.a.c(j, "DB error clearing country cache", e2);
        }
    }

    private void r() {
        try {
            Dao<UserSite, Integer> userSiteDao = p.getUserSiteDao();
            userSiteDao.delete(userSiteDao.queryForAll());
            mo.a.d("Deleted user sites from DB", new Object[0]);
            L("user_sites_cache_date");
        } catch (Exception e2) {
            mo.a.g(e2, "DB error clearing user sites cache", new Object[0]);
        }
    }

    private void t(GiftCard giftCard) {
        try {
            p.getGiftCardsDao().delete((Dao<GiftCard, Integer>) giftCard);
        } catch (SQLException e2) {
            jf.a.c(j, "Unable to delete giftcards from disk", e2);
        }
    }

    private void u(GiftCard giftCard) {
        List list;
        SparseArray sparseArray = (SparseArray) this.d.get(giftCard.getUserId());
        if (sparseArray == null || (list = (List) sparseArray.get(giftCard.getSiteID())) == null) {
            return;
        }
        list.remove(giftCard);
    }

    private long v(String str) {
        return Application.d().getSharedPreferences("FMAPref", 0).getLong(str, 0L);
    }

    private List<WorldRegionCountry> z() {
        if (this.f.isEmpty()) {
            return null;
        }
        return this.f;
    }

    public List<GiftCard> B(int i, t2.a aVar) {
        List<GiftCard> D = D(i, aVar);
        if (D != null) {
            return D;
        }
        List<GiftCard> C = C(i, aVar);
        if (C != null) {
            Iterator<GiftCard> it = C.iterator();
            while (it.hasNext()) {
                n(it.next());
            }
        }
        return C;
    }

    public void F(Integer num, Response.Listener<LiabilityRelease> listener, Response.ErrorListener errorListener) {
        if (!this.g.containsKey(num) || M(v("liability_release_cache_date"), m)) {
            qf.f.n().q().c(num.intValue(), new b(num, listener), new c(errorListener));
        } else if (listener != null) {
            listener.onResponse(this.g.get(num));
        }
    }

    public List<Location> G(int i) {
        SparseArray<Location> sparseArray = this.b.get(i);
        if (sparseArray == null) {
            return Collections.emptyList();
        }
        ArrayList arrayList = new ArrayList(sparseArray.size());
        int size = sparseArray.size();
        for (int i2 = 0; i2 < size; i2++) {
            arrayList.add(sparseArray.valueAt(i2));
        }
        return arrayList;
    }

    public void H(WorldRegionCountry worldRegionCountry, Response.Listener<List<WorldRegionProvince>> listener, Response.ErrorListener errorListener) {
        if (worldRegionCountry != null) {
            List list = (List) this.e.get(worldRegionCountry.getCode());
            if (list == null) {
                qf.f.n().s().f(worldRegionCountry, new a(worldRegionCountry, listener), errorListener);
            } else if (listener != null) {
                listener.onResponse(list);
            }
        }
    }

    public Rating I(long j2) {
        return (Rating) this.c.get(j2);
    }

    public void J(Integer num, Response.Listener<GetRequiredClientFieldsResponse> listener, Response.ErrorListener errorListener) {
        if (!this.h.containsKey(num) || M(v("required_fields_cache_date"), n)) {
            new l(new C0142d(errorListener), new e(num, listener)).i();
        } else if (listener != null) {
            listener.onResponse(this.h.get(num));
        }
    }

    public boolean K(int i) {
        return this.b.indexOfKey(i) >= 0;
    }

    public void P(long j2) {
        this.c.remove(j2);
    }

    public void R(Rating[] ratingArr) {
        p();
        if (ratingArr != null) {
            for (Rating rating : ratingArr) {
                this.c.put(rating.getVisitId(), rating);
            }
        }
    }

    public synchronized void S(List<WorldRegionCountry> list) {
        o();
        g(list);
    }

    public void i(Location location) {
        int siteId = location.getSiteId();
        this.a.put(location.getId(), location);
        SparseArray<Location> sparseArray = this.b.get(siteId);
        if (sparseArray == null) {
            sparseArray = new SparseArray<>();
            this.b.put(siteId, sparseArray);
        }
        sparseArray.put(location.getSiteLocationId(), location);
    }

    public void j(Collection<Location> collection) {
        Iterator<Location> it = collection.iterator();
        while (it.hasNext()) {
            i(it.next());
        }
    }

    public boolean l(GiftCard giftCard) {
        return m(giftCard);
    }

    public void p() {
        this.c.clear();
    }

    public void q() {
        p();
        r();
        Application.d().getSharedPreferences("FMAPref", 0).edit().remove("PREFERENCE_USER_SKIPPED_REQUIRED_FIELDS").apply();
    }

    public void s(GiftCard giftCard) {
        u(giftCard);
        t(giftCard);
    }

    public void w(Integer num, Response.Listener<GetClientReferralTypesResponse> listener, Response.ErrorListener errorListener) {
        if (!this.i.containsKey(num) || M(v("referral_cache_date"), o)) {
            new n6.g(new f(errorListener), new g(num, listener)).i();
        } else if (listener != null) {
            listener.onResponse(this.i.get(num));
        }
    }

    public void x(Response.Listener<List<WorldRegionCountry>> listener, Response.ErrorListener errorListener) {
        if (M(v("country_cache_date"), l)) {
            O(listener, errorListener);
            return;
        }
        List<WorldRegionCountry> z = z();
        if (z == null) {
            z = y();
        }
        if (z.size() < 10) {
            O(listener, errorListener);
        } else {
            listener.onResponse(z);
        }
    }

    public List<WorldRegionCountry> y() {
        try {
            Dao<WorldRegionCountry, Integer> countriesDao = p.getCountriesDao();
            if (countriesDao == null) {
                jf.a.b(j, "getCountriesDao was NULL");
                return Collections.EMPTY_LIST;
            }
            QueryBuilder<WorldRegionCountry, Integer> queryBuilder = countriesDao.queryBuilder();
            queryBuilder.orderBy("dbId", true);
            return countriesDao.query(queryBuilder.prepare());
        } catch (Exception e2) {
            jf.a.c(j, "DB error getting country cache", e2);
            return Collections.EMPTY_LIST;
        }
    }
}