Active IQ v6.7.1版本的 MD5 值为:5082594ca2b69fbfbe64e6d6ee2159a7

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


package com.netapp.myautosupport.presentation.systems.bestpractices;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.netapp.myautosupport.R;
import com.netapp.myautosupport.adapters.BestPracticesListAdapter;
import com.netapp.myautosupport.adapters.itemdecorator.ListItemDecorator;
import com.netapp.myautosupport.common.AppConstants;
import com.netapp.myautosupport.common.SharedPreferenceHandle;
import com.netapp.myautosupport.databinding.FragmentEfficiencyBinding;
import com.netapp.myautosupport.fragments.WebViewFragment;
import com.netapp.myautosupport.models.BestPractice;
import com.netapp.myautosupport.presentation.base.BaseFragment;
import com.netapp.myautosupport.presentation.clusters.ClusterFragment;
import com.netapp.myautosupport.presentation.home.CustomerFragment;
import com.netapp.myautosupport.presentation.main.MainActivity;
import com.netapp.myautosupport.presentation.sites.SiteDetailFragment;
import com.netapp.myautosupport.presentation.systems.SystemDetailFragment;
import com.netapp.myautosupport.presentation.systems.SystemListFragment;
import com.netapp.myautosupport.presentation.systems.bestpractices.EfficiencyContract;
import com.netapp.myautosupport.remote.ClusterService;
import com.netapp.myautosupport.remote.SystemService;
import com.netapp.myautosupport.services.ServiceGenerator;
import java.util.ArrayList;
import java.util.HashMap;
public class EfficiencyFragment extends BaseFragment implements EfficiencyContract.View {
    private static final String TAG = "EfficiencyFragment";
    private String clusterID;
    private String cookie;
    private HashMap<String, String> dataMap;
    private EfficiencyPresenter efficiencyPresenter;
    private BestPracticesListAdapter mAdapter;
    private String mBackHeaderTitle;
    private FragmentEfficiencyBinding mBinding;
    private RecyclerView.LayoutManager mLayoutManager;
    private String previousPage;
    private String previousTitle = "";
    private String serialNo;
    private SharedPreferenceHandle sharedPreferenceHandle;
    private String systemID;

    public static EfficiencyFragment newInstance(String str, HashMap<String, String> hashMap) {
        EfficiencyFragment efficiencyFragment = new EfficiencyFragment();
        Bundle bundle = new Bundle();
        bundle.putString(AppConstants.PREVIOUS_TITLE, str);
        bundle.putSerializable("dataMap", hashMap);
        efficiencyFragment.setArguments(bundle);
        return efficiencyFragment;
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (getArguments() != null) {
            this.dataMap = (HashMap) getArguments().getSerializable("dataMap");
            this.previousPage = getArguments().getString(AppConstants.PREVIOUS_TITLE);
            HashMap<String, String> hashMap = this.dataMap;
            if (hashMap != null) {
                this.mBackHeaderTitle = hashMap.get(AppConstants.DASHBOARD_OR_CUSTOMER_NAME);
            }
        }
    }

