Commit 8dee92f1 authored by linfeng's avatar linfeng

费用明细

parent 81a7f67e
......@@ -2,7 +2,9 @@ package com.ruiwenliu.wrapper.dialog;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
......@@ -27,8 +29,10 @@ import java.lang.ref.WeakReference;
public abstract class BasePopupWindow extends PopupWindow implements OnViewHolder {
private WeakReference<Activity> viewReference; //MvpView的子类的弱引用
protected ViewHolder helper;
// public boolean canDismiss=false;
public WindowManager.LayoutParams params;
// public boolean canDismiss=false;
public WindowManager.LayoutParams params;
public View view;
public BasePopupWindow(@NonNull Activity activity) {
viewReference = new WeakReference<>(activity);
......@@ -36,13 +40,13 @@ public abstract class BasePopupWindow extends PopupWindow implements OnViewHolde
setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
setClippingEnabled(false);
setOutsideTouchable(false);
setTouchable(true);
setFocusable(false);
setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(getDialogContext(), R.color.gray_50ffffff)));
setContentView(getHelperView(null, getViewLayout(), this));
}
public abstract int getViewLayout();
/**
......@@ -54,7 +58,8 @@ public abstract class BasePopupWindow extends PopupWindow implements OnViewHolde
* @return
*/
protected View getHelperView(ViewGroup group, int layoutId, OnViewHolder listener) {
helper = new ViewHolder(LayoutInflater.from(getDialogContext()).inflate(layoutId, group, false));
view = LayoutInflater.from(getDialogContext()).inflate(layoutId, group, false);
helper = new ViewHolder(view);
if (listener != null) {
listener.helper(helper);
}
......@@ -62,8 +67,6 @@ public abstract class BasePopupWindow extends PopupWindow implements OnViewHolde
}
@Override
public void helper(ViewHolder helper) {
......@@ -84,15 +87,15 @@ public abstract class BasePopupWindow extends PopupWindow implements OnViewHolde
/**
* 关闭处理
*/
public void onDestroy(){
if(viewReference!=null){
public void onDestroy() {
if (viewReference != null) {
viewReference.clear();
viewReference=null;
viewReference = null;
}
dismiss();
}
public void closePopupWindow()
{
}
public void closePopupWindow() {
if (this.isShowing()) {
this.dismiss();
setBgShadow(1f);
......@@ -102,11 +105,11 @@ public abstract class BasePopupWindow extends PopupWindow implements OnViewHolde
/**
* 设置阴影
*/
public void setBgShadow(float alpha){
if(params==null){
params=getDialogContext().getWindow().getAttributes();
public void setBgShadow(float alpha) {
if (params == null) {
params = getDialogContext().getWindow().getAttributes();
}
params.alpha=alpha;
params.alpha = alpha;
getDialogContext().getWindow().setAttributes(params);
}
......
......@@ -939,6 +939,7 @@ public class ConfirmOrderActivity extends BaseStatusActivity<CommonPresenter> {
* 显示价格明细弹窗
*/
private void showOrderDetail(final View view) {
if (orderPriceDetailBean != null) {
if (detailPw == null) {
detailPw = new OrderCarPriceDetailPw(mActivity) {
......@@ -948,31 +949,23 @@ public class ConfirmOrderActivity extends BaseStatusActivity<CommonPresenter> {
View contentView = detailPw.getContentView();
//需要先测量,PopupWindow还未弹出时,宽高为0
contentView.measure(makeDropDownMeasureSpec(detailPw.getWidth()), makeDropDownMeasureSpec(detailPw.getHeight()));
// int[] location = new int[2];
//
// view.getLocationOnScreen(location);
// int hh=location[1]-detailPw.getHeight();
// detailPw.showAtLocation(view, Gravity.NO_GRAVITY,
// location[0], hh);
detailPw.setHeight(detailPw.getContentView().getMeasuredHeight());
// detailPw.showAsDropDown(view, 0,0, Gravity.NO_GRAVITY);
// int kk=detailPw.getContentView().getMeasuredHeight();
// int cc=view.getHeight();
int offsetX = Math.abs(detailPw.getContentView().getMeasuredWidth() - view.getWidth()) / 2;
int offsetY = -(detailPw.getContentView().getMeasuredHeight() + view.getHeight());
PopupWindowCompat.showAsDropDown(detailPw, view, offsetX, offsetY, Gravity.START);
/**
* 点击popupWindow让背景变暗
*/
/**
* 点击popupWindow让背景变暗
*/
final WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.alpha = 0.5f;//代表透明程度,范围为0 - 1.0f
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
getWindow().setAttributes(lp);
/**
* 退出popupWindow时取消暗背景
*/
/**
* 退出popupWindow时取消暗背景
*/
detailPw.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
......
......@@ -4,9 +4,15 @@ import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.ruiwenliu.wrapper.dialog.BaseDialog;
import com.ruiwenliu.wrapper.dialog.BasePopupWindow;
import com.ruiwenliu.wrapper.util.ViewHolder;
import com.rv.home.R;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment