Skip to content

Instantly share code, notes, and snippets.

View SelvinPL's full-sized avatar

SelvinPL SelvinPL

View GitHub Profile
<!-- values/attr.xml -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="my_image" format="reference" />
</resources>
<!-- values/styles.xml -->
<style name="MyThemeBase" parent="@style/MyThemeBaseBase">
<item name="my_image">@drawable/my_image_en</item>
</style>
@SelvinPL
SelvinPL / build.gradle
Last active August 29, 2015 14:20
Minimal working example ... without NPE
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "pl.selvin.android.actionbar14"
minSdkVersion 14
targetSdkVersion 22
class Service {
onStartCommand() {
enableGatheringOfSignalData();
}
useSignalData(data) {
//do the stuff with signal data
}
@SelvinPL
SelvinPL / app_src_main_AndroidManifest.xml
Last active August 29, 2015 14:23
It's working for me
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pl.selvin.android.sigletaskissingle">
<application
android:allowBackup="true"
android:label="SingleTaskIsSingleTask">
<activity
android:name=".Activities$ActivityA"
android:label="Activity A"
android:launchMode="singleTask">
project.ext.versionCode = project.hasProperty("versionCode") ? project.versionCode.toInteger() : 3
project.ext.versionName = project.hasProperty("versionName") ? project.versionName : "1.0"
android {
defaultConfig {
versionCode project.versionCode
versionName project.versionName
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def getVersionCode(int default_) {
return project.hasProperty('versionCode') ? versionCode.toInteger() : default_
}
def getVersionName(String default_) {
return project.hasProperty('versionName') ? versionName : default_
}
versionCode getVersionCode(3)
versionName getVersionName("1.0")
public class MinimalArrayAdapter<T> extends BaseAdapter {
LayoutInflater inflater = null;
ArrayList<T> mObjects = null;
public MinimalArrayAdapter(Context ctx, ArrayList<T> list) {
mObjects = list;
inflater = LayoutInflater.from(ctx);
}
@Override
public class TestActivity extends Activity {
final Object uiHandlerLock = new Object();
Button butt;
HandlerThread thread;
Handler backgroundHandler;
Handler uiHandler;
@Override
@SelvinPL
SelvinPL / app_build.gradle
Last active August 29, 2015 14:25
LocalBroadcastManager for communication between activities is bad, m'kay!
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "pl.selvin.android.localbroadcastreceivertest"
minSdkVersion 4
targetSdkVersion 22
SimpleAdapter adapter = ...;
adapter.setViewBinder(new SimpleAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Object data, String textRepresentation) {
if(view.getId() == R.id.imageView1) { //view is our ImageView
((ImageView)view).setImageBitmap((Bitmap)data);
return true;
}
//Otherwise do default stuff