Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

31
LINES

< > BotCompany Repo | #1000427 // Android Example: Widget animation test (seems quite fast)

JavaX source code (Android) [tags: use-pretranspiled] - run with: the app

Libraryless. Click here for Pure Java version (1512L/10K/36K).

!7

import android.app.Activity;
import android.widget.*;
import android.graphics.*;
import android.content.*; // Intent etc.

p {
  int frames = 100;
  
  print("Putting " + frames + " frames on widget... Switching to home screen so you can see it!");

  // go to home screen    
  Intent startMain = new Intent(Intent.ACTION_MAIN);
  startMain.addCategory(Intent.CATEGORY_HOME);
  startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  call(androidContext, "startActivity", startMain);
  
  for f to frames: {
    int shift=new java.util.Random().nextInt();
    int w=256, h=256;
    int[] pixels = new int[w*h];
    for (int i=0; i < w*h; i++)
      pixels[i] = i+shift;

    Bitmap bitmap = Bitmap.createBitmap(pixels, w, h, Bitmap.Config.RGB_565);
  
    call(androidContext(), "updateWidgetWithBitmap", bitmap);
  }
  print("yo");
}

Author comment

Began life as a copy of #710

download  show line numbers  debug dex  old transpilations   

Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, exkalrxbqyxc, gwrvuhgaqvyk, hxnwyiuffukg, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, mrjhfnjfopze, odkhaoglnmdk, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000427
Snippet name: Android Example: Widget animation test (seems quite fast)
Eternal ID of this version: #1000427/2
Text MD5: 2c5d96291760795f9207b685ead4132b
Transpilation MD5: 3ffb95e23cfc9155d995f8ba3ab7669b
Author: stefan
Category: javax android
Type: JavaX source code (Android)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-21 00:21:24
Source code size: 866 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 639 / 637
Version history: 1 change(s)
Referenced in: [show references]