forked from DrKLO/Telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Oleg Isupov
committed
Oct 13, 2015
1 parent
433cf84
commit 118970b
Showing
3 changed files
with
72 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
TMessagesProj/src/main/java/org/telegram/Ytils/StickersManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) 2015 Yandex LLC. All rights reserved. | ||
// Author: Oleg Isupov <[email protected]> | ||
|
||
package org.telegram.Ytils; | ||
|
||
import android.content.Context; | ||
|
||
import org.telegram.messenger.AndroidUtilities; | ||
import org.telegram.messenger.query.StickersQuery; | ||
import org.telegram.tgnet.ConnectionsManager; | ||
import org.telegram.tgnet.RequestDelegate; | ||
import org.telegram.tgnet.TLObject; | ||
import org.telegram.tgnet.TLRPC; | ||
|
||
public class StickersManager { | ||
|
||
private static final String[] STICKER_SETS = new String[]{"fngrm_1", "fngrm_2"}; | ||
|
||
public static final StickersManager INSTANCE = new StickersManager(); | ||
|
||
private boolean started; | ||
private int counter = STICKER_SETS.length; | ||
|
||
public void installStickers(final Context context) { | ||
if (started) { | ||
return; | ||
} | ||
started = true; | ||
|
||
if (context.getSharedPreferences("YandexPreferences", Context.MODE_PRIVATE) | ||
.getBoolean("StickersInstalled", false)) { | ||
return; | ||
} | ||
|
||
for (int i = 0; i < STICKER_SETS.length; i++) { | ||
TLRPC.TL_inputStickerSetShortName stickerset = new TLRPC.TL_inputStickerSetShortName(); | ||
stickerset.short_name = STICKER_SETS[i]; | ||
TLRPC.TL_messages_installStickerSet req = new TLRPC.TL_messages_installStickerSet(); | ||
req.stickerset = stickerset; | ||
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { | ||
@Override | ||
public void run(final TLObject response, final TLRPC.TL_error error) { | ||
if (error == null) { | ||
checkAllStickersInstalled(context); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private void checkAllStickersInstalled(final Context context) { | ||
AndroidUtilities.runOnUIThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
counter--; | ||
if (counter == 0) { | ||
StickersQuery.loadStickers(false, true); | ||
// context.getSharedPreferences("YandexPreferences", Context.MODE_PRIVATE).edit() | ||
// .putBoolean("StickersInstalled", true); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters