Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions bottomdialog/src/main/java/me/shaohui/bottomdialog/BaseBottomDialog.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;

/**
* Created by shaohui on 16/10/11.
Expand All @@ -33,18 +34,27 @@ public void onCreate(Bundle savedInstanceState) {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle savedInstanceState) {
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().setCanceledOnTouchOutside(getCancelOutside());

View v = inflater.inflate(getLayoutRes(), container, false);
View v;
if (getDialogView() != null) {
v = inflater.inflate(R.layout.layout, container, false);
FrameLayout layout = ((FrameLayout) v.findViewById(R.id.root));
layout.addView(getDialogView());
} else {
v = inflater.inflate(getLayoutRes(), container, false);
bindView(v);
}
bindView(v);
return v;
}

@LayoutRes
public abstract int getLayoutRes();

public abstract View getDialogView();

public abstract void bindView(View v);

@Override
Expand Down
16 changes: 15 additions & 1 deletion bottomdialog/src/main/java/me/shaohui/bottomdialog/BottomDialog.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class BottomDialog extends BaseBottomDialog {

@LayoutRes
private int mLayoutRes;

private View mView;
private ViewListener mViewListener;

public static BottomDialog create(FragmentManager manager) {
Expand All @@ -50,7 +50,10 @@ public void onCreate(Bundle savedInstanceState) {

@Override
public void onSaveInstanceState(Bundle outState) {
if (mLayoutRes != 0) {

outState.putInt(KEY_LAYOUT_RES, mLayoutRes);
}
outState.putInt(KEY_HEIGHT, mHeight);
outState.putFloat(KEY_DIM, mDimAmount);
outState.putBoolean(KEY_CANCEL_OUTSIDE, mIsCancelOutside);
Expand Down Expand Up @@ -125,6 +128,17 @@ public String getFragmentTag() {
return mTag;
}

@Override
public View getDialogView() {
return mView;
}

public BottomDialog setDialogView(View view) {
// getParentFragment().getFragmentManager().set
mView = view;
return this;
}

public interface ViewListener {
void bindView(View v);
}
Expand Down
5 changes: 5 additions & 0 deletions example/src/main/java/me/shaohui/bottomdialogexample/EditTextDialog.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

import me.shaohui.bottomdialog.BaseBottomDialog;

/**
* Created by shaohui on 16/10/12.
*/

public class EditTextDialog extends BaseBottomDialog {
@Override
public View getDialogView() {
return null;
}

private EditText mEditText;

Expand Down
46 changes: 39 additions & 7 deletions example/src/main/java/me/shaohui/bottomdialogexample/MainActivity.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package me.shaohui.bottomdialogexample;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;

import me.shaohui.bottomdialog.BottomDialog;

import static me.shaohui.bottomdialog.BottomDialog.create;

public class MainActivity extends AppCompatActivity {

@Override
Expand All @@ -18,9 +19,9 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.show_dialog).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog();
// showDialog();
//shareDialog();

showViewDialog();
}
});
}
Expand All @@ -33,19 +34,50 @@ private void shareDialog() {
}

private void showDialog() {
BottomDialog.create(getSupportFragmentManager())
create(getSupportFragmentManager())
.setViewListener(new BottomDialog.ViewListener() {
@Override
public void bindView(View v) {
initView(v);
}
})
.setLayoutRes(R.layout.dialog_layout)
.setLayoutRes(R.layout.layout)
.setDimAmount(0.9f)
.setTag("BottomDialog")
.show();
}

private void showViewDialog() {
UFPictureSelectedView view = new UFPictureSelectedView(this);

final BottomDialog dialog = BottomDialog.create(getSupportFragmentManager())
.setViewListener(new BottomDialog.ViewListener() {
@Override
public void bindView(View v) {
v.findViewById(R.id.item_recommend).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "0", Toast.LENGTH_SHORT).show();
}
}); v.findViewById(R.id.item_take_photo).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "1", Toast.LENGTH_SHORT).show();
}
}); v.findViewById(R.id.item_get_photo).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "2", Toast.LENGTH_SHORT).show();
}
});
}
})
.setDialogView(view)
.setDimAmount(0.9f)
.setTag("BottomDialog");
dialog.show();
}

private void initView(final View view) {
//final EditText editText = (EditText) view.findViewById(R.id.edit_text);
//editText.post(new Runnable() {
Expand Down
11 changes: 8 additions & 3 deletions example/src/main/java/me/shaohui/bottomdialogexample/ShareBottomDialog.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package me.shaohui.bottomdialogexample;

import android.app.FragmentManager;
import android.view.View;

import me.shaohui.bottomdialog.BaseBottomDialog;

/**
* Created by shaohui on 16/10/11.
*/

public class ShareBottomDialog extends BaseBottomDialog{
public class ShareBottomDialog extends BaseBottomDialog {

@Override
public int getLayoutRes() {
return R.layout.dialog_layout;
return R.layout.layout;
}

@Override
public void bindView(View v) {
// do any thing you want
}

@Override
public View getDialogView() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package me.shaohui.bottomdialogexample;



public abstract class UFOnSelectedTypeListener {
public abstract void onSelected(int type);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package me.shaohui.bottomdialogexample;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;


public class UFPictureSelectedView extends LinearLayout {

public UFPictureSelectedView(Context context) {
super(context);
initView(context);
}

public UFPictureSelectedView(Context context, AttributeSet attrs) {
super(context, attrs);
initView(context);
}

public UFPictureSelectedView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initView(context);
}

private void initView(Context context) {
View root = LayoutInflater.from(context).inflate(R.layout.popup_pictures, this);

}


}
67 changes: 67 additions & 0 deletions example/src/main/res/layout/popup_pictures.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#36000000"
android:gravity="bottom"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical">

<Button
android:id="@+id/item_recommend"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@null"
android:gravity="center"
android:text="推荐"
android:textColor="#929292"/>

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ccc"/>

<Button
android:id="@+id/item_take_photo"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@null"
android:gravity="center"
android:text="拍照"
android:textColor="#929292"/>

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ccc"/>

<Button
android:id="@+id/item_get_photo"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@null"
android:gravity="center"
android:text="相册"
android:textColor="#929292"/>

<View
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="#f2f2f2f2"/>

<Button
android:id="@+id/item_cancel"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@null"
android:gravity="center"
android:text="取消"
android:textColor="#666666"/>

</LinearLayout>
</LinearLayout>