Guest User

Untitled

a guest
Jan 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. public class ImageDescription extends MainScreen implements FieldChangeListener
  2. {
  3. VerticalFieldManager vertical,ver;
  4. HorizontalFieldManager hor;
  5. Font font = Font.getDefault().derive(Font.BOLD, 15);
  6. // private CommonFeedBean obj;
  7. private HorizontalFieldManager hr1;
  8. private LabelField label[];
  9. ResponseHandler_Review response = new ResponseHandler_Review();
  10. // private LabelField label1[];
  11. public Bitmap scaleBit[];
  12. public Bitmap bit[];
  13.  
  14. // private BitmapField bit;
  15. public ImageDescription()
  16. {
  17. System.out.println("inside the ImageDescription Constructor");
  18.  
  19. if(ResponseHandler_Review.vectorLocation1.size()==0){
  20. System.out.println("inside the No data availabel method");
  21. UiApplication.getUiApplication().invokeLater(new Runnable() {
  22. public void run() {
  23. Dialog.inform("No data available");
  24. }
  25. });
  26. System.out.println("outside the No data availabel method");
  27. }else{
  28.  
  29. createGUI();
  30. System.out.println("goint into the createGUI method");
  31. }
  32.  
  33. }
  34. public void createGUI()
  35. {
  36. System.out.println("inside the createGUI method");
  37. label = new LabelField[ResponseHandler_Review.vectorLocation1.size()];
  38. System.out.println("label Data"+label.toString());
  39.  
  40. vertical = new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR){
  41. protected void sublayout(int maxWidth, int maxHeight) {
  42. super.sublayout(Display.getWidth(),Display.getHeight());
  43. setExtent(Display.getWidth(),Display.getHeight());
  44. }
  45. };
  46. System.out.println("after vertical field manager");
  47. vertical.setBackground(BackgroundFactory.createSolidBackground(0x95B9C7));
  48. ver = new VerticalFieldManager(VERTICAL_SCROLL|VERTICAL_SCROLLBAR);
  49.  
  50. String arg1[];
  51. System.out.println("at second vertical field manager");
  52. System.out.println("vectorlocation size " +ResponseHandler_Review.vectorLocation1.size());
  53. arg1 = new String[ResponseHandler_Review.vectorLocation1.size()];
  54. for(int k = 0; k< ResponseHandler_Review.vectorLocation1.size(); k++){
  55. arg1[k] = String.valueOf(ResponseHandler_Review.vectorLocation1.elementAt(k));
  56. System.out.println("Vector element is "+k+" = "+arg1[k]);
  57. }
  58. for(int i=0;i<ResponseHandler_Review.vectorLocation1.size();i++)
  59. {
  60. System.out.println("inside the for loop");
  61. // obj = (CommonFeedBean) ResponseHandler_Review.vectorLocation1.elementAt(i);
  62. System.out.println("inside the obj++++++");
  63. hr1 = new HorizontalFieldManager(){
  64. protected void onFocus(int direction) {
  65. invalidate();
  66. super.onFocus(direction);
  67. }
  68.  
  69. protected void onUnfocus() {
  70. invalidate();
  71. super.onUnfocus();
  72. }
  73.  
  74. public void paint(Graphics graphics) {
  75. if (isFocus()) {
  76. graphics.setBackgroundColor(Color.WHITE);
  77. graphics.clear();
  78. }
  79. super.paint(graphics);
  80. }
  81. };
  82.  
  83. String arg[] ;
  84.  
  85. System.out.println("vectorlocation size " + ResponseHandler_Review.vectorLocation1.size());
  86. arg = new String[ResponseHandler_Review.vectorLocation1.size()];
  87. for(int j = 0; j< ResponseHandler_Review.vectorLocation1.size(); j++){
  88. arg[j] = String.valueOf(ResponseHandler_Review.vectorLocation1.elementAt(j));
  89. System.out.println("Vector element is "+j+" = "+arg[j]);
  90. bit[j] = response.getImage(arg[j]);
  91. scaleBit[j] = new Bitmap(162, 120);
  92. bit[j].scaleInto(scaleBit[j], Bitmap.FILTER_LANCZOS);
  93. hr1.add(new BitmapField(scaleBit[j]));
  94. }
  95.  
  96. try{
  97. // label[i] = new LabelField(obj.getTitle(), Field.FIELD_VCENTER|Field.FOCUSABLE)
  98. // {
  99. // public int getPreferredWidth()
  100. // {
  101. // return Display.getWidth()-150;
  102. // }
  103. // protected boolean navigationClick(int status, int time) {
  104. // fieldChangeNotify(0);
  105. //// obj.getLink();
  106. // return true;
  107. //
  108. // }
  109. //
  110. // };
  111. // label[i].setFont(font);
  112. // label[i].setChangeListener(this);
  113. // label[i].setPadding(5, 5, 0, 5);
  114. //
  115. System.out.println("print all the labels++++++++++++"+label[i]);
  116.  
  117. // hr1.add(label[i]);
  118. //
  119. ver.add(hr1);
  120. ver.add(new SeparatorField());
  121. }catch(Throwable e){
  122. System.out.println("not printing the label field ");
  123. System.out.println(e.toString());
  124. e.printStackTrace();
  125. }
  126. }
  127. vertical.add(ver);
  128. add(vertical);
  129. }
  130. public void fieldChanged(Field field, int context)
  131. {
  132. for(int i=0;i<ResponseHandler_Review.vectorLocation1.size();i++){
  133. if(field==label[i]){
  134. Dialog.inform("details"+i);
  135. }
  136. }
  137. }
  138. public boolean onClose() {
  139. UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
  140. return true;
  141. }
Add Comment
Please, Sign In to add comment