2
2
3
3
import android .graphics .drawable .Drawable ;
4
4
import android .os .Bundle ;
5
- import android .view .View ;
6
5
import android .view .ViewGroup ;
7
6
import android .widget .ImageButton ;
8
7
import android .widget .ImageView ;
@@ -28,7 +27,7 @@ public class PhotoShowActivity extends TapiaActivity {
28
27
29
28
PhotoShowAdapter photoAdapter ;
30
29
ListView photoList ;
31
- int setcted = 0 ;
30
+ int setcted = 0 ;
32
31
String fileName ;
33
32
File dest ;
34
33
String dirPath ;
@@ -40,15 +39,15 @@ public class PhotoShowActivity extends TapiaActivity {
40
39
public List <PhotoListItem > curPhotoList ;
41
40
public String selectedPhoto ;
42
41
43
- public class PhotoListItem {
42
+ public class PhotoListItem {
44
43
public String [] pictureNames ;
45
44
public ImageView [] picturesView ;
46
45
47
- PhotoListItem (String [] photosName ){
46
+ PhotoListItem (String [] photosName ) {
48
47
pictureNames = new String [PHOTO_BY_LINE ];
49
48
picturesView = new ImageView [PHOTO_BY_LINE ];
50
49
int index = 0 ;
51
- for (String pName : photosName ) {
50
+ for (String pName : photosName ) {
52
51
pictureNames [index ] = pName ;
53
52
picturesView [index ] = new ImageView (activity );
54
53
index ++;
@@ -60,90 +59,79 @@ public class PhotoListItem{
60
59
protected void onCreate (Bundle savedInstanceState ) {
61
60
super .onCreate (savedInstanceState );
62
61
setContentView (R .layout .activity_showphoto );
63
- local = ( ImageButton ) findViewById (R .id .localButton );
64
- sdcard = ( ImageButton ) findViewById (R .id .sdcardButton );
65
- home = ( ImageButton ) findViewById (R .id .homeButton );
66
- photoList = ( ListView ) findViewById (android .R .id .list );
62
+ local = findViewById (R .id .localButton );
63
+ sdcard = findViewById (R .id .sdcardButton );
64
+ home = findViewById (R .id .homeButton );
65
+ photoList = findViewById (android .R .id .list );
67
66
// dirPath = CameraHelper.PICTURE_FOLDER;
68
67
dirPathThumbnail = CameraHelper .SMALL_PICTURE_FOLDER ;
69
68
loadPictures (dirPathThumbnail );
70
- photoAdapter = new PhotoShowAdapter (activity ,curPhotoList );
69
+ photoAdapter = new PhotoShowAdapter (activity , curPhotoList );
71
70
photoList .setAdapter (photoAdapter );
72
71
73
72
TapiaApp .setCustomViewBackground (((ViewGroup ) findViewById (android .R .id .content )).getChildAt (0 ).getBackground ());
74
73
75
74
local .setSelected (true );
76
75
sdcard .setSelected (false );
77
76
78
- sttProvider = TapiaApp .currentLanguage .getOnlineSTTProvider ();
79
- ttsProvider = TapiaApp .currentLanguage .getTTSProvider ();
80
- offlineNLUProvider = TapiaApp .currentLanguage .getOfflineNLUProvider ();
81
-
82
- home .setOnClickListener (new View .OnClickListener () {
83
- @ Override
84
- public void onClick (View v ) {
85
- finish ();
86
- }
77
+ sttProvider = TapiaApp .currentLanguage .getOnlineSTTProvider ();
78
+ ttsProvider = TapiaApp .currentLanguage .getTTSProvider ();
79
+ offlineNLUProvider = TapiaApp .currentLanguage .getOfflineNLUProvider ();
80
+
81
+ home .setOnClickListener (v -> finish ());
82
+ sdcard .setOnClickListener (v -> {
83
+ sdcard .setSelected (true );
84
+ local .setSelected (false );
85
+ dirPathThumbnail = "/storage/sdcard1/" ;//set to the sdcard path
86
+ loadPictures (dirPathThumbnail );
87
+ photoAdapter .refresh (curPhotoList );
87
88
});
88
- sdcard .setOnClickListener (new View .OnClickListener () {
89
- @ Override
90
- public void onClick (View v ) {
91
- sdcard .setSelected (true );
92
- local .setSelected (false );
93
- dirPathThumbnail = "/storage/sdcard1/" ;//set to the sdcard path
94
- loadPictures (dirPathThumbnail );
95
- photoAdapter .refresh (curPhotoList );
96
- }
97
- });
98
- local .setOnClickListener (new View .OnClickListener () {
99
- @ Override
100
- public void onClick (View v ) {
101
- local .setSelected (true );
102
- sdcard .setSelected (false );
103
- dirPathThumbnail = CameraHelper .SMALL_PICTURE_FOLDER ;
104
- loadPictures (dirPathThumbnail );
105
- photoAdapter .refresh (curPhotoList );
106
- }
89
+ local .setOnClickListener (v -> {
90
+ local .setSelected (true );
91
+ sdcard .setSelected (false );
92
+ dirPathThumbnail = CameraHelper .SMALL_PICTURE_FOLDER ;
93
+ loadPictures (dirPathThumbnail );
94
+ photoAdapter .refresh (curPhotoList );
107
95
});
108
96
109
97
}
110
98
111
99
112
- void loadPictures (String path ){
100
+ void loadPictures (String path ) {
113
101
File picFile = new File (path );
114
102
curPhotoList = new ArrayList <>();
115
103
String [] itemPictureList = new String [PHOTO_BY_LINE ];
116
104
int itemPicIndex = 0 ;
117
- if (picFile .exists () && picFile .isDirectory () && picFile .list () != null ){
118
- for (String pName : picFile .list ()) {
119
- if (pName .contains (".jpeg" ) || pName .contains (".jpg" ) || pName .contains (".png" )){
105
+ if (picFile .exists () && picFile .isDirectory () && picFile .list () != null ) {
106
+ for (String pName : picFile .list ()) {
107
+ if (pName .contains (".jpeg" ) || pName .contains (".jpg" ) || pName .contains (".png" )) {
120
108
itemPictureList [itemPicIndex ] = path + pName ;
121
109
itemPicIndex ++;
122
- if (itemPicIndex == PHOTO_BY_LINE ){
110
+ if (itemPicIndex == PHOTO_BY_LINE ) {
123
111
curPhotoList .add (new PhotoListItem (itemPictureList ));
124
112
itemPicIndex = 0 ;
125
113
}
126
114
}
127
115
}
128
116
129
- if (itemPicIndex > 0 ){
130
- for (int i = itemPicIndex ; i < PHOTO_BY_LINE ;i ++) {
117
+ if (itemPicIndex > 0 ) {
118
+ for (int i = itemPicIndex ; i < PHOTO_BY_LINE ; i ++) {
131
119
itemPictureList [i ] = null ;
132
120
}
133
121
curPhotoList .add (new PhotoListItem (itemPictureList ));
134
122
}
135
123
}
136
124
}
137
125
138
- public void refreshList (){
126
+ public void refreshList () {
139
127
loadPictures (dirPathThumbnail );
140
128
photoAdapter .refresh (curPhotoList );
141
129
}
142
130
143
- public Drawable findImageView (String photoName ){
144
- for (PhotoListItem photoItem : curPhotoList ) {
145
- for (int i = 0 ; i < PHOTO_BY_LINE ; i ++){
146
- if (photoItem .pictureNames [i ].equals (photoName ))
131
+ public Drawable findImageView (String photoName ) {
132
+ for (PhotoListItem photoItem : curPhotoList ) {
133
+ for (int i = 0 ; i < PHOTO_BY_LINE ; i ++) {
134
+ if (photoItem .pictureNames [i ].equals (photoName ))
147
135
return photoItem .picturesView [i ].getDrawable ();
148
136
}
149
137
}
0 commit comments