Skip to content

Instantly share code, notes, and snippets.

View j-onathan's full-sized avatar

Jonathan j-onathan

View GitHub Profile
private void setUpWebView()
{
mWebView = new WebView(getContext());
mWebView.setVerticalScrollBarEnabled(false);
mWebView.setHorizontalScrollBarEnabled(false);
mWebView.setWebViewClient(new FbDialog.FbWebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(mUrl);
mWebView.setLayoutParams(FILL);
mContent.addView(mWebView);
private void invokePlay( Boolean loop )
{
Boolean playing = ( mp.isLooping() || mp.isPlaying() );
if ( playing )
{
mp.pause();
mp.setLooping(loop);
mp.seekTo(0);
mp.start();
}
public void clearState() {
Editor editor = m_prefs.edit();
editor.remove(PREF_FIRSTRUN);
editor.remove(PREF_DONE_REV);
editor.remove(PREF_TODO_REV);
editor.remove(PREF_NEED_TO_PUSH);
editor.commit();
}
protected void onListItemClick (ListView listView, View view, int position, long id) {
super.onListItemClick(listView, view, position, id);
Editor editor = prefs.edit();
editor.putInt("index", listView.getFirstVisiblePosition());
editor.putInt("top", listView.getChildAt(0) == null ? 0 : listView.getChildAt(0).getTop());
editor.commit();
Object o = this.getListAdapter().getItem(position);
String testName = o.toString();
public static Location getLatestLocation(final Context context) {
LocationManager manager = (LocationManager) context
.getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(ACCURACY_FINE);
String provider = manager.getBestProvider(criteria, true);
Location bestLocation;
if (provider != null)
bestLocation = manager.getLastKnownLocation(provider);
else
public PushMessage(String jsonMessage) throws PreyException{
try {
JSONObject jsonObj = new JSONObject(jsonMessage);
JSONObject data = jsonObj.getJSONObject("data");
this.event = jsonObj.getString("event");
this.type = data.getString("type");
this.body = data.getString("body");
} catch (JSONException e) {
throw new PreyException("Couldn't parse pushed json message");
}
try {
in = pAssetManager.open(pAssetPath);
BitmapFactory.decodeStream(in, null, decodeOptions);
} catch (final IOException e) {
Debug.e("Failed loading Bitmap in AssetBitmapTextureAtlasSource. AssetPath: " + pAssetPath, e);
} finally {
StreamUtils.close(in);
}
TextView textView = (TextView)row.findViewById(android.R.id.text1);
float scale = activity.getResources().getDisplayMetrics().density;
boolean leftPadding = (parent.getTag().equals("right"));
boolean topPadding = (position == 0);
textView.setPadding((int)(20 * scale) * (leftPadding ? 2 : 1), (int)(20 * scale) * (!leftPadding && topPadding ? 1 : 0), (int)(20 * scale), 0);
textView.setText(item);
textView.setTextColor(Color.BLACK);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
protected void startRecording(String file){
if (!isRecording){
saveFile=file;
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(this.recording);
try {
recorder.prepare();
private void replyMessage(Context context, SmsMessage msg) {
SmsManager sms = SmsManager.getDefault();
String message = msg.getMessageBody();
sms.sendTextMessage(msg.getOriginatingAddress(), null, message, null, null);
}
}