BitmojiBaseActivity.java 5.06 KB
package com.bitstrips.imoji.ui;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import com.bitstrips.imoji.InjectorApplication;
import com.bitstrips.imoji.analytics.LegacyAnalyticsService;
import com.bitstrips.imoji.api.BitmojiApi;
import com.bitstrips.imoji.behaviour.BehaviourHelper;
import com.bitstrips.imoji.browser.ImojiBrowserActivity;
import com.bitstrips.imoji.manager.SnapchatManager;
import com.bitstrips.imoji.monouser.controllers.UserLogoutController;
import com.bitstrips.imoji.monouser.oauth2.OAuth2Manager;
import com.bitstrips.imoji.monouser.oauth2.OAuth2Manager.OnOAuth2TokenRefreshCallback;
import com.bitstrips.imoji.util.BugReporter;
import com.squareup.okhttp.Cache;
import javax.inject.Inject;

public abstract class BitmojiBaseActivity
  extends AppCompatActivity
  implements OAuth2Manager.OnOAuth2TokenRefreshCallback
{
  public static final String INTENT_ACTION_SHOW_FORCE_LOGOUT_DIALOG = "com.bitstrips.imoji.actions.show.force.logout.dialog";
  @Inject
  LegacyAnalyticsService K;
  @Inject
  BitmojiApi L;
  @Inject
  SnapchatManager M;
  @Inject
  Cache N;
  @Inject
  BugReporter O;
  @Inject
  BehaviourHelper P;
  @Inject
  OAuth2Manager Q;
  @Inject
  UserLogoutController R;
  private BroadcastReceiver n;
  private boolean o = false;
  
  private void a()
  {
    showAlertDialog(getString(2131230887), getString(2131230904), new Runnable()
    {
      public final void run()
      {
        BitmojiBaseActivity.this.returnToLogin();
      }
    }, null);
  }
  
  public static void sendShowForceLogoutDialogBroadcast(Context paramContext)
  {
    LocalBroadcastManager.getInstance(paramContext).sendBroadcast(new Intent("com.bitstrips.imoji.actions.show.force.logout.dialog"));
  }
  
  protected boolean isActivityValid()
  {
    if (isFinishing()) {}
    while ((Build.VERSION.SDK_INT >= 17) && (isDestroyed())) {
      return false;
    }
    return true;
  }
  
  public void logout()
  {
    this.R.logout();
    returnToLogin();
  }
  
  public void onCreate(@Nullable Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    ((InjectorApplication)getApplication()).inject(this);
    this.n = new BroadcastReceiver()
    {
      public final void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
      {
        if ((paramAnonymousIntent.getAction().equals("com.bitstrips.imoji.actions.show.force.logout.dialog")) && (BitmojiBaseActivity.a(BitmojiBaseActivity.this))) {
          BitmojiBaseActivity.b(BitmojiBaseActivity.this);
        }
      }
    };
    LocalBroadcastManager.getInstance(this).unregisterReceiver(this.n);
    paramBundle = new IntentFilter("com.bitstrips.imoji.actions.show.force.logout.dialog");
    LocalBroadcastManager.getInstance(this).registerReceiver(this.n, paramBundle);
  }
  
  public void onDestroy()
  {
    super.onDestroy();
    LocalBroadcastManager.getInstance(this).unregisterReceiver(this.n);
  }
  
  public void onPause()
  {
    super.onPause();
    this.o = false;
  }
  
  public void onResume()
  {
    super.onResume();
    this.o = true;
    if (this.Q.isUserLoggedIn())
    {
      boolean bool = this.P.isTokenRefreshForced();
      this.Q.asyncRefreshToken(bool, this);
    }
  }
  
  public void onStart()
  {
    super.onStart();
    this.K.reportStart(this);
    if ((this instanceof ImojiBrowserActivity)) {}
    for (String str = "sharing";; str = "identity")
    {
      this.O.updateTags(new String[] { str });
      return;
    }
  }
  
  public void onStop()
  {
    super.onStop();
    this.K.reportStop(this);
  }
  
  public void onTokenRefreshFailed(boolean paramBoolean)
  {
    if ((paramBoolean) && (this.o)) {
      a();
    }
  }
  
  public void onTokenRefreshSucceeded(boolean paramBoolean) {}
  
  protected void returnToLogin()
  {
    if (this.M.getCurrentLinkingIntent() != null)
    {
      this.M.goBackToSnapchat(this);
      finish();
    }
    do
    {
      return;
      startActivity(new Intent(getApplicationContext(), LoginActivity.class));
    } while ((this instanceof LoginActivity));
    finish();
  }
  
  @Deprecated
  public void showAlertDialog(String paramString1, @NonNull String paramString2, Runnable paramRunnable1, Runnable paramRunnable2)
  {
    if (!isActivityValid()) {
      return;
    }
    paramString2 = new BitmojiAlertDialog(this).withMessage(paramString2);
    if (paramString1 != null) {
      paramString2.withTitle(paramString1);
    }
    if (paramRunnable1 != null) {
      paramString2.withOnPositiveClick(paramRunnable1);
    }
    if (paramRunnable2 != null) {
      paramString2.withOnNegativeClick(paramRunnable2);
    }
    paramString2.show();
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/ui/BitmojiBaseActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */