Skip to content

Instantly share code, notes, and snippets.

@tonytan4ever
Last active August 29, 2015 14:08
Show Gist options
  • Save tonytan4ever/bc6178f0b4149485c068 to your computer and use it in GitHub Desktop.
Save tonytan4ever/bc6178f0b4149485c068 to your computer and use it in GitHub Desktop.
package com.example.jeromqexample;
import android.os.Handler;
import android.os.Bundle;
import android.os.Message;
public class Util {
public static final String MESSAGE_PAYLOAD_KEY = "jeromq-service-payload";
public static char[] reverseInPlace(byte[] input){
char[] string = new char[input.length];
for(int i=0;i < input.length;i++){
string[i] = (char)input[i];
};
for(int i = 0, j = string.length - 1; i < string.length / 2; i++, j--) {
char c = string[i];
string[i] = string[j];
string[j] = c;
}
return string;
};
public static Message bundledMessage(Handler uiThreadHandler, String msg) {
Message m = uiThreadHandler.obtainMessage();
prepareMessage(m, msg);
return m;
};
public static void prepareMessage(Message m, String msg){
Bundle b = new Bundle();
b.putString(MESSAGE_PAYLOAD_KEY, msg);
m.setData(b);
return ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment