Skip to content

Commit

Permalink
升级到Android3.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
langmanleguang@qq.com committed May 15, 2018
1 parent dac6b5f commit 684dcdd
Show file tree
Hide file tree
Showing 29 changed files with 774 additions and 61 deletions.
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.

30 changes: 18 additions & 12 deletions app/src/main/java/cn/itsite/adialog/demo/demo/DialogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,51 @@

import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.Toolbar;

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

import cn.itsite.adialog.ADialogListener;
import cn.itsite.adialog.BaseViewHolder;
import cn.itsite.adialog.common.BaseViewHolder;
import cn.itsite.adialog.demo.R;
import cn.itsite.adialog.dialog.BaseDialog;
import cn.itsite.adialog.dialog.LoadingDialog;
import cn.itsite.adialog.dialog.SelectorDialog;
import cn.itsite.adialog.support.ADialogListener;
import cn.itsite.adialog.support.dialog.BaseDialog;
import cn.itsite.adialog.support.dialog.LoadingDialog;
import cn.itsite.adialog.support.dialog.SelectorDialog;


public class DialogActivity extends AppCompatActivity implements View.OnClickListener {
private Button bt0, bt1, bt2, bt3, bt4, bt5;
private Toolbar toolbar;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialog);

toolbar.setTitle("Dialog");
initView();
initData();
}

private void initView() {
bt0 = (Button) findViewById(R.id.share);
bt1 = (Button) findViewById(R.id.selector);
bt2 = (Button) findViewById(R.id.edit_input);
bt3 = (Button) findViewById(R.id.lucky_money);
bt4 = (Button) findViewById(R.id.loading);
bt5 = (Button) findViewById(R.id.tips);
toolbar = findViewById(R.id.toolbar);
bt0 = findViewById(R.id.share);
bt1 = findViewById(R.id.selector);
bt2 = findViewById(R.id.edit_input);
bt3 = findViewById(R.id.lucky_money);
bt4 = findViewById(R.id.loading);
bt5 = findViewById(R.id.tips);
}

private void initData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -12,36 +14,41 @@
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.Toolbar;

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

import cn.itsite.adialog.ADialogListener;
import cn.itsite.adialog.BaseViewHolder;
import cn.itsite.adialog.common.BaseViewHolder;
import cn.itsite.adialog.demo.R;
import cn.itsite.adialog.dialogfragment.BaseDialogFragment;
import cn.itsite.adialog.dialogfragment.SelectorDialogFragment;
import cn.itsite.adialog.support.ADialogListener;
import cn.itsite.adialog.support.dialogfragment.BaseDialogFragment;
import cn.itsite.adialog.support.dialogfragment.SelectorDialogFragment;


public class DialogFragmentActivity extends AppCompatActivity implements View.OnClickListener {
private Button bt0, bt1, bt2, bt3, bt4, bt5, bt6;
private Toolbar toolbar;

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialogfragment);

toolbar.setTitle("DialogFragment");
initView();
initData();
}

private void initView() {
bt0 = (Button) findViewById(R.id.share);
bt1 = (Button) findViewById(R.id.selector);
bt2 = (Button) findViewById(R.id.edit_input);
bt3 = (Button) findViewById(R.id.lucky_money);
bt4 = (Button) findViewById(R.id.loading);
bt5 = (Button) findViewById(R.id.tips);
bt6 = (Button) findViewById(R.id.dialog_in_fragment);
toolbar = findViewById(R.id.toolbar);
bt0 = findViewById(R.id.share);
bt1 = findViewById(R.id.selector);
bt2 = findViewById(R.id.edit_input);
bt3 = findViewById(R.id.lucky_money);
bt4 = findViewById(R.id.loading);
bt5 = findViewById(R.id.tips);
bt6 = findViewById(R.id.dialog_in_fragment);
}

private void initData() {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
android:layout_height="match_parent"
android:orientation="vertical">

<include layout="@layout/toolbar" />

<Button
android:id="@+id/share"
android:layout_width="match_parent"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_dialogfragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
android:layout_height="match_parent"
android:orientation="vertical">

<include layout="@layout/toolbar" />

<Button
android:id="@+id/share"
android:layout_width="match_parent"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/layout/toolbar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Binary file not shown.
9 changes: 8 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ android {

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

vectorDrawables.useSupportLibrary = true

}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -28,6 +36,5 @@ dependencies {
testImplementation 'junit:junit:4.12'

api 'com.android.support:appcompat-v7:27.1.1'

api 'com.android.support:recyclerview-v7:27.1.1'
}
11 changes: 1 addition & 10 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="cn.itsite.adialog">

<application android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>
<manifest package="cn.itsite.adialog" />
4 changes: 3 additions & 1 deletion library/src/main/java/cn/itsite/adialog/ADialogListener.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package cn.itsite.adialog;

import android.app.Dialog;
import android.support.v4.app.DialogFragment;
import android.app.DialogFragment;
import android.view.View;

import cn.itsite.adialog.common.BaseViewHolder;

/**
* Author:leguang on 2016/10/12 0009 15:49
* Email:langmanleguang@qq.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.itsite.adialog;
package cn.itsite.adialog.common;

import android.graphics.Bitmap;
import android.graphics.Paint;
Expand Down Expand Up @@ -53,9 +53,6 @@ public class BaseViewHolder extends RecyclerView.ViewHolder {

public BaseViewHolder(final View view) {
super(view);
if (view == null) {
throw new IllegalArgumentException("rootView may not be null");
}
rootView = view;
this.views = new SparseArray<>();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.itsite.adialog;
package cn.itsite.adialog.common;

import android.content.Context;
import android.util.DisplayMetrics;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package cn.itsite.adialog.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.v7.app.AppCompatDialog;
import android.view.Window;
import android.view.WindowManager;

import cn.itsite.adialog.ADialogListener;
import cn.itsite.adialog.BaseViewHolder;
import cn.itsite.adialog.Utils;
import cn.itsite.adialog.common.BaseViewHolder;
import cn.itsite.adialog.common.Utils;

public class BaseDialog extends AppCompatDialog {
public class BaseDialog extends Dialog {
private static final String MARGIN = "margin";
private static final String WIDTH = "width";
private static final String HEIGHT = "height";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.support.annotation.StyleRes;
import android.widget.TextView;

import cn.itsite.adialog.BaseViewHolder;
import cn.itsite.adialog.common.BaseViewHolder;
import cn.itsite.adialog.R;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.List;

import cn.itsite.adialog.ADialogListener;
import cn.itsite.adialog.BaseViewHolder;
import cn.itsite.adialog.common.BaseViewHolder;
import cn.itsite.adialog.R;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package cn.itsite.adialog.dialogfragment;

import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import cn.itsite.adialog.ADialogListener;
import cn.itsite.adialog.BaseViewHolder;
import cn.itsite.adialog.common.BaseViewHolder;
import cn.itsite.adialog.R;
import cn.itsite.adialog.Utils;
import cn.itsite.adialog.common.Utils;

public class BaseDialogFragment extends AppCompatDialogFragment {
public class BaseDialogFragment extends DialogFragment {
private static final String TAG = BaseDialogFragment.class.getName();
private static final String MARGIN = "margin";
private static final String WIDTH = "width";
Expand Down Expand Up @@ -119,15 +118,15 @@ private void initWindow() {
lp.gravity = gravity;
// //设置dialog宽度
if (margin > 0) {
lp.width = Utils.getScreenWidth(getContext()) - 2 * Utils.dp2px(getContext(), margin);
lp.width = Utils.getScreenWidth(getActivity()) - 2 * Utils.dp2px(getActivity(), margin);
} else if (width > 0) {
lp.width = Utils.dp2px(getContext(), width);
lp.width = Utils.dp2px(getActivity(), width);
} else {
lp.width = width;
}
//设置dialog高度
if (height > 0) {
lp.height = Utils.dp2px(getContext(), height);
lp.height = Utils.dp2px(getActivity(), height);
} else {
lp.height = height;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SelectorDialogFragment extends BaseDialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new SelectorDialog(getContext())
return new SelectorDialog(getActivity())
.setTitle(title)
.setItemLayoutId(itemLayoutId)
.setData(mData)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cn.itsite.adialog.support;

import android.app.Dialog;
import android.support.v4.app.DialogFragment;
import android.view.View;

import cn.itsite.adialog.common.BaseViewHolder;

/**
* Author:leguang on 2016/10/12 0009 15:49
* Email:langmanleguang@qq.com
* <p>
* 页面状态点击事件监听器。
*/

public interface ADialogListener {

interface OnDialogConvertListener {

void convert(BaseViewHolder holder, Dialog dialog);
}

interface OnDialogFragmentConvertListener {

void convert(BaseViewHolder holder, DialogFragment dialog);
}

interface OnItemConvertListener {

void onItemConvert(BaseViewHolder holder, int position, Dialog dialog);
}

interface OnItemClickListener {

void onItemClick(View v, BaseViewHolder holder, int position, Dialog dialog);
}
}
Loading

0 comments on commit 684dcdd

Please sign in to comment.