11package com .github .developerpaul123 .filepickerlibrary ;
22
33import android .app .Activity ;
4+ import android .content .Context ;
45import android .content .Intent ;
56import android .support .annotation .ColorRes ;
67
7- import com .github .developerpaul123 .filepickerlibrary .enums .Scope ;
88import com .github .developerpaul123 .filepickerlibrary .enums .FileType ;
9+ import com .github .developerpaul123 .filepickerlibrary .enums .Scope ;
910
1011/**
1112 * Created by Paul on 11/23/2015.
1213 */
1314public class FilePickerBuilder {
1415
15- private final Activity mActivity ;
16- boolean useMaterial ;
17- private Scope mScope ;
18- private int requestCode ;
19- private int color ;
20- private FileType mimeType ;
16+ private final Context mContext ;
17+ private boolean useMaterial ;
18+ private Scope mScope = Scope . ALL ;
19+ private int requestCode = FilePicker . REQUEST_FILE ;
20+ private int color = android . R . color . holo_blue_bright ;
21+ private FileType mimeType = FileType . NONE ;
2122
2223 /**
2324 * Builder class to build a filepicker activity.
2425 *
25- * @param activity the calling activity.
26+ * @param context the calling activity.
2627 */
27- public FilePickerBuilder (Activity activity ) {
28- color = android .R .color .holo_blue_bright ;
29- mScope = Scope .ALL ;
30- mimeType = FileType .NONE ;
31- requestCode = FilePicker .REQUEST_FILE ;
32- mActivity = activity ;
33- useMaterial = false ;
28+ public FilePickerBuilder (Context context ) {
29+ mContext = context ;
3430 }
3531
3632 /**
@@ -93,7 +89,7 @@ public FilePickerBuilder useMaterialActivity(boolean use) {
9389 @ Deprecated
9490 public void launch () {
9591 Intent intent = build ();
96- mActivity .startActivityForResult (intent , requestCode );
92+ (( Activity ) mContext ) .startActivityForResult (intent , requestCode );
9793 }
9894
9995 /**
@@ -102,7 +98,7 @@ public void launch() {
10298 * @return a filepicker intent.
10399 */
104100 public Intent build () {
105- Intent filePicker = new Intent (mActivity , useMaterial ? FilePicker .class : FilePickerActivity .class );
101+ Intent filePicker = new Intent (mContext , useMaterial ? FilePicker .class : FilePickerActivity .class );
106102 filePicker .putExtra (FilePicker .SCOPE_TYPE , mScope );
107103 filePicker .putExtra (FilePicker .REQUEST_CODE , requestCode );
108104 filePicker .putExtra (FilePicker .INTENT_EXTRA_COLOR_ID , color );
@@ -117,6 +113,6 @@ public Intent build() {
117113 */
118114 public void launch (int requestCode ) {
119115 Intent intent = build ();
120- mActivity .startActivityForResult (intent , requestCode );
116+ (( Activity ) mContext ) .startActivityForResult (intent , requestCode );
121117 }
122118}
0 commit comments