Esempio n. 1
0
 private void LoadIcon()
 {
     if (this.useIndicator)
     {
         this.loadIcon.SetActive(true);
     }
     FMLogger.Log("load web " + this.pd.Id);
     this.iconDownloadTask = new IconDownloadTask(this.pd.WebPath.baseUrls, this.pd.WebPath.icon, this.pd.WebPath.CacheKey, delegate(bool success, Texture2D tex)
     {
         if (success && tex != null)
         {
             if (this.useIndicator)
             {
                 this.loadIcon.SetActive(false);
             }
             this.img.texture = tex;
         }
         else
         {
             FMLogger.Log("Error loading bonus pic: " + this.pd.Id);
         }
         this.iconDownloadTask = null;
     });
     ImageManager.Instance.DownloadIcon(this.iconDownloadTask);
 }
Esempio n. 2
0
    public static bool IsServerContentExpired()
    {
        double totalMinutes = (DateTime.Now - AppState.ContentReqTime).TotalMinutes;

        FMLogger.Log("check exp time. t:" + totalMinutes);
        return(totalMinutes > 240.0);
    }
Esempio n. 3
0
    private IEnumerator LoadIconAsync(IconDownloadTask task, bool queued = true)
    {
        for (int i = 0; i < task.BaseUrls.Length; i++)
        {
            using (UnityWebRequest www = UnityWebRequestTexture.GetTexture(task.BaseUrls[i] + task.RelativeUrl))
            {
                //www.timeout = 13;
                yield return(www.Send());

                if (!www.isNetworkError && www.responseCode == 200L)
                {
                    if (task.IsCanceled)
                    {
                        Texture2D content = DownloadHandlerTexture.GetContent(www);
                        if (content != null && content.width > 10 && content.height > 10)
                        {
                            task.FallbackCancelation(content);
                        }
                    }
                    else
                    {
                        Texture2D content2 = DownloadHandlerTexture.GetContent(www);
                        if (content2 != null && content2.width > 10 && content2.height > 10)
                        {
                            content2.wrapMode = TextureWrapMode.Clamp;
                            task.Result(true, content2);
                        }
                        else
                        {
                            task.Result(false, null);
                        }
                        this.SendConnectionResume();
                    }
                    yield return(0);

                    this.currentIconConnections--;
                    yield break;
                }
                FMLogger.Log(string.Concat(new object[]
                {
                    "icon dl error.",
                    i,
                    ". ",
                    task.BaseUrls[i],
                    string.Empty,
                    task.RelativeUrl,
                    " msg:",
                    www.error
                }));
            }
        }
        this.currentIconConnections--;
        this.StepFailedPicture();
        if (!task.IsCanceled)
        {
            FMLogger.Log("*************error task:" + task.RelativeUrl);
            task.Result(false, null);
        }
        yield break;
    }
 private void OnPicDeleted(PictureData delPicData, PictureData replacePicData)
 {
     if (replacePicData == null)
     {
         return;
     }
     for (int i = 0; i < this.items.Count; i++)
     {
         PicItem picItem            = null;
         FeaturedItem.ItemType type = this.items[i].Type;
         if (type != FeaturedItem.ItemType.Daily)
         {
             if (type == FeaturedItem.ItemType.PromoPic)
             {
                 picItem = ((PromoPicItem)this.items[i]).PicItem;
             }
         }
         else
         {
             picItem = ((DailyPicItem)this.items[i]).PicItem;
         }
         if (picItem != null && picItem.PictureData.Id == replacePicData.Id)
         {
             FMLogger.Log("found and replaced in featured section " + replacePicData.Id);
             picItem.Reset();
             picItem.Init(replacePicData, false, false, false);
         }
     }
 }
    private void CheckPrecacheResources()
    {
        PictureData pictureData = this.task.PictureData;

        if (FileHelper.FileExist(this.directory, this.iconPath))
        {
            this.iconState = PictureDataDownloader.DownloadState.Cached;
            FMLogger.Log("skip dl icon, already stored");
        }
        if (FileHelper.FileExist(this.directory, this.linePath))
        {
            this.lineState = PictureDataDownloader.DownloadState.Cached;
            FMLogger.Log("skip dl line, already stored");
        }
        if (pictureData.FillType == FillAlgorithm.Flood)
        {
            if (FileHelper.FileExist(this.directory, this.coloredPath))
            {
                this.colorState = PictureDataDownloader.DownloadState.Cached;
                FMLogger.Log("skip dl colormap, already stored");
            }
        }
        else
        {
            this.colorState = PictureDataDownloader.DownloadState.Cached;
            FMLogger.Log("skip dl colormap, not needed anymore");
        }
        if (FileHelper.FileExist(this.directory, this.jsonPath))
        {
            this.jsonState = PictureDataDownloader.DownloadState.Cached;
            FMLogger.Log("skip dl json, already stored");
        }
    }
