-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c829767
commit f8609fe
Showing
10 changed files
with
1,727 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
163 changes: 163 additions & 0 deletions
163
app/src/main/java/com/zhongjh/cameraapp/phone/customlayout/camera2/CameraFragment2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
package com.zhongjh.cameraapp.phone.customlayout.camera2; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.widget.AppCompatButton; | ||
import androidx.constraintlayout.widget.ConstraintLayout; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.otaliastudios.cameraview.CameraView; | ||
import com.zhongjh.albumcamerarecorder.camera.ui.camera.BaseCameraFragment; | ||
import com.zhongjh.albumcamerarecorder.camera.ui.camera.presenter.BaseCameraPicturePresenter; | ||
import com.zhongjh.albumcamerarecorder.camera.ui.camera.presenter.BaseCameraVideoPresenter; | ||
import com.zhongjh.albumcamerarecorder.camera.ui.camera.state.CameraStateManagement; | ||
import com.zhongjh.albumcamerarecorder.camera.widget.PhotoVideoLayout; | ||
import com.zhongjh.albumcamerarecorder.widget.childclickable.ChildClickableRelativeLayout; | ||
import com.zhongjh.albumcamerarecorder.widget.childclickable.IChildClickableLayout; | ||
import com.zhongjh.cameraapp.R; | ||
|
||
/** | ||
* 继承于BaseCameraFragment | ||
* 主要演示 BaseCameraPicturePresenter | ||
* | ||
* 使用 TODO 关键字可搜索相关自定义代码 | ||
* | ||
* @author zhongjh | ||
* @date 2022/8/12 | ||
*/ | ||
public class CameraFragment2 extends BaseCameraFragment<CameraStateManagement, BaseCameraPicturePresenter, BaseCameraVideoPresenter> { | ||
|
||
ViewHolder mViewHolder; | ||
CameraPicturePresenter cameraPicturePresenter = new CameraPicturePresenter(this); | ||
BaseCameraVideoPresenter cameraVideoPresenter = new BaseCameraVideoPresenter(this); | ||
CameraStateManagement cameraStateManagement = new CameraStateManagement(this); | ||
|
||
public static CameraFragment2 newInstance() { | ||
return new CameraFragment2(); | ||
} | ||
|
||
@Override | ||
public int setContentView() { | ||
return R.layout.fragment_camera_zjh; | ||
} | ||
|
||
@Override | ||
public void initView(View view, Bundle savedInstanceState) { | ||
mViewHolder = new ViewHolder(view); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public IChildClickableLayout getChildClickableLayout() { | ||
return mViewHolder.rlMain; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View getTopView() { | ||
return mViewHolder.clMenu; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public CameraView getCameraView() { | ||
return mViewHolder.cameraView; | ||
} | ||
|
||
@Override | ||
public RecyclerView getRecyclerViewPhoto() { | ||
return mViewHolder.rlPhoto; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View[] getMultiplePhotoView() { | ||
return new View[]{mViewHolder.vLine1, mViewHolder.vLine2}; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public PhotoVideoLayout getPhotoVideoLayout() { | ||
return mViewHolder.pvLayout; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public com.zhongjh.albumcamerarecorder.widget.ImageViewTouch getSinglePhotoView() { | ||
return mViewHolder.imgPhoto; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View getCloseView() { | ||
return mViewHolder.imgClose; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public ImageView getFlashView() { | ||
return mViewHolder.imgFlash; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public ImageView getSwitchView() { | ||
return mViewHolder.imgSwitch; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public CameraStateManagement getCameraStateManagement() { | ||
return cameraStateManagement; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public BaseCameraPicturePresenter getCameraPicturePresenter() { | ||
return cameraPicturePresenter; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public BaseCameraVideoPresenter getCameraVideoPresenter() { | ||
return cameraVideoPresenter; | ||
} | ||
|
||
public static class ViewHolder { | ||
|
||
View rootView; | ||
ChildClickableRelativeLayout rlMain; | ||
com.zhongjh.albumcamerarecorder.widget.ImageViewTouch imgPhoto; | ||
ImageView imgFlash; | ||
ImageView imgSwitch; | ||
PhotoVideoLayout pvLayout; | ||
RecyclerView rlPhoto; | ||
View vLine1; | ||
View vLine2; | ||
ImageView imgClose; | ||
CameraView cameraView; | ||
ConstraintLayout clMenu; | ||
AppCompatButton btnCustom; | ||
|
||
ViewHolder(View rootView) { | ||
this.rootView = rootView; | ||
this.rlMain = rootView.findViewById(R.id.rlMain); | ||
this.imgPhoto = rootView.findViewById(R.id.imgPhoto); | ||
this.imgFlash = rootView.findViewById(R.id.imgFlash); | ||
this.imgSwitch = rootView.findViewById(R.id.imgSwitch); | ||
this.pvLayout = rootView.findViewById(R.id.pvLayout); | ||
this.rlPhoto = rootView.findViewById(R.id.rlPhoto); | ||
this.vLine1 = rootView.findViewById(R.id.vLine1); | ||
this.vLine2 = rootView.findViewById(R.id.vLine2); | ||
this.imgClose = rootView.findViewById(R.id.imgClose); | ||
this.cameraView = rootView.findViewById(R.id.cameraView); | ||
this.clMenu = rootView.findViewById(R.id.clMenu); | ||
this.btnCustom = rootView.findViewById(R.id.btnCustom); | ||
} | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...rc/main/java/com/zhongjh/cameraapp/phone/customlayout/camera2/CameraPicturePresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.zhongjh.cameraapp.phone.customlayout.camera2; | ||
|
||
import android.widget.Toast; | ||
|
||
import com.zhongjh.albumcamerarecorder.camera.ui.camera.BaseCameraFragment; | ||
import com.zhongjh.albumcamerarecorder.camera.ui.camera.presenter.BaseCameraPicturePresenter; | ||
import com.zhongjh.albumcamerarecorder.camera.ui.camera.presenter.BaseCameraVideoPresenter; | ||
import com.zhongjh.albumcamerarecorder.camera.ui.camera.state.CameraStateManagement; | ||
|
||
/** | ||
* 主要演示 BaseCameraPicturePresenter | ||
* 可以看父类能提供什么方法给你覆写,更详细的注释等请看父类 | ||
* | ||
* @author zhongjh | ||
* @date 2022/8/25 | ||
*/ | ||
public class CameraPicturePresenter extends BaseCameraPicturePresenter { | ||
|
||
public CameraPicturePresenter(BaseCameraFragment<? extends CameraStateManagement, ? extends BaseCameraPicturePresenter, ? extends BaseCameraVideoPresenter> baseCameraFragment) { | ||
super(baseCameraFragment); | ||
} | ||
|
||
@Override | ||
public void takePhoto() { | ||
super.takePhoto(); | ||
Toast.makeText(baseCameraFragment.getMyContext(), "拍照时触发自定义事件!", Toast.LENGTH_SHORT).show(); | ||
} | ||
} |
Oops, something went wrong.