Skip to content

Instantly share code, notes, and snippets.

View safaorhan's full-sized avatar
👋
Hey.

Safa Orhan safaorhan

👋
Hey.
View GitHub Profile
@safaorhan
safaorhan / MediaUtil.java
Created September 1, 2015 08:53
Bitmap - String Conversion
public String encodeThumbnail(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
return Base64.encodeToString(stream.toByteArray(), Base64.DEFAULT);
}
private Bitmap decodeThumbnail(String thumbData) {
byte[] bytes = Base64.decode(thumbData, Base64.DEFAULT);
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
@safaorhan
safaorhan / QuickBloxHelper.java
Created August 16, 2015 21:06
QBHelper - Step 3
public interface OnChatHistoryLoadedListener {
void onSuccess(ArrayList<QBChatMessage> messages);
void onError(List<String> list);
}
public interface OnUnreadMessageListener {
void onUnreadMessage(int unreadDialogCount);
}
@safaorhan
safaorhan / QuickBloxHelper.java
Last active August 29, 2015 14:27
QBHelper - Step 2
public void sendMessageToUser(int opponentId, String message) {
QBPrivateChat privateChat = createPrivateChatIfNotExist(opponentId);
if (null == getDialogOfOpponent(opponentId)) {
retrieveDialogs();
}
sendMessageToChat(privateChat, message);
}
private QBPrivateChat createPrivateChatIfNotExist(int opponentId) {
QBPrivateChat privateChat = privateChatManager.getChat(opponentId);
@safaorhan
safaorhan / QuickBloxHelper.java
Last active August 29, 2015 14:27
QBHelper - Step 1
QBPrivateChatManagerListener privateChatManagerListener;
QBMessageListener<QBPrivateChat> privateChatMessageListener;
public void initFramework() {
//..
privateChatMessageListener = new QBMessageListener<QBPrivateChat>() {
@Override
public void processMessage(QBPrivateChat qbPrivateChat, QBChatMessage qbChatMessage) {
if (qbChatMessage.isMarkable()) {
int opponentId = qbPrivateChat.getParticipant();
@safaorhan
safaorhan / goat.java
Created July 6, 2015 08:59
isUserAGoat()
/**
* Used to determine whether the user making this call is subject to
* teleportations.
*
* <p>As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method can
* now automatically identify goats using advanced goat recognition technology.</p>
*
* @return Returns true if the user making this call is a goat.
*/
public boolean isUserAGoat() {