Esempio n. 6
0
    public bool FindEmptyZone()
    {
        if (this.palette.CurrentId == -1)
        {
            this.toastManager.ShowHintPickColor();
            return(false);
        }
        bool flag = this.validator.IsFilled(this.palette.CurrentId);

        if (flag)
        {
            FMLogger.Log("used fully. " + this.palette.CurrentId);
            this.toastManager.ShowHintAlreadyPainted();
            return(false);
        }
        int currentId = this.palette.CurrentId;

        int[] indexes = this.paletteData.entities[currentId].indexes;
        int   num     = -1;

        for (int i = 0; i < indexes.Length; i++)
        {
            Point p = default(Point);
            p.i = Mathf.FloorToInt((float)indexes[i] / (float)this.paintFill.TexWidth);
            p.j = indexes[i] - p.i * this.paintFill.TexWidth;
            Color32 a = this.paintFill.CurrentColorInPixel(p);
            Color32 c = this.paintFill.ExpectedColorInPixel(p);
            if (!ColorUtils.IsSameColors(a, c))
            {
                num = i;
                break;
            }
        }
        if (num == -1)
        {
            FMLogger.Log("element not found. never should happen");
            return(false);
        }
        int   num2 = this.paletteData.entities[currentId].indexes[num];
        Point p2   = default(Point);

        p2.i = Mathf.FloorToInt((float)num2 / (float)this.paintFill.TexWidth);
        p2.j = num2 - p2.i * this.paintFill.TexWidth;
        Vector2 b = this.TextureToCanvas(p2);

        this.boardController.ZoomToPosition(new Vector2(this.imageRect.width / 2f, this.imageRect.height / 2f) - b);
        if (this.hintRevealedIndexes.Contains(num2))
        {
            FMLogger.Log("already hint revealed");
            return(false);
        }
        this.hintRevealedIndexes.Add(num2);
        if (this.pictureSaveData != null)
        {
            this.pictureSaveData.hintsUsed++;
            FMLogger.Log("hints used " + this.pictureSaveData.hintsUsed);
        }
        return(true);
    }
 public void FallbackCancelation(Texture2D tex)
 {
     if (this.fallbackHandler != null)
     {
         FMLogger.Log("Fallback icon dl handle: " + this.CacheKey);
         this.fallbackHandler(this.CacheKey, tex);
     }
     this.fallbackHandler = null;
 }
Esempio n. 8
0
 private static void AddNewsItems(NewsDb item)
 {
     try
     {
         DatabaseManager.db.Insert(item);
     }
     catch (Exception ex)
     {
         FMLogger.Log("add news fail. " + ex.Message);
     }
 }
Esempio n. 9
0
 private void SendConnectionError()
 {
     if (this.noInternet)
     {
         return;
     }
     this.noInternet = true;
     this.ConnectionError.SafeInvoke();
     FMLogger.Log("launch IC from error");
     this.internetCheckerCoroutine = base.StartCoroutine(this.InternetChecker());
 }
Esempio n. 10
0
 private void OnApplicationPause(bool isPause)
 {
     if (!isPause && this.noInternet && this.ConnectionResume != null)
     {
         if (this.internetCheckerCoroutine != null)
         {
             base.StopCoroutine(this.internetCheckerCoroutine);
         }
         FMLogger.Log("launch IC from pause");
         this.internetCheckerCoroutine = base.StartCoroutine(this.InternetChecker());
     }
 }
Esempio n. 11
0
 private void OnApplicationFocus(bool hasFocus)
 {
     if (hasFocus && this.noInternet && this.ConnectionResume != null)
     {
         if (this.internetCheckerCoroutine != null)
         {
             base.StopCoroutine(this.internetCheckerCoroutine);
         }
         FMLogger.Log("launch IC from focus");
         this.internetCheckerCoroutine = base.StartCoroutine(this.InternetChecker());
     }
 }
Esempio n. 12
0
    public void ApplyDataTo(int count, int newCount, InfiniteScroll.Direction direction)
    {
        if (this._count == 0)
        {
            this.InitData(count, 0, false);
            return;
        }
        Vector2 anchoredPosition = this._content.anchoredPosition;

        FMLogger.Log(string.Concat(new object[]
        {
            "append new rows ",
            newCount,
            " total ",
            count
        }));
        this._count = count;
        float y = (float)(this.height * count) * 1f + (float)this.top + (float)this.bottom + (float)((count != 0) ? ((count - 1) * this.spacing) : 0);

        this._content.sizeDelta = new Vector2(this._content.sizeDelta.x, y);
        int num  = int.MaxValue;
        int num2 = int.MaxValue;

        for (int i = 0; i < this._views.Length; i++)
        {
            if (this._views[i].Row < num2)
            {
                num2 = this._views[i].Row;
                num  = i;
            }
        }
        int num3 = this.position - num2;

        if (num3 > 0)
        {
            int num4 = count - newCount;
            for (int j = 0; j < num3; j++)
            {
                int num5 = num;
                num++;
                if (num == this._views.Length)
                {
                    num = 0;
                }
                Vector2 anchoredPosition2 = this._rects[num5].anchoredPosition;
                anchoredPosition2.y = (float)(-(float)(this.top + num4 * this.spacing + num4 * this.height));
                this._rects[num5].anchoredPosition = anchoredPosition2;
                this.FillItem(num4, this._views[num5], true);
                num4++;
            }
        }
        base.StartCoroutine(this.UpdPosition(anchoredPosition, this._content));
    }
Esempio n. 13
0
 public static void UpdateSave(PictureSaveData pictureSaveData)
 {
     try
     {
         SaveDb obj = DbTypeConvertor.FromPictureSaveData(pictureSaveData);
         DatabaseManager.db.UpdateTable(obj);
     }
     catch (Exception ex)
     {
         FMLogger.Log("upd saveData fail. " + ex.Message);
     }
 }
Esempio n. 14
0
    public PictureData[] GetRowData(int row)
    {
        List <PictureData> pics = this.currentMonth.pics;

        row -= this.rowOffset;
        if (MenuScreen.RowItems == 2)
        {
            if (pics.Count - 1 >= row * 2 + 1)
            {
                return(new PictureData[]
                {
                    pics[row * 2],
                    pics[row * 2 + 1]
                });
            }
            if (pics.Count - 1 == row * 2)
            {
                return(new PictureData[]
                {
                    pics[row * 2]
                });
            }
        }
        else if (MenuScreen.RowItems == 3)
        {
            if (pics.Count - 1 >= row * 3 + 2)
            {
                return(new PictureData[]
                {
                    pics[row * 3],
                    pics[row * 3 + 1],
                    pics[row * 3 + 2]
                });
            }
            if (pics.Count - 1 >= row * 3 + 1)
            {
                return(new PictureData[]
                {
                    pics[row * 3],
                    pics[row * 3 + 1]
                });
            }
            if (pics.Count - 1 == row * 3)
            {
                return(new PictureData[]
                {
                    pics[row * 3]
                });
            }
        }
        FMLogger.Log("WTF EMPTY ROW: " + row);
        return(new PictureData[0]);
    }
Esempio n. 15
0
 public override void ReinitPicItem(PictureData picData)
 {
     for (int i = 0; i < this.pics.Count; i++)
     {
         if (this.pics[i].gameObject.activeSelf && this.pics[i].PictureData != null && this.pics[i].Id == picData.Id)
         {
             FMLogger.Log("reset pic " + picData.Id);
             this.pics[i].Reset();
             this.pics[i].Init(picData, false, true, false);
             break;
         }
     }
 }
Esempio n. 16
0
 public static void AddPicture(PictureData pd)
 {
     try
     {
         PictureDb obj = DbTypeConvertor.FromPictureData(pd);
         DatabaseManager.db.Insert(obj);
     }
     catch (Exception ex)
     {
         FMLogger.Log("error adding picture. " + ex.Message);
         AnalyticsManager.DbTransactionError("picDb", "AddPicture: " + ex.Message);
     }
 }
Esempio n. 17
0
 private void SaveIconLoaded(bool success, Texture2D tex)
 {
     if (success && tex != null)
     {
         this.saveMask.texture = tex;
         this.saveMask.gameObject.SetActive(true);
     }
     else
     {
         FMLogger.Log("Failed to load icon preview. file not found");
     }
     this.saveIconTask = null;
 }
Esempio n. 18
0
 private void LoadImageHandler(bool result, Texture2D tex)
 {
     if (result && tex != null)
     {
         this.loadIcon.SetActive(false);
         this.webImg.texture = tex;
     }
     else
     {
         FMLogger.Log("Error loading pic: " + this.pd.Id);
     }
     this.iconDownloadTask = null;
 }
Esempio n. 19
0
 public static void UpdatePicture(PictureData pd)
 {
     try
     {
         PictureDb obj = DbTypeConvertor.FromPictureData(pd);
         DatabaseManager.db.UpdateTable(obj);
     }
     catch (Exception ex)
     {
         FMLogger.Log("upd pic error. " + ex.Message);
         AnalyticsManager.DbTransactionError("picDb", "UpdatePicture: " + ex.Message);
     }
 }
Esempio n. 20
0
    private void Start()
    {
        int num  = (int)this.refRt.sizeDelta.y;
        int num2 = AdsManager.Instance.CalcBannerHeight(num);

        FMLogger.Log(string.Concat(new object[]
        {
            "banner height ",
            num2,
            " canvas height ",
            num
        }));
        this.topControls.anchoredPosition += new Vector2(0f, (float)num2);
    }
Esempio n. 21
0
 public PictureData[] GetRowData(int row)
 {
     if (MenuScreen.RowItems == 2)
     {
         if (this.tabData.Count - 1 >= row * 2 + 1)
         {
             return(new PictureData[]
             {
                 this.tabData[row * 2],
                 this.tabData[row * 2 + 1]
             });
         }
         if (this.tabData.Count - 1 == row * 2)
         {
             return(new PictureData[]
             {
                 this.tabData[row * 2]
             });
         }
     }
     else if (MenuScreen.RowItems == 3)
     {
         if (this.tabData.Count - 1 >= row * 3 + 2)
         {
             return(new PictureData[]
             {
                 this.tabData[row * 3],
                 this.tabData[row * 3 + 1],
                 this.tabData[row * 3 + 2]
             });
         }
         if (this.tabData.Count - 1 >= row * 3 + 1)
         {
             return(new PictureData[]
             {
                 this.tabData[row * 3],
                 this.tabData[row * 3 + 1]
             });
         }
         if (this.tabData.Count - 1 == row * 3)
         {
             return(new PictureData[]
             {
                 this.tabData[row * 3]
             });
         }
     }
     FMLogger.Log("WTF EMPTY ROW: " + row);
     return(new PictureData[0]);
 }
Esempio n. 22
0
 public void ReinitPicItem(PictureData picData)
 {
     for (int i = 0; i < this.pics.Count; i++)
     {
         if (this.pics[i].gameObject.activeSelf && this.pics[i].Id == picData.Id)
         {
             FMLogger.Log("reset pic " + picData.Id);
             int dailyTabDate = this.pics[i].PictureData.Extras.dailyTabDate;
             picData.SetDailyTabDate(dailyTabDate);
             this.pics[i].Reset();
             this.pics[i].Init(picData, false, false, true);
             break;
         }
     }
 }
