Skip to content

Commit

Permalink
update RxDialogChooseImage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamsiree committed Mar 24, 2020
1 parent 1bb8d89 commit fcd3bed
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class ActivityRxPhoto : ActivityBase() {
+ r.getResourceEntryName(R.drawable.circle_elves_ball))
rx_title.setLeftFinish(mContext)
iv_avatar.setOnClickListener { initDialogChooseImage() }
iv_avatar.setOnLongClickListener { // RxImageTool.showBigImageView(mContext, resultUri);
val rxDialogScaleView = RxDialogScaleView(mContext)
rxDialogScaleView.setImage(resultUri)
iv_avatar.setOnLongClickListener {
//RxImageTool.showBigImageView(mContext, resultUri);
val rxDialogScaleView = RxDialogScaleView(mContext, resultUri)
rxDialogScaleView.show()
false
}
Expand All @@ -68,7 +68,7 @@ class ActivityRxPhoto : ActivityBase() {
}

private fun initDialogChooseImage() {
val dialogChooseImage = RxDialogChooseImage(mContext)
val dialogChooseImage = RxDialogChooseImage(mContext, resultUri)
dialogChooseImage.show()
}

Expand Down
9 changes: 7 additions & 2 deletions RxKit/src/main/java/com/tamsiree/rxkit/RxActivityTool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ object RxActivityTool {
* 结束当前Activity(堆栈中最后一个压入的)
*/
@JvmStatic
fun finishActivity() {
@JvmOverloads
fun finishActivity(isTransition: Boolean = false) {
val activity = activityStack?.lastElement()
activity!!.finish()
if (isTransition) {
activity?.onBackPressed()
} else {
activity?.finish()
}
}

/**
Expand Down
7 changes: 1 addition & 6 deletions RxUI/src/main/java/com/tamsiree/rxui/view/RxTitle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import com.tamsiree.rxui.R
*/
class RxTitle : FrameLayout {

//*******************************************控件start******************************************

//*******************************************控件start******************************************
private var mRootView: View? = null

Expand Down Expand Up @@ -60,9 +58,9 @@ class RxTitle : FrameLayout {

//右边TextView控件
private var mTvRight: TextView? = null
//===========================================控件end=============================================

//===========================================控件end=============================================

//*******************************************属性start*******************************************
//Title文字
private var mTitle: String? = null
Expand All @@ -76,8 +74,6 @@ class RxTitle : FrameLayout {
//Title是否显示
private var mTitleVisibility = false

//------------------------------------------左侧布局---------------------------------------------

//------------------------------------------左侧布局---------------------------------------------
//左边 ICON 引用的资源ID
private var mLeftIcon = 0
Expand All @@ -99,7 +95,6 @@ class RxTitle : FrameLayout {

//--------------------------------------------右侧布局-------------------------------------------

//--------------------------------------------右侧布局-------------------------------------------
//右边 ICON 引用的资源ID
private var mRightIcon = 0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.tamsiree.rxui.view.dialog;

import android.app.Activity;
import android.net.Uri;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
Expand All @@ -22,7 +24,9 @@ public class RxDialogChooseImage extends RxDialog {
private LayoutType mLayoutType = LayoutType.TITLE;
private TextView mTvCamera;
private TextView mTvFile;
private TextView mTvCancel;
private Button btnCancel;
private TextView tvOriginalImage;
private Uri uriOriginalImage;

public RxDialogChooseImage(Activity context) {
super(context);
Expand All @@ -34,6 +38,18 @@ public RxDialogChooseImage(Fragment fragment) {
initView(fragment);
}

public RxDialogChooseImage(Activity context, Uri uri) {
super(context);
uriOriginalImage = uri;
initView(context);
}

public RxDialogChooseImage(Fragment fragment, Uri uri) {
super(fragment.getContext());
uriOriginalImage = uri;
initView(fragment);
}

public RxDialogChooseImage(Activity context, int themeResId) {
super(context, themeResId);
initView(context);
Expand Down Expand Up @@ -91,23 +107,17 @@ public RxDialogChooseImage(Fragment fragment, float alpha, int gravity, LayoutTy
initView(fragment);
}

public TextView getFromCameraView() {
return mTvCamera;
}

public TextView getFromFileView() {
return mTvFile;
}

public TextView getCancelView() {
return mTvCancel;
private void initView(final Activity activity) {
init();
setClickEvent(activity);
}

public LayoutType getLayoutType() {
return mLayoutType;
private void initView(final Fragment fragment) {
init();
setClickEvent(fragment);
}

private void initView(final Activity activity) {
private void init() {
View dialogView = null;
switch (mLayoutType) {
case TITLE:
Expand All @@ -120,16 +130,35 @@ private void initView(final Activity activity) {
break;
}


tvOriginalImage = dialogView.findViewById(R.id.tv_original_image);
mTvCamera = dialogView.findViewById(R.id.tv_camera);
mTvFile = dialogView.findViewById(R.id.tv_file);
mTvCancel = dialogView.findViewById(R.id.tv_cancel);
mTvCancel.setOnClickListener(new View.OnClickListener() {
btnCancel = dialogView.findViewById(R.id.btnCancel);


tvOriginalImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (uriOriginalImage != null) {
RxDialogScaleView rxDialogScaleView = new RxDialogScaleView(mContext, uriOriginalImage);
rxDialogScaleView.show();
}
}
});

btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
cancel();
}
});

setContentView(dialogView);
mLayoutParams.gravity = Gravity.BOTTOM;
mLayoutParams.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
}

private void setClickEvent(Activity activity) {
mTvCamera.setOnClickListener(new View.OnClickListener() {

@Override
Expand All @@ -146,33 +175,10 @@ public void onClick(View arg0) {
cancel();
}
});
setContentView(dialogView);
mLayoutParams.gravity = Gravity.BOTTOM;
mLayoutParams.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
}

private void initView(final Fragment fragment) {
View dialogView = null;
switch (mLayoutType) {
case TITLE:
dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_picker_pictrue, null);
break;
case NO_TITLE:
dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_camero_show, null);
break;
default:
break;
}

mTvCamera = dialogView.findViewById(R.id.tv_camera);
mTvFile = dialogView.findViewById(R.id.tv_file);
mTvCancel = dialogView.findViewById(R.id.tv_cancel);
mTvCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
cancel();
}
});
private void setClickEvent(Fragment fragment) {
mTvCamera.setOnClickListener(new View.OnClickListener() {

@Override
Expand All @@ -190,10 +196,38 @@ public void onClick(View arg0) {
cancel();
}
});
}

setContentView(dialogView);
mLayoutParams.gravity = Gravity.BOTTOM;
mLayoutParams.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
public TextView getCancelView() {
return btnCancel;
}

public TextView getFromCameraView() {
return mTvCamera;
}

public TextView getFromFileView() {
return mTvFile;
}

public TextView getTvOriginalImage() {
return tvOriginalImage;
}

public LayoutType getLayoutType() {
return mLayoutType;
}

public void setTvOriginalImage(TextView tvOriginalImage) {
this.tvOriginalImage = tvOriginalImage;
}

public Uri getUriOriginalImage() {
return uriOriginalImage;
}

public void setUriOriginalImage(Uri uriOriginalImage) {
this.uriOriginalImage = uriOriginalImage;
}

public enum LayoutType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@ public RxDialogScaleView(Activity context) {
}


public RxDialogScaleView(Context context,String filePath,boolean isAssets) {
public RxDialogScaleView(Context context, String filePath, boolean isAssets) {
super(context);
initView();
setImage(filePath,isAssets);
setImage(filePath, isAssets);
}

public RxDialogScaleView(Context context,Uri uri) {
public RxDialogScaleView(Context context, Uri uri) {
super(context);
initView();
setImage(uri);
}

public RxDialogScaleView(Context context,int resId,boolean isResId) {
public RxDialogScaleView(Context context, int resId, boolean isResId) {
super(context);
initView();
if (isResId) {
setImage(resId);
}
}

public RxDialogScaleView(Context context,Bitmap bitmap) {
public RxDialogScaleView(Context context, Bitmap bitmap) {
super(context);
initView();
setImage(bitmap);
Expand All @@ -85,11 +85,11 @@ public RxScaleImageView getRxScaleImageView() {
return mRxScaleImageView;
}

public void setImage(String filePath,boolean isAssets) {
public void setImage(String filePath, boolean isAssets) {
if (isAssets) {
this.fileAssetName = fileAssetName;
mRxScaleImageView.setImage(ImageSource.asset(filePath));
}else {
} else {
this.filePath = filePath;
mRxScaleImageView.setImage(ImageSource.uri(filePath));
}
Expand All @@ -114,7 +114,7 @@ private void initView() {
View dialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_scaleview, null);
mRxScaleImageView = dialogView.findViewById(R.id.rx_scale_view);
mRxScaleImageView.setMaxScale(maxScale);
ImageView ivClose = dialogView.findViewById(R.id.iv_close);
ImageView ivClose = dialogView.findViewById(R.id.iv_close);
ivClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down
Loading

0 comments on commit fcd3bed

Please sign in to comment.