// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.oliodevices.assist.app.fragments; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import butterknife.ButterKnife; import com.olio.util.ALog; import com.oliodevices.assist.app.EulaActivity; import com.oliodevices.assist.app.activities.SetupActivityCallbacks; import com.oliodevices.assist.app.api.ApiCallback; import com.oliodevices.assist.app.api.OlioApi; import com.oliodevices.assist.app.api.UserManager; import com.oliodevices.assist.app.api.models.TokenResponse; import com.oliodevices.assist.app.core.Utils; import com.oliodevices.assist.app.views.SetupInputView; import retrofit.RetrofitError; // Referenced classes of package com.oliodevices.assist.app.fragments: // SetupBaseFragment public class SetupLoginFragment extends SetupBaseFragment { private static final String FORGOT_PASSWORD_URL = "https://api.oliodevices.com/users/password/new"; private static final String PREF_LOGIN_EMAIL = "login_email"; SetupInputView mEmail; private final ApiCallback mLoginCallback = new ApiCallback() { final SetupLoginFragment this$0; public void failure(RetrofitError retrofiterror) { if (!isResumed()) goto _L2; else goto _L1 _L1: mCallbacks.hideProgress(); static class _cls5 { static final int $SwitchMap$retrofit$RetrofitError$Kind[]; static { $SwitchMap$retrofit$RetrofitError$Kind = new int[retrofit.RetrofitError.Kind.values().length]; try { $SwitchMap$retrofit$RetrofitError$Kind[retrofit.RetrofitError.Kind.HTTP.ordinal()] = 1; } catch (NoSuchFieldError nosuchfielderror3) { } try { $SwitchMap$retrofit$RetrofitError$Kind[retrofit.RetrofitError.Kind.CONVERSION.ordinal()] = 2; } catch (NoSuchFieldError nosuchfielderror2) { } try { $SwitchMap$retrofit$RetrofitError$Kind[retrofit.RetrofitError.Kind.NETWORK.ordinal()] = 3; } catch (NoSuchFieldError nosuchfielderror1) { } try { $SwitchMap$retrofit$RetrofitError$Kind[retrofit.RetrofitError.Kind.UNEXPECTED.ordinal()] = 4; } catch (NoSuchFieldError nosuchfielderror) { return; } } } _cls5..SwitchMap.retrofit.RetrofitError.Kind[retrofiterror.getKind().ordinal()]; JVM INSTR tableswitch 1 3: default 60 // 1 82 // 2 96 // 3 109; goto _L3 _L4 _L5 _L6 _L3: retrofiterror = getString(0x7f0600d9); _L8: Utils.showToastMessage(getActivity(), retrofiterror); _L2: return; _L4: retrofiterror = ((TokenResponse)retrofiterror.getBody()).errorDescription; continue; /* Loop/switch isn't completed */ _L5: retrofiterror = getString(0x7f0600d7); continue; /* Loop/switch isn't completed */ _L6: retrofiterror = getString(0x7f0600d8); if (true) goto _L8; else goto _L7 _L7: } public void success() { if (isResumed()) { mCallbacks.hideProgress(); getAllUserSettings(); showEulaActivity(); } } { this$0 = SetupLoginFragment.this; super(); } }; SetupInputView mPassword; public SetupLoginFragment() { } private void getAllUserSettings() { final android.support.v4.app.FragmentActivity context = getActivity(); long l = UserManager.getInstance().getUserId(); OlioApi.getInstance().getAllUserSettings(context, l, new ApiCallback() { final SetupLoginFragment this$0; final Context val$context; public void failure(RetrofitError retrofiterror) { if (isAdded()) { ALog.e((new StringBuilder()).append("Failed to load user settings from server, error: ").append(retrofiterror).toString(), new Object[0]); Utils.showToastMessage(context, getString(0x7f0601bc)); } } public void success() { ALog.d("Successfully loaded user settings from server.", new Object[0]); } { this$0 = SetupLoginFragment.this; context = context1; super(); } }); } private void getOneUserSetting(String s) { final android.support.v4.app.FragmentActivity context = getActivity(); long l = UserManager.getInstance().getUserId(); OlioApi.getInstance().getOneUserSetting(context, s, Long.valueOf(l), new ApiCallback() { final SetupLoginFragment this$0; final Context val$context; public void failure(RetrofitError retrofiterror) { if (isAdded()) { Utils.showToastMessage(context, getString(0x7f0601bc)); } } public void success() { ALog.d("Successfully loaded a specific user settings from server.", new Object[0]); } { this$0 = SetupLoginFragment.this; context = context1; super(); } }); } private boolean isFormValid() { String s = mEmail.getText().toString(); String s1 = mPassword.getText().toString(); if (s.isEmpty() || s1.isEmpty()) { mEmail.setErrorState(s.isEmpty()); mPassword.setErrorState(s1.isEmpty()); Utils.showToastMessage(getActivity(), getString(0x7f0600b9)); return false; } else { return true; } } private void onEulaAccepted() { if (UserManager.getInstance().getUnitId().isEmpty()) { mCallbacks.goToScreen(5); return; } else { mCallbacks.startApp(); return; } } private void populateForm(String s) { if (s != null) { mEmail.setText(s); } } private void showEulaActivity() { startActivityForResult(new Intent(getActivity(), com/oliodevices/assist/app/EulaActivity), 1); } private void showEulaNotAcceptedDialog() { (new android.app.AlertDialog.Builder(getActivity())).setTitle(0x7f0600cf).setMessage(0x7f0600cd).setPositiveButton(0x7f060119, new android.content.DialogInterface.OnClickListener() { final SetupLoginFragment this$0; public void onClick(DialogInterface dialoginterface, int i) { } { this$0 = SetupLoginFragment.this; super(); } }).show(); } public int getPageNumber() { return 2; } public int getTitleId() { return 0x7f0600d3; } public boolean isSkipVisible() { return false; } public void onActivityResult(int i, int j, Intent intent) { label0: { super.onActivityResult(i, j, intent); if (i == 1) { mCallbacks.hideProgress(); if (j != 1) { break label0; } onEulaAccepted(); } return; } UserManager.getInstance().clearDetails(); showEulaNotAcceptedDialog(); } public View onCreateView(LayoutInflater layoutinflater, ViewGroup viewgroup, Bundle bundle) { layoutinflater = layoutinflater.inflate(0x7f030047, viewgroup, false); ButterKnife.inject(this, layoutinflater); return layoutinflater; } public void onForgotPassword() { mCallbacks.openWebPage("https://api.oliodevices.com/users/password/new"); } public void onLogin() { if (isFormValid()) { Utils.hideKeyboard(getActivity()); String s = mEmail.getText().toString(); String s1 = mPassword.getText().toString(); PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putString("login_email", s).apply(); mCallbacks.showProgress(true); OlioApi.getInstance().logIn(s, s1, mLoginCallback); } } public void onResume() { super.onResume(); Utils.showKeyboardDelayed(getActivity(), ButterKnife.findById(mEmail, 0x7f0d01a8)); } public void onViewCreated(View view, Bundle bundle) { super.onViewCreated(view, bundle); populateForm(PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("login_email", null)); } }