j.java 3.49 KB
package com.instabug.library.internal.d.a;

import com.instabug.library.model.i;
import com.instabug.library.util.InstabugSDKLogger;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class j
{
  private static j a;
  
  public j()
  {
    InstabugSDKLogger.d(this, "Initializing ReadQueueCacheManager");
    g localg = new g("read_queue_memory_cache_key");
    e.a().a(localg);
  }
  
  public static j a()
  {
    if (a == null) {
      a = new j();
    }
    return a;
  }
  
  public static g<Integer, i> b()
  {
    if ((!e.a().b("read_queue_memory_cache_key")) || (e.a().a("read_queue_memory_cache_key").b().size() > 0))
    {
      InstabugSDKLogger.d(j.class, "In-memory cache not found, loading it from disk " + e.a().a("read_queue_memory_cache_key"));
      e.a().a("read_queue_disk_cache_key", "read_queue_memory_cache_key", new e.a() {});
      InstabugSDKLogger.d(j.class, "In-memory cache restored from disk, " + e.a().a("read_queue_memory_cache_key").b().size() + " elements restored");
    }
    InstabugSDKLogger.d(j.class, "In-memory cache found");
    return (g)e.a().a("read_queue_memory_cache_key");
  }
  
  public static void c()
  {
    if (!e.a().b("read_queue_memory_cache_key")) {
      return;
    }
    InstabugSDKLogger.d(j.class, "Saving In-memory cache to disk, no. of items to save is " + e.a().a("read_queue_memory_cache_key").b());
    e.a().a(e.a().a("read_queue_memory_cache_key"), e.a().a("read_queue_disk_cache_key"), new e.a() {});
    InstabugSDKLogger.d(j.class, "In-memory cache had been persisted on-disk, " + e.a().a("read_queue_disk_cache_key").b().size() + " elements saved");
  }
  
  public void a(i parami)
  {
    InstabugSDKLogger.v(this, "Adding message " + parami + " to read queue in-memory cache");
    e.a().a("read_queue_memory_cache_key").a(Integer.valueOf(parami.a()), parami);
    InstabugSDKLogger.v(this, "Added message " + parami + " to read queue in-memory cache " + e.a().a("read_queue_memory_cache_key").c());
  }
  
  public void a(List<i> paramList)
  {
    ListIterator localListIterator = e().listIterator();
    while (localListIterator.hasNext())
    {
      i locali1 = (i)localListIterator.next();
      Iterator localIterator = paramList.iterator();
      while (localIterator.hasNext())
      {
        i locali2 = (i)localIterator.next();
        if ((locali1.a() == locali2.a()) && (locali1.c() == locali2.c()))
        {
          int i = locali2.a();
          e.a().a("read_queue_memory_cache_key").a(Integer.valueOf(i));
        }
      }
    }
  }
  
  public JSONArray d()
  {
    JSONArray localJSONArray = new JSONArray();
    Iterator localIterator = e().iterator();
    while (localIterator.hasNext())
    {
      i locali = (i)localIterator.next();
      try
      {
        JSONObject localJSONObject = new JSONObject();
        localJSONObject.put("issue_id", locali.a());
        localJSONObject.put("last_email_id", locali.c());
        localJSONObject.put("read_at", locali.b());
        localJSONArray.put(localJSONObject);
      }
      catch (JSONException localJSONException)
      {
        localJSONException.printStackTrace();
      }
    }
    return localJSONArray;
  }
  
  public List<i> e()
  {
    return e.a().a("read_queue_memory_cache_key").b();
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/instabug/library/internal/d/a/j.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */