This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'iron_worker' | |
| class C2dmIronWorker < IronWorker::Base | |
| attr_accessor :auth_token | |
| attr_accessor :c2dms | |
| attr_accessor :params | |
| def run | |
| uri = URI.parse('https://android.clients.google.com/c2dm/send') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'iron_worker' | |
| class NotifsPusher | |
| def perform | |
| begin | |
| puts "Initializing IronWorker and pushing billions of C2dm into it..." | |
| IronWorker.configure do |config| | |
| config.token = ENV['IRON_WORKER_TOKEN'] | |
| config.project_id = ENV['IRON_WORKER_PROJECT_ID'] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| emulator-arm.exe -partition-size 123 -avd myandroid4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static final boolean isA = UUID.randomUUID().getLeastSignificantBits() % 2 == 0; | |
| @Override | |
| public void onCreate(...) { | |
| super.onCreate(saved...); | |
| if(!isA) { | |
| setContentView(R.layout.mainA); | |
| MyApp.getInstance().tracker().trackPageView("/AUser"); | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static boolean shinyNewAPIS = android.os.Build.VERSION_SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB; | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| Intent startActivityIntent = null; | |
| if(!shinyNewAPIS) { | |
| startActivityIntent = new Intent(this, legacyActivity.class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Limit allocations to find problems | |
| int prevLimit = -1; | |
| try { | |
| prevLimit = Debug.setAllocationLimit(0); | |
| // Do stuff | |
| } finally { | |
| Debug.setAllocationLimit(-1); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| view.setLayerType(View.LAYER_TYPE_HARDWARE, null); | |
| ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotationY", 180); | |
| animator.addListener(new AnimatorListenerAdapter() { | |
| @Override | |
| public void onAnimationEnd(Animator animation) { | |
| view.setLayerType(View.LAYER_TYPE_NONE, null); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Allocate a bitmap of the desired size | |
| Bitmap b = Bitmap.createBitmap(256, 256, BitmaP.Config.ARGB_8888); | |
| // Set the allocated bitmap as the target | |
| BitmapFactory.Options opts = new BitmapFactory.Options(); | |
| opts.inBitmap = b; | |
| // Decode resource in pre-allocated bitmap | |
| BitmapFactory.decodeResource(resources, R.drawable.texture, opts); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNDEFINED); | |
| view.measure(spec, spec); | |
| view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); | |
| Bitmap b = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); | |
| Canvas c = new Canvas(b); | |
| c.translate(-view.getScrollX(), -view.getScrollY()); | |
| view.draw(c); | |
| // OR | |
| view.setDrawingCacheEnabled(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Paint p = new Paint(); | |
| p.setAntiAlias(true); | |
| p.setTextSize(24); | |
| Bitmap b = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_8888); | |
| Canvas c = new Canvas(b); | |
| c.drawText("Devoxx", 0.0f, 128.0f, p); |