Active IQ v6.7.1版本的 MD5 值为:5082594ca2b69fbfbe64e6d6ee2159a7
以下内容为反编译后的 FlashAdvisorListFragment.java 源代码,内容仅作参考
package com.netapp.myautosupport.presentation.flashadvisor;
import android.app.AlertDialog;
import android.app.Dialog;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.CheckBox;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.netapp.myautosupport.R;
import com.netapp.myautosupport.adapters.FlashAdvisorCheckableAdapter;
import com.netapp.myautosupport.adapters.itemdecorator.ListItemDecorator;
import com.netapp.myautosupport.common.AppConstants;
import com.netapp.myautosupport.common.SharedPreferenceHandle;
import com.netapp.myautosupport.databinding.FragmentFlashAdvisorListBinding;
import com.netapp.myautosupport.fragments.TabBarFragment;
import com.netapp.myautosupport.models.FlashAdvisor;
import com.netapp.myautosupport.presentation.base.BaseFragment;
import com.netapp.myautosupport.presentation.clusters.ClusterFragment;
import com.netapp.myautosupport.presentation.flashadvisor.FlashAdvisorListContract;
import com.netapp.myautosupport.presentation.home.CustomerFragment;
import com.netapp.myautosupport.presentation.main.MainActivity;
import com.netapp.myautosupport.presentation.nagp.NAGPFragment;
import com.netapp.myautosupport.presentation.notificationsdashboard.NotificationsListFragment;
import com.netapp.myautosupport.presentation.sites.SiteDetailFragment;
import com.netapp.myautosupport.remote.FlashAdvisorService;
import com.netapp.myautosupport.services.ServiceGenerator;
import com.netapp.myautosupport.singleton.NotificationInfo;
import com.netapp.myautosupport.singleton.UserInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
public class FlashAdvisorListFragment extends BaseFragment implements FlashAdvisorCheckableAdapter.CheckboxInterface, View.OnClickListener, FlashAdvisorListContract.View {
private static final String PREVIOUS_PAGE = "previousPage";
private FlashAdvisorCheckableAdapter adapter;
private CheckBox cbSelectAllItems;
private String clusterName;
private String customerID;
private FlashAdvisorListPresenter flashAdvisorListPresenter;
private FragmentFlashAdvisorListBinding fragmentRenewalsListBinding;
private boolean isFromAVS;
private boolean isFromNAGP;
private String mAVSResponse;
private Dialog mObjDialog;
private String nagpID;
private String nagpName;
private String previousTitle;
private ArrayList<FlashAdvisor> renewalsList;
private RecyclerView rvRenewalsList;
private SharedPreferenceHandle sharedPreferenceHandle;
private String siteName;
private TextView tvRenewalsTeam;
private final String TAG = FlashAdvisorListFragment.class.getSimpleName();
private Set<Integer> selectedItemPositionSet = new TreeSet();
private String previousPage = "";
private String whichTitleVisible = "";
private String mBackHeaderTitle = "";
public static FlashAdvisorListFragment newInstance(String str, HashMap<String, String> hashMap, JsonObject jsonObject) {
FlashAdvisorListFragment flashAdvisorListFragment = new FlashAdvisorListFragment();
Bundle bundle = new Bundle();
bundle.putString(PREVIOUS_PAGE, str);
if (hashMap.containsKey(AppConstants.CUSTOMER_ID)) {
bundle.putString(AppConstants.CUSTOMER_ID, hashMap.get(AppConstants.CUSTOMER_ID));
bundle.putString(AppConstants.CUSTOMER_NAME, hashMap.get(AppConstants.CUSTOMER_NAME));
bundle.putString(AppConstants.DASHBOARD_OR_CUSTOMER_NAME, hashMap.get(AppConstants.DASHBOARD_OR_CUSTOMER_NAME));
}
if (hashMap.containsKey(AppConstants.NAGP_ID)) {
bundle.putString(AppConstants.NAGP_ID, hashMap.get(AppConstants.NAGP_ID));
bundle.putString(AppConstants.NAGP_NAME, hashMap.get(AppConstants.NAGP_NAME));
bundle.putString(AppConstants.DASHBOARD_OR_CUSTOMER_NAME, hashMap.get(AppConstants.DASHBOARD_OR_CUSTOMER_NAME));
bundle.putBoolean(AppConstants.IS_FROM_NAGP, true);
}
if (jsonObject != null) {
bundle.putBoolean(AppConstants.IS_FROM_AVS, true);
bundle.putString(AppConstants.AVS_RESPONSE, jsonObject.toString());
}
flashAdvisorListFragment.setArguments(bundle);
return flashAdvisorListFragment;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (getArguments() != null) {
Bundle arguments = getArguments();
if (arguments.getString(PREVIOUS_PAGE) != null) {
this.previousPage = arguments.getString(PREVIOUS_PAGE);
}
this.siteName = arguments.getString(AppConstants.SITE_NAME);
this.clusterName = arguments.getString(AppConstants.CLUSTER_NAME);
this.customerID = arguments.getString(AppConstants.CUSTOMER_ID);
this.nagpID = arguments.getString(AppConstants.NAGP_ID);
this.nagpName = arguments.getString(AppConstants.NAGP_NAME);
this.mBackHeaderTitle = arguments.getString(AppConstants.DASHBOARD_OR_CUSTOMER_NAME);
this.isFromNAGP = arguments.getBoolean(AppConstants.IS_FROM_NAGP, false);
this.isFromAVS = arguments.getBoolean(AppConstants.IS_FROM_AVS, false);
this.mAVSResponse = arguments.getString(AppConstants.AVS_RESPONSE, null);
}
if (this.activity.getToolbarTitleVisibility() == 0) {
this.previousTitle = this.activity.getToolbarTitleText();
String str = this.TAG;
Log.d(str, "onCreate: " + this.previousTitle);
}
}
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
this.fragmentRenewalsListBinding = (FragmentFlashAdvisorListBinding) DataBindingUtil.inflate(layoutInflater, R.layout.fragment_flash_advisor_list, viewGroup, false);
View root = this.fragmentRenewalsListBinding.getRoot();
this.flashAdvisorListPresenter = new FlashAdvisorListPresenter((FlashAdvisorService) ServiceGenerator.createService(FlashAdvisorService.class));
this.flashAdvisorListPresenter.attachView(this);
this.activity.logEvent("Flash Advisor");
this.sharedPreferenceHandle = SharedPreferenceHandle.getSharedPreferenceHandle(this.activity);
if (this.sharedPreferenceHandle.getString(AppConstants.USER_TYPE, "").equals(AppConstants.EXTERNAL)) {
this.customerID = this.sharedPreferenceHandle.getString(AppConstants.CUSTOMER_ID, "");
}
initView(root);
if (this.utils.isNetworkAvailable(this.activity)) {
if (this.isFromAVS) {
processesAvsResponse();
} else if (this.isFromNAGP) {
this.flashAdvisorListPresenter.flashAdvisorListForNAGP(this.nagpID);
} else {
this.flashAdvisorListPresenter.flashAdvisorList(this.customerID);
}
} else {
this.utils.showDialogWithOneButton(this.activity, AppConstants.CHECK_INTERNET_MSG);
}
this.whichTitleVisible = this.activity.whichTitleVisible();
this.fragmentRenewalsListBinding.setShowLabel(true);
return root;
}
public void setFlashInfo(String str) {
this.mAVSResponse = str;
processesAvsResponse();
}
private void processesAvsResponse() {
JsonArray processesResponse = processesResponse(this.mAVSResponse);
if (processesResponse.size() > 0) {
success(this.flashAdvisorListPresenter.getFlashData(processesResponse));
this.cbSelectAllItems.setChecked(true);
this.cbSelectAllItems.setEnabled(false);
this.cbSelectAllItems.setVisibility(8);
selectAllItems();
}
}
@Override
public void onViewCreated(View view, @Nullable Bundle bundle) {
super.onViewCreated(view, bundle);
}
private void initView(View view) {
this.tvRenewalsTeam = (TextView) view.findViewById(R.id.fragment_contact_flash_advisor_team_tv);
this.cbSelectAllItems = (CheckBox) view.findViewById(R.id.fragment_flash_advisor_list_select_all_items_cb);
this.rvRenewalsList = (RecyclerView) view.findViewById(R.id.fragment_flash_advisor_list_rv);
view.findViewById(R.id.fragment_flashadvisor_info_img).setOnClickListener(this);
this.cbSelectAllItems.setOnClickListener(this);
this.rvRenewalsList.setLayoutManager(new LinearLayoutManager(this.activity));
this.rvRenewalsList.addItemDecoration(new ListItemDecorator(getContext(), 1));
if (this.isFromNAGP) {
this.tvRenewalsTeam.setText(R.string.contact_flash_team_internal);
} else {
this.tvRenewalsTeam.setText(R.string.contact_flash_team);
}
}
private void selectAllItems() {
ArrayList<FlashAdvisor> arrayList = this.renewalsList;
if (arrayList != null && arrayList.size() != 0) {
ArrayList<FlashAdvisor> arrayList2 = this.renewalsList;
int i = 0;
if (this.cbSelectAllItems.isChecked()) {
checkboxCheckState(true);
Iterator<FlashAdvisor> it = this.renewalsList.iterator();
while (it.hasNext()) {
checkedAt(true, i);
arrayList2.get(this.renewalsList.indexOf(it.next())).setChecked(true);
i++;
}
} else {
checkboxCheckState(false);
Iterator<FlashAdvisor> it2 = this.renewalsList.iterator();
int i2 = 0;
while (it2.hasNext()) {
checkedAt(false, i2);
arrayList2.get(this.renewalsList.indexOf(it2.next())).setChecked(false);
i2++;
}
}
FlashAdvisorCheckableAdapter flashAdvisorCheckableAdapter = this.adapter;
if (flashAdvisorCheckableAdapter == null) {
this.adapter = new FlashAdvisorCheckableAdapter(arrayList2, this.activity, this, this.isFromAVS);
this.rvRenewalsList.setAdapter(this.adapter);
return;
}
flashAdvisorCheckableAdapter.swapArray(arrayList2);
return;
}
this.utils.showDialogWithOneButton(this.activity, getString(R.string.no_items_to_select));
}
private void checkboxCheckState(boolean z) {
if (z) {
this.cbSelectAllItems.setChecked(true);
} else {
this.cbSelectAllItems.setChecked(false);
}
}
@Override
public void checkedAt(boolean z, int i) {
if (z) {
this.selectedItemPositionSet.add(Integer.valueOf(i));
} else {
if (this.selectedItemPositionSet.contains(Integer.valueOf(i))) {
this.selectedItemPositionSet.remove(Integer.valueOf(i));
}
checkboxCheckState(false);
}
if (this.selectedItemPositionSet.size() == this.renewalsList.size()) {
checkboxCheckState(true);
}
if (this.selectedItemPositionSet.size() > 0) {
this.tvRenewalsTeam.setBackgroundColor(ContextCompat.getColor(this.activity, R.color.blue));
this.tvRenewalsTeam.setOnClickListener(this);
return;
}
this.tvRenewalsTeam.setBackgroundColor(ContextCompat.getColor(this.activity, R.color.charcoal_grey_t60));
this.tvRenewalsTeam.setOnClickListener(null);
}
@Override
public void onClick(View view) {
String str;
int id = view.getId();
if (id != R.id.fragment_contact_flash_advisor_team_tv) {
if (id == R.id.fragment_flash_advisor_list_select_all_items_cb) {
selectAllItems();
return;
} else if (id != R.id.fragment_flashadvisor_info_img) {
return;
} else {
displayFlashAdvisorDialog();
return;
}
}
this.activity.logEvent("Renewals - Contact Renewals Team");
String selectedItemsJsonString = getSelectedItemsJsonString(this.selectedItemPositionSet);
String str2 = this.TAG;
Log.e(str2, "onClick: " + selectedItemsJsonString);
if (this.previousPage.equalsIgnoreCase(CustomerFragment.class.getSimpleName())) {
str = this.mBackHeaderTitle;
} else if (this.previousPage.equalsIgnoreCase(MainActivity.class.getSimpleName())) {
str = this.mBackHeaderTitle;
} else if (this.previousPage.equalsIgnoreCase(SiteDetailFragment.class.getSimpleName())) {
str = this.siteName;
} else if (this.previousPage.equalsIgnoreCase(ClusterFragment.class.getSimpleName())) {
str = this.clusterName;
} else if (this.previousPage.equalsIgnoreCase(NotificationsListFragment.class.getSimpleName())) {
str = this.mBackHeaderTitle;
} else {
str = this.mBackHeaderTitle;
}
this.activity.addFragment(R.id.content_main, FlashEmailContentFragment.newInstance(selectedItemsJsonString, str, false, this.isFromNAGP));
}
@Override
public void onResume() {
super.onResume();
this.activity.enableBackButton(true, FlashAdvisorListFragment.class.getSimpleName());
if (this.previousPage.equalsIgnoreCase(CustomerFragment.class.getSimpleName())) {
this.activity.updateToolbarTitle(this.mBackHeaderTitle);
} else if (this.previousPage.equalsIgnoreCase(MainActivity.class.getSimpleName())) {
this.activity.updateToolbarTitle(this.mBackHeaderTitle);
this.activity.enableSearchButton(false);
} else if (this.previousPage.equalsIgnoreCase(TabBarFragment.class.getSimpleName())) {
this.activity.updateToolbarTitle(this.mBackHeaderTitle);
this.activity.enableSearchButton(false);
} else if (this.previousPage.equalsIgnoreCase(SiteDetailFragment.class.getSimpleName())) {
this.activity.updateToolbarTitle(this.siteName);
} else if (this.previousPage.equalsIgnoreCase(ClusterFragment.class.getSimpleName())) {
this.activity.updateToolbarTitle(this.clusterName);
} else if (this.previousPage.equalsIgnoreCase(NotificationsListFragment.class.getSimpleName())) {
this.activity.updateToolbarTitle(this.mBackHeaderTitle);
} else if (this.previousPage.equalsIgnoreCase(NAGPFragment.class.getSimpleName())) {
this.activity.updateToolbarTitle(this.mBackHeaderTitle);
}
}
@Override
public void onDestroy() {
super.onDestroy();
String str = this.previousPage;
if (str != null && str.equalsIgnoreCase(NotificationsListFragment.class.getSimpleName())) {
this.activity.enableBackButton(false, this.TAG);
this.activity.showMainTitle(true, getString(R.string.Notifications_title));
this.activity.enableSearchButton(false);
} else if (this.whichTitleVisible.equalsIgnoreCase(AppConstants.TOOLBAR_LOGO_KEY)) {
this.activity.enableBackButton(false, this.TAG);
this.activity.showMainTitle(false, "");
if (UserInfo.INSTANCE.getCustomerType().equals(AppConstants.INTERNAL)) {
this.activity.enableSearchButton(true);
}
} else if (this.whichTitleVisible.equalsIgnoreCase(AppConstants.TOOLBAR_MAIN_TITLE_KEY)) {
this.activity.enableBackButton(false, this.TAG);
this.activity.showMainTitle(true, this.previousTitle);
} else {
this.activity.updateToolbarTitle(this.previousTitle);
}
}
@Override
public void success(ArrayList<FlashAdvisor> arrayList) {
NotificationInfo.INSTANCE.reset();
this.renewalsList = arrayList;
this.adapter = new FlashAdvisorCheckableAdapter(arrayList, this.activity, this, this.isFromAVS);
this.rvRenewalsList.setAdapter(this.adapter);
}
private String getSelectedItemsJsonString(Set<Integer> set) {
NotificationInfo.INSTANCE.reset();
ArrayList arrayList = new ArrayList();
for (Integer num : set) {
arrayList.add(this.renewalsList.get(num.intValue()));
}
return new Gson().toJson(arrayList, new TypeToken<List<FlashAdvisor>>() {
}.getType());
}
public void updateScreen() {
this.cbSelectAllItems.setChecked(false);
selectAllItems();
}
public void displayFlashAdvisorDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this.activity);
builder.setCancelable(false);
MainActivity mainActivity = this.activity;
MainActivity mainActivity2 = this.activity;
View inflate = ((LayoutInflater) mainActivity.getSystemService("layout_inflater")).inflate(R.layout.dialog_flash_advisor, (ViewGroup) null);
final WebView webView = (WebView) inflate.findViewById(R.id.dialog_flash_advisor_title_wb);
webView.loadUrl("file:///android_asset/html/" + getResources().getString(R.string.getFlashLocale));
webView.setWebViewClient(new WebViewClient() {
@Override
@RequiresApi(api = 21)
public boolean shouldOverrideUrlLoading(WebView webView2, WebResourceRequest webResourceRequest) {
webView2.loadUrl(webResourceRequest.getUrl().toString());
webView2.setBackgroundResource(R.color.white);
return true;
}
@Override
public void onPageFinished(WebView webView2, String str) {
super.onPageFinished(webView2, str);
Log.e(FlashAdvisorListFragment.this.TAG, "onPageFinished: ");
WebView webView3 = webView;
webView3.loadUrl("javascript:document.getElementById('navigationText')style.fontFamily =src:url('file:///android_asset/fonts/Montserrat-Regular.ttf');");
FlashAdvisorListFragment.this.hideLoading();
}
});
builder.setView(inflate);
inflate.findViewById(R.id.dialog_flash_advisor_close_im).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FlashAdvisorListFragment.this.mObjDialog.dismiss();
}
});
this.mObjDialog = builder.create();
this.mObjDialog.show();
}
}