导航菜单

页面标题

页面副标题

BodyTech v7.6.4 - PerkvilleMainFragment.java 源代码

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

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


package com.fitnessmobileapps.fma.views.fragments;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Transformation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.navigation.fragment.FragmentKt;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.fitnessmobileapps.bodytech39559.R;
import com.fitnessmobileapps.fma.model.GetBalanceResponse;
import com.fitnessmobileapps.fma.model.PKVEntity;
import com.fitnessmobileapps.fma.model.PKVGetPerksResponse;
import com.fitnessmobileapps.fma.model.Perk;
import com.fitnessmobileapps.fma.model.enums.PerkSortOrder;
import com.fitnessmobileapps.fma.model.filters.PerkFilters;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

public class PerkvilleMainFragment extends PerkvilleFragment {
    private m6.b A;
    private m6.a B;
    private ArrayList<Perk> C;
    private Perk G;
    private PKVEntity H;
    private Button I;

    private ViewGroup f10761n;

    private ViewGroup f10762p;

    private ProgressBar f10763q;

    private TextView f10764r;

    private TextView f10765t;

    private TextView f10766v;

    private TextView f10767w;

    private TextView f10768x;

    private ImageView f10769y;

    private ImageView f10770z;

    class a extends Animation {

        final int f10771c;

        a(int i10) {
            this.f10771c = i10;
        }

        @Override
        protected void applyTransformation(float f10, Transformation transformation) {
            PerkvilleMainFragment.this.O((int) (this.f10771c * f10));
        }
    }

    private void F(int i10) {
        a aVar = new a(i10);
        aVar.setFillAfter(true);
        aVar.setInterpolator(new DecelerateInterpolator());
        aVar.setDuration(1500L);
        aVar.setAnimationListener(new b(i10));
        this.f10763q.startAnimation(aVar);
    }

    private void G(final String str, final String str2) {
        m6.b bVar = this.A;
        if (bVar != null) {
            bVar.cancel();
        }
        m6.b bVar2 = new m6.b(str, str2, new Response.Listener() {
            @Override
            public final void onResponse(Object obj) {
                PerkvilleMainFragment.this.J(str, str2, (PKVGetPerksResponse) obj);
            }
        }, new Response.ErrorListener() {
            @Override
            public final void onErrorResponse(VolleyError volleyError) {
                PerkvilleMainFragment.this.K(volleyError);
            }
        });
        this.A = bVar2;
        bVar2.h();
    }

    private void H(String str, String str2) {
        m6.a aVar = this.B;
        if (aVar != null) {
            aVar.cancel();
        }
        m6.a aVar2 = new m6.a(str, str2, new Response.Listener() {
            @Override
            public final void onResponse(Object obj) {
                PerkvilleMainFragment.this.L((GetBalanceResponse) obj);
            }
        }, new Response.ErrorListener() {
            @Override
            public final void onErrorResponse(VolleyError volleyError) {
                PerkvilleMainFragment.this.M(volleyError);
            }
        });
        this.B = aVar2;
        aVar2.h();
    }

    public void N(Button button) {
        if (button.getId() == R.id.earning) {
            FragmentKt.findNavController(this).navigate(u.INSTANCE.b((Perk[]) this.C.toArray(new Perk[0])));
            return;
        }
        if (button.getId() == R.id.refer_friends) {
            FragmentKt.findNavController(this).navigate(u.INSTANCE.a((Perk[]) this.C.toArray(new Perk[0])));
        } else if (button.getId() == R.id.vouchers) {
            FragmentKt.findNavController(this).navigate(u.INSTANCE.e());
        } else if (button.getId() == R.id.redeem) {
            FragmentKt.findNavController(this).navigate(u.INSTANCE.c((Perk[]) this.C.toArray(new Perk[0]), this.H));
        }
    }

    public void J(String str, String str2, PKVGetPerksResponse pKVGetPerksResponse) {
        if (pKVGetPerksResponse == null) {
            getDialogHelper().z(getString(R.string.dialog_error_title), new Throwable(getString(R.string.server_data_error)));
            this.f10770z.setVisibility(8);
            this.f10761n.setVisibility(8);
            return;
        }
        if (pKVGetPerksResponse.isSuccess() && pKVGetPerksResponse.getPerks() != null) {
            this.C = new ArrayList<>(pKVGetPerksResponse.getPerks());
            ArrayList arrayList = new ArrayList();
            Iterator<Perk> it = this.C.iterator();
            while (it.hasNext()) {
                Perk next = it.next();
                if (PerkFilters.filterValues(next)) {
                    it.remove();
                } else if (next.isRedeem()) {
                    arrayList.add(next);
                }
            }
            Collections.sort(arrayList, PerkSortOrder.POINT_ASC.getComparator());
            if (arrayList.size() > 0) {
                this.G = (Perk) arrayList.get(0);
            } else {
                this.G = null;
            }
        }
        H(str, str2);
    }

    public void K(VolleyError volleyError) {
        getDialogHelper().B(volleyError);
    }

    public void L(GetBalanceResponse getBalanceResponse) {
        this.B = null;
        if (getBalanceResponse != null && getBalanceResponse.isSuccess()) {
            PKVEntity entity = getBalanceResponse.getEntity();
            this.H = entity;
            if (entity.isActive()) {
                P();
                return;
            }
        }
        FragmentKt.findNavController(this).navigate(u.INSTANCE.d());
    }

    public void M(VolleyError volleyError) {
        getDialogHelper().B(volleyError);
    }

    public void O(int i10) {
        this.f10763q.setProgress(i10);
        if (i10 < 20) {
            i10 = 0;
        }
        ((LinearLayout.LayoutParams) this.f10764r.getLayoutParams()).weight = i10;
        this.f10764r.requestLayout();
    }

    protected void P() {
        this.f10762p.setVisibility(0);
        this.f10761n.setVisibility(8);
        this.f10770z.setVisibility(8);
        Perk perk = this.G;
        int points = perk != null ? perk.getPoints() : 0;
        int balance = this.H.getBalance();
        int i10 = points - balance;
        float f10 = (balance / points) * 100.0f;
        this.f10765t.setText(String.valueOf(balance));
        this.f10766v.setText(String.format("%1$s %2$s", this.H.getFirstName(), this.H.getLastName()));
        this.f10767w.setText(this.H.getEmail());
        this.f10764r.setText(getString(R.string.pkv_perks_pts, String.valueOf(balance)));
        if (this.G == null) {
            O(0);
            this.f10769y.setVisibility(8);
            this.f10768x.setText(R.string.pkv_no_perks_available);
            this.I.setVisibility(8);
            return;
        }
        if (i10 <= 0) {
            this.f10768x.setText(getString(R.string.pkv_enough_to_redeem));
            this.f10769y.setVisibility(8);
            this.I.setVisibility(0);
            F(100);
            return;
        }
        this.f10768x.setText(getString(R.string.pkv_perks_pts_until, String.valueOf(i10), this.G.getTitle()));
        this.f10769y.setVisibility(0);
        this.I.setVisibility(0);
        F((int) f10);
    }

    @Override
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View inflate = layoutInflater.inflate(R.layout.fragment_perkville_main, viewGroup, false);
        this.f10761n = (ViewGroup) inflate.findViewById(R.id.perkville_loading);
        this.f10762p = (ViewGroup) inflate.findViewById(R.id.perkville_main);
        this.f10763q = (ProgressBar) inflate.findViewById(R.id.pkv_progress);
        this.f10764r = (TextView) inflate.findViewById(R.id.pkv_progress_points);
        this.f10765t = (TextView) inflate.findViewById(R.id.pkv_points);
        this.f10766v = (TextView) inflate.findViewById(R.id.pkv_name);
        this.f10767w = (TextView) inflate.findViewById(R.id.pkv_email);
        this.f10768x = (TextView) inflate.findViewById(R.id.pkv_available_perk);
        this.f10769y = (ImageView) inflate.findViewById(R.id.pkv_arrow);
        this.f10770z = (ImageView) inflate.findViewById(R.id.pkv_success);
        int color = ContextCompat.getColor(inflate.getContext(), R.color.successAction);
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                PerkvilleMainFragment.this.N(view);
            }
        };
        Button button = (Button) inflate.findViewById(R.id.earning);
        com.fitnessmobileapps.fma.util.v.a(button, color);
        button.setOnClickListener(onClickListener);
        Button button2 = (Button) inflate.findViewById(R.id.refer_friends);
        com.fitnessmobileapps.fma.util.v.a(button2, color);
        button2.setOnClickListener(onClickListener);
        Button button3 = (Button) inflate.findViewById(R.id.vouchers);
        com.fitnessmobileapps.fma.util.v.a(button3, color);
        button3.setOnClickListener(onClickListener);
        Button button4 = (Button) inflate.findViewById(R.id.redeem);
        this.I = button4;
        com.fitnessmobileapps.fma.util.v.a(button4, color);
        this.I.setOnClickListener(onClickListener);
        return inflate;
    }

    @Override
    public void onPause() {
        super.onPause();
        m6.a aVar = this.B;
        if (aVar != null) {
            aVar.cancel();
            this.B = null;
        }
        m6.b bVar = this.A;
        if (bVar != null) {
            bVar.cancel();
            this.A = null;
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        this.f10762p.setVisibility(8);
        this.f10761n.setVisibility(0);
        G(h1.a.k(getContext()).g(), x().a(""));
    }

    class b implements Animation.AnimationListener {

        final int f10773a;

        b(int i10) {
            this.f10773a = i10;
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (this.f10773a == 100) {
                PerkvilleMainFragment.this.f10770z.setVisibility(0);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationStart(Animation animation) {
        }
    }
}