Commit 8df30b8dc9b213fe0d3d5d21b7e71c696b071901

Authored by 吴奎庆
1 parent 98e9df58

相机 拍照后数据处理

config.gradle
... ... @@ -21,7 +21,7 @@ ext {
21 21 //编译方式
22 22 debug : false,
23 23 //版本号
24   - version: "1.0.2.2",
  24 + version: "1.0.2.3",
25 25 //Lib库前缀
26 26 packeg : "com.cnlive.media",
27 27 //Lib库名称
... ...
lib_media/src/main/java/com/cnlive/media/frame/view/MediaPickerFragmentView.java
... ... @@ -196,14 +196,14 @@ public class MediaPickerFragmentView implements MvpView {
196 196 mediaActivity.allMedias.get(mediaActivity.allMedias.indexOf(select)).setSelect(true);
197 197 }
198 198 }
199   - List<Media> listMedias = medias.get(0).getMedias();
  199 +// List<Media> listMedias = medias.get(0).getMedias();
200 200 if (mediaActivity.needCamera && medias.get(0) != null && medias.get(0).getMedias() != null
201 201 && medias.get(0).getMedias().get(0) != null && medias.get(0).getMedias().get(0).mediaType != 0) {
202   - listMedias.add(0, new Media(0));
  202 + mediaActivity.allMedias.add(0, new Media(0));
203 203 }
204 204 if (mFragment.mMediaAdapter == null)
205 205 mFragment.mMediaAdapter = new MediaAdapter(mFragment.getActivity(), mediaActivity.showTime, mediaActivity.mOptions);
206   - mFragment.mMediaAdapter.updateItems(listMedias);
  206 + mFragment.mMediaAdapter.updateItems(mediaActivity.allMedias);