    @Override
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.mBinding = (FragmentEfficiencyBinding) DataBindingUtil.inflate(layoutInflater, R.layout.fragment_efficiency, viewGroup, false);
        View root = this.mBinding.getRoot();
        this.sharedPreferenceHandle = SharedPreferenceHandle.getSharedPreferenceHandle(this.activity);
        this.activity.logEvent("Efficiency Page");
        firstTimeLoginEfficiencyAlert();
        this.mBinding.fragmentEfficiencyPracticesImplemented1Tv.setMovementMethod(LinkMovementMethod.getInstance());
        this.mBinding.fragmentEfficiencyPracticesImplemented1Tv.setText(getWebLinkString(this.mBinding.fragmentEfficiencyPracticesImplemented1Tv.getText().toString()), TextView.BufferType.SPANNABLE);
        this.mBinding.fragmentEfficiencyPracticesImplemented1Tv.setSelected(true);
        this.mBinding.fragmentEfficiencyPracticesListRv.setHasFixedSize(true);
        this.mLayoutManager = new LinearLayoutManager(getActivity());
        this.mBinding.fragmentEfficiencyPracticesListRv.setLayoutManager(this.mLayoutManager);
        this.mBinding.fragmentEfficiencyPracticesListRv.addItemDecoration(new ListItemDecorator(getContext(), 1));
        this.efficiencyPresenter = new EfficiencyPresenter((ClusterService) ServiceGenerator.createService(ClusterService.class), (SystemService) ServiceGenerator.createService(SystemService.class));
        this.efficiencyPresenter.attachView(this);
        this.mBinding.setEfficiency(this.dataMap.get(AppConstants.EFFICIENCY));
        this.mBinding.setEfficiencyWOClone(this.dataMap.get(AppConstants.EFFICIENCY_WITHOUT_CLONE));
        if (this.utils.isNetworkAvailable(this.activity)) {
            String str = this.previousPage;
            if (str != null && str.equalsIgnoreCase(ClusterFragment.class.getSimpleName())) {
                this.efficiencyPresenter.bestPracticesForCluster(this.dataMap.get(AppConstants.CLUSTER_ID));
            } else {
                String str2 = this.previousPage;
                if (str2 != null && str2.equalsIgnoreCase(SystemDetailFragment.class.getSimpleName())) {
                    this.efficiencyPresenter.bestPracticesForSystem(this.dataMap.get(AppConstants.SYSTEM_SERIAL_NO), this.dataMap.get(AppConstants.SYSTEM_ID));
                }
            }
        } else {
            this.utils.showDialogWithOneButton(this.activity, AppConstants.CHECK_INTERNET_MSG);
        }
        if (this.activity.getToolbarTitleVisibility() == 0) {
            this.previousTitle = this.activity.getToolbarTitleText();
        }
        return root;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.activity = (MainActivity) context;
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    @Override
    @RequiresApi(api = 21)
    public void success(ArrayList<BestPractice> arrayList) {
        if (arrayList.size() > 0) {
            this.mAdapter = new BestPracticesListAdapter(arrayList, this.activity);
            this.mBinding.fragmentEfficiencyPracticesListRv.setAdapter(this.mAdapter);
        } else {
            this.mBinding.fragmentEfficiencyPracticesImplementedTv.setVisibility(0);
            this.mBinding.fragmentEfficiencyPracticesImplemented1Tv.setVisibility(0);
        }
        this.mBinding.fragmentEfficiencyEfficiencyWithoutCloneContainerRl.setOnTouchListener(new View.OnTouchListener() {
            int downX;
            int upX;

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (motionEvent.getAction() == 0) {
                    this.downX = (int) motionEvent.getX();
                    return true;
                } else if (motionEvent.getAction() == 1) {
                    this.upX = (int) motionEvent.getX();
                    if (this.upX - this.downX > 200) {
                        EfficiencyFragment.this.expandEfficiencyAnimation();
                    }
                    return true;
                } else {
                    return false;
                }
            }
        });
        this.mBinding.fragmentEfficiencyEfficiencyContainerRl.setOnTouchListener(new View.OnTouchListener() {
            int downX;
            int upX;

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                if (motionEvent.getAction() == 0) {
                    this.downX = (int) motionEvent.getX();
                    return true;
                } else if (motionEvent.getAction() == 1) {
                    this.upX = (int) motionEvent.getX();
                    int i = this.upX;
                    int i2 = this.downX;
                    if (i - i2 <= 100 && i2 - i > -100 && i2 > i + 10) {
                        EfficiencyFragment.this.expandEfficiencyWithoutCloneAnimation();
                    }
                    return true;
                } else {
                    return false;
                }
            }
        });
    }

    public void expandEfficiencyWithoutCloneAnimation() {
        ViewWeightWrapper viewWeightWrapper = new ViewWeightWrapper(this.mBinding.fragmentEfficiencyEfficiencyContainerRl);
        ViewWeightWrapper viewWeightWrapper2 = new ViewWeightWrapper(this.mBinding.fragmentEfficiencyEfficiencyWithoutCloneContainerRl);
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(viewWeightWrapper, "weight", 19.0f, 1.0f);
        ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(viewWeightWrapper2, "weight", 1.0f, 19.0f);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(100L);
        animatorSet.play(ofFloat).with(ofFloat2);
        animatorSet.start();
        this.mBinding.fragmentEfficiencyEfficiencyTv.setAlpha(0.0f);
        this.mBinding.fragmentEfficiencyEfficiencyWithoutCloneTv.setAlpha(1.0f);
    }

    public void expandEfficiencyAnimation() {
        ViewWeightWrapper viewWeightWrapper = new ViewWeightWrapper(this.mBinding.fragmentEfficiencyEfficiencyContainerRl);
        ViewWeightWrapper viewWeightWrapper2 = new ViewWeightWrapper(this.mBinding.fragmentEfficiencyEfficiencyWithoutCloneContainerRl);
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(viewWeightWrapper, "weight", 1.0f, 19.0f);
        ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(viewWeightWrapper2, "weight", 19.0f, 1.0f);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(100L);
        animatorSet.play(ofFloat).with(ofFloat2);
        animatorSet.start();
        this.mBinding.fragmentEfficiencyEfficiencyTv.setAlpha(1.0f);
        this.mBinding.fragmentEfficiencyEfficiencyWithoutCloneTv.setAlpha(0.0f);
    }

    @Override
    public void onResume() {
        super.onResume();
        this.activity.updateToolbarTitle(this.mBackHeaderTitle);
        String str = TAG;
        Log.d(str, "onResume: " + this.previousPage);
        String str2 = this.previousPage;
        if (str2 != null && str2.equalsIgnoreCase(CustomerFragment.class.getSimpleName())) {
            this.activity.enableBackButton(true, SystemListFragment.class.getSimpleName());
            this.activity.updateToolbarTitle(this.mBackHeaderTitle);
            return;
        }
        String str3 = this.previousPage;
        if (str3 != null && str3.equalsIgnoreCase(SiteDetailFragment.class.getSimpleName())) {
            this.activity.enableBackButton(true, SystemListFragment.class.getSimpleName());
            this.activity.updateToolbarTitle(this.mBackHeaderTitle);
            return;
        }
        String str4 = this.previousPage;
        if (str4 != null && str4.equalsIgnoreCase(ClusterFragment.class.getSimpleName())) {
            this.activity.enableBackButton(true, SystemListFragment.class.getSimpleName());
            this.activity.updateToolbarTitle(this.mBackHeaderTitle);
        } else if (this.activity.tabBarFragment.tabHost == null || this.activity.tabBarFragment.tabHost.getCurrentTab() != 4) {
        } else {
            this.activity.updateToolbarTitle(getString(R.string.tab_favorites_title));
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.activity.updateToolbarTitle(this.previousTitle);
    }

    private void circularAnimationOfEfficiency() {
        Math.hypot(this.mBinding.fragmentEfficiencyEfficiencyContainerRl.getWidth(), this.mBinding.fragmentEfficiencyEfficiencyContainerRl.getMeasuredHeight() / 2);
    }

    private SpannableString getWebLinkString(String str) {
        SpannableString spannableString = new SpannableString(str);
        String string = getResources().getString(R.string.kb_article);
        spannableString.setSpan(new ClickableSpan() {
            @Override
            public void onClick(View view) {
                EfficiencyFragment.this.activity.addFragment(R.id.content_main, WebViewFragment.newInstance(EfficiencyFragment.this.previousPage, "https://kb.netapp.com/support/s/article/ka31A00000013KkQAI/How-to-maximize-storage-efficiency-on-All-Flash-FAS-systems-running-ONTAP-9-x", "Boost Efficiency"));
            }
        }, str.indexOf(string), str.indexOf(string) + string.length(), 0);
        spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#0067C5")), str.indexOf(string), str.indexOf(string) + string.length(), 0);
        return spannableString;
    }

    public class ViewWeightWrapper {
        private View view;

        public ViewWeightWrapper(View view) {
            if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) {
                this.view = view;
                return;
            }
            throw new IllegalArgumentException("The view should have LinearLayout as parent");
        }

        public void setWeight(float f) {
            ((LinearLayout.LayoutParams) this.view.getLayoutParams()).weight = f;
            this.view.getParent().requestLayout();
        }

        public float getWeight() {
            return ((LinearLayout.LayoutParams) this.view.getLayoutParams()).weight;
        }
    }

    private void firstTimeLoginEfficiencyAlert() {
        if (this.sharedPreferenceHandle.getString(AppConstants.FIRST_TIME_USER_LOGIN_EFFICIENCY_ALERT, "").equalsIgnoreCase("yes")) {
            this.mBinding.rlFragmentEfficiencyAlertContainer.setVisibility(0);
            this.mBinding.rlFragmentEfficiencyAlertContainer.bringToFront();
            this.mBinding.ivFragmentEfficiencyAlertOkayButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    EfficiencyFragment.this.mBinding.rlFragmentEfficiencyAlertContainer.setVisibility(8);
                    EfficiencyFragment.this.sharedPreferenceHandle.putString(AppConstants.FIRST_TIME_USER_LOGIN_EFFICIENCY_ALERT, "no");
                }
            });
        }
    }
}