TOUManager.java 3.04 KB
package com.bitstrips.imoji.manager;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.util.Log;
import com.bitstrips.imoji.api.BitmojiApi;
import com.bitstrips.imoji.injection.ForApplication;
import com.bitstrips.imoji.models.UserData;
import com.bitstrips.imoji.util.PreferenceUtils;
import com.squareup.okhttp.Cache;
import java.util.Iterator;
import javax.inject.Inject;
import javax.inject.Singleton;
import retrofit.Callback;
import retrofit.RetrofitError;

@Singleton
public class TOUManager
{
  private BroadcastReceiver a;
  private boolean b = false;
  private final BitmojiApi c;
  private final Context d;
  private final PreferenceUtils e;
  private final Cache f;
  
  @Inject
  public TOUManager(@ForApplication Context paramContext, BitmojiApi paramBitmojiApi, PreferenceUtils paramPreferenceUtils, Cache paramCache)
  {
    this.d = paramContext;
    this.c = paramBitmojiApi;
    this.e = paramPreferenceUtils;
    this.f = paramCache;
  }
  
  protected void checkTOUUpdate()
  {
    if (TextUtils.isEmpty(this.e.getString(2131231175, null))) {
      Log.i("TOUManager", "Current avatar id is null, not checking terms.");
    }
    while (this.b) {
      return;
    }
    this.b = true;
    this.c.getUserData(new Callback()
    {
      public final void failure(RetrofitError paramAnonymousRetrofitError)
      {
        TOUManager.a(TOUManager.this);
        Log.i("TOUManager", "Failed get for terms of service", paramAnonymousRetrofitError);
      }
    });
  }
  
  public void checkTermsChanged(Context paramContext)
  {
    LocalBroadcastManager.getInstance(paramContext).sendBroadcast(new Intent("com.bitstrips.imoji.TOU_CHANGED_CHECK"));
  }
  
  public void initializeReceiver()
  {
    if (this.a == null)
    {
      IntentFilter localIntentFilter = new IntentFilter();
      localIntentFilter.addAction("com.bitstrips.imoji.TOU_CHANGED_CHECK");
      this.a = new BroadcastReceiver()
      {
        public final void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent)
        {
          TOUManager.this.checkTOUUpdate();
        }
      };
      LocalBroadcastManager.getInstance(this.d).registerReceiver(this.a, localIntentFilter);
    }
  }
  
  public void invalidateCache()
  {
    try
    {
      if (this.f == null)
      {
        Log.e("TOUManager", "Cache was null");
        return;
      }
      Iterator localIterator = this.f.urls();
      while (localIterator.hasNext()) {
        if (((String)localIterator.next()).endsWith("user/data"))
        {
          localIterator.remove();
          return;
        }
      }
    }
    catch (Exception localException)
    {
      Log.e("TOUManager", "Failed to obtain urls from cache", localException);
    }
  }
}


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