207 207 }
208 208  
209 209 public void showPrew(MediaActivity mActivity) {
... ...
lib_media/src/main/java/com/cnlive/media/frame/view/MediaPreviewView.java
... ... @@ -32,12 +32,16 @@ public class MediaPreviewView implements MvpView {
32 32  
33 33 public void initView(MediaActivity mActivity) {
34 34 if (mFragment.isPre) {
35   - mFragment. mediaPreviewAdapter = new MediaPreviewAdapter(mActivity, mActivity.selects);
  35 + mFragment.mediaPreviewAdapter = new MediaPreviewAdapter(mActivity, mActivity.selects);
36 36 mFragment.binding.viewpager.setAdapter(mFragment.mediaPreviewAdapter);
37 37 mFragment.binding.viewpager.setCurrentItem(0, false);
38 38 mFragment.preMedias = mActivity.selects;
39 39 } else {
40   - mFragment.preMedias = mActivity.allMedias;
  40 +
  41 + if (mFragment.preMedias.size() == 0) mFragment.preMedias.addAll(mActivity.allMedias);
  42 + if (mFragment.preMedias != null && mFragment.preMedias.size() > 0 && mFragment.preMedias.get(0).mediaType == 0) {
  43 + mFragment.preMedias.remove(0);
  44 + }
41 45 mFragment.mediaPreviewAdapter = new MediaPreviewAdapter(mActivity, mFragment.preMedias);
42 46 if (mFragment.mMedia == null) {
43 47 currentPosition = 0;
... ...
lib_media/src/main/java/com/cnlive/media/frame/view/MediaView.java
... ... @@ -227,32 +227,6 @@ public class MediaView implements MvpView {
227 227 }
228 228 }
229 229  
230   - /**
231   - * 展示选中状态
232   - *
233   - * @param media
234   - */
235   - public void showPrew(Media media) {
236   -
237   - if (mActivity.isPre) {
238   - String barTitleText = String.format(mActivity.getResources().getString(R.string.btn_bar_title), mActivity.selects.indexOf(media) + 1, mActivity.selects.size());
239   - barTitle.setText(barTitleText);
240   - checkLayout.setVisibility(View.GONE);
241   - } else {
242   - String barTitleText = String.format(mActivity.getResources().getString(R.string.btn_bar_title), mActivity.allMedias.indexOf(media) + 1, mActivity.allMedias.size());
243   - barTitle.setText(barTitleText);
244   - checkLayout.setVisibility(View.VISIBLE);
245   - }
246   -
247   - if (media.isSelect()) {
248   - checkImage.setImageResource(R.drawable.xc_xuanzhong);
249   - } else {
250   - checkImage.setImageResource(R.drawable.xc_weixuan);
251   - }
252   - if (previewBottomAdapter != null) {
253   - previewBottomAdapter.updateBgState(mActivity.selects.indexOf(media));
254   - }
255   - }
256 230  
257 231 /**
258 232 * 展示底部预览
... ... @@ -442,20 +416,54 @@ public class MediaView implements MvpView {
442 416  
443 417 }
444 418  
  419 +// /**
  420 +// * 预览页面滑动
  421 +// *
  422 +// * @param media
  423 +// */
  424 +// public void showSelectPrew(Media media) {
  425 +// if (mActivity.isPre) {
  426 +// String barTitleText = String.format(mActivity.getResources().getString(R.string.btn_bar_title), mActivity.selects.indexOf(media) + 1, mActivity.selects.size());
  427 +// barTitle.setText(barTitleText);
  428 +// checkLayout.setVisibility(View.GONE);
  429 +// } else {
  430 +// String barTitleText = String.format(mActivity.getResources().getString(R.string.btn_bar_title), mActivity.allMedias.indexOf(media) + 1, mActivity.allMedias.size());
  431 +// barTitle.setText(barTitleText);
  432 +// checkLayout.setVisibility(View.VISIBLE);
  433 +// }
  434 +//
  435 +// if (media.isSelect()) {
  436 +// checkImage.setImageResource(R.drawable.xc_xuanzhong);
  437 +// } else {
  438 +// checkImage.setImageResource(R.drawable.xc_weixuan);
  439 +// }
  440 +//
  441 +// if (previewBottomAdapter != null) {
  442 +// previewBottomAdapter.updateBgState(mActivity.selects.indexOf(media));
  443 +// }
  444 +// }
  445 +
445 446 /**
446   - * 预览页面滑动
  447 + * 展示选中状态
447 448 *
448 449 * @param media
449 450 */
450   - public void showSelectPrew(Media media) {
  451 + public void showPrew(Media media) {
451 452 if (mActivity.isPre) {
452 453 String barTitleText = String.format(mActivity.getResources().getString(R.string.btn_bar_title), mActivity.selects.indexOf(media) + 1, mActivity.selects.size());
453 454 barTitle.setText(barTitleText);
454 455 checkLayout.setVisibility(View.GONE);
455 456 } else {
456   - String barTitleText = String.format(mActivity.getResources().getString(R.string.btn_bar_title), mActivity.allMedias.indexOf(media) + 1, mActivity.allMedias.size());
457   - barTitle.setText(barTitleText);
458   - checkLayout.setVisibility(View.VISIBLE);
  457 + if (mActivity.allMedias.get(0).mediaType==0) {
  458 + String barTitleText = String.format(mActivity.getResources().getString(R.string.btn_bar_title), mActivity.allMedias.indexOf(media), mActivity.allMedias.size() - 1);
  459 + barTitle.setText(barTitleText);
  460 + checkLayout.setVisibility(View.VISIBLE);
  461 + } else {
  462 + String barTitleText = String.format(mActivity.getResources().getString(R.string.btn_bar_title), mActivity.allMedias.indexOf(media) + 1, mActivity.allMedias.size());
  463 + barTitle.setText(barTitleText);
  464 + checkLayout.setVisibility(View.VISIBLE);
  465 + }
  466 +
459 467 }
460 468  
461 469 if (media.isSelect()) {
... ... @@ -463,7 +471,6 @@ public class MediaView implements MvpView {
463 471 } else {
464 472 checkImage.setImageResource(R.drawable.xc_weixuan);
465 473 }
466   -
467 474 if (previewBottomAdapter != null) {
468 475 previewBottomAdapter.updateBgState(mActivity.selects.indexOf(media));
469 476 }
... ... @@ -570,4 +577,10 @@ public class MediaView implements MvpView {
570 577 });
571 578 }
572 579  
  580 + public void processFolderSize(Media media) {
  581 + if (media == null || mActivity.mediasList == null || mActivity.mediasList.size() == 0) {
  582 + return;
  583 + }
  584 + mActivity.mediasList.get(0).getMedias().add(0, media);
  585 + }
573 586 }
... ...
lib_media/src/main/java/com/cnlive/media/ui/activity/MediaActivity.java
... ... @@ -217,12 +217,14 @@ public class MediaActivity extends MvpBindingActivity&lt;MediaView, MediaPresenter,
217 217 public void update(Observable o, Object arg) {
218 218 if (o instanceof MediaAddObservable) {
219 219 Media media = (Media) arg;
  220 + //拍照后添加的逻辑
220 221 if (media != null) {
221 222 Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.frame);
222 223 if (currentFragment instanceof MediaPickerFragment) {
223 224 MediaPickerFragment mediaPickerFragment = (MediaPickerFragment) currentFragment;
224 225 mediaPickerFragment.addMedia(media);
225 226 getMvpView().setSingleMode(media);
  227 + getMvpView().processFolderSize(media);
226 228  
227 229 }
228 230 }
... ... @@ -242,7 +244,7 @@ public class MediaActivity extends MvpBindingActivity&lt;MediaView, MediaPresenter,
242 244 } else if (o instanceof MediaPageSelectStateObservable) {
243 245 Media media = (Media) arg;
244 246 if (media != null) {
245   - if (getMvpView() != null) getMvpView().showSelectPrew(media);
  247 + if (getMvpView() != null) getMvpView().showPrew(media);
246 248 }
247 249 } else if (o instanceof MediaOpenActivityObservable) {
248 250 MediaOpenInfo info = (MediaOpenInfo) arg;
... ...
lib_media/src/main/java/com/cnlive/media/ui/fragment/MediaPickerFragment.java
... ... @@ -88,12 +88,14 @@ public class MediaPickerFragment extends MvpBindingFragment&lt;MediaPickerFragmentV
88 88 }
89 89 }
90 90  
91   - public void addMedia(Media media){
92   - if (media!=null&&mMediaAdapter!=null){
93   - if (mActivity.mOptions.isNeedCamera()){
94   - mMediaAdapter.addItem(1,media);
95   - }else {
96   - mMediaAdapter.addItem(0,media);
  91 + public void addMedia(Media media) {
  92 + if (media != null && mMediaAdapter != null) {
  93 + if (mActivity.mOptions.isNeedCamera()) {
  94 + mActivity.allMedias.add(1, media);
  95 + mMediaAdapter.addItem(1, media);
  96 + } else {
  97 + mActivity.allMedias.add(0, media);
  98 + mMediaAdapter.addItem(0, media);
97 99 }
98 100 }
99 101 }
... ... @@ -115,7 +117,8 @@ public class MediaPickerFragment extends MvpBindingFragment&lt;MediaPickerFragmentV
115 117 public void update(Observable o, Object arg) {
116 118 if (o instanceof SelectStateUpdateObservable) {
117 119 Media isUpdateMedia = (Media) arg;
118   - if (getMvpView() != null && isUpdateMedia!=null) getMvpView().selectDateUpdate(mActivity,isUpdateMedia);
  120 + if (getMvpView() != null && isUpdateMedia != null)
  121 + getMvpView().selectDateUpdate(mActivity, isUpdateMedia);
119 122 }
120 123 }
121 124 }
... ...