b.java 2.58 KB
package com.instabug.library.migration;

import android.content.Context;
import com.instabug.library.u;
import com.instabug.library.util.InstabugSDKLogger;
import java.util.ArrayList;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public final class b
{
  private static final AbstractMigration[] a = { new a() };
  
  public static void a(Context paramContext)
  {
    ArrayList localArrayList = new ArrayList();
    AbstractMigration[] arrayOfAbstractMigration = a;
    int j = arrayOfAbstractMigration.length;
    int i = 0;
    if (i < j)
    {
      AbstractMigration localAbstractMigration = arrayOfAbstractMigration[i];
      localAbstractMigration.initialize(paramContext);
      if ((localAbstractMigration.shouldMigrate()) && (localAbstractMigration.getMigrationVersion() > u.a().u()) && (localAbstractMigration.getMigrationVersion() <= 1)) {}
      for (boolean bool = true;; bool = false)
      {
        InstabugSDKLogger.d(b.class, "Checking if should apply this migration: " + localAbstractMigration + ", result is " + bool + " last migration version is " + u.a().u() + " target migration version 1");
        if (bool) {
          localArrayList.add(localAbstractMigration.migrate());
        }
        i += 1;
        break;
      }
    }
    paramContext = a(localArrayList);
    if (paramContext.length != 0)
    {
      Observable.merge(paramContext).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(new Subscriber()
      {
        public final void onCompleted()
        {
          InstabugSDKLogger.d(b.class, "All Migrations completed, setting lastMigrationVersion to 1");
          u.a().a(1);
        }
        
        public final void onError(Throwable paramAnonymousThrowable)
        {
          InstabugSDKLogger.d(b.class, "Migration failed" + paramAnonymousThrowable.getMessage());
        }
        
        public final void onStart()
        {
          super.onStart();
        }
      });
      return;
    }
    InstabugSDKLogger.d(b.class, "No migrations to run");
  }
  
  private static Observable[] a(ArrayList<Observable<String>> paramArrayList)
  {
    Observable[] arrayOfObservable = new Observable[paramArrayList.size()];
    int i = 0;
    while (i < paramArrayList.size())
    {
      arrayOfObservable[i] = ((Observable)paramArrayList.get(i));
      i += 1;
    }
    return arrayOfObservable;
  }
}


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