PrefixSearchEngine.java 3.66 KB
package com.bitstrips.imoji.search;

import android.os.AsyncTask;
import android.support.annotation.WorkerThread;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

public class PrefixSearchEngine
{
  private final SearchIndex a;
  
  public PrefixSearchEngine(SearchIndex paramSearchIndex)
  {
    this.a = paramSearchIndex;
  }
  
  private static List<String> a(String paramString)
  {
    paramString = paramString.toLowerCase().replace("'", "").split(" ");
    ArrayList localArrayList = new ArrayList(paramString.length);
    int j = paramString.length;
    int i = 0;
    while (i < j)
    {
      Object localObject = paramString[i];
      if (!((String)localObject).isEmpty()) {
        localArrayList.add(localObject);
      }
      i += 1;
    }
    return localArrayList;
  }
  
  private static boolean a(List<String> paramList1, List<String> paramList2)
  {
    paramList1 = paramList1.iterator();
    while (paramList1.hasNext()) {
      if (!paramList2.contains((String)paramList1.next())) {
        return false;
      }
    }
    return true;
  }
  
  private static boolean b(List<String> paramList1, List<String> paramList2)
  {
    paramList1 = paramList1.iterator();
    for (;;)
    {
      if (paramList1.hasNext())
      {
        String str = (String)paramList1.next();
        Iterator localIterator = paramList2.iterator();
        do
        {
          if (!localIterator.hasNext()) {
            break;
          }
        } while (!((String)localIterator.next()).startsWith(str));
      }
      for (int i = 1; i == 0; i = 0)
      {
        return false;
        return true;
      }
    }
  }
  
  public void fetchMatchingTags(final String paramString, final Callback paramCallback)
  {
    new AsyncTask() {}.execute(new Void[0]);
  }
  
  @WorkerThread
  public List<String> getMatchingTags(String paramString)
  {
    System.currentTimeMillis();
    final HashMap localHashMap = new HashMap();
    List localList = a(paramString);
    if (localList.isEmpty()) {
      return new ArrayList();
    }
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator = this.a.getTags().iterator();
    label229:
    while (localIterator.hasNext())
    {
      String str = (String)localIterator.next();
      paramString = a(str);
      if (localList.equals(paramString)) {
        paramString = a.a;
      }
      for (;;)
      {
        if (paramString == a.f) {
          break label229;
        }
        localHashMap.put(str, Integer.valueOf(paramString.g));
        localArrayList.add(str);
        break;
        if (a(localList, paramString))
        {
          if (((String)paramString.get(0)).equals(localList.get(0))) {
            paramString = a.b;
          } else {
            paramString = a.c;
          }
        }
        else if (b(localList, paramString))
        {
          if (((String)paramString.get(0)).startsWith((String)localList.get(0))) {
            paramString = a.d;
          } else {
            paramString = a.e;
          }
        }
        else {
          paramString = a.f;
        }
      }
    }
    Collections.sort(localArrayList, new Comparator() {});
    return localArrayList;
  }
  
  public static abstract interface Callback
  {
    public abstract void onComplete(List<String> paramList);
  }
  
  static enum a
  {
    final int g;
    
    private a(int paramInt)
    {
      this.g = paramInt;
    }
  }
}


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