Commit 0fccab18 by gao.chao

标题栏,日期选择对话框,时间选择对话框,地方选择对话框

parent 3dbab070
......@@ -18,8 +18,9 @@
</intent-filter>
</activity>
<activity android:name=".TsetActviity" />
<activity android:name=".ViewActviity" />
<activity android:name=".QRActivity" />
<activity android:name=".TitleActivity" />
</application>
<!-- 配置APP ID -->
......
......@@ -10,8 +10,6 @@ import android.view.ViewGroup;
import android.widget.Button;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.util.LogUtils;
import com.mayi.fastdevelop.util.SpUtil;
import java.util.ArrayList;
import java.util.List;
......@@ -25,14 +23,10 @@ public class MainActivity extends BaseActivity {
RecyclerView listView = findViewById(R.id.list);
listView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
final List<ItemBean> list = new ArrayList<>();
list.add(new ItemBean("BaseActivity", new View.OnClickListener() {
list.add(new ItemBean("常用控件", new View.OnClickListener() {
@Override
public void onClick(View v) {
LogUtils.postCatchedException(new Exception("11"));
SpUtil.set("ss",System.currentTimeMillis());
LogUtils.i("ss="+ SpUtil.get("ss",-1L));
// gotoActivity(TsetActviity.class);
gotoActivity(ViewActviity.class);
}
}));
list.add(new ItemBean("二维码", new View.OnClickListener() {
......
package com.mayi.demo;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.util.ToastUtil;
import com.mayi.fastdevelop.view.CustomTitleBar;
public class TitleActivity extends BaseActivity{
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.title_activity_layout);
CustomTitleBar titleBar1=findViewById(R.id.title1);
titleBar1.setOnClickLeftViewListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtil.show(v.getContext(),"点击返回");
}
});
titleBar1.setTextCenter("标题1");
CustomTitleBar titleBar2=findViewById(R.id.title2);
titleBar2.setTextCenter("标题2");
titleBar2.hideLeftView();
titleBar2.setOnClickCenterTextListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtil.show(v.getContext(),"点击标题");
}
});
CustomTitleBar titleBar3=findViewById(R.id.title3);
titleBar3.setTextCenter("标题3");
titleBar3.showLeftCloseView();
titleBar3.setTextRight("右边");
titleBar3.setOnClickRightTextListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtil.show(v.getContext(),"点击右边");
}
});
titleBar3.hideLeftView();
titleBar3.setOnClickLeftCloseListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtil.show(v.getContext(),"点击关闭");
}
});
CustomTitleBar titleBar4=findViewById(R.id.title4);
titleBar4.setTextCenter("标题4");
titleBar4.setImageRight(R.mipmap.icon_back);
titleBar4.showRightView();
titleBar4.setOnClickRightViewListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtil.show(v.getContext(),"点击右边");
}
});
CustomTitleBar titleBar5=findViewById(R.id.title5);
titleBar5.setTextCenter("标题5");
titleBar5.setTextCenterDrawableLeftRight(R.mipmap.ic_launcher,R.mipmap.ic_launcher_round);
}
}
package com.mayi.demo;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.view.View;
import com.mayi.fastdevelop.base.BaseActivity;
public class TsetActviity extends BaseActivity {
private Handler handler;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_layout);
handler = new Handler();
findViewById(R.id.showLoading).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showLoadingDialog();
handler.postDelayed(new Runnable() {
@Override
public void run() {
dismssLoadingDialog();
}
}, 4000);
}
});
}
}
package com.mayi.demo;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.util.DialogUtils;
import com.mayi.fastdevelop.util.ToastUtil;
import com.mayi.fastdevelop.view.wheel.ChangeAddressDialog;
import com.mayi.fastdevelop.view.wheel.ChangeBirthDialog;
import com.mayi.fastdevelop.view.wheel.ChangeDateDialog;
import com.mayi.fastdevelop.view.wheel.ChangeTimeDialog;
public class ViewActviity extends BaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test_layout);
findViewById(R.id.b1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ChangeAddressDialog(v.getContext(), new ChangeAddressDialog.OnAddressCListener() {
@Override
public void onClick(String province, String city) {
ToastUtil.show(ViewActviity.this, "province=" + province + " city=" + city);
}
}).show();
}
});
findViewById(R.id.b2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ChangeBirthDialog(v.getContext(), new ChangeBirthDialog.OnBirthListener() {
@Override
public void onClick(String year, String month, String day) {
ToastUtil.show(ViewActviity.this, "year=" + year + " month=" + month + " day=" + day);
}
}).show();
}
});
findViewById(R.id.b3).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ChangeDateDialog(v.getContext(), new ChangeDateDialog.OnDateListener() {
@Override
public void onClick(String year, String month, String day) {
ToastUtil.show(ViewActviity.this, "year=" + year + " month=" + month + " day=" + day);
}
}).show();
}
});
findViewById(R.id.b4).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ChangeTimeDialog(v.getContext(), new ChangeTimeDialog.OnTimeListener() {
@Override
public void onClick(String year, String month, String day, String hour, String minute) {
ToastUtil.show(ViewActviity.this, "year=" + year + " month="
+ month + " day=" + day + " hour=" + hour + " minute=" + minute);
}
}).show();
}
});
findViewById(R.id.b5).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogUtils.showCommonDialog("标题", "左边", "右边", v.getContext(), new DialogUtils.DefaultDialogListener() {
@Override
public void onClickLeft() {
ToastUtil.show(ViewActviity.this,"点击左边");
}
@Override
public void onClickRight() {
ToastUtil.show(ViewActviity.this,"点击右边");
}
});
}
});
findViewById(R.id.b6).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogUtils.showCommonDialog("标题", v.getContext(), new DialogUtils.DefaultDialogListener() {
@Override
public void onClickLeft() {
ToastUtil.show(ViewActviity.this,"取消");
}
@Override
public void onClickRight() {
ToastUtil.show(ViewActviity.this,"确定");
}
});
}
});
findViewById(R.id.b7).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogUtils.showTipsDialog("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", v.getContext(), new DialogUtils.TipsDialogListener() {
@Override
public void onClickOK() {
ToastUtil.show(ViewActviity.this,"确定");
}
});
}
});
findViewById(R.id.b8).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogUtils.showTipsDialog("1234567890yiersn", v.getContext(), new DialogUtils.TipsDialogListener() {
@Override
public void onClickOK() {
ToastUtil.show(ViewActviity.this,"确定");
}
});
}
});
findViewById(R.id.b9).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gotoActivity(TitleActivity.class);
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/showLoading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="显示对话框"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
\ No newline at end of file
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="城市二级联动对话框" />
<Button
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="日期选择对话框1" />
<Button
android:id="@+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="日期选择对话框2" />
<Button
android:id="@+id/b4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="日期时间对话框" />
<Button
android:id="@+id/b5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="常用对话框-样式1" />
<Button
android:id="@+id/b6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="常用对话框-样式2" />
<Button
android:id="@+id/b7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="常用对话框-样式3" />
<Button
android:id="@+id/b8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="常用对话框-样式4" />
<Button
android:id="@+id/b9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="标题栏" />
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.mayi.fastdevelop.view.CustomTitleBar
android:id="@+id/title1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/im_dp_20" />
<com.mayi.fastdevelop.view.CustomTitleBar
android:id="@+id/title2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/im_dp_20" />
<com.mayi.fastdevelop.view.CustomTitleBar
android:id="@+id/title3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/im_dp_20" />
<com.mayi.fastdevelop.view.CustomTitleBar
android:id="@+id/title4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/im_dp_20" />
<com.mayi.fastdevelop.view.CustomTitleBar
android:id="@+id/title5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/im_dp_20" />
</LinearLayout>
</ScrollView>
\ No newline at end of file
package com.mayi.fastdevelop.util;
import android.content.Context;
import android.view.View;
import com.mayi.fastdevelop.R;
import com.mayi.fastdevelop.view.dialog.BaseDialog;
import com.mayi.fastdevelop.view.dialog.DialogViewHolder;
/**
* 常用对话框
*/
public class DialogUtils {
public static BaseDialog showCommonDialog(final String titel, final String left, final String right, Context context, final DefaultDialogListener dialogListener) {
return new BaseDialog(context, R.layout.dialog_default_sure) {
@Override
public void convert(DialogViewHolder holder) {
holder.setText(R.id.tv_title, titel);
holder.setText(R.id.tv_left, left);
holder.setText(R.id.tv_right, right);
holder.setOnClick(R.id.tv_right, new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
if (dialogListener != null) {
dialogListener.onClickRight();
}
}
});
holder.setOnClick(R.id.tv_left, new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
if (dialogListener != null) {
dialogListener.onClickLeft();
}
}
});
}
}.setCanceledOnTouchOutside(true)
.setCancelAble(true)
.show();
}
public static BaseDialog showCommonDialog(String title, Context context, DefaultDialogListener listener) {
return showCommonDialog(title, "取消", "确定", context, listener);
}
public static BaseDialog showTipsDialog(final String content, Context context, final TipsDialogListener listener) {
return new BaseDialog(context, R.layout.dialog_default_tips) {
@Override
public void convert(DialogViewHolder holder) {
holder.setText(R.id.tv_content, content);
holder.setOnClick(R.id.tv_ok, new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
if (listener != null) {
listener.onClickOK();
}
}
});
}
}.setCanceledOnTouchOutside(true)
.setCancelAble(true)
.show();
}
public interface TipsDialogListener {
void onClickOK();
}
public interface DefaultDialogListener {
void onClickLeft();
void onClickRight();
}
}
......@@ -27,7 +27,7 @@ public class SpUtil {
* 清空所有数据
*/
public static void clear() {
getSp().edit().clear().apply();
getSp().edit().clear().commit();
}
/**
......@@ -37,7 +37,7 @@ public class SpUtil {
* @param value 值(boolean).
*/
public static void set(String key, boolean value) {
getSp().edit().putBoolean(key, value).apply();
getSp().edit().putBoolean(key, value).commit();
}
/**
......@@ -47,7 +47,7 @@ public class SpUtil {
* @param value 值(float).
*/
public static void set(String key, float value) {
getSp().edit().putFloat(key, value).apply();
getSp().edit().putFloat(key, value).commit();
}
/**
......@@ -57,7 +57,7 @@ public class SpUtil {
* @param value 值(int).
*/
public static void set(String key, int value) {
getSp().edit().putInt(key, value).apply();
getSp().edit().putInt(key, value).commit();
}
/**
......@@ -67,7 +67,7 @@ public class SpUtil {
* @param value 值(long).
*/
public static void set(String key, long value) {
getSp().edit().putLong(key, value).apply();
getSp().edit().putLong(key, value).commit();
}
/**
......@@ -77,7 +77,7 @@ public class SpUtil {
* @param value 值(String).
*/
public static void set(String key, String value) {
getSp().edit().putString(key, value).apply();
getSp().edit().putString(key, value).commit();
}
/**
......@@ -86,7 +86,7 @@ public class SpUtil {
* @param key 键.
*/
public static void remove(String key) {
getSp().edit().remove(key).apply();
getSp().edit().remove(key).commit();
}
/**
......
package com.mayi.fastdevelop.view;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.text.Html;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.mayi.fastdevelop.R;
import com.mayi.fastdevelop.util.DisplayUtil;
/**
* 页面的顶部。
* 注意,该类包含元素:左边返回icon 文字、中间标题、右边提示文字、右边图片按钮。不符合这种顶部的UI自己写布局,符合的都用这个。
* 默认只显示返回按钮和中间标题。布局文件添加见类头部注释
*/
public class CustomTitleBar extends RelativeLayout {
private ImageView iv_left, iv_logo;
private View layout_left, layout_right, layout_close, v_right;
private TextView tv_left, tv_center, tv_right;
private OnClickListener onClickLeftView, onClickRightView, onClickRightText, onClickLeftClose, onClickCenterText;
private static String defaultTitle;//默认标题
public CustomTitleBar(Context context) {
super(context);
init();
}
public CustomTitleBar(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public CustomTitleBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
View view = LayoutInflater.from(getContext()).inflate(R.layout.view_title_bar, null);
iv_left = (ImageView) view.findViewById(R.id.iv_left);
tv_left = (TextView) view.findViewById(R.id.tv_left);
iv_logo = (ImageView) view.findViewById(R.id.iv_logo);
layout_left = view.findViewById(R.id.layout_left);
layout_right = view.findViewById(R.id.layout_right);
layout_close = view.findViewById(R.id.layout_close);
v_right = view.findViewById(R.id.v_right);
tv_center = (TextView) view.findViewById(R.id.tv_center);
tv_right = (TextView) view.findViewById(R.id.tv_right);
layout_right.setVisibility(View.GONE);
tv_right.setVisibility(View.GONE);
if (defaultTitle != null) {
setTextCenter(defaultTitle);
}
layout_left.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onClickLeftView != null)
onClickLeftView.onClick(v);
}
});
layout_right.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onClickRightView != null)
onClickRightView.onClick(v);
}
});
tv_right.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onClickRightText != null)
onClickRightText.onClick(v);
}
});
layout_close.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onClickLeftClose != null) {
onClickLeftClose.onClick(v);
}
}
});
iv_logo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (onClickCenterText != null) {
onClickCenterText.onClick(v);
}
}
});
addView(view);
}
/**
* 设置全局默认标题,如果没有设置默认,则默认为teamlib,所以需要在AppContext中设置默认标题
*/
public static void setDefaultTitle(String defaultTitle) {
CustomTitleBar.defaultTitle = defaultTitle;
}
/**
* 设置左上角返回按钮的图片
*/
public void setLeftImageResource(int resId) {
iv_left.setImageResource(resId);
}
/**
* 设置标题左边LOGO图片
*/
public void setLogoImageResource(int resId) {
iv_logo.setImageResource(resId);
tv_center.setEms(4);
}
/**
* 设置返回文字
*
* @param text
*/
public void setTextLeft(CharSequence text) {
if (text != null) {
tv_left.setText(Html.fromHtml(text.toString().trim()));
}
}
/**
* 隐藏返回按钮
*/
public void hideLeftView() {
layout_left.setVisibility(View.GONE);
}
public TextView getLeftText() {
return tv_left;
}
/**
* 设置返回文字
*
* @param textResId 文字id
*/
public void setTextLeft(int textResId) {
setTextLeft(getContext().getString(textResId).trim());
}
/**
* 设置返回文字颜色
*
* @param textLeftColor 颜色值ID
*/
public void setTextLeftColor(int textLeftColor) {
tv_left.setTextColor(textLeftColor);
}
/**
* 设置显隐返回文字
*
* @param hide true 隐藏
*/
public void setTextLeftVisible(boolean hide) {
tv_left.setVisibility(hide ? GONE : VISIBLE);
}
/**
* 设置中间标题文字
*
* @param text
*/
public void setTextCenter(CharSequence text) {
if (text != null) {
tv_center.setText(Html.fromHtml(text.toString().trim()));
}
}
/**
* 设置中间标题文字
*
* @param textResId
*/
public void setTextCenter(int textResId) {
setTextCenter(getContext().getString(textResId).trim());
}
/**
* 设置中间文字大小
*
* @param size
*/
public void setTextCenterSize(int size) {
tv_center.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
}
/**
* 标题右边图片
*
* @param resId
*/
public void setTextCenterDrawableRight(@DrawableRes int resId) {
Drawable drawable = getResources().getDrawable(resId);
drawable.setBounds(0, 0, DisplayUtil.dip2px(getContext(), 14), DisplayUtil.dip2px(getContext(), 14));
tv_center.setCompoundDrawables(null, null, drawable, null);
}
/**
* 标题左右两边图片
*
* @param leftResId
* @param rightResId
*/
public void setTextCenterDrawableLeftRight(@DrawableRes int leftResId, @DrawableRes int rightResId) {
Drawable drawable_l = getResources().getDrawable(leftResId);
drawable_l.setBounds(0, 0, DisplayUtil.dip2px(getContext(), 14), DisplayUtil.dip2px(getContext(), 14));
Drawable drawable_r = getResources().getDrawable(rightResId);
drawable_r.setBounds(0, 0, DisplayUtil.dip2px(getContext(), 14), DisplayUtil.dip2px(getContext(), 14));
tv_center.setCompoundDrawables(drawable_l, null, drawable_r, null);
}
/**
* 设置右边提示文字
*/
public void setTextRight(String text) {
if (TextUtils.isEmpty(text)) {
tv_right.setVisibility(View.GONE);
} else {
tv_right.setText(text.trim());
tv_right.setVisibility(View.VISIBLE);
}
}
/**
* 设置右边提示文字
*/
public void setTextRight(int textResId) {
setTextRight(getContext().getString(textResId).trim());
}
/**
* 设置右边提示文字颜色
*/
public void setTextRightColor(int color) {
tv_right.setTextColor(color);
}
/**
* 设置右上角按钮图片
*/
public void setImageRight(int resId) {
v_right.setBackgroundResource(resId);
}
/**
* 点击左边图标,一般是返回按钮事件
*/
public void setOnClickLeftViewListener(OnClickListener onClickLeftView) {
this.onClickLeftView = onClickLeftView;
}
/**
* 点击右边图标,例如删除按钮事件
*/
public void setOnClickRightViewListener(OnClickListener onClickRightView) {
this.onClickRightView = onClickRightView;
}
/**
* 点击中间文字事件
*/
public void setOnClickCenterTextListener(OnClickListener onClickCenterText) {
this.onClickCenterText = onClickCenterText;
tv_center.setOnClickListener(onClickCenterText);
}
/**
* 点击右边文字,例如优惠券说明等
*/
public void setOnClickRightTextListener(OnClickListener onClickRightText) {
this.onClickRightText = onClickRightText;
}
/**
* 对于webView,显示关闭按钮,直接关闭activity
*/
public void setOnClickLeftCloseListener(OnClickListener onClickLeftClose) {
this.onClickLeftClose = onClickLeftClose;
}
/**
* 对于webView,显示关闭按钮,直接关闭activity,点击返回按钮则web.goback
*/
public void showLeftCloseView() {
layout_close.setVisibility(View.VISIBLE);
}
/**
* 隐藏右上角文字
*/
public void hideRightText() {
tv_right.setVisibility(View.GONE);
}
/**
* 显示右上角文字
*/
public void showRightText() {
tv_right.setVisibility(View.VISIBLE);
}
public TextView getRightText() {
return tv_right;
}
/**
* 显示右上角图标按钮
*/
public void showRightView() {
layout_right.setVisibility(View.VISIBLE);
}
/**
* 隐藏右上角图标按钮
*/
public void hideRightView() {
layout_right.setVisibility(View.GONE);
}
}
package com.mayi.fastdevelop.view.dialog;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.FloatRange;
import android.support.annotation.StyleRes;
import android.support.v7.app.AlertDialog;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import com.mayi.fastdevelop.R;
/**
* 自定义dialog {@link # https://github.com/luoshihai/XXDialog/}
* <p>
* 用法:<BR/>
* {@code new BaseDialog(this,R.layout.dialog)实现 convert()
* .setCancelable......}
* <p>
* API:<BR/>
* {@link #show()} 显示dialog <BR/>
* {@link #show(boolean)} 如果为true 就显示默认的一个缩放动画<BR/>
* {@link #showWithAnim(int)} 显示一个Dialog自定义一个弹出方式 具体怎么写 可以模仿上面的<BR/>
* {@link #dismiss()} dismiss dialog<BR/>
* {@link #backgroundLight(float light)} 弹出时背景亮度 值为0.0~1.0 1.0表示全黑 0.0表示全白<BR/>
* {@link #fromBottomToMiddle()} 从底部一直弹到中间<BR/>
* {@link #fromBottom()} 从底部弹出 显示在底部<BR/>
* {@link #fromLeftToMiddle()} 从左边一直弹到中间退出也是到左边<BR/>
* {@link #fromRightToMiddle()} 从右边一直弹到中间退出也是到右边<BR/>
* {@link #fromTop()} 从顶部弹出 从顶部弹出 保持在顶部<BR/>
* {@link #fromTopToMiddle()} 从顶部谈到中间 从顶部弹出 保持在中间<BR/>
* {@link #fullScreen()} 全屏显示<BR/>
* {@link #fullWidth()} 全屏宽度<BR/>
* {@link #fullHeight()} 全屏高度<BR/>
* {@link #setWidthAndHeight(int width, int height)} 自定义宽高<BR/>
* {@link #setOnKeyListener(DialogInterface.OnKeyListener onKeyListener)} 当dialog弹出是 按键的点击事件会被dialog获取<BR/>
* {@link #setDialogDismissListener(DialogInterface.OnDismissListener)} 设置dismiss监听<BR/>
* {@link #setOnCancelListener(DialogInterface.OnCancelListener)} 设置取消监听<BR/>
* {@link #setCancelAble(boolean)} 设置能否被取消<BR/>
* {@link #setCanceledOnTouchOutside(boolean cancel)} 设置点击其他地方能否被取消<BR/>
* Created by ludas on 2017/5/5.
*/
public abstract class BaseDialog {
private static Dialog mDialog;
private Window mDialogWindow;
private DialogViewHolder dialogHolder;
private View mRootView;
public BaseDialog(Context context, int layoutId) {
dialogHolder = DialogViewHolder.get(context, layoutId);
mRootView = dialogHolder.getConvertView();
mDialog = new Dialog(context, R.style.dialog);
mDialog.setContentView(mRootView);
mDialogWindow = mDialog.getWindow();
convert(dialogHolder);
}
/**
* 把弹出框view holder传出去
*/
public abstract void convert(DialogViewHolder holder);
public static AlertDialog.Builder creatNormalDialogBuilder(Context context, String title, String message) {
return new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(message);
}
public static Dialog getDialog() {
return mDialog;
}
/**
* 显示dialog
*/
public BaseDialog show() {
if (mDialog != null && !mDialog.isShowing()) {
mDialog.show();
}
return this;
}
/**
* @param light 弹出时背景亮度 值为0.0~1.0 1.0表示全黑 0.0表示全白
* @return
*/
public BaseDialog backgroundLight(@FloatRange(from = 0, to = 1) float light) {
if (light < 0.0 || light > 1.0)
return this;
WindowManager.LayoutParams lp = mDialogWindow.getAttributes();
lp.dimAmount = light;
mDialogWindow.setAttributes(lp);
return this;
}
/**
* 从底部一直弹到中间
*/
@SuppressLint("NewApi")
public BaseDialog fromBottomToMiddle() {
mDialogWindow.setWindowAnimations(R.style.window_bottom_in_bottom_out);
return this;
}
/**
* 从底部弹出
*/
public BaseDialog fromBottom() {
fromBottomToMiddle();
mDialogWindow.setGravity(Gravity.CENTER | Gravity.BOTTOM);
return this;
}
/**
* 从左边一直弹到中间退出也是到左边
*/
public BaseDialog fromLeftToMiddle() {
mDialogWindow.setWindowAnimations(R.style.window_left_in_left_out);
mDialogWindow.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
mDialogWindow.setGravity(Gravity.CENTER | Gravity.START);
return this;
}
/**
* 设置窗体的显示类型
*/
public BaseDialog setWindowType() {
mDialogWindow.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
return this;
}
/**
* 从右边一直弹到中间退出也是到右边
*
* @return
*/
public BaseDialog fromRightToMiddle() {
mDialogWindow.setWindowAnimations(R.style.window_right_in_right_out);
mDialogWindow.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
mDialogWindow.setGravity(Gravity.END);
return this;
}
/**
* 从顶部弹出 从顶部弹出 保持在顶部
*
* @return
*/
public BaseDialog fromTop() {
fromTopToMiddle();
mDialogWindow.setGravity(Gravity.CENTER | Gravity.TOP);
return this;
}
/**
* 从顶部谈到中间 从顶部弹出 保持在中间
*
* @return
*/
public BaseDialog fromTopToMiddle() {
mDialogWindow.setWindowAnimations(R.style.window_top_in_top_out);
mDialogWindow.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
return this;
}
/**
* @param style 显示一个Dialog自定义一个弹出方式 具体怎么写 可以模仿上面的
* @return
*/
public BaseDialog showWithAnim(@StyleRes int style) {
mDialogWindow.setWindowAnimations(style);
mDialog.show();
return this;
}
/**
* @param isAnimation 如果为true 就显示默认的一个缩放动画
* @return
*/
public BaseDialog show(boolean isAnimation) {
mDialogWindow.setWindowAnimations(R.style.dialog_scale_animstyle);
mDialog.show();
return this;
}
/**
* 全屏显示
*/
public BaseDialog fullScreen() {
WindowManager.LayoutParams wl = mDialogWindow.getAttributes();
wl.height = ViewGroup.LayoutParams.MATCH_PARENT;
wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
mDialog.onWindowAttributesChanged(wl);
return this;
}
public BaseDialog setOnKeyListener(DialogInterface.OnKeyListener onKeyListener) {
mDialog.setOnKeyListener(onKeyListener);
return this;
}
/**
* 全屏宽度
*/
public BaseDialog fullWidth() {
WindowManager.LayoutParams wl = mDialogWindow.getAttributes();
wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
mDialog.onWindowAttributesChanged(wl);
return this;
}
/**
* 全屏高度
*/
public BaseDialog fullHeight() {
WindowManager.LayoutParams wl = mDialogWindow.getAttributes();
wl.height = ViewGroup.LayoutParams.MATCH_PARENT;
mDialog.onWindowAttributesChanged(wl);
return this;
}
/**
* @param width 自定义的宽度
* @param height 自定义的高度
* @return
*/
public BaseDialog setWidthAndHeight(int width, int height) {
WindowManager.LayoutParams wl = mDialogWindow.getAttributes();
wl.width = width;
wl.height = height;
mDialog.onWindowAttributesChanged(wl);
return this;
}
/**
* cancel dialog
*/
public void cancelDialog() {
if (mDialog != null && mDialog.isShowing())
dismiss();
}
/**
* cancel dialog
*/
public void dismiss() {
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
}
/**
* 设置监听
*/
public BaseDialog setDialogDismissListener(DialogInterface.OnDismissListener listener) {
mDialog.setOnDismissListener(listener);
return this;
}
/**
* 设置监听
*/
public BaseDialog setOnCancelListener(DialogInterface.OnCancelListener listener) {
mDialog.setOnCancelListener(listener);
return this;
}
/**
* 设置是否能取消
*/
public BaseDialog setCancelAble(boolean cancel) {
mDialog.setCancelable(cancel);
return this;
}
/**
* 设置触摸其他地方是否能取消
*/
public BaseDialog setCanceledOnTouchOutside(boolean cancel) {
mDialog.setCanceledOnTouchOutside(cancel);
return this;
}
}
package com.mayi.fastdevelop.view.dialog;
import android.content.Context;
import android.support.annotation.StringRes;
import android.util.SparseArray;
import android.view.View;
import android.widget.TextView;
public class DialogViewHolder {
private final SparseArray<View> mViews;
private View mDialogView;
private DialogViewHolder(Context context, int layoutId) {
this.mViews = new SparseArray<>();
mDialogView = View.inflate(context, layoutId, null);
}
public static DialogViewHolder get(Context context, int layoutId) {
return new DialogViewHolder(context, layoutId);
}
public View getConvertView() {
return mDialogView;
}
public DialogViewHolder setText(int viewId, CharSequence text) {
TextView view = getView(viewId);
view.setText(text);
return this;
}
public DialogViewHolder setText(int viewId, @StringRes int redId) {
TextView view = getView(viewId);
view.setText(redId);
return this;
}
/**
* 设置view 显示状态
*
* @param viewId view id
* @param viewState View.VISIBLE / GONE /INVISIBLE
* @return
*/
public DialogViewHolder setViewVisibleState(int viewId, int viewState) {
View view = getView(viewId);
view.setVisibility(viewState);
return this;
}
/**
* 设置点击事件
*/
public DialogViewHolder setOnClick(int viewId, View.OnClickListener onClick) {
View view = getView(viewId);
view.setOnClickListener(onClick);
return this;
}
/**
* Through control the Id of the access to control, if not join views
*
* @param viewId
* @return
*/
private <T extends View> T getView(int viewId) {
View view = mViews.get(viewId);
if (view == null) {
view = mDialogView.findViewById(viewId);
mViews.put(viewId, view);
}
return (T) view;
}
}
package com.mayi.fastdevelop.view.wheel;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mayi.fastdevelop.R;
import com.mayi.fastdevelop.view.wheel.adapters.AbstractWheelTextAdapter;
import com.mayi.fastdevelop.view.wheel.views.CustomWheelView;
import com.mayi.fastdevelop.view.wheel.views.OnWheelChangedListener;
import com.mayi.fastdevelop.view.dialog.DialogViewHolder;
import com.mayi.fastdevelop.view.dialog.BaseDialog;
import java.util.ArrayList;
import java.util.Calendar;
import static java.lang.Integer.parseInt;
/**
* 选择日期dialog
*/
public class ChangeDateDialog extends BaseDialog implements View.OnClickListener {
private Context mContext;
private OnDateListener onTimeListener;
private ArrayList<String> array_years = new ArrayList<>();
private ArrayList<String> array_months = new ArrayList<>();
private ArrayList<String> array_days = new ArrayList<>();
private CalendarTextAdapter mYearAdapter;
private CalendarTextAdapter mMonthAdapter;
private CalendarTextAdapter mDaydapter;
private CalendarTextAdapter mHourAdapter;
private CalendarTextAdapter mMinuteAdapter;
private String mYear, mMonth, mDay, mHour, mMinute;
private CustomWheelView wvYear;
private CustomWheelView wvMonth;
private CustomWheelView wvDay;
private TextView btnSure;
private TextView btnCancel;
private int day;
private int currentYear, currentMonth, currentDay;
private int maxTextSize = 20;
private int minTextSize = 14;
public ChangeDateDialog(Context context, OnDateListener onTimeListener) {
super(context, R.layout.view_wheel_date);
this.mContext = context;
this.onTimeListener = onTimeListener;
getDate();
initDataAndBindEvent();
}
private void getDate() {
this.currentYear = getYear();
this.currentMonth = getMonth();
this.currentDay = getDay();
calDays(currentYear, currentMonth);/*计算当月天数*/
}
private void initDataAndBindEvent() {
initYears();
mYearAdapter = new CalendarTextAdapter(mContext, array_years, 1, maxTextSize, minTextSize);
wvYear.setVisibleItems(5);
wvYear.setViewAdapter(mYearAdapter);
wvYear.setCurrentItem(1);
mYear = array_years.get(1);
initMonths();
mMonthAdapter = new CalendarTextAdapter(mContext, array_months, currentMonth, maxTextSize, minTextSize);
wvMonth.setVisibleItems(5);
wvMonth.setViewAdapter(mMonthAdapter);
wvMonth.setCurrentItem(currentMonth - 1);
mMonth = array_months.get(currentMonth - 1);
initDays(day);
mDaydapter = new CalendarTextAdapter(mContext, array_days, currentDay - 1, maxTextSize, minTextSize);
wvDay.setVisibleItems(5);
wvDay.setViewAdapter(mDaydapter);
wvDay.setCurrentItem(currentDay - 1);
mDay = array_days.get(currentDay - 1);
wvYear.addChangingListener(new OnWheelChangedListener() {
@Override
public void onChanged(CustomWheelView wheel, int oldValue, int newValue) {
mYear = (String) mYearAdapter.getItemText(wheel.getCurrentItem());
currentYear = parseInt(mYear);
}
});
wvMonth.addChangingListener(new OnWheelChangedListener() {
@Override
public void onChanged(CustomWheelView wheel, int oldValue, int newValue) {
mMonth = (String) mMonthAdapter.getItemText(wheel.getCurrentItem());
currentMonth = parseInt(mMonth);
calDays(currentYear, currentMonth);
initDays(day);
mDaydapter = new CalendarTextAdapter(mContext, array_days, currentDay - 1, maxTextSize, minTextSize);
wvDay.setVisibleItems(5);
wvDay.setViewAdapter(mDaydapter);
wvDay.setCurrentItem(currentDay - 1);
}
});
wvDay.addChangingListener(new OnWheelChangedListener() {
@Override
public void onChanged(CustomWheelView wheel, int oldValue, int newValue) {
mDay = (String) mDaydapter.getItemText(wheel.getCurrentItem());
currentDay = parseInt(mDay);
}
});
}
private void initYears() {
array_years.clear();
for (int i = currentYear - 1; i <= currentYear + 1; i++) {
array_years.add(String.valueOf(i));
}
}
private void initMonths() {
array_months.clear();
for (int i = 1; i <= 12; i++) {
array_months.add(String.valueOf(i));
}
}
private void initDays(int days) {
array_days.clear();
for (int i = 1; i <= days; i++) {
array_days.add(String.valueOf(i));
}
}
/**
* 计算每月多少天
*/
public void calDays(int yrear, int month) {
boolean leayyear;
if (currentYear % 4 == 0 && currentYear % 100 != 0) {
leayyear = true;
} else {
leayyear = false;
}
for (int i = 1; i <= 12; i++) {
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
this.day = 31;
break;
case 2:
if (leayyear) {
this.day = 29;
} else {
this.day = 28;
}
break;
case 4:
case 6:
case 9:
case 11:
this.day = 30;
break;
}
}
}
private int getYear() {
Calendar c = Calendar.getInstance();
return c.get(Calendar.YEAR);
}
private int getMonth() {
Calendar c = Calendar.getInstance();
return c.get(Calendar.MONTH) + 1;
}
private int getDay() {
Calendar c = Calendar.getInstance();
return c.get(Calendar.DAY_OF_MONTH);
}
public interface OnDateListener {
void onClick(String year, String month, String day);
}
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.txt_complete) {
if (onTimeListener != null) {
mMonth = parseInt(mMonth) > 9 ? mMonth : "0" + mMonth;
mDay = parseInt(mDay) > 9 ? mDay : "0" + mDay;
onTimeListener.onClick(mYear, mMonth, mDay);
}
dismiss();
} else if (i == R.id.txt_think) {
dismiss();
}
}
@Override
public void convert(DialogViewHolder holder) {
View view = holder.getConvertView();
wvYear = (CustomWheelView) view.findViewById(R.id.wv_year);
wvMonth = (CustomWheelView) view.findViewById(R.id.wv_month);
wvDay = (CustomWheelView) view.findViewById(R.id.wv_day);
btnSure = (TextView) view.findViewById(R.id.txt_complete);
btnCancel = (TextView) view.findViewById(R.id.txt_think);
btnSure.setOnClickListener(this);
btnCancel.setOnClickListener(this);
}
private class CalendarTextAdapter extends AbstractWheelTextAdapter {
ArrayList<String> list;
protected CalendarTextAdapter(Context context, ArrayList<String> list, int currentItem, int maxsize, int minsize) {
super(context, R.layout.item_birth_year, NO_RESOURCE, currentItem, maxsize, minsize);
this.list = list;
setItemTextResource(R.id.tempValue);
}
@Override
public View getItem(int index, View cachedView, ViewGroup parent) {
View view = super.getItem(index, cachedView, parent);
return view;
}
@Override
public int getItemsCount() {
return list.size();
}
@Override
protected CharSequence getItemText(int index) {
return list.get(index) + "";
}
}
}
/*
* /**
* * Copyright &copy; 2017-2020 All rights reserved.
* * Licensed under the yen License, Version 1.0 (the "License");
*
*/
package com.mayi.fastdevelop.view.wheel.adapters;
import android.database.DataSetObserver;
import android.view.View;
import android.view.ViewGroup;
import java.util.LinkedList;
import java.util.List;
/**
* Abstract Wheel adapter.
*/
public abstract class AbstractWheelAdapter implements WheelViewAdapter {
// Observers
private List<DataSetObserver> datasetObservers;
@Override
public View getEmptyItem(View convertView, ViewGroup parent) {
return null;
}
@Override
public void registerDataSetObserver(DataSetObserver observer) {
if (datasetObservers == null) {
datasetObservers = new LinkedList<>();
}
datasetObservers.add(observer);
}
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
if (datasetObservers != null) {
datasetObservers.remove(observer);
}
}
/**
* Notifies observers about data changing
*/
protected void notifyDataChangedEvent() {
if (datasetObservers != null) {
for (DataSetObserver observer : datasetObservers) {
observer.onChanged();
}
}
}
/**
* Notifies observers about invalidating data
*/
protected void notifyDataInvalidatedEvent() {
if (datasetObservers != null) {
for (DataSetObserver observer : datasetObservers) {
observer.onInvalidated();
}
}
}
}
package com.mayi.fastdevelop.view.wheel.adapters;
import android.content.Context;
import android.graphics.Typeface;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
/**
* Abstract wheel adapter provides common functionality for adapters.
*/
public abstract class AbstractWheelTextAdapter extends AbstractWheelAdapter {
/** Text view resource. Used as a default view for adapter. */
public static final int TEXT_VIEW_ITEM_RESOURCE = -1;
/** No resource constant. */
protected static final int NO_RESOURCE = 0;
/** Default text color */
public static final int DEFAULT_TEXT_COLOR = 0xFF101010;
/** Default text color */
public static final int LABEL_COLOR = 0xFF700070;
/** Default text size */
public static final int DEFAULT_TEXT_SIZE = 20;
// Text settings
private int textColor = DEFAULT_TEXT_COLOR;
private int textSize = DEFAULT_TEXT_SIZE;
// Current context
protected Context context;
// Layout inflater
protected LayoutInflater inflater;
// Items resources
protected int itemResourceId;
protected int itemTextResourceId;
// Empty items resources
protected int emptyItemResourceId;
private int currentIndex = 0;
private static int maxsize = 17;
private static int minsize = 14;
private ArrayList<View> arrayList = new ArrayList<View>();
/**
* Constructor
*
* @param context
* the current context
*/
protected AbstractWheelTextAdapter(Context context) {
this(context, TEXT_VIEW_ITEM_RESOURCE);
}
/**
* Constructor
*
* @param context
* the current context
* @param itemResource
* the resource ID for a layout file containing a TextView to use
* when instantiating items views
*/
protected AbstractWheelTextAdapter(Context context, int itemResource) {
this(context, itemResource, NO_RESOURCE, 0, maxsize, minsize);
}
/**
* Constructor
*
* @param context
* the current context
* @param itemResource
* the resource ID for a layout file containing a TextView to use
* when instantiating items views
* @param itemTextResource
* the resource ID for a text view in the item layout
*/
protected AbstractWheelTextAdapter(Context context, int itemResource, int itemTextResource, int currentIndex,
int maxsize, int minsize) {
this.context = context;
itemResourceId = itemResource;
itemTextResourceId = itemTextResource;
this.currentIndex = currentIndex;
this.maxsize = maxsize;
this.minsize = minsize;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
/**
* get the list of show textview
*
* @return the array of textview
*/
public ArrayList<View> getTestViews() {
return arrayList;
}
/**
* Gets text color
*
* @return the text color
*/
public int getTextColor() {
return textColor;
}
/**
* Sets text color
*
* @param textColor
* the text color to set
*/
public void setTextColor(int textColor) {
this.textColor = textColor;
}
/**
* Gets text size
*
* @return the text size
*/
public int getTextSize() {
return textSize;
}
/**
* Sets text size
*
* @param textSize
* the text size to set
*/
public void setTextSize(int textSize) {
this.textSize = textSize;
}
/**
* Gets resource Id for items views
*
* @return the item resource Id
*/
public int getItemResource() {
return itemResourceId;
}
/**
* Sets resource Id for items views
*
* @param itemResourceId
* the resource Id to set
*/
public void setItemResource(int itemResourceId) {
this.itemResourceId = itemResourceId;
}
/**
* Gets resource Id for text view in item layout
*
* @return the item text resource Id
*/
public int getItemTextResource() {
return itemTextResourceId;
}
/**
* Sets resource Id for text view in item layout
*
* @param itemTextResourceId
* the item text resource Id to set
*/
public void setItemTextResource(int itemTextResourceId) {
this.itemTextResourceId = itemTextResourceId;
}
/**
* Gets resource Id for empty items views
*
* @return the empty item resource Id
*/
public int getEmptyItemResource() {
return emptyItemResourceId;
}
/**
* Sets resource Id for empty items views
*
* @param emptyItemResourceId
* the empty item resource Id to set
*/
public void setEmptyItemResource(int emptyItemResourceId) {
this.emptyItemResourceId = emptyItemResourceId;
}
/**
* Returns text for specified item
*
* @param index
* the item index
* @return the text of specified items
*/
protected abstract CharSequence getItemText(int index);
@Override
public View getItem(int index, View convertView, ViewGroup parent) {
if (index >= 0 && index < getItemsCount()) {
if (convertView == null) {
convertView = getView(itemResourceId, parent);
}
TextView textView = getTextView(convertView, itemTextResourceId);
if (!arrayList.contains(textView)) {
arrayList.add(textView);
}
if (textView != null) {
CharSequence text = getItemText(index);
if (text == null) {
text = "";
}
textView.setText(text);
// if (index == currentIndex) {
// textView.setTextSize(maxsize);
// } else {
// textView.setTextSize(minsize);
// }
if (itemResourceId == TEXT_VIEW_ITEM_RESOURCE) {
configureTextView(textView);
}
}
return convertView;
}
return null;
}
@Override
public View getEmptyItem(View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getView(emptyItemResourceId, parent);
}
if (emptyItemResourceId == TEXT_VIEW_ITEM_RESOURCE && convertView instanceof TextView) {
configureTextView((TextView) convertView);
}
return convertView;
}
/**
* Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
*
* @param view
* the text view to be configured
*/
protected void configureTextView(TextView view) {
view.setTextColor(textColor);
view.setGravity(Gravity.CENTER);
view.setTextSize(textSize);
view.setLines(1);
view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
}
/**
* Loads a text view from view
*
* @param view
* the text view or layout containing it
* @param textResource
* the text resource Id in layout
* @return the loaded text view
*/
private TextView getTextView(View view, int textResource) {
TextView text = null;
try {
if (textResource == NO_RESOURCE && view instanceof TextView) {
text = (TextView) view;
} else if (textResource != NO_RESOURCE) {
text = (TextView) view.findViewById(textResource);
}
} catch (ClassCastException e) {
Log.e("AbstractWheelAdapter", "You must supply a resource ID for a TextView");
throw new IllegalStateException("AbstractWheelAdapter requires the resource ID to be a TextView", e);
}
return text;
}
/**
* Loads view from resources
*
* @param resource
* the resource Id
* @return the loaded view or null if resource is not set
*/
private View getView(int resource, ViewGroup parent) {
switch (resource) {
case NO_RESOURCE:
return null;
case TEXT_VIEW_ITEM_RESOURCE:
return new TextView(context);
default:
return inflater.inflate(resource, parent, false);
}
}
}
package com.mayi.fastdevelop.view.wheel.adapters;
import android.database.DataSetObserver;
import android.view.View;
import android.view.ViewGroup;
/**
* Wheel items adapter interface
*/
public interface WheelViewAdapter {
/**
* Gets items count
*
* @return the count of wheel items
*/
int getItemsCount();
/**
* Get a View that displays the data at the specified position in the data
* set
*
* @param index the item index
* @param convertView the old view to reuse if possible
* @param parent the parent that this view will eventually be attached to
* @return the wheel item View
*/
View getItem(int index, View convertView, ViewGroup parent);
/**
* Get a View that displays an empty wheel item placed before the first or
* after the last wheel item.
*
* @param convertView the old view to reuse if possible
* @param parent the parent that this view will eventually be attached to
* @return the empty item View
*/
View getEmptyItem(View convertView, ViewGroup parent);
/**
* Register an observer that is called when changes happen to the data used
* by this adapter.
*
* @param observer the observer to be registered
*/
void registerDataSetObserver(DataSetObserver observer);
/**
* Unregister an observer that has previously been registered
*
* @param observer the observer to be unregistered
*/
void unregisterDataSetObserver(DataSetObserver observer);
}
package com.mayi.fastdevelop.view.wheel.views;
/**
* Range for visible items.
*/
public class ItemsRange {
// First item number
private int first;
// Items count
private int count;
/**
* Default constructor. Creates an empty range
*/
public ItemsRange() {
this(0, 0);
}
/**
* Constructor
*
* @param first
* the number of first item
* @param count
* the count of items
*/
public ItemsRange(int first, int count) {
this.first = first;
this.count = count;
}
/**
* Gets number of first item
*
* @return the number of the first item
*/
public int getFirst() {
return first;
}
/**
* Gets number of last item
*
* @return the number of last item
*/
public int getLast() {
return getFirst() + getCount() - 1;
}
/**
* Get items count
*
* @return the count of items
*/
public int getCount() {
return count;
}
/**
* Tests whether item is contained by range
*
* @param index
* the item number
* @return true if item is contained
*/
public boolean contains(int index) {
return index >= getFirst() && index <= getLast();
}
}
\ No newline at end of file
/*
* /**
* * Copyright &copy; 2017-2020 All rights reserved.
* * Licensed under the yen License, Version 1.0 (the "License");
*
*/
package com.mayi.fastdevelop.view.wheel.views;
/**
* Wheel changed listener interface.
* <p>
* The onChanged() method is called whenever current wheel positions is changed:
* <li>New Wheel position is set
* <li>Wheel view is scrolled
*/
public interface OnWheelChangedListener {
/**
* Callback method to be invoked when current item changed
*
* @param wheel
* the wheel view whose state has changed
* @param oldValue
* the old value of current item
* @param newValue
* the new value of current item
*/
void onChanged(CustomWheelView wheel, int oldValue, int newValue);
}
/*
* /**
* * Copyright &copy; 2017-2020 All rights reserved.
* * Licensed under the yen License, Version 1.0 (the "License");
*
*/
package com.mayi.fastdevelop.view.wheel.views;
/**
* Wheel clicked listener interface.
* <p>
* The onItemClicked() method is called whenever a wheel item is clicked
* <li>New Wheel position is set
* <li>Wheel view is scrolled
*/
public interface OnWheelClickedListener {
/**
* Callback method to be invoked when current item clicked
*
* @param wheel
* the wheel view
* @param itemIndex
* the index of clicked item
*/
void onItemClicked(CustomWheelView wheel, int itemIndex);
}
package com.mayi.fastdevelop.view.wheel.views;
/**
* Wheel scrolled listener interface.
*/
public interface OnWheelScrollListener {
/**
* Callback method to be invoked when scrolling started.
*
* @param wheel
* the wheel view whose state has changed.
*/
void onScrollingStarted(CustomWheelView wheel);
/**
* Callback method to be invoked when scrolling ended.
*
* @param wheel
* the wheel view whose state has changed.
*/
void onScrollingFinished(CustomWheelView wheel);
}
package com.mayi.fastdevelop.view.wheel.views;
import android.view.View;
import android.widget.LinearLayout;
import java.util.LinkedList;
import java.util.List;
/**
* Recycle stores wheel items to reuse.
*/
public class WheelRecycle {
// Cached items
private List<View> items;
// Cached empty items
private List<View> emptyItems;
// Wheel view
private CustomWheelView wheel;
/**
* Constructor
*
* @param wheel
* the wheel view
*/
public WheelRecycle(CustomWheelView wheel) {
this.wheel = wheel;
}
/**
* Recycles items from specified layout. There are saved only items not
* included to specified range. All the cached items are removed from
* original layout.
*
* @param layout
* the layout containing items to be cached
* @param firstItem
* the number of first item in layout
* @param range
* the range of current wheel items
* @return the new value of first item number
*/
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
int index = firstItem;
for (int i = 0; i < layout.getChildCount();) {
if (!range.contains(index)) {
recycleView(layout.getChildAt(i), index);
layout.removeViewAt(i);
if (i == 0) { // first item
firstItem++;
}
} else {
i++; // go to next item
}
index++;
}
return firstItem;
}
/**
* Gets item view
*
* @return the cached view
*/
public View getItem() {
return getCachedView(items);
}
/**
* Gets empty item view
*
* @return the cached empty view
*/
public View getEmptyItem() {
return getCachedView(emptyItems);
}
/**
* Clears all views
*/
public void clearAll() {
if (items != null) {
items.clear();
}
if (emptyItems != null) {
emptyItems.clear();
}
}
/**
* Adds view to specified cache. Creates a cache list if it is null.
*
* @param view
* the view to be cached
* @param cache
* the cache list
* @return the cache list
*/
private List<View> addView(View view, List<View> cache) {
if (cache == null) {
cache = new LinkedList<View>();
}
cache.add(view);
return cache;
}
/**
* Adds view to cache. Determines view type (item view or empty one) by
* index.
*
* @param view
* the view to be cached
* @param index
* the index of view
*/
private void recycleView(View view, int index) {
int count = wheel.getViewAdapter().getItemsCount();
if ((index < 0 || index >= count) && !wheel.isCyclic()) {
// empty view
emptyItems = addView(view, emptyItems);
} else {
while (index < 0) {
index = count + index;
}
index %= count;
items = addView(view, items);
}
}
/**
* Gets view from specified cache.
*
* @param cache
* the cache
* @return the first view from cache.
*/
private View getCachedView(List<View> cache) {
if (cache != null && cache.size() > 0) {
View view = cache.get(0);
cache.remove(0);
return view;
}
return null;
}
}
package com.mayi.fastdevelop.view.wheel.views;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.animation.Interpolator;
import android.widget.Scroller;
/**
* Scroller class handles scrolling events and updates the
*/
public class WheelScroller {
/**
* Scrolling listener interface
*/
public interface ScrollingListener {
/**
* Scrolling callback called when scrolling is performed.
*
* @param distance the distance to scroll
*/
void onScroll(int distance);
/**
* Starting callback called when scrolling is started
*/
void onStarted();
/**
* Finishing callback called after justifying
*/
void onFinished();
/**
* Justifying callback called to justify a view when scrolling is ended
*/
void onJustify();
}
/**
* Scrolling duration
*/
private static final int SCROLLING_DURATION = 235;
/**
* Minimum delta for scrolling
*/
public static final int MIN_DELTA_FOR_SCROLLING = 1;
// Listener
private ScrollingListener listener;
// Context
private Context context;
// Scrolling
private GestureDetector gestureDetector;
private Scroller scroller;
private int lastScrollY;
private float lastTouchedY;
private boolean isScrollingPerformed;
/**
* Constructor
*
* @param context the current context
* @param listener the scrolling listener
*/
public WheelScroller(Context context, ScrollingListener listener) {
gestureDetector = new GestureDetector(context, gestureListener);
gestureDetector.setIsLongpressEnabled(false);
scroller = new Scroller(context);
this.listener = listener;
this.context = context;
}
/**
* Set the the specified scrolling interpolator
*
* @param interpolator the interpolator
*/
public void setInterpolator(Interpolator interpolator) {
scroller.forceFinished(true);
scroller = new Scroller(context, interpolator);
}
/**
* Scroll the wheel
*
* @param distance the scrolling distance
* @param time the scrolling duration
*/
public void scroll(int distance, int time) {
scroller.forceFinished(true);
lastScrollY = 0;
scroller.startScroll(0, 0, 0, distance, time != 0 ? time : SCROLLING_DURATION);
setNextMessage(MESSAGE_SCROLL);
startScrolling();
}
/**
* Stops scrolling
*/
public void stopScrolling() {
scroller.forceFinished(true);
}
/**
* Handles Touch event
*
* @param event the motion event
* @return
*/
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
lastTouchedY = event.getY();
scroller.forceFinished(true);
clearMessages();
break;
case MotionEvent.ACTION_MOVE:
// perform scrolling
int distanceY = (int) (event.getY() - lastTouchedY);
if (distanceY != 0) {
startScrolling();
listener.onScroll(distanceY);
lastTouchedY = event.getY();
}
break;
}
if (!gestureDetector.onTouchEvent(event) && event.getAction() == MotionEvent.ACTION_UP) {
justify();
}
return true;
}
// gesture listener
private SimpleOnGestureListener gestureListener = new SimpleOnGestureListener() {
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
// Do scrolling in onTouchEvent() since onScroll() are not call
// immediately
// when user touch and move the wheel
return true;
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
lastScrollY = 0;
final int maxY = 0x7FFFFFFF;
final int minY = -maxY;
scroller.fling(0, lastScrollY, 0, (int) -velocityY, 0, 0, minY, maxY);
setNextMessage(MESSAGE_SCROLL);
return true;
}
};
// Messages
private final int MESSAGE_SCROLL = 0;
private final int MESSAGE_JUSTIFY = 1;
/**
* Set next message to queue. Clears queue before.
*
* @param message the message to set
*/
private void setNextMessage(int message) {
clearMessages();
animationHandler.sendEmptyMessage(message);
}
/**
* Clears messages from queue
*/
private void clearMessages() {
animationHandler.removeMessages(MESSAGE_SCROLL);
animationHandler.removeMessages(MESSAGE_JUSTIFY);
}
// animation handler
private Handler animationHandler = new Handler() {
public void handleMessage(Message msg) {
scroller.computeScrollOffset();
int currY = scroller.getCurrY();
int delta = lastScrollY - currY;
lastScrollY = currY;
if (delta != 0) {
listener.onScroll(delta);
}
// scrolling is not finished when it comes to final Y
// so, finish it manually
if (Math.abs(currY - scroller.getFinalY()) < MIN_DELTA_FOR_SCROLLING) {
currY = scroller.getFinalY();
scroller.forceFinished(true);
}
if (!scroller.isFinished()) {
animationHandler.sendEmptyMessage(msg.what);
} else if (msg.what == MESSAGE_SCROLL) {
justify();
} else {
finishScrolling();
}
}
};
/**
* Justifies wheel
*/
private void justify() {
listener.onJustify();
setNextMessage(MESSAGE_JUSTIFY);
}
/**
* Starts scrolling
*/
private void startScrolling() {
if (!isScrollingPerformed) {
isScrollingPerformed = true;
listener.onStarted();
}
}
/**
* Finishes scrolling
*/
void finishScrolling() {
if (isScrollingPerformed) {
listener.onFinished();
isScrollingPerformed = false;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--从底部弹出-->
<translate
android:duration="400"
android:fromXDelta="0"
android:fromYDelta="100%p"
android:toXDelta="0"
android:toYDelta="0" />
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--往底部收回-->
<translate
android:duration="400"
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="0"
android:toYDelta="100%p"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--从左边弹出-->
<translate
android:duration="400"
android:fromXDelta="-100%p"
android:fromYDelta="0"
android:toXDelta="0"
android:interpolator="@android:anim/bounce_interpolator"
android:toYDelta="0"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--往左边收回-->
<translate
android:duration="400"
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="-100%p"
android:toYDelta="0"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="400"
android:fromXDelta="100%p"
android:fromYDelta="0"
android:interpolator="@android:anim/bounce_interpolator"
android:toXDelta="0"
android:toYDelta="0"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="400"
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="100%p"
android:toYDelta="0"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--缩放淡入-->
<scale
android:duration="235"
android:fromXScale="0.8"
android:fromYScale="0.8"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="1.0"
android:toYScale="1.0"/>
<alpha
android:duration="235"
android:fromAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="1.0"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--缩放淡出-->
<scale
android:duration="150"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.6"
android:toYScale="0.6"/>
<alpha
android:duration="150"
android:fromAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:toAlpha="0.0"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:fromYDelta="0"
android:interpolator="@android:anim/bounce_interpolator"
android:toXDelta="0"
android:toYDelta="-100%p"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="400"
android:fromXDelta="0"
android:fromYDelta="0"
android:toXDelta="0"
android:toYDelta="-100%p"/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/alpha_75_white">
<item
android:id="@android:id/mask"
android:drawable="@color/alpha_05_white"/>
</ripple>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/ripple">
<item android:drawable="@color/white"/>
</ripple>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/ripple">
<item
android:id="@android:id/mask"
android:drawable="@color/background_quanju"/>
</ripple>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充颜色 -->
<solid android:color="@color/white"/>
<!-- 矩形的圆角半径 -->
<corners android:radius="5dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/transparent" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"/>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:centerColor="#00ffffff"
android:endColor="#1A000000"
android:startColor="#1A000000"/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/bg_dialog_shape"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/im_dp_20"
android:gravity="center"
android:text="标题"
android:textColor="@color/color_333333"
android:textSize="@dimen/txt_size_36px" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_left"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/cancel"
android:textColor="@color/color_333333"
android:textSize="@dimen/txt_size_32px" />
<View
android:layout_width="@dimen/im_dp_0.5"
android:layout_height="match_parent"
android:background="@color/color_666666" />
<TextView
android:id="@+id/tv_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/sure"
android:textColor="@color/color_333333"
android:textSize="@dimen/txt_size_32px" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/im_dp_0.5"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/im_dp_50"
android:background="@color/color_666666" />
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/bg_dialog_shape"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:padding="@dimen/im_dp_10"
android:gravity="center"
android:text="内容"
android:textColor="@color/color_333333"
android:textSize="@dimen/txt_size_36px" />
<TextView
android:id="@+id/tv_ok"
android:layout_width="match_parent"
android:layout_height="@dimen/im_dp_50"
android:layout_below="@+id/tv_content"
android:gravity="center"
android:text="@string/sure"
android:textColor="@color/color_333333"
android:textSize="@dimen/txt_size_32px" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/im_dp_0.5"
android:layout_below="@+id/tv_content"
android:background="@color/color_666666" />
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ly_myinfo_changeaddress_child"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="@+id/tv_share_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/space_30px"
android:gravity="center_vertical"
android:text="选择地区"
android:textColor="@color/txt_grey"
android:textSize="18sp"/>
<TextView
android:id="@+id/btn_sure"
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="@string/sure"
android:textColor="@color/txt_notice_color_blue"
android:textSize="16sp"/>
<TextView
android:id="@+id/btn_cancel"
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_toLeftOf="@+id/btn_sure"
android:gravity="center"
android:text="@string/cancel"
android:textColor="@color/txt_grey"
android:textSize="16sp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="175dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_address_province"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"/>
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_address_city"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ly_myinfo_changeaddress_child"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="@+id/btn_sure"
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:gravity="center"
android:text="@string/sure"
android:textColor="@color/txt_notice_color_blue"
android:textSize="16sp" />
<TextView
android:id="@+id/btn_cancel"
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:gravity="center"
android:text="@string/cancel"
android:textColor="@color/txt_grey"
android:textSize="16sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="175dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_birth_year"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_20px"
android:text="年" />
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_birth_month"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_20px"
android:text="月" />
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_birth_day"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_20px"
android:text="日" />
</LinearLayout>
</LinearLayout>
<?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="35dip"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/tempValue"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#000000"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/title_bar_height"
android:background="@color/white">
<!--返回-->
<RelativeLayout
android:id="@+id/layout_left"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/llib_ripple_round_bg_quanju"
android:paddingLeft="10dp"
android:paddingRight="15dp">
<ImageView
android:id="@+id/iv_left"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_centerVertical="true"
android:src="@mipmap/icon_back" />
<TextView
android:id="@+id/tv_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="2dp"
android:layout_toRightOf="@id/iv_left"
android:text="@string/back"
android:textColor="#222222"
android:textSize="@dimen/txt_size_28px" />
</RelativeLayout>
<!--关闭按钮,针对webview,返回按钮是goback,部分需要直接关闭-->
<RelativeLayout
android:id="@+id/layout_close"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_toRightOf="@id/layout_left"
android:background="@drawable/llib_ripple_round_bg_quanju"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/close"
android:textColor="#666666"
android:textSize="14sp" />
</RelativeLayout>
<!--标题-->
<TextView
android:id="@+id/tv_center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="@drawable/llib_ripple_round_bg_quanju"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:maxWidth="150dp"
android:singleLine="true"
android:text="@string/app_name"
android:textColor="#222222"
android:textSize="18sp" />
<ImageView
android:id="@+id/iv_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/tv_center" />
<!--右边文字、图标-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true">
<TextView
android:id="@+id/tv_right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/llib_ripple_round_bg_quanju"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:singleLine="true"
android:text="@string/app_name"
android:textColor="#666666"
android:textSize="14sp"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/layout_right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/llib_ripple_round_bg_quanju"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:visibility="gone">
<View
android:id="@+id/v_right"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerInParent="true" />
</RelativeLayout>
</RelativeLayout>
<!--底部线条-->
<View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:layout_alignParentBottom="true"
android:background="@color/background_line" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<TextView
android:id="@+id/txt_think"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="@dimen/space_20px"
android:text="@string/cancel"
android:textSize="@dimen/txt_size_34px" />
<TextView
android:id="@+id/txt_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:padding="@dimen/space_20px"
android:textSize="@dimen/txt_size_34px" />
<!--完成-->
<TextView
android:id="@+id/txt_complete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="@dimen/space_20px"
android:text="完成"
android:textSize="@dimen/txt_size_34px" />
<View
android:id="@+id/view_line"
style="@style/line_h"
android:layout_below="@id/txt_think" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/view_line"
android:gravity="center_vertical"
android:minHeight="100dp"
android:orientation="horizontal">
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_year"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_30px"
android:text="年" />
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_month"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_30px"
android:text="月" />
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_day"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_30px"
android:text="日" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<!--再想想-->
<TextView
android:id="@+id/txt_think"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:padding="@dimen/space_20px"
android:text="@string/cancel"
android:textSize="@dimen/txt_size_34px" />
<TextView
android:id="@+id/txt_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:padding="@dimen/space_20px"
android:textSize="@dimen/txt_size_34px" />
<!--完成-->
<TextView
android:id="@+id/txt_complete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:padding="@dimen/space_20px"
android:text="完成"
android:textSize="@dimen/txt_size_34px" />
<View
android:id="@+id/view_line"
style="@style/line_h"
android:layout_below="@id/txt_think" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/view_line"
android:gravity="center_vertical"
android:minHeight="100dp"
android:orientation="horizontal">
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_year"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_6px"
android:text="年" />
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_month"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_6px"
android:text="月" />
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_day"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_6px"
android:text="日" />
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_hour"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_6px"
android:text="时" />
<com.mayi.fastdevelop.view.wheel.views.CustomWheelView
android:id="@+id/wv_minute"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_6px"
android:text="分" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="gray">#D1D1D1</color>
<color name="black">#000</color>
<color name="title_blue">#6B7195</color>
<color name="text_color_blue">#bf9d4c</color>
<color name="green">#2bd34f</color>
<color name="title_bar_bg">#222222</color>
<color name="colorPrimary">#ff9100</color>
<color name="colorPrimaryDark">#ff9100</color>
<color name="colorAccent">#ff9100</color>
<color name="colorTheme">#ff9100</color>
<color name="white">#fff</color>
<!--透明色-->
<color name="transparent">#00000000</color>
<!--半透明-->
<color name="transparentHalf">#11000000</color>
<!--全局背景-->
<color name="background_quanju">#f4f4f4</color>
<!--内容区域底色-->
<color name="background_layout_grey">#f5f5f5</color>
<!--边框灰色-->
<color name="border_grey">#e8e8e8</color>
<!--分割线颜色-->
<color name="background_line">#e9e9e9</color>
<color name="progress">#ffb80d</color>
<!--灰色字体-->
<color name="txt_grey">#9d9d9d</color>
<!--输入提示文本颜色-->
<color name="txt_color_hint">#c8c8c8</color>
<!--重要级文字信息-->
<color name="txt_black">#333333</color>
<!--不可操作提示性文字颜色-->
<color name="txt_notice_color_yellow">#f7a735</color>
<!--可操作提示性文字蓝色-->
<color name="txt_notice_color_blue">#2f9efc</color>
<!--字体亮红 特别强调和突出的字体-->
<color name="txt_red_dark">#F00000</color>
<!--字体亮灰-->
<color name="txt_grey_light">#ffcccccc</color>
<!--按钮效果-->
<color name="ripple">#F3E5E5E5</color>
<!--按钮不可用背景颜色-->
<color name="background_enable_false">#F1F1F1</color>
<color name="tlib_psts_background_tab_pressed">#1AFFFFFF</color>
<color name="alpha_05_white">#0DFFFFFF</color>
<color name="alpha_10_white">#1AFFFFFF</color>
<color name="alpha_15_white">#26FFFFFF</color>
<color name="alpha_20_white">#33FFFFFF</color>
<color name="alpha_25_white">#40FFFFFF</color>
<color name="alpha_30_white">#4DFFFFFF</color>
<color name="alpha_35_white">#59FFFFFF</color>
<color name="alpha_40_white">#66FFFFFF</color>
<color name="alpha_45_white">#73FFFFFF</color>
<color name="alpha_50_white">#80FFFFFF</color>
<color name="alpha_55_white">#8CFFFFFF</color>
<color name="alpha_60_white">#99FFFFFF</color>
<color name="alpha_65_white">#A6FFFFFF</color>
<color name="alpha_70_white">#B3FFFFFF</color>
<color name="alpha_75_white">#BFFFFFFF</color>
<color name="alpha_80_white">#CCFFFFFF</color>
<color name="alpha_85_white">#D9FFFFFF</color>
<color name="alpha_90_white">#E6FFFFFF</color>
<color name="alpha_95_white">#F2FFFFFF</color>
<color name="alpha_05_black">#0D000000</color>
<color name="alpha_10_black">#1A000000</color>
<color name="alpha_15_black">#26000000</color>
<color name="alpha_20_black">#33000000</color>
<color name="alpha_25_black">#40000000</color>
<color name="alpha_30_black">#4D000000</color>
<color name="alpha_35_black">#59000000</color>
<color name="alpha_40_black">#66000000</color>
<color name="alpha_45_black">#73000000</color>
<color name="alpha_50_black">#80000000</color>
<color name="alpha_55_black">#8C000000</color>
<color name="alpha_60_black">#99000000</color>
<color name="alpha_65_black">#A6000000</color>
<color name="alpha_70_black">#B3000000</color>
<color name="alpha_75_black">#BF000000</color>
<color name="alpha_80_black">#CC000000</color>
<color name="alpha_85_black">#D9000000</color>
<color name="alpha_90_black">#E6000000</color>
<color name="alpha_95_black">#F2000000</color>
<color name="color_333333">#333333</color>
<color name="color_666666">#666666</color>
<color name="color_999999">#999999</color>
</resources>
<resources>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="normal_size">14sp</dimen>
<dimen name="default_size">12sp</dimen>
<dimen name="title_height">0dp</dimen>
<!--默认圆角半径-->
<dimen name="shape_radius_default">4dp</dimen>
<!--距离 1dp-->
<dimen name="space_2px">1dp</dimen>
<!--距离 mini-->
<dimen name="space_6px">3dp</dimen>
<!--距离 小-->
<dimen name="space_10px">5dp</dimen>
<!--距离 默认-->
<dimen name="space_20px">10dp</dimen>
<!--距离 大-->
<dimen name="space_30px">15dp</dimen>
<!--距离 加大-->
<dimen name="space_40px">20dp</dimen>
<!--titlebar height-->
<dimen name="title_bar_height">50dp</dimen>
<dimen name="line_height">0.5dp</dimen>
<!--字体大小-->
<dimen name="txt_size_130px">65sp</dimen>
<dimen name="txt_size_80px">40sp</dimen>
<dimen name="txt_size_70px">35sp</dimen>
<dimen name="txt_size_60px">30sp</dimen>
<dimen name="txt_size_40px">20sp</dimen>
<dimen name="txt_size_36px">18sp</dimen>
<dimen name="txt_size_34px">17sp</dimen>
<dimen name="txt_size_32px">16sp</dimen>
<dimen name="txt_size_30px">15sp</dimen>
<dimen name="txt_size_28px">14sp</dimen>
<dimen name="txt_size_26px">13sp</dimen>
<dimen name="txt_size_24px">12sp</dimen>
<dimen name="txt_size_22px">11sp</dimen>
<dimen name="txt_size_18px">9sp</dimen>
<dimen name="txt_size_16px">8sp</dimen>
<dimen name="im_dp_0.5">0.5dp</dimen>
<dimen name="im_dp_1">1dp</dimen>
<dimen name="im_dp_2">2dp</dimen>
<dimen name="im_dp_3">3dp</dimen>
<dimen name="im_dp_4">4dp</dimen>
<dimen name="im_dp_5">5dp</dimen>
<dimen name="im_dp_6">6dp</dimen>
<dimen name="im_dp_7">7dp</dimen>
<dimen name="im_dp_8">8dp</dimen>
<dimen name="im_dp_9">9dp</dimen>
<dimen name="im_dp_10">10dp</dimen>
<dimen name="im_dp_11">11dp</dimen>
<dimen name="im_dp_12">12dp</dimen>
<dimen name="im_dp_13">13dp</dimen>
<dimen name="im_dp_14">14dp</dimen>
<dimen name="im_dp_15">15dp</dimen>
<dimen name="im_dp_16">16dp</dimen>
<dimen name="im_dp_20">20dp</dimen>
<dimen name="im_dp_25">25dp</dimen>
<dimen name="im_dp_30">30dp</dimen>
<dimen name="im_dp_33">33dp</dimen>
<dimen name="im_dp_36">36dp</dimen>
<dimen name="im_dp_40">40dp</dimen>
<dimen name="im_dp_48">48dp</dimen>
<dimen name="im_dp_50">50dp</dimen>
<dimen name="im_dp_54">54dp</dimen>
<dimen name="im_dp_60">60dp</dimen>
<dimen name="im_dp_72">72dp</dimen>
<dimen name="im_dp_80">80dp</dimen>
<dimen name="im_dp_96">96dp</dimen>
<dimen name="im_dp_120">120dp</dimen>
<dimen name="im_dp_150">150dp</dimen>
<dimen name="im_dp_200">200dp</dimen>
<dimen name="im_dp_250">250dp</dimen>
</resources>
......@@ -3,4 +3,9 @@
<string name="save_img_failed_2">图片地址异常,保存图片失败!</string>
<string name="save_img_success">保存图片成功!</string>
<string name="save_img_failed">保存图片失败!</string>
<string name="close">关闭</string>
<string name="sure">确定</string>
<string name="cancel">取消</string>
<string name="back">返回</string>
</resources>
......@@ -11,4 +11,61 @@
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
<!-- ################### dialog ################### -->
<style name="dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<!-- 是否浮现在activity之上 -->
<item name="android:windowIsFloating">true</item>
<!-- 边框 -->
<item name="android:windowIsTranslucent">false</item>
<!-- 无标题 -->
<item name="android:windowNoTitle">true</item>
<!-- 背景透明 -->
<item name="android:windowBackground">@android:color/transparent</item>
<!-- 模糊 -->
<item name="android:backgroundDimEnabled">true</item>
</style>
<style name="window_bottom_in_bottom_out">
<item name="android:windowEnterAnimation">@anim/dialog_bottom_in</item>
<item name="android:windowExitAnimation">@anim/dialog_bottom_out</item>
</style>
<style name="window_left_in_left_out">
<item name="android:windowEnterAnimation">@anim/dialog_left_in</item>
<item name="android:windowExitAnimation">@anim/dialog_left_out</item>
</style>
<style name="window_left_in_right_out">
<item name="android:windowEnterAnimation">@anim/dialog_left_in</item>
<item name="android:windowExitAnimation">@anim/dialog_right_out</item>
</style>
<style name="window_right_in_right_out">
<item name="android:windowEnterAnimation">@anim/dialog_right_in</item>
<item name="android:windowExitAnimation">@anim/dialog_right_out</item>
</style>
<style name="window_right_in_left_out">
<item name="android:windowEnterAnimation">@anim/dialog_right_in</item>
<item name="android:windowExitAnimation">@anim/dialog_left_out</item>
</style>
<style name="dialog_scale_animstyle">
<item name="android:windowEnterAnimation">@anim/dialog_scale_in</item>
<item name="android:windowExitAnimation">@anim/dialog_scale_out</item>
</style>
<style name="window_top_in_top_out">
<item name="android:windowEnterAnimation">@anim/dialog_top_in</item>
<item name="android:windowExitAnimation">@anim/dialog_top_out</item>
</style>
<!--水平分隔线-->
<style name="line_h">
<item name="android:background">@color/background_line</item>
<item name="android:layout_height">@dimen/line_height</item>
<item name="android:layout_width">match_parent</item>
</style>
</resources>
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