PreferenceUtils.java 6.32 KB
package com.bitstrips.imoji.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.text.TextUtils;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class PreferenceUtils
{
  private final Context a;
  private final SharedPreferences b;
  
  public PreferenceUtils(Context paramContext, int paramInt)
  {
    this.a = paramContext;
    this.b = paramContext.getSharedPreferences(paramContext.getString(paramInt), 0);
  }
  
  private Map<String, String> a()
  {
    return MapUtils.asMap(getString(2131231319, null));
  }
  
  public void clearKey(int paramInt)
  {
    this.b.edit().remove(this.a.getString(paramInt)).apply();
  }
  
  public void clearSnapchatUserData()
  {
    this.b.edit().remove(this.a.getString(2131231250)).apply();
  }
  
  public void clearTokens()
  {
    this.b.edit().remove(this.a.getString(2131231186)).remove(this.a.getString(2131231251)).remove(this.a.getString(2131231318)).remove(this.a.getString(2131231283)).apply();
  }
  
  public boolean containsKey(int paramInt)
  {
    return this.b.contains(this.a.getString(paramInt));
  }
  
  public boolean getBoolean(int paramInt, boolean paramBoolean)
  {
    return this.b.getBoolean(this.a.getString(paramInt), paramBoolean);
  }
  
  public boolean getBoolean(String paramString, boolean paramBoolean)
  {
    return this.b.getBoolean(paramString, paramBoolean);
  }
  
  public Integer getInt(int paramInt1, int paramInt2)
  {
    return Integer.valueOf(this.b.getInt(this.a.getString(paramInt1), paramInt2));
  }
  
  public Integer getInt(String paramString, int paramInt)
  {
    return Integer.valueOf(this.b.getInt(paramString, paramInt));
  }
  
  public Long getLong(int paramInt, long paramLong)
  {
    return Long.valueOf(this.b.getLong(this.a.getString(paramInt), paramLong));
  }
  
  public Long getLong(String paramString, long paramLong)
  {
    return Long.valueOf(this.b.getLong(paramString, paramLong));
  }
  
  public Map<String, Integer> getShareImagePackagePriorityMap(String[] paramArrayOfString)
  {
    Object localObject1 = a();
    int i = paramArrayOfString.length - 1;
    Object localObject2;
    while (i >= 0)
    {
      localObject2 = paramArrayOfString[i];
      if (!((Map)localObject1).containsKey(localObject2)) {
        ((Map)localObject1).put(localObject2, String.valueOf(paramArrayOfString.length - i));
      }
      i -= 1;
    }
    paramArrayOfString = getString(2131231292, null);
    if (!TextUtils.isEmpty(paramArrayOfString)) {
      ((Map)localObject1).put(paramArrayOfString, "2147483647");
    }
    paramArrayOfString = new HashMap(((Map)localObject1).size());
    localObject1 = ((Map)localObject1).entrySet().iterator();
    while (((Iterator)localObject1).hasNext())
    {
      localObject2 = (Map.Entry)((Iterator)localObject1).next();
      paramArrayOfString.put(((Map.Entry)localObject2).getKey(), Integer.valueOf(Integer.parseInt((String)((Map.Entry)localObject2).getValue())));
    }
    return paramArrayOfString;
  }
  
  public String getString(int paramInt, String paramString)
  {
    return this.b.getString(this.a.getString(paramInt), paramString);
  }
  
  public PreferenceTimer getTimer(int paramInt)
  {
    return new PreferenceTimer(this, paramInt);
  }
  
  public void increaseShareImageAppPriority(String paramString)
  {
    Map localMap = a();
    if (!localMap.containsKey(paramString)) {
      localMap.put(paramString, "0");
    }
    localMap.put(paramString, String.valueOf(Integer.parseInt((String)localMap.get(paramString)) + 1000));
    putString(2131231319, MapUtils.toString(localMap));
    putString(2131231292, paramString);
  }
  
  public void logoutForSnapchatLoginIfDifferentAvatarId(String paramString1, String paramString2)
  {
    if (!paramString2.equals(paramString1))
    {
      paramString1 = getString(2131231318, null);
      paramString2 = getString(2131231236, "{}");
      reset();
      putString(2131231318, paramString1);
      putString(2131231236, paramString2);
    }
  }
  
  public void putBoolean(int paramInt, boolean paramBoolean)
  {
    SharedPreferences.Editor localEditor = this.b.edit();
    localEditor.putBoolean(this.a.getString(paramInt), paramBoolean);
    localEditor.apply();
  }
  
  public void putBoolean(String paramString, boolean paramBoolean)
  {
    SharedPreferences.Editor localEditor = this.b.edit();
    localEditor.putBoolean(paramString, paramBoolean);
    localEditor.apply();
  }
  
  public void putInt(int paramInt1, int paramInt2)
  {
    SharedPreferences.Editor localEditor = this.b.edit();
    localEditor.putInt(this.a.getString(paramInt1), paramInt2);
    localEditor.apply();
  }
  
  public void putInt(String paramString, int paramInt)
  {
    SharedPreferences.Editor localEditor = this.b.edit();
    localEditor.putInt(paramString, paramInt);
    localEditor.apply();
  }
  
  public void putLong(int paramInt, long paramLong)
  {
    SharedPreferences.Editor localEditor = this.b.edit();
    localEditor.putLong(this.a.getString(paramInt), paramLong);
    localEditor.apply();
  }
  
  public void putLong(String paramString, long paramLong)
  {
    SharedPreferences.Editor localEditor = this.b.edit();
    localEditor.putLong(paramString, paramLong);
    localEditor.apply();
  }
  
  public void putString(int paramInt, String paramString)
  {
    SharedPreferences.Editor localEditor = this.b.edit();
    localEditor.putString(this.a.getString(paramInt), paramString);
    localEditor.apply();
  }
  
  public void registerOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener paramOnSharedPreferenceChangeListener)
  {
    this.b.registerOnSharedPreferenceChangeListener(paramOnSharedPreferenceChangeListener);
  }
  
  public boolean reset()
  {
    return this.b.edit().clear().commit();
  }
  
  public void unregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener paramOnSharedPreferenceChangeListener)
  {
    this.b.unregisterOnSharedPreferenceChangeListener(paramOnSharedPreferenceChangeListener);
  }
}


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