Skip to content

Commit

Permalink
修复九宫预览界面打开的详情界面禁止编辑
Browse files Browse the repository at this point in the history
  • Loading branch information
aaatttcccc committed Mar 2, 2022
1 parent 5054223 commit 1d6d478
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@

import androidx.annotation.Nullable;


import com.zhongjh.albumcamerarecorder.album.entity.Album;
import com.zhongjh.albumcamerarecorder.album.model.AlbumMediaCollection;
import com.zhongjh.albumcamerarecorder.album.model.SelectedItemCollection;
import com.zhongjh.albumcamerarecorder.preview.adapter.PreviewPagerAdapter;
import com.zhongjh.albumcamerarecorder.settings.GlobalSpec;
import com.zhongjh.albumcamerarecorder.utils.MultiMediaUtils;
import com.zhongjh.common.entity.MultiMedia;

import java.util.ArrayList;
import java.util.List;

import com.zhongjh.common.entity.MultiMedia;

/**
* 点击相册图片或者视频、九宫格、编辑处都可以进来
* @author zhongjh
Expand Down Expand Up @@ -67,7 +65,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
} else {
mViewHolder.checkView.setChecked(mSelectedCollection.isSelected(item));
}
updateSize(item);
updateUI(item);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class BasePreviewActivity extends AppCompatActivity implements View.OnCli
public static final String IS_SELECTED_CHECK = "is_selected_check";
public static final String IS_EXTERNAL_USERS = "is_external_users";
public static final String IS_BY_ALBUM = "is_by_album";
public static final String IS_BY_PROGRESS_GRIDVIEW = "is_by_progress_gridview";

protected final SelectedItemCollection mSelectedCollection = new SelectedItemCollection(this);
protected GlobalSpec mGlobalSpec;
Expand Down Expand Up @@ -116,6 +117,10 @@ public class BasePreviewActivity extends AppCompatActivity implements View.OnCli
* 是否从相册界面进来的
*/
protected boolean mIsByAlbum = false;
/**
* 是否从九宫格进来的
*/
protected boolean mIsByProgressGridView = false;

/**
* 图片存储器
Expand Down Expand Up @@ -156,6 +161,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mIsSelectedCheck = getIntent().getBooleanExtra(IS_SELECTED_CHECK, true);
mIsExternalUsers = getIntent().getBooleanExtra(IS_EXTERNAL_USERS, false);
mIsByAlbum = getIntent().getBooleanExtra(IS_BY_ALBUM, false);
mIsByProgressGridView = getIntent().getBooleanExtra(IS_BY_PROGRESS_GRIDVIEW, false);

// 设置图片路径
if (mGlobalSpec.pictureStrategy != null) {
Expand Down Expand Up @@ -389,7 +395,7 @@ public void onPageSelected(int position) {
mViewHolder.checkView.setEnabled(!mSelectedCollection.maxSelectableReached());
}
}
updateSize(item);
updateUI(item);
}
mPreviousPos = position;
}
Expand Down Expand Up @@ -486,13 +492,14 @@ private int countOverMaxSize() {
}

/**
* 更新ui
* 如果当前item是gif就显示多少M的文本
* 如果当前item是video就显示播放按钮
*
* @param item 当前图片
*/
@SuppressLint("SetTextI18n")
protected void updateSize(MultiMedia item) {
protected void updateUI(MultiMedia item) {
if (item.isGif()) {
mViewHolder.size.setVisibility(View.VISIBLE);
mViewHolder.size.setText(PhotoMetadataUtils.getSizeInMb(item.getSize()) + "M");
Expand All @@ -506,7 +513,8 @@ protected void updateSize(MultiMedia item) {
mViewHolder.originalLayout.setVisibility(View.VISIBLE);
}

if (item.isImage() && mGlobalSpec.isImageEdit) {
// 属于图片 & 可编辑 & 不是从进度九宫控件进来的
if (item.isImage() && mGlobalSpec.isImageEdit && !mIsByProgressGridView) {
mViewHolder.tvEdit.setVisibility(View.VISIBLE);
} else {
mViewHolder.tvEdit.setVisibility(View.GONE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.zhongjh.albumcamerarecorder.preview;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.zhongjh.albumcamerarecorder.settings.GlobalSpec;
import com.zhongjh.albumcamerarecorder.album.model.SelectedItemCollection;
import com.zhongjh.albumcamerarecorder.settings.GlobalSpec;
import com.zhongjh.common.entity.MultiMedia;

import java.util.List;

import com.zhongjh.common.entity.MultiMedia;

/**
* 点击相册的预览按钮进入的界面
* @author zhongjh
Expand All @@ -36,7 +36,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mViewHolder.checkView.setChecked(true);
}
mPreviousPos = 0;
updateSize(selected.get(0));
updateUI(selected.get(0));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ public void openPreviewData(Activity activity, int requestCode,
intent.putExtra(BasePreviewActivity.EXTRA_IS_ALLOW_REPEAT, true);
intent.putExtra(BasePreviewActivity.IS_SELECTED_CHECK, false);
intent.putExtra(BasePreviewActivity.IS_EXTERNAL_USERS, true);
intent.putExtra(BasePreviewActivity.IS_BY_PROGRESS_GRIDVIEW, true);
GlobalSpec globalSpec = GlobalSpec.getInstance();
activity.startActivityForResult(intent, requestCode);
if (globalSpec.isCutscenes) {
Expand Down

0 comments on commit 1d6d478

Please sign in to comment.