@@ -81,6 +81,9 @@ public class ExtrasFragment extends Fragment {
81
81
private UUID barcodeTileId = UUID .fromString ("23d392df-dd0c-4e93-8c0d-63dd7b02eb52" );
82
82
private UUID flashlightTileId = UUID .fromString ("c2187a9c-db5c-4e73-9f9d-d742113f91e8" );
83
83
84
+ String barcode39 = "MK12345509" ;
85
+ String barcode417 = "901234567890123456" ;
86
+
84
87
public static ExtrasFragment newInstance () {
85
88
return new ExtrasFragment ();
86
89
}
@@ -149,28 +152,28 @@ public void onClick(View v) {
149
152
public void onItemSelected (AdapterView <?> parent , View view , int position , long id ) {
150
153
switch (position ) {
151
154
case 1 :
152
- name .setText (sharedPreferences .getString ("name1" , "CODE39 " ));
153
- number .setText (sharedPreferences .getString ("no1" , "MK12345509" ));
155
+ name .setText (sharedPreferences .getString ("name1" , "Barcode 1 " ));
156
+ number .setText (sharedPreferences .getString ("no1" , barcode39 ));
154
157
typeSpinner .setSelection (sharedPreferences .getInt ("type1" , 1 ));
155
158
break ;
156
159
case 2 :
157
- name .setText (sharedPreferences .getString ("name2" , "PDF417 " ));
158
- number .setText (sharedPreferences .getString ("no2" , "901234567890123456" ));
160
+ name .setText (sharedPreferences .getString ("name2" , "Barcode 2 " ));
161
+ number .setText (sharedPreferences .getString ("no2" , barcode417 ));
159
162
typeSpinner .setSelection (sharedPreferences .getInt ("type2" , 2 ));
160
163
break ;
161
164
case 3 :
162
- name .setText (sharedPreferences .getString ("name3" , "CODE39 " ));
163
- number .setText (sharedPreferences .getString ("no3" , "MK12345509" ));
165
+ name .setText (sharedPreferences .getString ("name3" , "Barcode 3 " ));
166
+ number .setText (sharedPreferences .getString ("no3" , barcode39 ));
164
167
typeSpinner .setSelection (sharedPreferences .getInt ("type3" , 1 ));
165
168
break ;
166
169
case 4 :
167
- name .setText (sharedPreferences .getString ("name4" , "PDF417 " ));
168
- number .setText (sharedPreferences .getString ("no4" , "901234567890123456" ));
170
+ name .setText (sharedPreferences .getString ("name4" , "Barcode 4 " ));
171
+ number .setText (sharedPreferences .getString ("no4" , barcode417 ));
169
172
typeSpinner .setSelection (sharedPreferences .getInt ("type4" , 2 ));
170
173
break ;
171
174
case 5 :
172
- name .setText (sharedPreferences .getString ("name5" , "CODE39 " ));
173
- number .setText (sharedPreferences .getString ("no5" , "MK12345509" ));
175
+ name .setText (sharedPreferences .getString ("name5" , "Barcode 5 " ));
176
+ number .setText (sharedPreferences .getString ("no5" , barcode39 ));
174
177
typeSpinner .setSelection (sharedPreferences .getInt ("type5" , 1 ));
175
178
break ;
176
179
}
@@ -529,11 +532,11 @@ private boolean addBarcodeTile() throws Exception {
529
532
SharedPreferences sharedPreferences = getContext ().getSharedPreferences ("MyPrefs" , 0 );
530
533
BandTile tile = new BandTile .Builder (barcodeTileId , getString (R .string .barcode_tile ), tileIcon )
531
534
.setTileSmallIcon (badgeIcon ).setPageLayouts (
532
- createBarcodeLayout (sharedPreferences .getInt ("type1 " , 1 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 , 50 , 51 ),
533
- createBarcodeLayout (sharedPreferences .getInt ("type2 " , 1 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 , 52 , 53 ),
534
- createBarcodeLayout (sharedPreferences .getInt ("type3" , 1 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 , 54 , 55 ),
535
- createBarcodeLayout (sharedPreferences .getInt ("type4 " , 1 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 , 56 , 57 ),
536
- createBarcodeLayout (sharedPreferences .getInt ("type5 " , 1 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 , 58 , 59 )).build ();
535
+ createBarcodeLayout (sharedPreferences .getInt ("type5 " , 1 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 ),
536
+ createBarcodeLayout (sharedPreferences .getInt ("type4 " , 2 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 ),
537
+ createBarcodeLayout (sharedPreferences .getInt ("type3" , 1 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 ),
538
+ createBarcodeLayout (sharedPreferences .getInt ("type2 " , 2 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 ),
539
+ createBarcodeLayout (sharedPreferences .getInt ("type1 " , 1 ) == 1 ? BarcodeType .CODE39 : BarcodeType .PDF417 )).build ();
537
540
appendToUI (getString (R .string .barcode_tile_adding ), Style .INFO );
538
541
if (client .getTileManager ().addTile (getActivity (), tile ).await ()) {
539
542
appendToUI (getString (R .string .barcode_tile_added ), Style .CONFIRM );
@@ -544,38 +547,42 @@ private boolean addBarcodeTile() throws Exception {
544
547
}
545
548
}
546
549
547
- private PageLayout createBarcodeLayout (BarcodeType type , int id1 , int id2 ) {
550
+ private PageLayout createBarcodeLayout (BarcodeType type ) {
548
551
return new PageLayout (
549
552
new FlowPanel (15 , 0 , 245 , 105 , FlowPanelOrientation .VERTICAL )
550
553
.addElements (new Barcode (0 , 0 , 221 , 70 , type )
551
- .setId (id1 ).setMargins (3 , 0 , 0 , 0 ))
554
+ .setId (11 ).setMargins (3 , 0 , 0 , 0 ))
552
555
.addElements (new TextBlock (0 , 0 , 230 , 30 , TextBlockFont .SMALL , 0 )
553
- .setId (id2 ).setColor (Color .RED )));
556
+ .setId (21 ).setColor (Color .RED )));
554
557
}
555
558
556
559
private void updateBarcodePages () throws BandIOException {
557
- SharedPreferences sharedPreferences = getContext ().getSharedPreferences ("MyPrefs" , 0 );
560
+ final SharedPreferences sharedPreferences = getContext ().getSharedPreferences ("MyPrefs" , 0 );
561
+ final String no1 = sharedPreferences .getString ("no1" , barcode39 );
562
+ final String no2 = sharedPreferences .getString ("no2" , barcode417 );
563
+ final String no3 = sharedPreferences .getString ("no3" , barcode39 );
564
+ final String no4 = sharedPreferences .getString ("no4" , barcode417 );
565
+ final String no5 = sharedPreferences .getString ("no5" , barcode39 );
558
566
client .getTileManager ().setPages (barcodeTileId ,
559
- new PageData (barcodeId5 , 4 )
560
- .update (new BarcodeData (59 , sharedPreferences .getString ("no5" , "MK12345509" ),
561
- (sharedPreferences .getInt ("type5" , 1 ) == 1 ) ? BarcodeType .CODE39 : BarcodeType .PDF417 ))
562
- .update (new TextBlockData (58 , sharedPreferences .getString ("no5" , "MK12345509" ))),
563
- new PageData (barcodeId4 , 3 )
564
- .update (new BarcodeData (57 , sharedPreferences .getString ("no4" , "901234567890123456" ),
565
- (sharedPreferences .getInt ("type4" , 1 ) == 1 ) ? BarcodeType .CODE39 : BarcodeType .PDF417 ))
566
- .update (new TextBlockData (56 , sharedPreferences .getString ("no4" , "901234567890123456" ))),
567
+ new PageData (barcodeId1 , 0 )
568
+ .update (new BarcodeData (11 , no5 , (sharedPreferences .getInt ("type5" , 1 ) == 1 ) ? BarcodeType .CODE39 : BarcodeType .PDF417 ))
569
+ .update (new TextBlockData (21 , no5 )),
570
+ new PageData (barcodeId2 , 1 )
571
+ .update (new BarcodeData (11 , no4 ,
572
+ (sharedPreferences .getInt ("type4" , 2 ) == 1 ) ? BarcodeType .CODE39 : BarcodeType .PDF417 ))
573
+ .update (new TextBlockData (21 , no4 )),
567
574
new PageData (barcodeId3 , 2 )
568
- .update (new BarcodeData (55 , sharedPreferences . getString ( " no3" , "MK12345509" ) ,
575
+ .update (new BarcodeData (11 , no3 ,
569
576
(sharedPreferences .getInt ("type3" , 1 ) == 1 ) ? BarcodeType .CODE39 : BarcodeType .PDF417 ))
570
- .update (new TextBlockData (54 , sharedPreferences . getString ( " no3" , "MK12345509" ) )),
571
- new PageData (barcodeId2 , 1 )
572
- .update (new BarcodeData (53 , sharedPreferences . getString ( " no2" , "901234567890123456" ) ,
573
- (sharedPreferences .getInt ("type2" , 1 ) == 1 ) ? BarcodeType .CODE39 : BarcodeType .PDF417 ))
574
- .update (new TextBlockData (52 , sharedPreferences . getString ( " no2" , "901234567890123456" ) )),
575
- new PageData (barcodeId1 , 0 )
576
- .update (new BarcodeData (51 , sharedPreferences . getString ( " no1" , "MK12345509" ) ,
577
+ .update (new TextBlockData (21 , no3 )),
578
+ new PageData (barcodeId4 , 3 )
579
+ .update (new BarcodeData (11 , no2 ,
580
+ (sharedPreferences .getInt ("type2" , 2 ) == 1 ) ? BarcodeType .CODE39 : BarcodeType .PDF417 ))
581
+ .update (new TextBlockData (21 , no2 )),
582
+ new PageData (barcodeId5 , 4 )
583
+ .update (new BarcodeData (11 , no1 ,
577
584
(sharedPreferences .getInt ("type1" , 1 ) == 1 ) ? BarcodeType .CODE39 : BarcodeType .PDF417 ))
578
- .update (new TextBlockData (50 , sharedPreferences . getString ( " no1" , "MK12345509" ) )));
585
+ .update (new TextBlockData (21 , no1 )));
579
586
}
580
587
581
588
private PageLayout createFlashlight1Layout () {
0 commit comments