Esempio n. 23
0
    private IEnumerator DailyPageTaskTimeout(DailyPageContentTask pageTask, float warningTime)
    {
        yield return(new WaitForSeconds(warningTime));

        if (pageTask != null && !pageTask.Completed)
        {
            FMLogger.Log("daily page long load report");
            pageTask.TriggerWarning();
        }
        else
        {
            FMLogger.Log("daily Wtf task is completed");
        }
        this.dailyPageTaskTimeoutCoroutine = null;
        yield break;
    }
Esempio n. 24
0
 public static void DeletePicture(PictureData pd)
 {
     if (pd.HasSave)
     {
         DatabaseManager.DeleteSave(pd.Id, false);
     }
     try
     {
         PictureDb obj = DbTypeConvertor.FromPictureData(pd);
         DatabaseManager.db.Delete <PictureDb>(obj);
     }
     catch (Exception ex)
     {
         FMLogger.Log("error del pic. " + ex.Message);
         AnalyticsManager.DbTransactionError("picDb", "DeletePicture: " + ex.Message);
     }
 }
Esempio n. 25
0
    public static bool AddBonusCode(BonusCodeData bonusCode)
    {
        bool result;

        try
        {
            GiftDb obj = DbTypeConvertor.FromGiftData(bonusCode);
            DatabaseManager.db.Insert(obj);
            result = true;
        }
        catch (Exception ex)
        {
            FMLogger.Log("add gift fail. " + ex.Message);
            result = false;
        }
        return(result);
    }
Esempio n. 26
0
 public void LoadDailyPage(DailyPageContentTask dailyPageTask)
 {
     if (this.dailyPageResponse != null && this.dailyTabInfo != null)
     {
         dailyPageTask.Result(true, this.dailyTabInfo);
     }
     else
     {
         if (this.dailyPageTaskTimeoutCoroutine != null)
         {
             FMLogger.Log("daily Multi page load invocation");
             base.StopCoroutine(this.dailyPageTaskTimeoutCoroutine);
             FMLogger.Log("terminate prev daily page task handler");
         }
         this.dailyPageTaskTimeoutCoroutine = base.StartCoroutine(this.DailyPageTaskTimeout(dailyPageTask, 5f));
         TGFModule.Instance.GetDailyPage(delegate(DailyPageResponse response)
         {
             if (dailyPageTask == null || dailyPageTask.IsCanceled)
             {
                 FMLogger.Log("daily task canceled " + dailyPageTask.Page);
             }
             else if (dailyPageTask != null && dailyPageTask.Completed)
             {
                 FMLogger.Log("daily task already completed " + dailyPageTask.Page);
             }
             else
             {
                 if (this.dailyPageTaskTimeoutCoroutine != null)
                 {
                     this.StopCoroutine(this.dailyPageTaskTimeoutCoroutine);
                     this.dailyPageTaskTimeoutCoroutine = null;
                 }
                 if (response != null)
                 {
                     this.ParseDailyPageContent(response);
                     this.dailyPageResponse = response;
                     dailyPageTask.Result(true, this.dailyTabInfo);
                 }
                 else
                 {
                     dailyPageTask.Result(false, null);
                 }
             }
         });
     }
 }
