fix MultiImageSelectorFragment
This commit is contained in:
parent
ca83824959
commit
9734e9fc73
|
|
@ -44,7 +44,7 @@
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,6 @@ public class MultiImageSelectorFragment extends Fragment {
|
||||||
public static final String EXTRA_SELECT_MODE = "select_count_mode";
|
public static final String EXTRA_SELECT_MODE = "select_count_mode";
|
||||||
/** Whether show camera,true by default */
|
/** Whether show camera,true by default */
|
||||||
public static final String EXTRA_SHOW_CAMERA = "show_camera";
|
public static final String EXTRA_SHOW_CAMERA = "show_camera";
|
||||||
/** Result data set,ArrayList<String>*/
|
|
||||||
public static final String EXTRA_RESULT = "select_result";
|
|
||||||
/** Original data set */
|
/** Original data set */
|
||||||
public static final String EXTRA_DEFAULT_SELECTED_LIST = "default_list";
|
public static final String EXTRA_DEFAULT_SELECTED_LIST = "default_list";
|
||||||
|
|
||||||
|
|
@ -98,10 +96,7 @@ public class MultiImageSelectorFragment extends Fragment {
|
||||||
private TextView mCategoryText;
|
private TextView mCategoryText;
|
||||||
private View mPopupAnchorView;
|
private View mPopupAnchorView;
|
||||||
|
|
||||||
private int mDesireImageCount;
|
|
||||||
|
|
||||||
private boolean hasFolderGened = false;
|
private boolean hasFolderGened = false;
|
||||||
private boolean mIsShowCamera = false;
|
|
||||||
|
|
||||||
private File mTmpFile;
|
private File mTmpFile;
|
||||||
|
|
||||||
|
|
@ -124,19 +119,14 @@ public class MultiImageSelectorFragment extends Fragment {
|
||||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
mDesireImageCount = getArguments().getInt(EXTRA_SELECT_COUNT);
|
final int mode = selectMode();
|
||||||
|
|
||||||
final int mode = getArguments().getInt(EXTRA_SELECT_MODE);
|
|
||||||
|
|
||||||
if(mode == MODE_MULTI) {
|
if(mode == MODE_MULTI) {
|
||||||
ArrayList<String> tmp = getArguments().getStringArrayList(EXTRA_DEFAULT_SELECTED_LIST);
|
ArrayList<String> tmp = getArguments().getStringArrayList(EXTRA_DEFAULT_SELECTED_LIST);
|
||||||
if(tmp != null && tmp.size()>0) {
|
if(tmp != null && tmp.size()>0) {
|
||||||
resultList = tmp;
|
resultList = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mImageAdapter = new ImageGridAdapter(getActivity(), showCamera(), 3);
|
||||||
mIsShowCamera = getArguments().getBoolean(EXTRA_SHOW_CAMERA, true);
|
|
||||||
mImageAdapter = new ImageGridAdapter(getActivity(), mIsShowCamera, 3);
|
|
||||||
mImageAdapter.showSelectIndicator(mode == MODE_MULTI);
|
mImageAdapter.showSelectIndicator(mode == MODE_MULTI);
|
||||||
|
|
||||||
mPopupAnchorView = view.findViewById(R.id.footer);
|
mPopupAnchorView = view.findViewById(R.id.footer);
|
||||||
|
|
@ -231,7 +221,7 @@ public class MultiImageSelectorFragment extends Fragment {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
|
getActivity().getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
|
||||||
mCategoryText.setText(R.string.folder_all);
|
mCategoryText.setText(R.string.folder_all);
|
||||||
if (mIsShowCamera) {
|
if (showCamera()) {
|
||||||
mImageAdapter.setShowCamera(true);
|
mImageAdapter.setShowCamera(true);
|
||||||
} else {
|
} else {
|
||||||
mImageAdapter.setShowCamera(false);
|
mImageAdapter.setShowCamera(false);
|
||||||
|
|
@ -288,6 +278,7 @@ public class MultiImageSelectorFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
// delete tmp file
|
||||||
while (mTmpFile != null && mTmpFile.exists()){
|
while (mTmpFile != null && mTmpFile.exists()){
|
||||||
boolean success = mTmpFile.delete();
|
boolean success = mTmpFile.delete();
|
||||||
if(success){
|
if(success){
|
||||||
|
|
@ -379,7 +370,7 @@ public class MultiImageSelectorFragment extends Fragment {
|
||||||
mCallback.onImageUnselected(image.path);
|
mCallback.onImageUnselected(image.path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(mDesireImageCount == resultList.size()){
|
if(selectImageCount() == resultList.size()){
|
||||||
Toast.makeText(getActivity(), R.string.msg_amount_limit, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), R.string.msg_amount_limit, Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -498,6 +489,18 @@ public class MultiImageSelectorFragment extends Fragment {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean showCamera(){
|
||||||
|
return getArguments() == null || getArguments().getBoolean(EXTRA_SHOW_CAMERA, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int selectMode(){
|
||||||
|
return getArguments() == null ? MODE_MULTI : getArguments().getInt(EXTRA_SELECT_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int selectImageCount(){
|
||||||
|
return getArguments() == null ? 9 : getArguments().getInt(EXTRA_SELECT_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for host activity
|
* Callback for host activity
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue