Skip to content

Instantly share code, notes, and snippets.

@a-v-ebrahimi
a-v-ebrahimi / spinner_with_icons
Last active April 2, 2020 08:50
Android Spinner with icons
final Item[] items = {
new Item("Email", android.R.drawable.ic_menu_add),
new Item("Facebook", android.R.drawable.ic_menu_delete),
new Item("...", 0),//no icon for this one
};
ListAdapter adapter = new ArrayAdapter<Item>(
this,
android.R.layout.select_dialog_item,
android.R.id.text1,
@a-v-ebrahimi
a-v-ebrahimi / check_google_play_services
Created July 2, 2014 12:57
Check Google Play Services Is Available
private void checkGooglePlayServicesIsAvailable() {
int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (errorCode != ConnectionResult.SUCCESS) {
GooglePlayServicesUtil.getErrorDialog(errorCode, this, 0).show();
}
}
@a-v-ebrahimi
a-v-ebrahimi / exec_honey
Created June 8, 2014 21:19
Android:Execute AsyncTask Honeycomb
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
my_task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[])null);
else
my_task.execute((Void[])null);
@a-v-ebrahimi
a-v-ebrahimi / ios_show_alert
Created March 2, 2014 11:52
iOS : Show alert
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title"
message:@"prompt"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil ];
alert.tag = 10;
[alert show];
@a-v-ebrahimi
a-v-ebrahimi / autoselectimage
Created November 29, 2012 11:32
iOS : Auto select image for Retina 4
#define isPhone568 ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568)
#define iPhone568ImageNamed(image) (isPhone568 ? [NSString stringWithFormat:@"%@-568h.%@", [image stringByDeletingPathExtension], [image pathExtension]] : image)
#define iPhone568Image(image) ([UIImage imageNamed:iPhone568ImageNamed(image)])
@a-v-ebrahimi
a-v-ebrahimi / multithread_blocks
Created August 8, 2012 14:16
iOS : Multithread block + UI
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Add code here to do background processing
//
//
dispatch_async( dispatch_get_main_queue(), ^{
// Add code here to update the UI/send notifications based on the
// results of the background processing
});
});
@a-v-ebrahimi
a-v-ebrahimi / gist:2487014
Created April 25, 2012 06:08
Android: show progress dialog
private ProgressDialog myProgressDialog;
...
myProgressDialog = ProgressDialog.show(actRSS.this,
"Please wait...", "Loading Data...", true);
...
myProgressDialog.dismiss();
@a-v-ebrahimi
a-v-ebrahimi / AnimationHelepr
Created April 21, 2012 02:11
android animation helper for viewflipper
//flip1.setInAnimation(AnimationHelper
// .inFromRightAnimation(300));
// flip1.setOutAnimation(AnimationHelper
// .outToLeftAnimation(300));
package com.euphratesmedia.commonroutines;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
@a-v-ebrahimi
a-v-ebrahimi / changetablebackground
Created April 9, 2012 13:05
iPhone : Change background of UITableView to image
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"BackgroundPattern.png"]];
@a-v-ebrahimi
a-v-ebrahimi / AsyncTask
Created April 8, 2012 04:54
Android AsyncTask
.
.
.
new DownloadFilesTask().execute(url1, url2, url3);
.
.
.
private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {