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).

1  
!7
2  
3  
import android.app.Activity;
4  
import android.widget.*;
5  
import android.graphics.*;
6  
import android.content.*; // Intent etc.
7  
8  
p {
9  
  int frames = 100;
10  
  
11  
  print("Putting " + frames + " frames on widget... Switching to home screen so you can see it!");
12  
13  
  // go to home screen    
14  
  Intent startMain = new Intent(Intent.ACTION_MAIN);
15  
  startMain.addCategory(Intent.CATEGORY_HOME);
16  
  startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
17  
  call(androidContext, "startActivity", startMain);
18  
  
19  
  for f to frames: {
20  
    int shift=new java.util.Random().nextInt();
21  
    int w=256, h=256;
22  
    int[] pixels = new int[w*h];
23  
    for (int i=0; i < w*h; i++)
24  
      pixels[i] = i+shift;
25  
26  
    Bitmap bitmap = Bitmap.createBitmap(pixels, w, h, Bitmap.Config.RGB_565);
27  
  
28  
    call(androidContext(), "updateWidgetWithBitmap", bitmap);
29  
  }
30  
  print("yo");
31  
}

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: 646 / 648
Version history: 1 change(s)
Referenced in: [show references]