Esempio n. 27
0
 public void LoadMainPage(PageContentTask pageTask)
 {
     if (pageTask.Page == 1 && this.orderedMainPage != null && this.orderedMainPage.Count > 0 && this.libResponse != null)
     {
         pageTask.Result(true, new PageContentInfo(this.orderedMainPage, this.featuredSection, this.newsTabInfo, this.libResponse.categories, this.libResponse.update_dialog, this.libResponse.bonus_category_config));
     }
     else if (pageTask.Page == 1)
     {
         if (this.mainPageTaskTimeoutCoroutine != null)
         {
             FMLogger.Log("Multi page load invocation");
             base.StopCoroutine(this.mainPageTaskTimeoutCoroutine);
             FMLogger.Log("terminate prev main page task handler");
         }
         this.mainPageTaskTimeoutCoroutine = base.StartCoroutine(this.MainPageTaskTimeout(pageTask, 5f));
         TGFModule.Instance.GetMainPage(pageTask.Page, delegate(LibraryPageResponce response)
         {
             if (pageTask == null || pageTask.IsCanceled)
             {
                 FMLogger.Log("task canceled " + pageTask.Page);
             }
             else if (pageTask != null && pageTask.Completed)
             {
                 FMLogger.Log("task already completed " + pageTask.Page);
             }
             else
             {
                 if (this.mainPageTaskTimeoutCoroutine != null)
                 {
                     this.StopCoroutine(this.mainPageTaskTimeoutCoroutine);
                     this.mainPageTaskTimeoutCoroutine = null;
                 }
                 if (response != null)
                 {
                     this.ParseMainPageContent(response);
                     this.libResponse = response;
                     pageTask.Result(true, new PageContentInfo(this.orderedMainPage, this.featuredSection, this.newsTabInfo, this.libResponse.categories, this.libResponse.update_dialog, this.libResponse.bonus_category_config));
                 }
                 else
                 {
                     pageTask.Result(false, null);
                 }
             }
         });
     }
 }
Esempio n. 28
0
 public static SystemUtils.DevicePerfomance GetDevicePerfomance()
 {
     SystemUtils.DevicePerfomance devicePerfomance = GeneralSettings.DevicePerfomance;
     if (devicePerfomance == SystemUtils.DevicePerfomance.Unknown)
     {
         try
         {
             int num = 2013;
             using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("fmt.deviceperf.DevicePower"))
             {
                 using (AndroidJavaClass androidJavaClass2 = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
                 {
                     AndroidJavaObject @static = androidJavaClass2.GetStatic <AndroidJavaObject>("currentActivity");
                     int num2 = androidJavaClass.CallStatic <int>("GetDeviceYear", new object[]
                     {
                         @static
                     });
                     if (num2 >= num)
                     {
                         devicePerfomance = SystemUtils.DevicePerfomance.High;
                     }
                     else
                     {
                         devicePerfomance = SystemUtils.DevicePerfomance.Low;
                     }
                     FMLogger.Log(string.Concat(new object[]
                     {
                         "detect ",
                         devicePerfomance,
                         " y: ",
                         num2
                     }));
                 }
             }
         }
         catch (Exception ex)
         {
             FMLogger.Log("device detect ex. fallback low");
             devicePerfomance = SystemUtils.DevicePerfomance.Low;
             Debug.Log(ex.ToString());
         }
         GeneralSettings.DevicePerfomance = devicePerfomance;
     }
     return(devicePerfomance);
 }
Esempio n. 29
0
    private IEnumerator InternetChecker()
    {
        int   fastPacedAttemps = 5;
        float shortTimeStep    = 3f;
        float longTimeStep     = 60f;

        while (fastPacedAttemps > 0 && this.noInternet)
        {
            fastPacedAttemps--;
            FMLogger.Log("short step internet check");
            this.InternetCheck(null);
            yield return(new WaitForSeconds(shortTimeStep));
        }
        while (this.noInternet)
        {
            FMLogger.Log("short step internet check");
            this.InternetCheck(null);
            yield return(new WaitForSeconds(longTimeStep));
        }
        yield break;
    }
Esempio n. 30
0
 private void LoadIcon()
 {
     if (this.lazyLoad)
     {
         return;
     }
     this.loadIcon.SetActive(true);
     this.iconDownloadTask = new IconDownloadTask(this.imageData.baseUrl, this.imageData.relativePath, this.imageData.CacheKey, delegate(bool success, Texture2D tex)
     {
         if (success && tex != null)
         {
             this.loadIcon.SetActive(false);
             this.img.texture = tex;
         }
         else
         {
             FMLogger.Log("Error loading external pic: " + this.imageData.relativePath);
         }
         this.iconDownloadTask = null;
     });
     ImageManager.Instance.DownloadIcon(this.iconDownloadTask);
 }