Commit cd442f97 by 郑鹏

init

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

*.iml
.gradle
/local.properties
.DS_Store
/build
/captures
.externalNativeBuild
/.idea/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DkAndroidTemplates</name>
<comment>Project DkAndroidTemplates created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
connection.project.dir=
eclipse.preferences.version=1
apply plugin: 'com.android.library'
//apply plugin: 'com.github.dcendents.android-maven'
//apply plugin: 'com.jfrog.bintray'
// 这个version是区分library版本的,因此当我们需要更新library时记得修改这个version
version = "2.1.2"
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 212
versionName version
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:27.1.1'
}
//def siteUrl = 'https://github.com/H07000223' // 项目的主页
//def gitUrl = 'https://github.com/H07000223' // Git仓库的url
//group = "com.flyco.tablayout" // Maven Group ID for the artifact,一般填你唯一的包名
//install {
// repositories.mavenInstaller {
// // This generates POM.xml with proper parameters
// pom {
// project {
// packaging 'aar'
// // Add your description here
// name 'Android TabLayout Library' //项目描述
// url siteUrl
// // Set your license
// licenses {
// license {
// name 'MIT'
// url 'http://opensource.org/licenses/MIT'
// }
// }
// developers {
// developer {
// id 'H07000223' //填写的一些基本信息
// name 'H07000223'
// email '867318349@qq.com'
// }
// }
// scm {
// connection gitUrl
// developerConnection gitUrl
// url siteUrl
// }
// }
// }
// }
//}
//
//task sourcesJar(type: Jar) {
// from android.sourceSets.main.java.srcDirs
// classifier = 'sources'
//}
//
//artifacts {
// archives sourcesJar
//}
//
//android.libraryVariants.all { variant ->
// println variant.javaCompile.classpath.files
// if (variant.name == 'release') { //我们只需 release 的 javadoc
// task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
// // title = ''
// // description = ''
// source = variant.javaCompile.source
// classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath())
// options {
// encoding "utf-8"
// links "http://docs.oracle.com/javase/7/docs/api/"
// linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
// }
// exclude '**/BuildConfig.java'
// exclude '**/R.java'
// }
// task("javadoc${variant.name.capitalize()}Jar", type: Jar, dependsOn: "generate${variant.name.capitalize()}Javadoc") {
// classifier = 'javadoc'
// from tasks.getByName("generate${variant.name.capitalize()}Javadoc").destinationDir
// }
// artifacts {
// archives tasks.getByName("javadoc${variant.name.capitalize()}Jar")
// }
// }
//}
//
//Properties properties = new Properties()
//properties.load(project.rootProject.file('local.properties').newDataInputStream())
//bintray {
// user = properties.getProperty("bintray.user")
// key = properties.getProperty("bintray.apikey")
// configurations = ['archives']
// pkg {
// repo = "maven"
// name = "FlycoTabLayout_Lib" //发布到JCenter上的项目名字
// websiteUrl = siteUrl
// vcsUrl = gitUrl
// licenses = ["MIT"]
// publish = true
// }
//}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/lihui/work/AndroidStudio/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
<manifest
package="com.flyco.tablayout">
</manifest>
package com.flyco.tablayout.listener;
import android.support.annotation.DrawableRes;
public interface CustomTabEntity {
String getTabTitle();
@DrawableRes
int getTabSelectedIcon();
@DrawableRes
int getTabUnselectedIcon();
}
\ No newline at end of file
package com.flyco.tablayout.listener;
public interface OnTabSelectListener {
void onTabSelect(int position);
void onTabReselect(int position);
}
\ No newline at end of file
package com.flyco.tablayout.utils;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import java.util.ArrayList;
public class FragmentChangeManager {
private FragmentManager mFragmentManager;
private int mContainerViewId;
/** Fragment切换数组 */
private ArrayList<Fragment> mFragments;
/** 当前选中的Tab */
private int mCurrentTab;
public FragmentChangeManager(FragmentManager fm, int containerViewId, ArrayList<Fragment> fragments) {
this.mFragmentManager = fm;
this.mContainerViewId = containerViewId;
this.mFragments = fragments;
initFragments();
}
/** 初始化fragments */
private void initFragments() {
for (Fragment fragment : mFragments) {
mFragmentManager.beginTransaction().add(mContainerViewId, fragment).hide(fragment).commit();
}
setFragments(0);
}
/** 界面切换控制 */
public void setFragments(int index) {
for (int i = 0; i < mFragments.size(); i++) {
FragmentTransaction ft = mFragmentManager.beginTransaction();
Fragment fragment = mFragments.get(i);
if (i == index) {
ft.show(fragment);
} else {
ft.hide(fragment);
}
ft.commit();
}
mCurrentTab = index;
}
public int getCurrentTab() {
return mCurrentTab;
}
public Fragment getCurrentFragment() {
return mFragments.get(mCurrentTab);
}
}
\ No newline at end of file
package com.flyco.tablayout.utils;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.RelativeLayout;
import com.flyco.tablayout.widget.MsgView;
/**
* 未读消息提示View,显示小红点或者带有数字的红点:
* 数字一位,圆
* 数字两位,圆角矩形,圆角是高度的一半
* 数字超过两位,显示99+
*/
public class UnreadMsgUtils {
public static void show(MsgView msgView, int num) {
if (msgView == null) {
return;
}
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) msgView.getLayoutParams();
DisplayMetrics dm = msgView.getResources().getDisplayMetrics();
msgView.setVisibility(View.VISIBLE);
if (num <= 0) {//圆点,设置默认宽高
msgView.setStrokeWidth(0);
msgView.setText("");
lp.width = (int) (5 * dm.density);
lp.height = (int) (5 * dm.density);
msgView.setLayoutParams(lp);
} else {
lp.height = (int) (18 * dm.density);
if (num > 0 && num < 10) {//圆
lp.width = (int) (18 * dm.density);
msgView.setText(num + "");
} else if (num > 9 && num < 100) {//圆角矩形,圆角是高度的一半,设置默认padding
lp.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
msgView.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
msgView.setText(num + "");
} else {//数字超过两位,显示99+
lp.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
msgView.setPadding((int) (6 * dm.density), 0, (int) (6 * dm.density), 0);
msgView.setText("99+");
}
msgView.setLayoutParams(lp);
}
}
public static void setSize(MsgView rtv, int size) {
if (rtv == null) {
return;
}
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) rtv.getLayoutParams();
lp.width = size;
lp.height = size;
rtv.setLayoutParams(lp);
}
}
package com.flyco.tablayout.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.StateListDrawable;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.TextView;
import com.flyco.tablayout.R;
/** 用于需要圆角矩形框背景的TextView的情况,减少直接使用TextView时引入的shape资源文件 */
public class MsgView extends TextView {
private Context context;
private GradientDrawable gd_background = new GradientDrawable();
private int backgroundColor;
private int cornerRadius;
private int strokeWidth;
private int strokeColor;
private boolean isRadiusHalfHeight;
private boolean isWidthHeightEqual;
public MsgView(Context context) {
this(context, null);
}
public MsgView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public MsgView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
obtainAttributes(context, attrs);
}
private void obtainAttributes(Context context, AttributeSet attrs) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MsgView);
backgroundColor = ta.getColor(R.styleable.MsgView_mv_backgroundColor, Color.TRANSPARENT);
cornerRadius = ta.getDimensionPixelSize(R.styleable.MsgView_mv_cornerRadius, 0);
strokeWidth = ta.getDimensionPixelSize(R.styleable.MsgView_mv_strokeWidth, 0);
strokeColor = ta.getColor(R.styleable.MsgView_mv_strokeColor, Color.TRANSPARENT);
isRadiusHalfHeight = ta.getBoolean(R.styleable.MsgView_mv_isRadiusHalfHeight, false);
isWidthHeightEqual = ta.getBoolean(R.styleable.MsgView_mv_isWidthHeightEqual, false);
ta.recycle();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (isWidthHeightEqual() && getWidth() > 0 && getHeight() > 0) {
int max = Math.max(getWidth(), getHeight());
int measureSpec = MeasureSpec.makeMeasureSpec(max, MeasureSpec.EXACTLY);
super.onMeasure(measureSpec, measureSpec);
return;
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (isRadiusHalfHeight()) {
setCornerRadius(getHeight() / 2);
} else {
setBgSelector();
}
}
public void setBackgroundColor(int backgroundColor) {
this.backgroundColor = backgroundColor;
setBgSelector();
}
public void setCornerRadius(int cornerRadius) {
this.cornerRadius = dp2px(cornerRadius);
setBgSelector();
}
public void setStrokeWidth(int strokeWidth) {
this.strokeWidth = dp2px(strokeWidth);
setBgSelector();
}
public void setStrokeColor(int strokeColor) {
this.strokeColor = strokeColor;
setBgSelector();
}
public void setIsRadiusHalfHeight(boolean isRadiusHalfHeight) {
this.isRadiusHalfHeight = isRadiusHalfHeight;
setBgSelector();
}
public void setIsWidthHeightEqual(boolean isWidthHeightEqual) {
this.isWidthHeightEqual = isWidthHeightEqual;
setBgSelector();
}
public int getBackgroundColor() {
return backgroundColor;
}
public int getCornerRadius() {
return cornerRadius;
}
public int getStrokeWidth() {
return strokeWidth;
}
public int getStrokeColor() {
return strokeColor;
}
public boolean isRadiusHalfHeight() {
return isRadiusHalfHeight;
}
public boolean isWidthHeightEqual() {
return isWidthHeightEqual;
}
protected int dp2px(float dp) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dp * scale + 0.5f);
}
protected int sp2px(float sp) {
final float scale = this.context.getResources().getDisplayMetrics().scaledDensity;
return (int) (sp * scale + 0.5f);
}
private void setDrawable(GradientDrawable gd, int color, int strokeColor) {
gd.setColor(color);
gd.setCornerRadius(cornerRadius);
gd.setStroke(strokeWidth, strokeColor);
}
public void setBgSelector() {
StateListDrawable bg = new StateListDrawable();
setDrawable(gd_background, backgroundColor, strokeColor);
bg.addState(new int[]{-android.R.attr.state_pressed}, gd_background);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {//16
setBackground(bg);
} else {
//noinspection deprecation
setBackgroundDrawable(bg);
}
}
}
<?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:clipChildren="false"
android:clipToPadding="false">
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:singleLine="true"/>
<com.flyco.tablayout.widget.MsgView
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</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:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
<ImageView
android:id="@+id/iv_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<com.flyco.tablayout.widget.MsgView
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ll_tap"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</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:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
</LinearLayout>
<com.flyco.tablayout.widget.MsgView
android:layout_toRightOf="@+id/ll_tap"
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</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:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
<ImageView
android:id="@+id/iv_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<com.flyco.tablayout.widget.MsgView
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ll_tap"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</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:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
</LinearLayout>
<com.flyco.tablayout.widget.MsgView
android:layout_toRightOf="@+id/ll_tap"
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</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:clipChildren="false"
android:clipToPadding="false">
<LinearLayout
android:id="@+id/ll_tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_tab_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/tv_tab_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"/>
</LinearLayout>
<com.flyco.tablayout.widget.MsgView
android:id="@+id/rtv_msg_tip"
xmlns:mv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ll_tap"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="11.5sp"
android:visibility="gone"
mv:mv_backgroundColor="#FD481F"
mv:mv_isRadiusHalfHeight="true"
mv:mv_strokeColor="#ffffff"
mv:mv_strokeWidth="1dp"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- indicator -->
<!-- 设置显示器颜色 -->
<attr name="tl_indicator_color" format="color"/>
<!-- 设置显示器高度 -->
<attr name="tl_indicator_height" format="dimension"/>
<!-- 设置显示器固定宽度 -->
<attr name="tl_indicator_width" format="dimension"/>
<!-- 设置显示器margin,当indicator_width大于0,无效 -->
<attr name="tl_indicator_margin_left" format="dimension"/>
<attr name="tl_indicator_margin_top" format="dimension"/>
<attr name="tl_indicator_margin_right" format="dimension"/>
<attr name="tl_indicator_margin_bottom" format="dimension"/>
<!-- 设置显示器圆角弧度-->
<attr name="tl_indicator_corner_radius" format="dimension"/>
<!-- 设置显示器上方还是下方,只对圆角矩形有用-->
<attr name="tl_indicator_gravity" format="enum">
<enum name="TOP" value="48"/>
<enum name="BOTTOM" value="80"/>
</attr>
<!-- 设置显示器为常规|三角形|背景色块|-->
<attr name="tl_indicator_style" format="enum">
<enum name="NORMAL" value="0"/>
<enum name="TRIANGLE" value="1"/>
<enum name="BLOCK" value="2"/>
</attr>
<!-- 设置显示器长度与title一样长,只有在STYLE_NORMAL并且indicatorWidth小于零有效-->
<attr name="tl_indicator_width_equal_title" format="boolean"/>
<!-- 设置显示器支持动画-->
<attr name="tl_indicator_anim_enable" format="boolean"/>
<!-- 设置显示器动画时间-->
<attr name="tl_indicator_anim_duration" format="integer"/>
<!-- 设置显示器支持动画回弹效果-->
<attr name="tl_indicator_bounce_enable" format="boolean"/>
<!-- underline -->
<!-- 设置下划线颜色 -->
<attr name="tl_underline_color" format="color"/>
<!-- 设置下划线高度 -->
<attr name="tl_underline_height" format="dimension"/>
<!-- 设置下划线上方还是下方-->
<attr name="tl_underline_gravity" format="enum">
<enum name="TOP" value="48"/>
<enum name="BOTTOM" value="80"/>
</attr>
<!-- divider -->
<!-- 设置分割线颜色 -->
<attr name="tl_divider_color" format="color"/>
<!-- 设置分割线宽度 -->
<attr name="tl_divider_width" format="dimension"/>
<!-- 设置分割线的paddingTop和paddingBottom -->
<attr name="tl_divider_padding" format="dimension"/>
<!-- tab -->
<!-- 设置tab的paddingLeft和paddingRight -->
<attr name="tl_tab_padding" format="dimension"/>
<!-- 设置tab大小等分 -->
<attr name="tl_tab_space_equal" format="boolean"/>
<!-- 设置tab固定大小 -->
<attr name="tl_tab_width" format="dimension"/>
<!-- title -->
<!-- 设置字体大小 -->
<attr name="tl_textsize" format="dimension"/>
<!-- 设置字体选中颜色 -->
<attr name="tl_textSelectColor" format="color"/>
<!-- 设置字体未选中颜色 -->
<attr name="tl_textUnselectColor" format="color"/>
<!-- 设置字体加粗 -->
<attr name="tl_textBold" format="enum">
<enum name="NONE" value="0"/>
<enum name="SELECT" value="1"/>
<enum name="BOTH" value="2"/>
</attr>
<!-- 设置字体全大写 -->
<attr name="tl_textAllCaps" format="boolean"/>
<declare-styleable name="SlidingTabLayout">
<!-- indicator -->
<attr name="tl_indicator_color"/>
<attr name="tl_indicator_height"/>
<attr name="tl_indicator_width"/>
<attr name="tl_indicator_margin_left"/>
<attr name="tl_indicator_margin_top"/>
<attr name="tl_indicator_margin_right"/>
<attr name="tl_indicator_margin_bottom"/>
<attr name="tl_indicator_corner_radius"/>
<attr name="tl_indicator_gravity"/>
<attr name="tl_indicator_style"/>
<attr name="tl_indicator_width_equal_title"/>
<!-- underline -->
<attr name="tl_underline_color"/>
<attr name="tl_underline_height"/>
<attr name="tl_underline_gravity"/>
<!-- divider -->
<attr name="tl_divider_color"/>
<attr name="tl_divider_width"/>
<attr name="tl_divider_padding"/>
<!-- tab -->
<attr name="tl_tab_padding"/>
<attr name="tl_tab_space_equal"/>
<attr name="tl_tab_width"/>
<!-- title -->
<attr name="tl_textsize"/>
<attr name="tl_textSelectColor"/>
<attr name="tl_textUnselectColor"/>
<attr name="tl_textBold"/>
<attr name="tl_textAllCaps"/>
</declare-styleable>
<declare-styleable name="CommonTabLayout">
<!-- indicator -->
<attr name="tl_indicator_color"/>
<attr name="tl_indicator_height"/>
<attr name="tl_indicator_width"/>
<attr name="tl_indicator_margin_left"/>
<attr name="tl_indicator_margin_top"/>
<attr name="tl_indicator_margin_right"/>
<attr name="tl_indicator_margin_bottom"/>
<attr name="tl_indicator_corner_radius"/>
<attr name="tl_indicator_gravity"/>
<attr name="tl_indicator_style"/>
<attr name="tl_indicator_anim_enable"/>
<attr name="tl_indicator_anim_duration"/>
<attr name="tl_indicator_bounce_enable"/>
<!-- underline -->
<attr name="tl_underline_color"/>
<attr name="tl_underline_height"/>
<attr name="tl_underline_gravity"/>
<!-- divider -->
<attr name="tl_divider_color"/>
<attr name="tl_divider_width"/>
<attr name="tl_divider_padding"/>
<!-- tab -->
<attr name="tl_tab_padding"/>
<attr name="tl_tab_space_equal"/>
<attr name="tl_tab_width"/>
<!-- title -->
<attr name="tl_textsize"/>
<attr name="tl_textSelectColor"/>
<attr name="tl_textUnselectColor"/>
<attr name="tl_textBold"/>
<attr name="tl_textAllCaps"/>
<!-- icon -->
<!-- 设置icon宽度 -->
<attr name="tl_iconWidth" format="dimension"/>
<!-- 设置icon高度 -->
<attr name="tl_iconHeight" format="dimension"/>
<!-- 设置icon是否可见 -->
<attr name="tl_iconVisible" format="boolean"/>
<!-- 设置icon显示位置,对应Gravity中常量值 -->
<attr name="tl_iconGravity" format="enum">
<enum name="LEFT" value="3"/>
<enum name="TOP" value="48"/>
<enum name="RIGHT" value="5"/>
<enum name="BOTTOM" value="80"/>
</attr>
<!-- 设置icon与文字间距 -->
<attr name="tl_iconMargin" format="dimension"/>
</declare-styleable>
<declare-styleable name="SegmentTabLayout">
<!-- indicator -->
<attr name="tl_indicator_color"/>
<attr name="tl_indicator_height"/>
<attr name="tl_indicator_margin_left"/>
<attr name="tl_indicator_margin_top"/>
<attr name="tl_indicator_margin_right"/>
<attr name="tl_indicator_margin_bottom"/>
<attr name="tl_indicator_corner_radius"/>
<attr name="tl_indicator_anim_enable"/>
<attr name="tl_indicator_anim_duration"/>
<attr name="tl_indicator_bounce_enable"/>
<!-- divider -->
<attr name="tl_divider_color"/>
<attr name="tl_divider_width"/>
<attr name="tl_divider_padding"/>
<!-- tab -->
<attr name="tl_tab_padding"/>
<attr name="tl_tab_space_equal"/>
<attr name="tl_tab_width"/>
<!-- title -->
<attr name="tl_textsize"/>
<attr name="tl_textSelectColor"/>
<attr name="tl_textUnselectColor"/>
<attr name="tl_textBold"/>
<attr name="tl_textAllCaps"/>
<attr name="tl_bar_color" format="color"/>
<attr name="tl_bar_stroke_color" format="color"/>
<attr name="tl_bar_stroke_width" format="dimension"/>
</declare-styleable>
<declare-styleable name="MsgView">
<!-- 圆角矩形背景色 -->
<attr name="mv_backgroundColor" format="color"/>
<!-- 圆角弧度,单位dp-->
<attr name="mv_cornerRadius" format="dimension"/>
<!-- 圆角弧度,单位dp-->
<attr name="mv_strokeWidth" format="dimension"/>
<!-- 圆角边框颜色-->
<attr name="mv_strokeColor" format="color"/>
<!-- 圆角弧度是高度一半-->
<attr name="mv_isRadiusHalfHeight" format="boolean"/>
<!-- 圆角矩形宽高相等,取较宽高中大值-->
<attr name="mv_isWidthHeightEqual" format="boolean"/>
</declare-styleable>
</resources>
\ No newline at end of file
# Android 韩国点餐
## 一. 项目目录结构
```yaml
android-koreadc-client:
baselib: 基础库一些通用工具自定义View等
app: 核心库,主要功能的实现
module-user: 登录注册等
refresh-layout: 下拉刷新库
ucrop: 图片裁剪库
picture_library: 图片选择处理
zxing_library: 二维码扫码处理
```
## 二. 项目框架
- RxJava + Retrofit:网络请求
- EventBus :传递数据
- Glide :图片加载框架
- rxAndroid
- rxPermissions
## 三. 使用第三方接口
- 腾讯云 :文件存储
- 谷歌推送Firebase : 消息推送
- 谷歌地图 : 地图定位服务
- bugly+腾讯移动应用分析 :统计应用数据
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
kapt {
arguments {
arg("moduleName", project.getName())
}
}
android {
compileSdkVersion build_versions.compile_sdk
defaultConfig {
multiDexEnabled true
applicationId "com.mhq.smartorder"
minSdkVersion build_versions.min_sdk
targetSdkVersion build_versions.target_sdk
versionCode 1
versionName "1.0.0"
//路由
javaCompileOptions.annotationProcessorOptions {
arguments = [moduleName: project.getName()]
}
ndk {
abiFilters "armeabi-v7a", "armeabi", "x86"
}
manifestPlaceholders = [
MTA_APPKEY:"AIAF8SC17A3L",
MTA_CHANNEL:"GooglePay"
//极光推送
/* JPUSH_PKGNAME: applicationId,
JPUSH_APPKEY : "xx", //JPush上注册的包名对应的appkey.
JPUSH_CHANNEL: "xx-default", //暂时填写默认值即可.*/
]
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
/* adbOptions {
timeOutInMs=5*1000
installOptions '-r','-s'
}
*/
signingConfigs {
def appStoreFilePath = System.getProperty('StoreFilePath')
def appStorePassword = System.getProperty('StorePassword')
def appKeyAlias = System.getProperty('KeyAlias')
def appKeyPassword = System.getProperty('KeyPassword')
/* Properties properties = new Properties()
if (rootProject.file("local.properties").exists()) {
properties.load(rootProject.file("local.properties").newDataInputStream())
storeFilePath= properties.get("STOREFILE")
storePassword= properties.get("STOREPASSWORD")
keyAlias= properties.get("KEYALIAS")
keyPassword= properties.get("KEYPASSWORD")
}*/
if (!appStoreFilePath || !appStorePassword || !appKeyAlias || !appKeyPassword) {
//将.android下的debug.keystore放到app目录下
appStoreFilePath = "dankal.jks"
appStorePassword = "123456"
appKeyAlias = "dankal"
appKeyPassword = "123456"
}
jenkins {
storeFile file(appStoreFilePath)
storePassword appStorePassword
keyAlias appKeyAlias
keyPassword appKeyPassword
v1SigningEnabled true
v2SigningEnabled true
}
}
buildTypes {
debug {
// buildConfigField 'String','NAME','value'
zipAlignEnabled true
minifyEnabled false
// shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.jenkins
}
release {
// buildConfigField 'String','NAME','value'
zipAlignEnabled true
minifyEnabled false
// shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.jenkins
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//DomainObjectCollection集合
applicationVariants.all { variant ->
variant.outputs.each { output ->
if (output.outputFile != null && output.outputFile.name.endsWith('.apk')
&& 'release'.equals(variant.buildType.name)) {
def flavorName = variant.flavorName.startsWith("_") ?
variant.flavorName.substring(1) : variant.flavorName
def apkFile = new File(output.outputFile.getParent(),
//渠道,版本,构建时间
"Haha_${flavorName}_v${variant.versionName}_${buildTime()}.apk")
// output.outputFile=apkFile
}
}
}
}
def buildTime() {
def date = new Date();
def formattedDate = date.format("yyyyMMdd");
return formattedDate
}
def getAppVersionName() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--abbrev=0', '--tags'
standardOutput = stdout
}
return stout.toString()
}
def getAppVersionCode() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'tag', '--list'
standardOutput = stdout
}
return stout.toString().split("\n").size()
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// api deps.support.multidex
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.android.support:appcompat-v7:23.4.0'
annotationProcessor deps.glide.compiler
annotationProcessor deps.butterknife.butterknife_compiler
annotationProcessor deps.alibaba.arouter_compiler
kapt deps.glide.compiler
kapt deps.butterknife.butterknife_compiler
kapt deps.alibaba.arouter_compiler
api project(':module-user')
api project(':baselib')
//kapt deps.alibaba.arouter_compiler
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation project(path: ':zxinglibrary')
implementation project(':picture_library')
implementation project(':FlycoTabLayout_Lib')
}
apply plugin: 'com.google.gms.google-services'
File added
{
"project_info": {
"project_number": "636998814874",
"firebase_url": "https://smartorder-7e6e7.firebaseio.com",
"project_id": "smartorder-7e6e7",
"storage_bucket": "smartorder-7e6e7.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:636998814874:android:f8d6327180b9267d",
"android_client_info": {
"package_name": "com.mhq.smartorder"
}
},
"oauth_client": [
{
"client_id": "636998814874-i8lu56hg21pee1qvvnqrikj37pdprqp2.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDwJv9yhHjoVEczxUngI33HgYtyi5ZtrXA"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "636998814874-i8lu56hg21pee1qvvnqrikj37pdprqp2.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
\ No newline at end of file
package cn.dankal.dankalktsample
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("cn.dankal.dankalktsample", appContext.packageName)
}
}
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=50:E6:E4:3A:D5:D7:C6:9B:BC:1E:28:F7:89:0B:9F:D7:3D:F5:97:D8%3Bcn.dankal.templates.ui.home.map
You can also add your credentials to an existing key, using these values:
Package name:
50:E6:E4:3A:D5:D7:C6:9B:BC:1E:28:F7:89:0B:9F:D7:3D:F5:97:D8
SHA-1 certificate fingerprint:
50:E6:E4:3A:D5:D7:C6:9B:BC:1E:28:F7:89:0B:9F:D7:3D:F5:97:D8
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIzaSyDwJv9yhHjoVEczxUngI33HgYtyi5ZtrXA</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<litepal>
<dbname value="shop.db"></dbname>
<version value="2"></version>
<lits>
<mapping class="cn.dankal.entities.home.HistoryEntity"></mapping>
<mapping class="cn.dankal.entities.home.FoodEntity"></mapping>
<mapping class="cn.dankal.entities.shop.MallSearchHistoryEntity"></mapping>
</lits>
</litepal>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
package cn.dankal.client.adapter;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.basiclib.widget.GradeStarView;
import cn.dankal.entities.home.BottomAroundEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/4/24.
*/
public class BottomItemAdapter extends BaseQuickAdapter<BottomAroundEntity.DataBean, BaseViewHolder> {
public BottomItemAdapter(int layoutResId, @Nullable List<BottomAroundEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, BottomAroundEntity.DataBean item) {
helper.setText(R.id.tv_home_bottom_name, item.getHotel_name());
helper.setText(R.id.tv_home_bottom_distance, mContext.getString(R.string.distance) + item.getDistance());
FrameLayout frameLayout = helper.getView(R.id.fl_tip);
if (item.getQueue_number() == 0) {
frameLayout.setVisibility(View.GONE);
helper.setText(R.id.tv_tip_queue, R.string.no_queuing_is_required_at_present);
helper.setText(R.id.tv_home_bottom_queue, String.valueOf(item.getQueue_number()));
} else {
frameLayout.setVisibility(View.VISIBLE);
helper.setText(R.id.tv_home_bottom_queue, String.valueOf(item.getQueue_number()));
helper.setText(R.id.tv_tip_queue, mContext.getString(R.string.current_queuing_situation));
}
GradeStarView gradeStarView = helper.getView(R.id.sv_store_star);
gradeStarView.setCurrentChoose(item.getStar_level());
ImageView imageView = helper.getView(R.id.iv_image);
PicUtils.loadNormal(item.getImg_list(), imageView);
}
}
package cn.dankal.client.adapter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.flyco.tablayout.SlidingTabLayout;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cn.dankal.basiclib.base.fragmentactivity.FragmentAdapter;
import cn.dankal.basiclib.util.AppUtils;
import cn.dankal.basiclib.util.DisplayHelper;
import cn.dankal.basiclib.widget.banner.DkBanner;
import cn.dankal.basiclib.widget.banner.VH;
import cn.dankal.entities.home.BottomAroundEntity;
import cn.dankal.entities.home.TopHomeInfoEntity;
import cn.dankal.client.R;
import cn.dankal.entities.home.HomeEntity;
import cn.dankal.client.ui.home.details.MerchantDetailsActivity;
import cn.dankal.client.ui.home.MenuItemFragment;
/**
* Created by zhengpeng on 2019/4/23.
*/
public class HomeAdapter extends BaseMultiItemQuickAdapter<HomeEntity, BaseViewHolder> {
private Context context;
private List<HomeEntity> homeEntityList;
private List<BottomAroundEntity.DataBean> bottomEntityList;
private List<Fragment> dataList;
private List<String> titles;
private FragmentManager fragmentManager;
public SlidingTabLayout tabLayout;
private DkBanner<String> mDkBanner;
private BottomItemAdapter bottomItemAdapter;
private List<String> stringList;//轮播图地址
private FragmentAdapter fragmentAdapter;
public HomeAdapter(Context context, FragmentManager fragmentManager, @Nullable List<HomeEntity> data) {
super(data);
this.context = context;
this.homeEntityList = data;
this.fragmentManager = fragmentManager;
addItemType(HomeEntity.HEAD, R.layout.item_home_head);
addItemType(HomeEntity.MENU, R.layout.item_home_menu);
addItemType(HomeEntity.BOTTOM, R.layout.item_home_bottom);
initData();
}
private void initData() {
stringList = new ArrayList<>();
dataList = new ArrayList<>();
titles = new ArrayList<>();
bottomEntityList = new ArrayList<>();
bottomItemAdapter = new BottomItemAdapter(R.layout.item_home_bottom_item, bottomEntityList);
bottomItemAdapter.setOnItemClickListener((adapter, view, position) -> {
if (position < bottomEntityList.size())
context.startActivity(new Intent(context, MerchantDetailsActivity.class).putExtra(MerchantDetailsActivity.HOTELUUID, bottomEntityList.get(position).getUuid()));
});
fragmentAdapter = new FragmentAdapter(fragmentManager, dataList, titles);
}
private Fragment getFragment(String type) {
MenuItemFragment menuItemFragment = new MenuItemFragment();
Bundle bundle = new Bundle();
bundle.putString("uuid", type);
menuItemFragment.setArguments(bundle);
return menuItemFragment;
}
public void addTopData(TopHomeInfoEntity topHomeInfoEntity) {
List<TopHomeInfoEntity.BannerListBean> bannerListBean = topHomeInfoEntity.getBanner_list();
stringList.clear();
for (int i = 0; i < bannerListBean.size(); i++) {
stringList.add(bannerListBean.get(i).getImg_url());
}
if (mDkBanner != null) {
mDkBanner.notifyDataSetChanged();
}
List<TopHomeInfoEntity.HotelTypeListBean> listBeans = topHomeInfoEntity.getHotel_type_list();
dataList.clear();
titles.clear();
for (int i = 0; i < listBeans.size(); i++) {
TopHomeInfoEntity.HotelTypeListBean hotelTypeListBeans = listBeans.get(i);
dataList.add(getFragment(hotelTypeListBeans.getUuid()));
titles.add(hotelTypeListBeans.getName());
}
notifyItemRangeChanged(0, 2);
}
public void addBottomData(List<BottomAroundEntity.DataBean> dataBeans) {
if (bottomEntityList != null) {
bottomEntityList.clear();
bottomEntityList.addAll(dataBeans);
notifyItemChanged(2);
}
}
@Override
protected void convert(BaseViewHolder helper, HomeEntity item) {
switch (helper.getItemViewType()) {
case HomeEntity.HEAD:
mDkBanner = helper.itemView.findViewById(R.id.banner);
mDkBanner.setIndicatorPoint(R.drawable.oval_indicator, R.drawable.oval_indicator_unselect,
DisplayHelper.dp2px(AppUtils.getApp(), 10), DisplayHelper.dp2px(AppUtils.getApp(), 10));
mDkBanner.setVpAdapter(stringList, () -> new BannerItemView());
break;
case HomeEntity.MENU:
if (titles!=null && titles.size()>0){
tabLayout = helper.itemView.findViewById(R.id.sliding_tabs);
ViewPager viewPager = helper.itemView.findViewById(R.id.vp_pager);
viewPager.setAdapter(fragmentAdapter);
tabLayout.setViewPager(viewPager);
}
break;
case HomeEntity.BOTTOM:
helper.addOnClickListener(R.id.tv_item_filter);
RecyclerView rvBottom = helper.itemView.findViewById(R.id.rv_bottom_child);
rvBottom.setLayoutManager(new LinearLayoutManager(context));
rvBottom.setAdapter(bottomItemAdapter);
break;
}
}
public class BannerItemView implements VH<String> {
@BindView(R.id.iv_img)
ImageView mIvImg;
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
View inflate = inflater.inflate(R.layout.banner_item, container, false);
ButterKnife.bind(this, inflate);
return inflate;
}
@Override
public void onBind(View view, String url) {
//PicUtils.loadNormal(url, mIvImg);
}
}
}
package cn.dankal.client.adapter;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.home.RestaurantEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/4/24.
*/
public class MenuItemAdapter extends BaseQuickAdapter<RestaurantEntity.DataBean, BaseViewHolder> {
public MenuItemAdapter(int layoutResId, @Nullable List<RestaurantEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, RestaurantEntity.DataBean item) {
helper.setText(R.id.tv_menu_text, item.getHotel_name() + "(" + item.getAddress() + ")");
if (!TextUtils.isEmpty(item.getDistance())){
helper.setText(R.id.tv_menu_distance, mContext.getString(R.string.distance) + item.getDistance());
}
ImageView imageView = helper.getView(R.id.iv_menu_image);
PicUtils.loadNormal(item.getImg_list(), imageView);
}
}
package cn.dankal.client.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/6/28.
*/
public class MyAutoCompleteTvAdapter extends BaseAdapter implements Filterable {
private Context context;
//该list存放的是最终弹出列表的数据
private List<String> list = new ArrayList<>();
private List<String> mSearchDataBaseList;
public MyAutoCompleteTvAdapter(Context context, List<String> mSearchDataBaseList) {
this.context = context;
this.mSearchDataBaseList = mSearchDataBaseList;
}
@Override
public Filter getFilter() {
Filter filter = new Filter() {
/**
* 在后台线程执行,定义过滤算法
* @param constraint :就是你在输入框输入的字符串
* @return 符合条件的数据结果,会在下面的publishResults方法中将数据传给list
*/
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
if (constraint == null || constraint.length() == 0) {
//
results.values = mSearchDataBaseList;
results.count = mSearchDataBaseList.size();
} else {
//这个newList是实际搜索出的结果集合,实际上是将该newList的数据赋给了list
List<String> newList = new ArrayList<>();
for (String s : mSearchDataBaseList) {
//包含就添加到newList中
if (s.contains(constraint.toString().trim()
)) {
newList.add(s);
}
}
//将newList传给results
results.values = newList;
results.count = newList.size();
newList = null;
}
return results;
}
/**
* 本方法在UI线程执行,用于更新自动完成列表
* @param constraint
* @param results
*/
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
if (results != null && results.count > 0) {//有符合过滤规则的数据
list.clear();
list.addAll((List<String>) results.values);
notifyDataSetChanged();
} else {//没有符合过滤规则的数据
notifyDataSetInvalidated();
}
}
/**
* 将符合条件的数据转换为你想要的方式,一般无需实现
* 控制用户点击提示时要填充至输入框的文本内容。
*/
@Override
public CharSequence convertResultToString(Object resultValue) {
return super.convertResultToString(resultValue);
//假如这里写 return "啊哈哈";
//那么,无论你点击哪个条目,出现在输入框的永远是"啊哈哈"这几个字。
}
};
return filter;
}
@Override
public int getCount() {
return list != null && list.size() > 0 ? list.size() : 0;
}
/**
* 这里必须返回list.get(position),否则点击条目后输入框显示的是position,而非该position的数据
*
* @param position
* @return
*/
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
TvViewHolder holder;
if (convertView == null) {
convertView = View.inflate(context, R.layout.item_autocompletetv_simple_dropdown, null);
holder = new TvViewHolder();
holder.tv = (TextView) convertView.findViewById(R.id.text1);
convertView.setTag(holder);
} else {
holder = (TvViewHolder) convertView.getTag();
}
//注意这里不要为convertView添加点击事件,默认是点击后:①下拉窗收起;
//②点击的条目数据会显示在搜索框中;③光标定位到字符串末位。
//如果自己添加点击事件,就要首先实现上面的①、②、③。
holder.tv.setText(list.get(position));
return convertView;
}
class TvViewHolder {
TextView tv;
}
}
\ No newline at end of file
package cn.dankal.client.adapter.car;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.CheckBox;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import api.MallServiceFactory;
import cn.dankal.basiclib.base.BaseView;
import cn.dankal.basiclib.rx.AbstractDialogSubscriber;
import cn.dankal.basiclib.util.ToastUtils;
import cn.dankal.basiclib.widget.CommonDialog;
import cn.dankal.entities.event.UpdateCarEvent;
import cn.dankal.entities.shop.AddCarResultEntity;
import cn.dankal.client.R;
import cn.dankal.entities.car.ShopCarEntity;
import io.reactivex.disposables.Disposable;
import okhttp3.ResponseBody;
/**
* Created by zhengpeng on 2019/4/30.
*/
public class CarShopAdapter extends BaseQuickAdapter<ShopCarEntity.DataBean, BaseViewHolder> {
private Context context;
private List<ShopCarEntity.DataBean> dataBeanList;
private List<String> list = new ArrayList<>();
private CommonDialog commonDialog = null;
private SelectShowListen selectShowListen = null;
public CarShopAdapter(Context context, int layoutResId, @Nullable List<ShopCarEntity.DataBean> data) {
super(layoutResId, data);
this.context = context;
this.dataBeanList = data;
}
public void setSelectShowListen(SelectShowListen selectShowListen) {
this.selectShowListen = selectShowListen;
}
@Override
protected void convert(BaseViewHolder helper, ShopCarEntity.DataBean item) {
if (item.getStore_cart_goods_list() == null && item.getStore_cart_goods_list().size() == 0) {
return;
}
CheckBox rbStoreName = helper.getView(R.id.cb_store_name);
rbStoreName.setText(item.getStore_name());
if (item.isSelectAllChild()) {
rbStoreName.setChecked(true);
} else {
rbStoreName.setChecked(false);
}
List<ShopCarEntity.DataBean.StoreCartGoodsListBean> list = item.getStore_cart_goods_list();
CarShopChildAdapter carShopChildAdapter = new CarShopChildAdapter(R.layout.item_car_child_shop, list);
carShopChildAdapter.setHasStableIds(true);
rbStoreName.setOnCheckedChangeListener((buttonView, isChecked) -> {
for (int i = 0; i < list.size(); i++) {
list.get(i).setShopSelect(isChecked);
}
if (selectShowListen != null) {
selectShowListen.onShowListen();
}
carShopChildAdapter.notifyDataSetChanged();
});
carShopChildAdapter.setOnItemChildClickListener((adapter, view, position) -> {
switch (view.getId()) {
case R.id.tv_right_delete:
CommonDialog.Builder builder = new CommonDialog.Builder(context);
builder.setTitle(context.getString(R.string.need_to_delete));
builder.setNegativeButton(R.string.cancel, context.getResources().getColor(cn.dankal.basiclib.R.color.font_313131), type -> {
if (commonDialog != null) {
commonDialog.dismiss();
}
});
builder.setPositiveButton(R.string.ok, context.getResources().getColor(cn.dankal.basiclib.R.color.font_313131), type -> {
if (commonDialog != null) {
commonDialog.dismiss();
}
operateCart(carShopChildAdapter, list.get(position).getUuid(), "2", position);
});
commonDialog = builder.create();
commonDialog.show();
break;
case R.id.cl_car_reduce:
int number = list.get(position).getNumber();
if (number > 1) {
carShopChildAdapter.updateNumber(position, --number);
carShopChildAdapter.notifyItemChanged(position);
operateCart(carShopChildAdapter, list.get(position).getUuid(), "1", position);
} else {
ToastUtils.showShort(R.string.no_more_reductions);
}
break;
case R.id.cl_car_add:
int numberTow = list.get(position).getNumber();
carShopChildAdapter.updateNumber(position, ++numberTow);
carShopChildAdapter.notifyItemChanged(position);
addCart(list.get(position));
break;
case R.id.cb_select_shop:
if (selectShowListen != null) {
selectShowListen.onShowListen();
}
break;
}
});
RecyclerView recyclerView = helper.getView(R.id.rv_shop_car_child);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setAdapter(carShopChildAdapter);
}
public void addCart(ShopCarEntity.DataBean.StoreCartGoodsListBean storeCartGoodsListBean) {
Map<String, Object> map = new HashMap<>();
map.put("goods_specs_uuid", storeCartGoodsListBean.getGoods_specs_uuid());
map.put("number", 1);
map.put("store_goods_uuid", storeCartGoodsListBean.getStore_goods_uuid());
map.put("store_uuid", storeCartGoodsListBean.getStore_uuid());
MallServiceFactory.addCart(map).subscribe(new AbstractDialogSubscriber<AddCarResultEntity>((BaseView) context) {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(AddCarResultEntity addCarResultEntity) {
}
});
}
public void operateCart(CarShopChildAdapter carShopChildAdapter, String uuid, String type, int position) {
list.clear();
list.add(uuid);
Map<String, Object> map = new HashMap<>();
map.put("cart_goods_list", list);
map.put("type", type);
MallServiceFactory.operateCart(map).subscribe(new AbstractDialogSubscriber<ResponseBody>((BaseView) context) {
@Override
public void onNext(ResponseBody responseBody) {
if ("2".equals(type)) {
carShopChildAdapter.remove(position);
notifyDataSetChanged();
EventBus.getDefault().post(new UpdateCarEvent());
}
}
});
}
/**
* 回调,用来通知界面刷新购物车底部的值
*/
public interface SelectShowListen {
public void onShowListen();
}
}
package cn.dankal.client.adapter.car;
import android.support.annotation.Nullable;
import android.widget.CheckBox;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.car.ShopCarEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/4/30.
*/
public class CarShopChildAdapter extends BaseQuickAdapter<ShopCarEntity.DataBean.StoreCartGoodsListBean, BaseViewHolder> {
private List<ShopCarEntity.DataBean.StoreCartGoodsListBean> listBeans;
public CarShopChildAdapter(int layoutResId, @Nullable List<ShopCarEntity.DataBean.StoreCartGoodsListBean> data) {
super(layoutResId, data);
this.listBeans = data;
}
@Override
protected void convert(BaseViewHolder helper, ShopCarEntity.DataBean.StoreCartGoodsListBean item) {
helper.setText(R.id.tv_item_shop_name, item.getGoods_name());
helper.setText(R.id.tv_item_shop_specs, item.getGoods_specs());
helper.setText(R.id.tv_item_shop_number, String.valueOf(item.getNumber()));
helper.setText(R.id.tv_car_shop_perice, UIUtile.stringToPrice(item.getUnit_price()));
ImageView imageShop = helper.getView(R.id.iv_image_shop);
PicUtils.loadNormal(item.getSpecs_img_list(), imageShop);
CheckBox checkBox = helper.getView(R.id.cb_select_shop);
checkBox.setChecked(item.isShopSelect());
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
listBeans.get(helper.getAdapterPosition()).setShopSelect(isChecked);
});
helper.addOnClickListener(R.id.tv_right_delete, R.id.cl_car_reduce, R.id.cl_car_add, R.id.cb_select_shop);
}
public void updateNumber(int position, int number) {
ShopCarEntity.DataBean.StoreCartGoodsListBean storeCartGoodsListBean = listBeans.get(position);
storeCartGoodsListBean.setNumber(number);
listBeans.set(position, storeCartGoodsListBean);
notifyItemChanged(position);
}
@Override
public long getItemId(int position) {
return listBeans.get(position).hashCode();
}
}
package cn.dankal.client.adapter.home;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.home.CommitHotelEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/5/5.
*/
public class OrderResultAdapter extends BaseQuickAdapter<CommitHotelEntity.PaySettleGoodsListBean, BaseViewHolder> {
private int isStamp;//0不是邮票兑换商品
public OrderResultAdapter(int layoutResId, @Nullable List<CommitHotelEntity.PaySettleGoodsListBean> data, int isStamp) {
super(layoutResId, data);
this.isStamp = isStamp;
}
@Override
protected void convert(BaseViewHolder helper, CommitHotelEntity.PaySettleGoodsListBean item) {
helper.setText(R.id.tv_item_shop_name, item.getGoods_name());
if (item.getIs_stamp() == 1 && isStamp == 1) {
helper.setText(R.id.tv_item_shop_price, UIUtile.stringToStamp(item.getStamp_number()));
} else {
helper.setText(R.id.tv_item_shop_price, UIUtile.stringToPrice(item.getGoods_price()));
}
helper.setText(R.id.tv_item_shop_count, "×" + item.getNumber());
helper.setText(R.id.tv_item_shop_desc, item.getGoods_specs());
ImageView imageView = helper.getView(R.id.iv_image);
if (item.getImg_list_temp() != null || item.getImg_list_temp().size() > 0) {
PicUtils.loadNormal(item.getImg_list_temp().get(0), imageView);
}
}
}
package cn.dankal.client.adapter.home;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.home.RestaurantEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/6/10.
*/
public class SearchShopAdapter extends BaseQuickAdapter<RestaurantEntity.DataBean, BaseViewHolder> {
public SearchShopAdapter(int layoutResId, @Nullable List<RestaurantEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, RestaurantEntity.DataBean item) {
helper.setText(R.id.tv_recommend_name, item.getHotel_name());
helper.setText(R.id.tv_recommend_distance, mContext.getString(R.string.distance) + item.getDistance());
helper.setText(R.id.tv_recommend_address, item.getAddress());
helper.setText(R.id.tv_recommend_sale, mContext.getString(R.string.monthly_sale) + item.getSales_all());
PicUtils.loadNormal(item.getImg_list(), helper.getView(R.id.iv_recommend_picture));
}
}
package cn.dankal.client.adapter.home;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.home.CouponEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/5/5.
*/
public class SelectCouponAdapter extends BaseQuickAdapter<CouponEntity.DataBean, BaseViewHolder> {
public SelectCouponAdapter(int layoutResId, @Nullable List<CouponEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, CouponEntity.DataBean item) {
CouponEntity.DataBean.CouponVoBean couponVoBean = item.getCoupon_vo();
helper.setText(R.id.tv_coupon_title, couponVoBean.getName());
helper.setText(R.id.tv_coupon_full,item.getCoupon_vo().getFull());
try {
String startTime = couponVoBean.getEffective_time().split(" ")[0];
String endTime = couponVoBean.getExpires_time().split(" ")[0];
helper.setText(R.id.tv_coupon_time, startTime + mContext.getString(R.string.to) + endTime);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package cn.dankal.client.adapter.home;
import android.util.Log;
import android.view.View;
import com.zhy.view.flowlayout.FlowLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Created by zhengpeng on 2019/7/25.
*/
public abstract class SelectTagAdapter<T> {
private List<T> mTagDatas;
private OnDataChangedListener mOnDataChangedListener;
@Deprecated
private HashSet<Integer> mCheckedPosList = new HashSet<Integer>();
public SelectTagAdapter(List<T> datas) {
mTagDatas = datas;
}
@Deprecated
public SelectTagAdapter(T[] datas) {
mTagDatas = new ArrayList<T>(Arrays.asList(datas));
}
interface OnDataChangedListener {
void onChanged();
}
void setOnDataChangedListener(OnDataChangedListener listener) {
mOnDataChangedListener = listener;
}
@Deprecated
public void setSelectedList(int... poses) {
Set<Integer> set = new HashSet<>();
for (int pos : poses) {
set.add(pos);
}
setSelectedList(set);
}
@Deprecated
public void setSelectedList(Set<Integer> set) {
mCheckedPosList.clear();
if (set != null) {
mCheckedPosList.addAll(set);
}
notifyDataChanged();
}
@Deprecated
public void cleanAllData() {
mCheckedPosList.clear();
notifyDataChanged();
}
@Deprecated
HashSet<Integer> getPreCheckedList() {
return mCheckedPosList;
}
public int getCount() {
return mTagDatas == null ? 0 : mTagDatas.size();
}
public void notifyDataChanged() {
if (mOnDataChangedListener != null)
mOnDataChangedListener.onChanged();
}
public T getItem(int position) {
return mTagDatas.get(position);
}
public abstract View getView(FlowLayout parent, int position, T t);
public void onSelected(int position, View view){
Log.d("zhy","onSelected " + position);
}
public void unSelected(int position, View view){
Log.d("zhy","unSelected " + position);
}
public boolean setSelected(int position, T t) {
return false;
}
}
package cn.dankal.client.adapter.home;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/4/29.
*/
public class ShopArrayAdapter extends ArrayAdapter<String> {
private Context context;
private int resource;
public ShopArrayAdapter(@NonNull Context context, int resource, @NonNull List<String> objects) {
super(context, resource, objects);
this.context = context;
this.resource = resource;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
String title = getItem(position);
View view = LayoutInflater.from(context).inflate(resource, null);
TextView textView = view.findViewById(R.id.tv_title);
textView.setText(title);
return view;
}
}
package cn.dankal.client.adapter.home;
import android.support.annotation.Nullable;
import android.view.View;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import org.litepal.LitePal;
import java.util.Collections;
import java.util.List;
import cn.dankal.entities.home.FoodEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/5/5.
*/
public class ShopBottomListAdapter extends BaseQuickAdapter<FoodEntity, BaseViewHolder> {
private List<FoodEntity> data;
private UpdateListenc updateListenc;
public ShopBottomListAdapter(int layoutResId, @Nullable List<FoodEntity> data, UpdateListenc updateListenc) {
super(layoutResId, data);
this.data = data;
this.updateListenc = updateListenc;
}
@Override
protected void convert(BaseViewHolder helper, FoodEntity item) {
helper.setText(R.id.tv_item_shop_name, item.getFoodName());
helper.setText(R.id.tv_show_spec, item.getSpecShow());
if (item.getIsStamp() == 0) {//不是邮票兑换商品
helper.setText(R.id.tv_item_shop_price, UIUtile.stringToPrice(item.getFoodPrice()));
} else {//普通商品
helper.setText(R.id.tv_item_shop_price, UIUtile.stringToStamp(item.getStampPrice()));
}
helper.setText(R.id.tv_item_count, String.valueOf(item.getNumber()));
helper.getView(R.id.tv_item_add).setOnClickListener(v -> {
int number = item.getNumber();
++number;
updateShopNumber(helper, item, number);
if (updateListenc != null) {
updateListenc.update();
}
});
helper.getView(R.id.tv_item_reduce).setOnClickListener(v -> {
int number = item.getNumber();
--number;
updateShopNumber(helper, item, number);
if (updateListenc != null) {
updateListenc.update();
}
});
}
private void updateShopNumber(BaseViewHolder helper, FoodEntity item, int number) {
//找到购物车商品
List<FoodEntity> entities = LitePal.where("storeUUid=? and goods_uuid=? and second_main_specs_uuid=? and specShow=?", item.getStoreUUid(),
item.getGoods_uuid(), item.getSecond_main_specs_uuid(), item.getSpecShow()).order("id desc").find(FoodEntity.class);
if (entities != null && entities.size() > 0) {
if (entities.size() == 1) {
FoodEntity foodEntity = entities.get(0);
if (number == 0) {//删除
foodEntity.delete();
data.remove(helper.getAdapterPosition());
} else {
foodEntity.setNumber(number);
foodEntity.save();
//替换指定元素
Collections.replaceAll(data, data.get(helper.getAdapterPosition()), foodEntity);
}
if (data.size() == 0) {
View emptyView = UIUtile.getView(R.layout.adapter_layout_empty_food_car, null);
this.setEmptyView(emptyView);
}
}
notifyDataSetChanged();
}
}
public interface UpdateListenc {
public void update();
}
}
package cn.dankal.client.adapter.home;
import android.content.Context;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.dankal.entities.home.RestaurantSpecEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/6/26.
*/
public class ShopSpecListAdapter extends BaseQuickAdapter<RestaurantSpecEntity.GoodsMainSpecsListBean, BaseViewHolder> {
private Context context;
private Map<Integer, String> selectSpec = new HashMap<>();
private TagSelectChangeListen tagSelectChangeListen;
private Map<Integer, String> specNameList = new HashMap<>();
public ShopSpecListAdapter(Context context, int layoutResId, @Nullable List<RestaurantSpecEntity.GoodsMainSpecsListBean> data) {
super(layoutResId, data);
this.context = context;
//循环遍历初始化选中
for (int i = 0; i < data.size(); i++) {
RestaurantSpecEntity.GoodsMainSpecsListBean goodsMainSpecsListBean = data.get(i);//获得当前辅规格
List<RestaurantSpecEntity.GoodsMainSpecsListBean.SecondSpecsVolistBean> specsList = goodsMainSpecsListBean.getSecond_specs_volist();//获得辅规格所有规格选项
if (specsList != null && specsList.size() > 0) {//默认选中第一个
selectSpec.put(i, specsList.get(0).getUuid());
specNameList.put(i, specsList.get(0).getSpecs_name());
}
}
}
public void setTagSelectChangeListen(TagSelectChangeListen tagSelectChangeListen) {
this.tagSelectChangeListen = tagSelectChangeListen;
}
@Override
protected void convert(BaseViewHolder helper, RestaurantSpecEntity.GoodsMainSpecsListBean item) {
helper.setText(R.id.tv_spicy, item.getSpecs_name());
final List<RestaurantSpecEntity.GoodsMainSpecsListBean.SecondSpecsVolistBean> listOne = item.getSecond_specs_volist();
TagFlowLayout tagFlowLayout = helper.getView(R.id.fl_tag_tow);
TagAdapter tagAdapter = new TagAdapter(listOne) {
@Override
public View getView(FlowLayout flowLayout, int i, Object o) {
RestaurantSpecEntity.GoodsMainSpecsListBean.SecondSpecsVolistBean bean = (RestaurantSpecEntity.GoodsMainSpecsListBean.SecondSpecsVolistBean) o;
TextView tv = (TextView) LayoutInflater.from(context).inflate(R.layout.item_dialog_format, tagFlowLayout, false);
tv.setText(bean.getSpecs_name());
return tv;
}
};
tagAdapter.setSelectedList(0);
tagFlowLayout.setAdapter(tagAdapter);
tagFlowLayout.setOnSelectListener(selectPosSet -> {
if (selectPosSet != null && selectPosSet.size() > 0) {
int position = 0;
for (Integer index : selectPosSet) {
position = index;
}
selectSpec.put(helper.getAdapterPosition(), listOne.get(position).getUuid());
specNameList.put(helper.getAdapterPosition(), listOne.get(position).getSpecs_name());
}else {
selectSpec.remove(helper.getAdapterPosition());
specNameList.remove(helper.getAdapterPosition());
}
if (tagSelectChangeListen != null) {
tagSelectChangeListen.tagSelectListen();
}
});
}
public Map<Integer, String> getSelectSpec() {
return selectSpec;
}
public Map<Integer, String> getSelectSpecName() {
return specNameList;
}
public interface TagSelectChangeListen {
public abstract void tagSelectListen();
}
}
package cn.dankal.client.adapter.personal;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.personal.AfterEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/7/2.
*/
public class AfterListAdapter extends BaseQuickAdapter<AfterEntity.DataBean, BaseViewHolder> {
public AfterListAdapter(int layoutResId, @Nullable List<AfterEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, AfterEntity.DataBean item) {
if (item.getImg_list_temp() != null && item.getImg_list_temp().size() > 0) {
PicUtils.loadNormal(item.getImg_list_temp().get(0), helper.getView(R.id.iv_shop_image));
}
helper.setText(R.id.tv_shop_item_name, item.getGoods_name());
helper.setText(R.id.tv_shop_item_specs, item.getGoods_specs());
helper.setText(R.id.tv_shop_item_unit_price, UIUtile.stringToPrice(item.getUnit_price()));
helper.setText(R.id.tv_store_name, item.getStore_name());
helper.setText(R.id.tv_shop_item_number, "× " + item.getNumber());
TextView tvOriginalPrice = helper.getView(R.id.tv_shop_item_original_price);
tvOriginalPrice.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
tvOriginalPrice.setText(UIUtile.stringToPrice(item.getOriginal_price()));
switch (item.getRefund_status()) {
case 0://待审核
if (item.getOrder_status() == 6) {
helper.setText(R.id.tv_state, mContext.getString(R.string.only_refund) + " " + mContext.getString(R.string.refund_pending));
} else if (item.getOrder_status() == 7) {
helper.setText(R.id.tv_state, mContext.getString(R.string.refund) + " " + mContext.getString(R.string.refund_pending));
} else {
helper.setText(R.id.tv_state, mContext.getString(R.string.refund_pending));
}
break;
case 1://审核通过
if (item.getOrder_status() == 8) {
//helper.setText(R.id.tv_state, R.string.successful_refund_only);
helper.setText(R.id.tv_state, mContext.getString(R.string.only_refund) + " " + mContext.getString(R.string.successful_refund_tow));
} else if (item.getOrder_status() == 9) {
//helper.setText(R.id.tv_state, R.string.successful_refund);
helper.setText(R.id.tv_state, mContext.getString(R.string.refund) + " " + mContext.getString(R.string.successful_refund_tow));
} else {
helper.setText(R.id.tv_state, R.string.successful_refund_tow);
}
break;
case 2://审核拒绝,只有4
helper.setText(R.id.tv_state, mContext.getString(R.string.refusal_of_refund));
break;
case 3://撤销退款
helper.setText(R.id.tv_state, mContext.getString(R.string.refund_closure));
break;
default:
helper.setText(R.id.tv_state, "");
break;
}
}
}
package cn.dankal.client.adapter.personal;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.basiclib.widget.FullyGridLayoutManager;
import cn.dankal.basiclib.widget.GradeStarView;
import cn.dankal.entities.home.EvaluationCommitEntity;
import cn.dankal.entities.personal.MallOrderDetailEntity;
import cn.dankal.client.R;
import cn.dankal.client.adapter.shop.GridImageEvaluationAdapter;
/**
* Created by zhengpeng on 2019/5/13.
*/
public class EvaluationListAdapter extends BaseQuickAdapter<MallOrderDetailEntity.OrdersGoodsListBean, BaseViewHolder> implements GridImageEvaluationAdapter.onAddPicClickListener {
private Context context;
public int mPosition;//记录当前单击的位置
private Map<String, List<LocalMedia>> selectMap = new HashMap<>();
public Map<String, List<String>> uploadImage = new HashMap<>();//上传到腾讯云的图片
private List<EvaluationCommitEntity> resultData;//评论需要返回的数据
private List<EditText> editTextList;
private List<GradeStarView> gradeStarViewList;
private List<MallOrderDetailEntity.OrdersGoodsListBean> data;//当前每个item的数据
public EvaluationListAdapter(Context context, int layoutResId, @Nullable List<MallOrderDetailEntity.OrdersGoodsListBean> data) {
super(layoutResId, data);
this.context = context;
this.data = data;
resultData = new ArrayList<>();
editTextList = new ArrayList<>();
gradeStarViewList = new ArrayList<>();
}
@Override
protected void convert(BaseViewHolder helper, MallOrderDetailEntity.OrdersGoodsListBean item) {
if (item.getImg_list_temp() != null && item.getImg_list_temp().size() > 0) {
PicUtils.loadNormal(item.getImg_list_temp().get(0), helper.getView(R.id.iv_evaluation_img));
}
RecyclerView rvList = helper.getView(R.id.rv_item_img_list);
EditText editText = helper.getView(R.id.et_feedback);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
helper.setText(R.id.tv_text_size, s.length() + "/500");
}
@Override
public void afterTextChanged(Editable s) {
}
});
editTextList.add(editText);
GradeStarView gradeStarView = helper.getView(R.id.sv_shop_case);
gradeStarViewList.add(gradeStarView);
FullyGridLayoutManager manager = new FullyGridLayoutManager(context, 4, GridLayoutManager.VERTICAL, false);
rvList.setLayoutManager(manager);
GridImageEvaluationAdapter adapter = new GridImageEvaluationAdapter(context, helper.getAdapterPosition(), this);
rvList.setAdapter(adapter);
List<LocalMedia> mediaList = selectMap.get(String.valueOf(helper.getAdapterPosition()));
if (mediaList != null) {
helper.setText(R.id.tv_tag_paint, context.getString(R.string.upload_pictures) + "(" + mediaList.size() + "/6)");
adapter.setList(mediaList);
}
}
@Override
public void onAddPicClick(int position) {
mPosition = position;
List<LocalMedia> mediaList = selectMap.get(String.valueOf(position));
if (mediaList == null) {
mediaList = new ArrayList<>();
selectMap.put(String.valueOf(mPosition), mediaList);
}
// 进入相册 以下是例子:不需要的api可以不写
PictureSelector.create((Activity) context)
.openGallery(PictureMimeType.ofImage())// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio()
.theme(R.style.picture_default_style)// 主题样式设置 具体参考 values/styles 用法:R.style.picture.white.style
.maxSelectNum(6)// 最大图片选择数量
.minSelectNum(1)// 最小选择数量
.imageSpanCount(4)// 每行显示个数
.selectionMode(PictureConfig.MULTIPLE)// 多选 or 单选
.previewImage(true)// 是否可预览图片
.isCamera(true)// 是否显示拍照按钮
.isZoomAnim(true)// 图片列表点击 缩放效果 默认true
.enableCrop(false)// 是否裁剪
.compress(true)// 是否压缩
.synOrAsy(true)//同步true或异步false 压缩 默认同步
.glideOverride(160, 160)// glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度
.freeStyleCropEnabled(true)// 裁剪框是否可拖拽
.selectionMedia(mediaList)// 是否传入已选图片
.minimumCompressSize(100)// 小于100kb的图片不压缩
.forResult(PictureConfig.CHOOSE_REQUEST);//结果回调onActivityResult code
}
public void setList(int mPosition, List<LocalMedia> selectList) {
List<String> listImage = new ArrayList<>();//需要上传到腾讯云的图片列表
for (int j = 0; j < selectList.size(); j++) {
LocalMedia media = selectList.get(j);
String path = "";
if (media.isCompressed() || media.isCut() && media.isCompressed()) {
// 压缩过,或者裁剪同时压缩过,以最终压缩过图片为准
path = media.getCompressPath();
}
listImage.add(path);
}
uploadImage.put(String.valueOf(mPosition), listImage);
selectMap.put(String.valueOf(mPosition), selectList);
notifyDataSetChanged();
}
/**
* 获取所有已填写的内容
*
* @return
*/
@org.jetbrains.annotations.Nullable
public List<EvaluationCommitEntity> getSelectResult() {
resultData.clear();
for (int i = 0; i < data.size(); i++) {
EvaluationCommitEntity evaluationCommitEntity = new EvaluationCommitEntity();
evaluationCommitEntity.setContent(editTextList.get(i).getText().toString());
evaluationCommitEntity.setType(1);
evaluationCommitEntity.setOrder_uuid(data.get(i).getOrder_uuid());
evaluationCommitEntity.setOrder_goods_uuid(data.get(i).getUuid());
evaluationCommitEntity.setStar_level(gradeStarViewList.get(i).getSelectStar());
List<String> commitListImage = new ArrayList<>();//图片列表上传到后台
evaluationCommitEntity.setImg_list(commitListImage);
if (selectMap.size() > 0) {
List<LocalMedia> localMedias = selectMap.get(String.valueOf(i));
for (int j = 0; j < localMedias.size(); j++) {
LocalMedia media = localMedias.get(i);
String path = "";
if (media.isCompressed() || media.isCut() && media.isCompressed()) {
// 压缩过,或者裁剪同时压缩过,以最终压缩过图片为准
path = media.getCompressPath();
}
String avatar = getFormatKey(path);
commitListImage.add(avatar);
}
}
resultData.add(evaluationCommitEntity);
}
return resultData;
}
@NotNull
private String getFormatKey(String path) {
String cosPath = path.substring(path.lastIndexOf("/") + 1);
String[] strings = cosPath.split("\\.");
if (strings.length > 1) {
cosPath = strings[0] + "_" + System.currentTimeMillis() + "." + strings[1];
}
return cosPath;
}
}
package cn.dankal.client.adapter.personal;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.personal.OrderHotelDetail;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/5/9.
*/
public class FoodDetailsAdapter extends BaseQuickAdapter<OrderHotelDetail.OrdersGoodsListBean, BaseViewHolder> {
private int payType;
public FoodDetailsAdapter(int layoutResId, @Nullable List<OrderHotelDetail.OrdersGoodsListBean> data, int payType) {
super(layoutResId, data);
this.payType = payType;
}
@Override
protected void convert(BaseViewHolder helper, OrderHotelDetail.OrdersGoodsListBean item) {
helper.setText(R.id.tv_item_shop_name, item.getGoods_name());
helper.setText(R.id.tv_item_shop_desc, item.getGoods_specs());
if (payType == 2) {//邮票支付
helper.setText(R.id.tv_item_shop_price, UIUtile.stringToStamp(item.getUnit_price()));
} else {
helper.setText(R.id.tv_item_shop_price, UIUtile.stringToPrice(item.getUnit_price()));
}
helper.setText(R.id.tv_item_shop_count, "×" + item.getNumber());
List<String> listImage = item.getImg_list_temp();
if (listImage != null && listImage.size() > 0) {
PicUtils.loadNormal(listImage.get(0), helper.getView(R.id.iv_image));
}
}
}
package cn.dankal.client.adapter.personal;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.PicUtil;
import cn.dankal.entities.personal.FoodOrderEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/5/9.
*/
public class FoodOrderListAdapter extends BaseQuickAdapter<FoodOrderEntity.DataBean, BaseViewHolder> {
public FoodOrderListAdapter(int layoutResId, @Nullable List<FoodOrderEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, FoodOrderEntity.DataBean item) {
helper.setText(R.id.tv_order_food_name, item.getHotel_name());
helper.setText(R.id.tv_order_food_time, mContext.getString(R.string.order_time) + item.getCreate_time());
helper.setText(R.id.tv_order_food_count, mContext.getString(R.string.common) + item.getGoods_number() + mContext.getString(R.string.goods));
if (item.getPay_type() == 2) {//邮票支付
helper.setText(R.id.tv_order_food_price, UIUtile.stringToStamp(item.getReal_pay_price()));
} else {
helper.setText(R.id.tv_order_food_price, UIUtile.stringToPrice(item.getReal_pay_price()));
}
PicUtil.setHeadPhoto(helper.getView(R.id.iv_image_head), item.getImg_list());
String status = "";
switch (item.getOrder_status()) {
case "0"://待支付
status = mContext.getString(R.string.to_be_paid);
break;
case "1"://已支付
status = mContext.getString(R.string.paymented);
break;
case "2"://退款申请中
status = mContext.getString(R.string.application_for_refund);
break;
case "3"://待收货
status = mContext.getString(R.string.to_be_received);
break;
case "4"://已完成
status = mContext.getString(R.string.completed);
break;
case "5"://"已取消"
status = mContext.getString(R.string.cancelled);
break;
case "6"://仅退款
status = mContext.getString(R.string.only_refund);
break;
case "7":
status = mContext.getString(R.string.refund);
break;
case "8":
status = mContext.getString(R.string.successful_refund_only);
break;
case "9":
status = mContext.getString(R.string.successful_refund);
break;
case "10":
status = mContext.getString(R.string.refusal_of_refund);
break;
case "11":
status = mContext.getString(R.string.successful_partial_refund);
break;
case "12":
status = mContext.getString(R.string.successful_full_refund);
break;
default:
status = "";
break;
}
helper.setText(R.id.tv_order_food_state, status);
}
}
package cn.dankal.client.adapter.personal;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.PicUtil;
import cn.dankal.entities.personal.LeaveNotesListEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/5/17.
*/
public class LeaveMessageAdapter extends BaseQuickAdapter<LeaveNotesListEntity.DataBean, BaseViewHolder> {
private Context context;
public LeaveMessageAdapter(Context context, int layoutResId, @Nullable List<LeaveNotesListEntity.DataBean> data) {
super(layoutResId, data);
this.context = context;
}
@Override
protected void convert(BaseViewHolder helper, LeaveNotesListEntity.DataBean item) {
helper.setText(R.id.tv_name, item.getName());
helper.setText(R.id.tv_time, item.getCreate_time());
helper.setText(R.id.tv_content, item.getContent());
ImageView imageView = helper.getView(R.id.iv_avatar);
PicUtil.setHeadPhoto(imageView,item.getAvatar());
ReplyMessageAdapter adapter = new ReplyMessageAdapter(R.layout.item_message_reply, item.getInside_notes_list_list());
RecyclerView recyclerView = helper.getView(R.id.rv_reply_list);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setAdapter(adapter);
}
}
package cn.dankal.client.adapter.personal;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.personal.MallOrderDetailEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/5/9.
*/
public class MallOrderDetailsAdapter extends BaseQuickAdapter<MallOrderDetailEntity.OrdersGoodsListBean, BaseViewHolder> {
private int order_status;
private boolean isBeyoud = false;
public MallOrderDetailsAdapter(int layoutResId, @Nullable List<MallOrderDetailEntity.OrdersGoodsListBean> data, int order_status, boolean isBeyoud) {
super(layoutResId, data);
this.order_status = order_status;
this.isBeyoud = isBeyoud;
}
public MallOrderDetailsAdapter(int layoutResId, @Nullable List<MallOrderDetailEntity.OrdersGoodsListBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, MallOrderDetailEntity.OrdersGoodsListBean item) {
helper.setText(R.id.tv_shop_name, item.getGoods_name());
helper.setText(R.id.tv_shop_unit_price, UIUtile.stringToPrice(item.getUnit_price()));
helper.setText(R.id.tv_shop_number, "×" + item.getNumber());
helper.setText(R.id.tv_shop_specs, item.getGoods_specs());
TextView tvOriginalPrice = helper.getView(R.id.tv_shop_original_price);
tvOriginalPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
tvOriginalPrice.setText(UIUtile.stringToPrice(item.getOriginal_price()));
List<String> listImage = item.getImg_list_temp();
if (listImage != null && listImage.size() > 0) {
PicUtils.loadNormal(listImage.get(0), helper.getView(R.id.iv_shop_image));
}
helper.addOnClickListener(R.id.tv_apply_after_sale);
TextView tvSale = helper.getView(R.id.tv_apply_after_sale);
if (order_status == 4 && item.getIs_after_sale() == 0) {//显示售后按钮
tvSale.setVisibility(View.VISIBLE);
} else {//不显示
tvSale.setVisibility(View.GONE);
}
}
}
package cn.dankal.client.adapter.personal;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.personal.MallOrderListEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/5/9.
*/
public class MallOrderItemListAdapter extends BaseQuickAdapter<MallOrderListEntity.DataBean.OrdersGoodsListBean, BaseViewHolder> {
public MallOrderItemListAdapter(int layoutResId, @Nullable List<MallOrderListEntity.DataBean.OrdersGoodsListBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, MallOrderListEntity.DataBean.OrdersGoodsListBean item) {
helper.setText(R.id.tv_shop_item_name, item.getGoods_name());
helper.setText(R.id.tv_shop_item_specs, item.getGoods_specs());
helper.setText(R.id.tv_shop_item_unit_price, UIUtile.stringToPriceTow(item.getUnit_price()));
helper.setText(R.id.tv_shop_item_number, "×" + item.getNumber());
TextView tvOriginalPrice = helper.getView(R.id.tv_shop_item_original_price);
tvOriginalPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
tvOriginalPrice.setText(UIUtile.stringToPrice(item.getOriginal_price()));
List<String> listImage = item.getImg_list_temp();
if (listImage != null && listImage.size() > 0) {
PicUtils.loadNormal(listImage.get(0), helper.getView(R.id.iv_shop_image));
}
}
}
package cn.dankal.client.adapter.personal;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.personal.MallOrderListEntity;
import cn.dankal.client.R;
import cn.dankal.client.constants.ConstantsRestaurantType;
import cn.dankal.client.ui.personal.order.mall.MallOrderDetailsActivity;
import cn.dankal.client.ui.personal.order.mall.MallOrderDetailsCancelActivity;
import cn.dankal.client.ui.personal.order.mall.MallOrderDetailsCompleteActivity;
import cn.dankal.client.ui.personal.order.mall.MallOrderDetailsPayActivity;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/5/9.
*/
public class MallOrderListAdapter extends BaseQuickAdapter<MallOrderListEntity.DataBean, BaseViewHolder> {
private FragmentActivity fragmentActivity;
private Context context;
public MallOrderListAdapter(Context context, int layoutResId, FragmentActivity fragmentActivity, @Nullable List<MallOrderListEntity.DataBean> data) {
super(layoutResId, data);
this.fragmentActivity = fragmentActivity;
this.context = context;
}
@Override
protected void convert(BaseViewHolder helper, MallOrderListEntity.DataBean item) {
helper.setText(R.id.tv_store_name, item.getStore_name());
TextView tvEvaluate = helper.getView(R.id.tv_store_evaluate);
TextView tvCancel = helper.getView(R.id.tv_store_order_cancel);
TextView tvPay = helper.getView(R.id.tv_store_order_pay);
TextView tvSure = helper.getView(R.id.tv_store_order_sure);
tvEvaluate.setVisibility(View.GONE);
tvCancel.setVisibility(View.GONE);
tvPay.setVisibility(View.GONE);
tvSure.setVisibility(View.GONE);
String status = "";
switch (item.getOrder_status()) {
case 0://待支付
status = mContext.getString(R.string.to_be_paid);
tvCancel.setVisibility(View.VISIBLE);
tvPay.setVisibility(View.VISIBLE);
break;
case 1://已支付
status = mContext.getString(R.string.to_be_delivered);
tvCancel.setVisibility(View.VISIBLE);
break;
case 2://退款申请中
status = mContext.getString(R.string.application_for_refund);
break;
case 3://待收货
status = mContext.getString(R.string.to_be_received);
tvSure.setVisibility(View.VISIBLE);
break;
case 4://已完成
status = mContext.getString(R.string.completed);
break;
case 5://"已取消"
status = mContext.getString(R.string.cancelled);
break;
case 6://仅退款
status = mContext.getString(R.string.only_refund);
break;
case 7:
status = mContext.getString(R.string.refund);
break;
case 8:
status = mContext.getString(R.string.successful_refund_only);
break;
case 9:
status = mContext.getString(R.string.successful_refund);
break;
case 10:
status = mContext.getString(R.string.refusal_of_refund);
break;
default:
status = "";
break;
}
if (item.getOrder_status() == 4) {//交易已完成
if (item.getIs_comment() == 0) {//未评价显示评价按钮
tvEvaluate.setVisibility(View.VISIBLE);
}
}
helper.setText(R.id.tv_store_status, status);
helper.setText(R.id.tv_store_count, mContext.getString(R.string.common) + item.getGoods_number() + mContext.getString(R.string.components_total));
helper.setText(R.id.tv_store_price, UIUtile.stringToPriceTow(item.getReal_pay_price()));
helper.addOnClickListener(R.id.rv_item_mall_order, R.id.tv_store_order_cancel, R.id.tv_store_order_pay, R.id.tv_store_order_sure,R.id.tv_store_evaluate);
RecyclerView recyclerView = helper.getView(R.id.rv_item_mall_order);
recyclerView.setLayoutManager(new LinearLayoutManager(fragmentActivity));
MallOrderItemListAdapter adapter = new MallOrderItemListAdapter(R.layout.item_mall_order_layout, item.getOrders_goods_list());
adapter.setOnItemClickListener((adapter1, view, position) -> {
switch (item.getOrder_status()) {
case 0://待支付
context.startActivity(new Intent(context, MallOrderDetailsPayActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 1://已支付
context.startActivity(new Intent(context, MallOrderDetailsActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 2://退款申请中
context.startActivity(new Intent(context, MallOrderDetailsCancelActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 3://待收货
context.startActivity(new Intent(context, MallOrderDetailsActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 4://已完成
context.startActivity(new Intent(context, MallOrderDetailsCompleteActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 5://"已取消"
context.startActivity(new Intent(context, MallOrderDetailsCancelActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 6://仅退款
context.startActivity(new Intent(context, MallOrderDetailsCancelActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 7:
context.startActivity(new Intent(context, MallOrderDetailsCancelActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 8:
context.startActivity(new Intent(context, MallOrderDetailsCancelActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 9:
context.startActivity(new Intent(context, MallOrderDetailsCancelActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
case 10:
context.startActivity(new Intent(context, MallOrderDetailsCancelActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
default:
context.startActivity(new Intent(context, MallOrderDetailsActivity.class).putExtra(ConstantsRestaurantType.UUID, item.getUuid()));
break;
}
});
recyclerView.setAdapter(adapter);
}
}
package cn.dankal.client.adapter.personal;
import android.support.annotation.Nullable;
import android.util.SparseBooleanArray;
import android.widget.CheckBox;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.personal.CollectShopEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/5/14.
*/
public class MyCollectAdapter extends BaseQuickAdapter<CollectShopEntity.DataBean, BaseViewHolder> {
public boolean isAllSelect = false;//是否全选
public SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
public MyCollectAdapter(int layoutResId, @Nullable List<CollectShopEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, CollectShopEntity.DataBean item) {
if (item.getGoods_specs_vo() != null && item.getGoods_specs_vo().size() > 0) {
CollectShopEntity.DataBean.GoodsSpecsVoBean goodsSpecsVoBean = item.getGoods_specs_vo().get(0);
if (goodsSpecsVoBean != null) {
helper.setText(R.id.tv_collect_price, UIUtile.stringToPrice(goodsSpecsVoBean.getUnit_price()));
helper.setText(R.id.tv_collect_price_original, UIUtile.stringToPrice(goodsSpecsVoBean.getOriginal_price()));
}
}
helper.setText(R.id.tv_collect_name, item.getGoods_name());
helper.setText(R.id.tv_collect_desc, item.getGoods_desc());
helper.setText(R.id.tv_collect_sales, item.getSales() + mContext.getString(R.string.personal_payment));
List<String> imageList = item.getImg_list_temp();
if (imageList != null && imageList.size() > 0) {
PicUtils.loadNormal(imageList.get(0), helper.getView(R.id.iv_shop));
}
CheckBox checkBox = helper.getView(R.id.cb_choose_service);
checkBox.setChecked(isAllSelect);
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> sparseBooleanArray.put(helper.getAdapterPosition(), isChecked));
}
}
package cn.dankal.client.adapter.personal;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.user.CouponListEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/5/5.
*/
public class MyCouponAdapter extends BaseQuickAdapter<CouponListEntity.DataBean, BaseViewHolder> {
private int type = 0;//0,选择优惠券,1,列表进入
public MyCouponAdapter(int layoutResId, @Nullable List<CouponListEntity.DataBean> data, int type) {
super(layoutResId, data);
this.type = type;
}
@Override
protected void convert(BaseViewHolder helper, CouponListEntity.DataBean item) {
CouponListEntity.DataBean.CouponVoBean couponVoBean = item.getCoupon_vo();
helper.setText(R.id.tv_coupon_title, couponVoBean.getName());
if (couponVoBean.getCoupon_type() == 0) {//满减优惠券
helper.setText(R.id.tv_coupon_full, "₩" + couponVoBean.getReduce());
} else {//满折优惠券
helper.setText(R.id.tv_coupon_full, couponVoBean.getReduce() + mContext.getString(R.string.zhe));
}
try {
String startTime = couponVoBean.getEffective_time().split(" ")[0];
String endTime = couponVoBean.getExpires_time().split(" ")[0];
helper.setText(R.id.tv_coupon_time, startTime + mContext.getString(R.string.to) + endTime);
} catch (Exception e) {
e.printStackTrace();
}
ImageView imageView = helper.getView(R.id.iv_state);
if (imageView != null) {
if (couponVoBean.getCoupon_status() == 2) {//已过期
imageView.setImageResource(R.mipmap.pic_home_order_coupon_invalid);
}
if (item.getIs_use() == 1) {//已使用
imageView.setImageResource(R.mipmap.pic_home_order_coupon_use);
}
}
TextView tvUser = helper.getView(R.id.tv_user);
if (type == 0) {
if (tvUser != null)
tvUser.setVisibility(View.VISIBLE);
} else {
if (tvUser != null)
tvUser.setVisibility(View.INVISIBLE);
}
}
}
package cn.dankal.client.adapter.personal;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.personal.QueueEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/5/8.
*/
public class QueueListAdapter extends BaseQuickAdapter<QueueEntity.HotelQueueListBean, BaseViewHolder> {
private int type;
public QueueListAdapter(int layoutResId, @Nullable List<QueueEntity.HotelQueueListBean> data, int type) {
super(layoutResId, data);
this.type = type;
}
@Override
protected void convert(BaseViewHolder helper, QueueEntity.HotelQueueListBean item) {
helper.setText(R.id.tv_queue_title, item.getHotel_name());
helper.setText(R.id.tv_queue_number_tow, item.getPrefix() + item.getQueue_number());
helper.setText(R.id.tv_table_specs, item.getTable_specs());
if (type == 0) {
helper.setText(R.id.tv_queue_waiting_count, item.getTables_number());
helper.setText(R.id.tv_queue_minute_count, ">" + item.getWait_time());
} else {
String status = "";
TextView textViewState = helper.getView(R.id.tv_queue_state);
switch (item.getIs_over_number()) {
case 0:
status = mContext.getString(R.string.in_the_ine);
textViewState.setTextColor(ContextCompat.getColor(mContext, R.color.btn_bg));
break;
case 1:
status = mContext.getString(R.string.successful_queuing);
textViewState.setTextColor(ContextCompat.getColor(mContext, R.color.btn_bg));
break;
case 2:
status = mContext.getString(R.string.passed_number);
textViewState.setTextColor(ContextCompat.getColor(mContext, R.color.color99));
break;
}
textViewState.setText(status);
}
}
}
package cn.dankal.client.adapter.personal;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.personal.LeaveNotesListEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/5/17.
*/
public class ReplyMessageAdapter extends BaseQuickAdapter<LeaveNotesListEntity.DataBean.InsideNotesListListBean, BaseViewHolder> {
public ReplyMessageAdapter(int layoutResId, @Nullable List<LeaveNotesListEntity.DataBean.InsideNotesListListBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, LeaveNotesListEntity.DataBean.InsideNotesListListBean item) {
helper.setText(R.id.tv_reply_content, item.getContent());
}
}
package cn.dankal.client.adapter.shop;
import android.support.annotation.Nullable;
import android.view.View;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.client.R;
import cn.dankal.entities.shop.AddressEntity;
/**
* Created by zhengpeng on 2019/5/7.
*/
public class AddressManagerAdapter extends BaseQuickAdapter<AddressEntity.DataBean, BaseViewHolder> {
public AddressManagerAdapter(int layoutResId, @Nullable List<AddressEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, AddressEntity.DataBean item) {
helper.addOnClickListener(R.id.tv_right_default, R.id.tv_right_edit, R.id.tv_right_delete, R.id.content);
if (item.getIs_default() == 1) {
helper.getView(R.id.tv_address_default).setVisibility(View.VISIBLE);
} else {
helper.getView(R.id.tv_address_default).setVisibility(View.GONE);
}
helper.setText(R.id.tv_address_name, mContext.getString(R.string.consignee) + item.getName());
helper.setText(R.id.tv_address_info, item.getAddress() + item.getDetail());
helper.setText(R.id.tv_address_phone, item.getPhone());
}
}
package cn.dankal.client.adapter.shop;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.shop.CommentContentEntity;
/**
* Created by zhengpeng on 2019/5/6.
*/
public class CommentContentAdapter extends BaseQuickAdapter<CommentContentEntity, BaseViewHolder> {
public CommentContentAdapter(int layoutResId, @Nullable List<CommentContentEntity> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, CommentContentEntity item) {
}
}
package cn.dankal.client.adapter.shop;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/7/15.
*/
public class CommentImageAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
public CommentImageAdapter(int layoutResId, @Nullable List<String> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, String item) {
PicUtils.loadNormal(item, helper.getView(R.id.iv_comment));
}
}
package cn.dankal.client.adapter.shop;
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.SparseBooleanArray;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.client.R;
import cn.dankal.entities.shop.CommentTypeEntity;
/**
* Created by zhengpeng on 2019/5/6.
*/
public class CommentTypeAdapter extends BaseQuickAdapter<CommentTypeEntity, BaseViewHolder> {
public SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
private Context context;
public CommentTypeAdapter(Context context, int layoutResId, @Nullable List<CommentTypeEntity> data) {
super(layoutResId, data);
this.context = context;
sparseBooleanArray.put(0, true);
}
@Override
protected void convert(BaseViewHolder helper, CommentTypeEntity item) {
helper.setText(R.id.tv_type_text,item.getTypeText());
if (sparseBooleanArray.get(helper.getAdapterPosition())) {
helper.setBackgroundColor(R.id.cl_type_layout, context.getResources().getColor(R.color.bg_FAD0D0));
helper.setTextColor(R.id.tv_type_text, context.getResources().getColor(R.color.btn_bg));
helper.setVisible(R.id.tv_type_tag, true);
} else {
helper.setBackgroundColor(R.id.cl_type_layout, context.getResources().getColor(R.color.bg_E7EAED));
helper.setTextColor(R.id.tv_type_text, context.getResources().getColor(R.color.black));
helper.setVisible(R.id.tv_type_tag, false);
}
}
}
package cn.dankal.client.adapter.shop;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.home.ExpressEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/5/11.
*/
public class ExpressAdapter extends BaseQuickAdapter<ExpressEntity.TrackingDetailsBean, BaseViewHolder> {
public ExpressAdapter(int layoutResId, @Nullable List<ExpressEntity.TrackingDetailsBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, ExpressEntity.TrackingDetailsBean item) {
helper.setText(R.id.tv_logistics_content, item.getWhere());
helper.setText(R.id.tv_logistics_time, item.getTimeString());
if (helper.getAdapterPosition() != 0) {
ImageView ivTag = helper.getView(R.id.iv_tag);
ivTag.setImageResource(R.mipmap.ic_point);
//helper.setVisible(R.id.tv_item_line, true);
}
}
}
package cn.dankal.client.adapter.shop;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.tools.DateUtils;
import com.luck.picture.lib.tools.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/5/13.
*/
public class GridImageAdapter extends
RecyclerView.Adapter<GridImageAdapter.ViewHolder> {
public static final int TYPE_CAMERA = 1;
public static final int TYPE_PICTURE = 2;
private LayoutInflater mInflater;
private List<LocalMedia> list = new ArrayList<>();
private int selectMax = 9;
private Context context;
/**
* 点击添加图片跳转
*/
private onAddPicClickListener mOnAddPicClickListener;
public interface onAddPicClickListener {
void onAddPicClick();
}
public GridImageAdapter(Context context, onAddPicClickListener mOnAddPicClickListener) {
this.context = context;
mInflater = LayoutInflater.from(context);
this.mOnAddPicClickListener = mOnAddPicClickListener;
}
public void setSelectMax(int selectMax) {
this.selectMax = selectMax;
}
public void setList(List<LocalMedia> list) {
this.list = list;
}
public class ViewHolder extends RecyclerView.ViewHolder {
ImageView mImg;
LinearLayout ll_del;
TextView tv_duration;
TextView tvTip;
public ViewHolder(View view) {
super(view);
mImg = (ImageView) view.findViewById(R.id.fiv);
ll_del = (LinearLayout) view.findViewById(R.id.ll_del);
tv_duration = (TextView) view.findViewById(R.id.tv_duration);
tvTip = view.findViewById(R.id.tv_tip_text);
}
}
@Override
public int getItemCount() {
if (list.size() < selectMax) {
return list.size() + 1;
} else {
return list.size();
}
}
@Override
public int getItemViewType(int position) {
if (isShowAddItem(position)) {
return TYPE_CAMERA;
} else {
return TYPE_PICTURE;
}
}
/**
* 创建ViewHolder
*/
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = mInflater.inflate(R.layout.gv_filter_image,
viewGroup, false);
final ViewHolder viewHolder = new ViewHolder(view);
return viewHolder;
}
private boolean isShowAddItem(int position) {
int size = list.size() == 0 ? 0 : list.size();
return position == size;
}
/**
* 设置值
*/
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int position) {
//少于8张,显示继续添加的图标
if (getItemViewType(position) == TYPE_CAMERA) {
viewHolder.mImg.setImageResource(R.mipmap.pic_mall_order_comment);
viewHolder.mImg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mOnAddPicClickListener.onAddPicClick();
}
});
viewHolder.ll_del.setVisibility(View.INVISIBLE);
viewHolder.tvTip.setVisibility(View.VISIBLE);
} else {
viewHolder.tvTip.setVisibility(View.GONE);
viewHolder.ll_del.setVisibility(View.VISIBLE);
viewHolder.ll_del.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int index = viewHolder.getAdapterPosition();
// 这里有时会返回-1造成数据下标越界,具体可参考getAdapterPosition()源码,
// 通过源码分析应该是bindViewHolder()暂未绘制完成导致,知道原因的也可联系我~感谢
if (index != RecyclerView.NO_POSITION) {
list.remove(index);
notifyItemRemoved(index);
notifyItemRangeChanged(index, list.size());
}
}
});
LocalMedia media = list.get(position);
int mimeType = media.getMimeType();
String path = "";
if (media.isCut() && !media.isCompressed()) {
// 裁剪过
path = media.getCutPath();
} else if (media.isCompressed() || (media.isCut() && media.isCompressed())) {
// 压缩过,或者裁剪同时压缩过,以最终压缩过图片为准
path = media.getCompressPath();
} else {
// 原图
path = media.getPath();
}
// 图片
if (media.isCompressed()) {
Log.i("compress image result:", new File(media.getCompressPath()).length() / 1024 + "k");
Log.i("压缩地址::", media.getCompressPath());
}
Log.i("原图地址::", media.getPath());
int pictureType = PictureMimeType.isPictureType(media.getPictureType());
if (media.isCut()) {
Log.i("裁剪地址::", media.getCutPath());
}
long duration = media.getDuration();
viewHolder.tv_duration.setVisibility(pictureType == PictureConfig.TYPE_VIDEO
? View.VISIBLE : View.GONE);
if (mimeType == PictureMimeType.ofAudio()) {
viewHolder.tv_duration.setVisibility(View.VISIBLE);
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.picture_audio);
StringUtils.modifyTextViewDrawable(viewHolder.tv_duration, drawable, 0);
} else {
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.video_icon);
StringUtils.modifyTextViewDrawable(viewHolder.tv_duration, drawable, 0);
}
viewHolder.tv_duration.setText(DateUtils.timeParse(duration));
if (mimeType == PictureMimeType.ofAudio()) {
viewHolder.mImg.setImageResource(R.drawable.audio_placeholder);
} else {
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(R.color.white)
.diskCacheStrategy(DiskCacheStrategy.ALL);
Glide.with(viewHolder.itemView.getContext())
.load(path)
.apply(options)
.into(viewHolder.mImg);
}
//itemView 的点击事件
if (mItemClickListener != null) {
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int adapterPosition = viewHolder.getAdapterPosition();
mItemClickListener.onItemClick(adapterPosition, v);
}
});
}
}
}
protected OnItemClickListener mItemClickListener;
public interface OnItemClickListener {
void onItemClick(int position, View v);
}
public void setOnItemClickListener(OnItemClickListener listener) {
this.mItemClickListener = listener;
}
}
package cn.dankal.client.adapter.shop;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.tools.DateUtils;
import com.luck.picture.lib.tools.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/5/13.
*/
public class GridImageEvaluationAdapter extends
RecyclerView.Adapter<GridImageEvaluationAdapter.ViewHolder> {
public static final int TYPE_CAMERA = 1;
public static final int TYPE_PICTURE = 2;
private LayoutInflater mInflater;
private List<LocalMedia> list = new ArrayList<>();
private int selectMax = 9;
private Context context;
private int mPoint = 0;//指示器用来标识,当前是哪一个商品
/**
* 点击添加图片跳转
*/
private onAddPicClickListener mOnAddPicClickListener;
public interface onAddPicClickListener {
void onAddPicClick(int position);
}
public GridImageEvaluationAdapter(Context context, int point, onAddPicClickListener mOnAddPicClickListener) {
this.context = context;
mInflater = LayoutInflater.from(context);
this.mOnAddPicClickListener = mOnAddPicClickListener;
this.mPoint = point;
}
public void setSelectMax(int selectMax) {
this.selectMax = selectMax;
}
public void setList(List<LocalMedia> list) {
this.list = list;
}
public class ViewHolder extends RecyclerView.ViewHolder {
ImageView mImg;
LinearLayout ll_del;
TextView tv_duration;
TextView tvTip;
public ViewHolder(View view) {
super(view);
mImg = (ImageView) view.findViewById(R.id.fiv);
ll_del = (LinearLayout) view.findViewById(R.id.ll_del);
tv_duration = (TextView) view.findViewById(R.id.tv_duration);
tvTip = view.findViewById(R.id.tv_tip_text);
}
}
@Override
public int getItemCount() {
if (list.size() < selectMax) {
return list.size() + 1;
} else {
return list.size();
}
}
@Override
public int getItemViewType(int position) {
if (isShowAddItem(position)) {
return TYPE_CAMERA;
} else {
return TYPE_PICTURE;
}
}
/**
* 创建ViewHolder
*/
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = mInflater.inflate(R.layout.gv_filter_image,
viewGroup, false);
final ViewHolder viewHolder = new ViewHolder(view);
return viewHolder;
}
private boolean isShowAddItem(int position) {
int size = list.size() == 0 ? 0 : list.size();
return position == size;
}
/**
* 设置值
*/
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int position) {
//少于8张,显示继续添加的图标
if (getItemViewType(position) == TYPE_CAMERA) {
viewHolder.mImg.setImageResource(R.mipmap.pic_mall_order_comment);
viewHolder.mImg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mOnAddPicClickListener.onAddPicClick(mPoint);
}
});
viewHolder.ll_del.setVisibility(View.INVISIBLE);
viewHolder.tvTip.setVisibility(View.VISIBLE);
} else {
viewHolder.tvTip.setVisibility(View.GONE);
viewHolder.ll_del.setVisibility(View.VISIBLE);
viewHolder.ll_del.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int index = viewHolder.getAdapterPosition();
// 这里有时会返回-1造成数据下标越界,具体可参考getAdapterPosition()源码,
// 通过源码分析应该是bindViewHolder()暂未绘制完成导致,知道原因的也可联系我~感谢
if (index != RecyclerView.NO_POSITION) {
list.remove(index);
notifyItemRemoved(index);
notifyItemRangeChanged(index, list.size());
}
}
});
LocalMedia media = list.get(position);
int mimeType = media.getMimeType();
String path = "";
if (media.isCut() && !media.isCompressed()) {
// 裁剪过
path = media.getCutPath();
} else if (media.isCompressed() || (media.isCut() && media.isCompressed())) {
// 压缩过,或者裁剪同时压缩过,以最终压缩过图片为准
path = media.getCompressPath();
} else {
// 原图
path = media.getPath();
}
// 图片
if (media.isCompressed()) {
Log.i("compress image result:", new File(media.getCompressPath()).length() / 1024 + "k");
Log.i("压缩地址::", media.getCompressPath());
}
Log.i("原图地址::", media.getPath());
int pictureType = PictureMimeType.isPictureType(media.getPictureType());
if (media.isCut()) {
Log.i("裁剪地址::", media.getCutPath());
}
long duration = media.getDuration();
viewHolder.tv_duration.setVisibility(pictureType == PictureConfig.TYPE_VIDEO
? View.VISIBLE : View.GONE);
if (mimeType == PictureMimeType.ofAudio()) {
viewHolder.tv_duration.setVisibility(View.VISIBLE);
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.picture_audio);
StringUtils.modifyTextViewDrawable(viewHolder.tv_duration, drawable, 0);
} else {
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.video_icon);
StringUtils.modifyTextViewDrawable(viewHolder.tv_duration, drawable, 0);
}
viewHolder.tv_duration.setText(DateUtils.timeParse(duration));
if (mimeType == PictureMimeType.ofAudio()) {
viewHolder.mImg.setImageResource(R.drawable.audio_placeholder);
} else {
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(R.color.white)
.diskCacheStrategy(DiskCacheStrategy.ALL);
Glide.with(viewHolder.itemView.getContext())
.load(path)
.apply(options)
.into(viewHolder.mImg);
}
//itemView 的点击事件
if (mItemClickListener != null) {
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int adapterPosition = viewHolder.getAdapterPosition();
mItemClickListener.onItemClick(adapterPosition, v);
}
});
}
}
}
protected OnItemClickListener mItemClickListener;
public interface OnItemClickListener {
void onItemClick(int position, View v);
}
public void setOnItemClickListener(OnItemClickListener listener) {
this.mItemClickListener = listener;
}
}
package cn.dankal.client.adapter.shop;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.shop.ConsultHistoryEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/5/11.
*/
public class LogisticsAdapter extends BaseQuickAdapter<ConsultHistoryEntity.DataBean, BaseViewHolder> {
public LogisticsAdapter(int layoutResId, @Nullable List<ConsultHistoryEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, ConsultHistoryEntity.DataBean item) {
helper.setText(R.id.tv_logistics_content, item.getContent());
helper.setText(R.id.tv_logistics_time, item.getCreate_time());
if (helper.getAdapterPosition() != 0) {
ImageView ivTag = helper.getView(R.id.iv_tag);
ivTag.setImageResource(R.mipmap.ic_point);
helper.setVisible(R.id.tv_item_line,false);
}
}
}
package cn.dankal.client.adapter.shop;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.shop.StoreEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/4/24.
*/
public class MallAdapter extends BaseQuickAdapter<StoreEntity.DataBean, BaseViewHolder> {
public MallAdapter(int layoutResId, @Nullable List<StoreEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, StoreEntity.DataBean item) {
helper.setText(R.id.tv_recommend_name, item.getStore_name());
String sale = (item.getSales_all() != null) ? item.getSales_all() : "0";
helper.setText(R.id.tv_recommend_sale, mContext.getString(R.string.monthly_sale) + sale);
helper.setText(R.id.tv_recommend_address, item.getAddress());
helper.setText(R.id.tv_recommend_distance, mContext.getString(R.string.distance) + item.getDistance());
ImageView imageView = helper.getView(R.id.iv_recommend_picture);
String images = item.getImg_list();
if (!TextUtils.isEmpty(images)) {
PicUtils.loadNormal(images, imageView);
}
}
}
package cn.dankal.client.adapter.shop;
import android.content.Context;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.shop.MerchantShopEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/4/28.
*/
public class MallTypeContentAdapter extends BaseQuickAdapter<MerchantShopEntity.DataBean, BaseViewHolder> {
private Context context;
public MallTypeContentAdapter(Context context, int layoutResId, @Nullable List<MerchantShopEntity.DataBean> data) {
super(layoutResId, data);
this.context = context;
}
@Override
protected void convert(BaseViewHolder helper, MerchantShopEntity.DataBean item) {
helper.setText(R.id.tv_shop_content_name, item.getGoods_name());
helper.setText(R.id.tv_shop_content_description, mContext.getString(R.string.monthly_sale) + item.getSales());
List<MerchantShopEntity.DataBean.GoodsSpecsVoBean> goodsSpecsVoBeans = item.getGoods_specs_vo();
if (goodsSpecsVoBeans != null && goodsSpecsVoBeans.size() > 0) {
helper.setText(R.id.tv_shop_content_price, UIUtile.stringToPrice(goodsSpecsVoBeans.get(0).getUnit_price()));
}
List<String> listImage = item.getImg_list_temp();
if (listImage != null && listImage.size() > 0) {
PicUtils.loadNormal(listImage.get(0), helper.getView(R.id.iv_image_shop));
}
}
}
package cn.dankal.client.adapter.shop;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutCompat;
import android.util.SparseBooleanArray;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.shop.MerchantHomeEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/4/28.
*/
public class MallTypeTitleAdapter extends BaseQuickAdapter<MerchantHomeEntity.StoreTypeListBean, BaseViewHolder> {
public SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
private Context context;
public MallTypeTitleAdapter(Context context, int layoutResId, @Nullable List<MerchantHomeEntity.StoreTypeListBean> data) {
super(layoutResId, data);
this.context = context;
sparseBooleanArray.put(0, true);//初始化选中第一个
}
@Override
protected void convert(BaseViewHolder helper, MerchantHomeEntity.StoreTypeListBean item) {
helper.setText(R.id.tv_menu_type, item.getName());
LinearLayoutCompat linearLayoutCompat = helper.getView(R.id.ll_item_title);
if (sparseBooleanArray.get(helper.getAdapterPosition())) {
helper.setVisible(R.id.tv_item_title_tag, true);
linearLayoutCompat.setBackgroundColor(context.getResources().getColor(R.color.white));
} else {
helper.setVisible(R.id.tv_item_title_tag, false);
linearLayoutCompat.setBackgroundColor(context.getResources().getColor(R.color.btn_bg_tow));
}
}
}
package cn.dankal.client.adapter.shop;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.shop.QueueEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/4/29.
*/
public class QueueAdapter extends BaseQuickAdapter<QueueEntity.DataBean, BaseViewHolder> {
public QueueAdapter(int layoutResId, @Nullable List<QueueEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, QueueEntity.DataBean item) {
helper.setText(R.id.tv_tables_name, item.getTables_name());
helper.setText(R.id.tv_number_min_max, item.getNumber_min() + "-" + item.getNumber_max() + mContext.getString(R.string.people));
helper.setText(R.id.tv_time, mContext.getString(R.string.about) + item.getWait_time() + mContext.getString(R.string.minute));
helper.setText(R.id.tv_front, mContext.getString(R.string.ahead) + item.getTables_number() + mContext.getString(R.string.table));
}
}
package cn.dankal.client.adapter.shop;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.shop.ShopEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/4/24.
*/
public class ShopAdapter extends BaseQuickAdapter<ShopEntity.DataBean, BaseViewHolder> {
public ShopAdapter(int layoutResId, @Nullable List<ShopEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, ShopEntity.DataBean item) {
helper.setText(R.id.iv_item_shop_title, item.getGoods_name());
helper.setText(R.id.tv_item_shop_description, item.getGoods_desc());
List<ShopEntity.DataBean.GoodsSpecsVoBean> goodsSpecsVoBeanList = item.getGoods_specs_vo();
if (goodsSpecsVoBeanList != null && goodsSpecsVoBeanList.size() > 0) {
ShopEntity.DataBean.GoodsSpecsVoBean goodsSpecsVoBean = goodsSpecsVoBeanList.get(0);
TextView tvOriginalPrice = helper.getView(R.id.tv_item_original_price);
tvOriginalPrice.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
tvOriginalPrice.setText(UIUtile.stringToPrice(goodsSpecsVoBean.getOriginal_price()));
helper.setText(R.id.tv_item_current_price, UIUtile.stringToPrice(goodsSpecsVoBean.getUnit_price()));
}
helper.setText(R.id.tv_item_current_sales, item.getSales() + mContext.getString(R.string.personal_payment));
ImageView imageView = helper.getView(R.id.iv_item_shop_image);
List<String> listImage = item.getImg_list_temp();
if (listImage != null && listImage.size() > 0) {
PicUtils.loadNormal(listImage.get(0), imageView);
}
}
}
package cn.dankal.client.adapter.shop;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.shop.RecommendShopEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/4/24.
*/
public class ShopResultAdapter extends BaseQuickAdapter<RecommendShopEntity.DataBean, BaseViewHolder> {
public ShopResultAdapter(int layoutResId, @Nullable List<RecommendShopEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, RecommendShopEntity.DataBean item) {
helper.setText(R.id.iv_item_shop_title, item.getGoods_name());
helper.setText(R.id.tv_item_shop_description, item.getGoods_desc());
List<RecommendShopEntity.DataBean.GoodsSpecsVoBean> goodsSpecsVoBeanList = item.getGoods_specs_vo();
if (goodsSpecsVoBeanList != null && goodsSpecsVoBeanList.size() > 0) {
RecommendShopEntity.DataBean.GoodsSpecsVoBean goodsSpecsVoBean = goodsSpecsVoBeanList.get(0);
helper.setText(R.id.tv_item_current_price, UIUtile.stringToPrice(goodsSpecsVoBean.getUnit_price()));
TextView tvOriginalPrice = helper.getView(R.id.tv_item_original_price);
tvOriginalPrice.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
PicUtils.loadNormal(goodsSpecsVoBeanList.get(0).getImg_list(), helper.getView(R.id.iv_item_shop_image));
}
helper.setText(R.id.tv_item_current_sales, item.getSales() + mContext.getString(R.string.personal_payment));
}
}
package cn.dankal.client.adapter.shop;
import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.PicUtil;
import cn.dankal.basiclib.widget.AdaptTextView;
import cn.dankal.client.R;
import cn.dankal.entities.shop.ShopTypeContentEntity;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/4/28.
*/
public class ShopTypeContentAdapter extends BaseQuickAdapter<ShopTypeContentEntity.DataBean, BaseViewHolder> {
private Context context;
private int showState = -1;
public int isStamp = 0;
public ShopTypeContentAdapter(Context context, int layoutResId, @Nullable List<ShopTypeContentEntity.DataBean> data) {
super(layoutResId, data);
this.context = context;
}
@Override
protected void convert(BaseViewHolder helper, ShopTypeContentEntity.DataBean item) {
helper.setText(R.id.tv_shop_content_name, item.getGoods_name());
helper.setText(R.id.tv_shop_content_sales, mContext.getString(R.string.monthly_sale) + item.getSales());
ShopTypeContentEntity.DataBean.GoodsSpecsVoBean goodsSpecsVoBean = item.getGoods_specs_vo();
if (goodsSpecsVoBean != null) {
AdaptTextView adaptTextView = helper.getView(R.id.tv_shop_content_price);
if (item.getIsStamp() == 1 && isStamp == 1) {
adaptTextView.setText(UIUtile.stringToStamp(goodsSpecsVoBean.getStamp_number()));
} else {
adaptTextView.setText(UIUtile.stringToPrice(goodsSpecsVoBean.getGoods_price()));
}
}
List<String> imageList = item.getImg_list_temp();
if (imageList != null && imageList.size() > 0) {
PicUtil.setPhoto(helper.getView(R.id.iv_shop_picture), item.getImg_list_temp().get(0));
}
if (showState == 0) {
TextView tvSelectFormat = helper.getView(R.id.tv_select_format);
tvSelectFormat.setBackground(context.getResources().getDrawable(R.drawable.bg_select_type_unavailable));
}
helper.addOnClickListener(R.id.tv_select_format, R.id.ll_shop_bg);
}
public void setShowState(int showState) {
this.showState = showState;
notifyDataSetChanged();
}
public void setIsStamp(int is_stamp) {
this.isStamp = is_stamp;
notifyDataSetChanged();
}
}
package cn.dankal.client.adapter.shop;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutCompat;
import android.util.SparseBooleanArray;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.entities.home.RestaurantDetailEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/4/28.
*/
public class ShopTypeTitleAdapter extends BaseQuickAdapter<RestaurantDetailEntity.GoodsTypeListBean, BaseViewHolder> {
public SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
private Context context;
public ShopTypeTitleAdapter(Context context, int layoutResId, @Nullable List<RestaurantDetailEntity.GoodsTypeListBean> data) {
super(layoutResId, data);
this.context = context;
sparseBooleanArray.put(0, true);//初始化选中第一个
}
@Override
protected void convert(BaseViewHolder helper, RestaurantDetailEntity.GoodsTypeListBean item) {
helper.setText(R.id.tv_menu_type, item.getName());
LinearLayoutCompat linearLayoutCompat = helper.getView(R.id.ll_item_title);
if (sparseBooleanArray.get(helper.getAdapterPosition())) {
helper.setVisible(R.id.tv_item_title_tag, true);
linearLayoutCompat.setBackgroundColor(context.getResources().getColor(R.color.white));
} else {
helper.setVisible(R.id.tv_item_title_tag, false);
linearLayoutCompat.setBackgroundColor(context.getResources().getColor(R.color.btn_bg_tow));
}
}
}
package cn.dankal.client.adapter.shop;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.shop.StoreEntity;
import cn.dankal.client.R;
/**
* Created by zhengpeng on 2019/4/24.
*/
public class StoreAdapter extends BaseQuickAdapter<StoreEntity.DataBean, BaseViewHolder> {
public StoreAdapter(int layoutResId, @Nullable List<StoreEntity.DataBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, StoreEntity.DataBean item) {
helper.setText(R.id.iv_item_shop_title, item.getStore_name());
helper.setText(R.id.tv_item_shop_description, item.getAddress());
//List<ShopEntity.DataBean.GoodsSpecsVoBean> goodsSpecsVoBeanList = item.getGoods_specs_vo();
/*if (goodsSpecsVoBeanList != null && goodsSpecsVoBeanList.size() > 0) {
ShopEntity.DataBean.GoodsSpecsVoBean goodsSpecsVoBean = goodsSpecsVoBeanList.get(0);
TextView tvOriginalPrice = helper.getView(R.id.tv_item_original_price);
tvOriginalPrice.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
tvOriginalPrice.setText(UIUtile.stringToPrice(goodsSpecsVoBean.getOriginal_price()));
helper.setText(R.id.tv_item_current_price, UIUtile.stringToPrice(goodsSpecsVoBean.getUnit_price()));
}*/
helper.getView(R.id.tv_item_original_price).setVisibility(View.GONE);
helper.getView(R.id.tv_item_current_price).setVisibility(View.GONE);
helper.setText(R.id.tv_item_current_sales, item.getSales_all() + mContext.getString(R.string.personal_payment));
ImageView imageView = helper.getView(R.id.iv_item_shop_image);
PicUtils.loadNormal(item.getImg_list(), imageView);
}
}
package cn.dankal.client.adapter.shop;
import android.support.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import java.util.List;
import cn.dankal.basiclib.util.image.PicUtils;
import cn.dankal.entities.car.SettleEntity;
import cn.dankal.client.R;
import cn.dankal.client.util.UIUtile;
/**
* Created by zhengpeng on 2019/5/7.
*/
public class SureOrderAdapter extends BaseQuickAdapter<SettleEntity.UserStorePaySettleListBean.StoreCartGoodsListBean, BaseViewHolder> {
public SureOrderAdapter(int layoutResId, @Nullable List<SettleEntity.UserStorePaySettleListBean.StoreCartGoodsListBean> data) {
super(layoutResId, data);
}
@Override
protected void convert(BaseViewHolder helper, SettleEntity.UserStorePaySettleListBean.StoreCartGoodsListBean item) {
helper.setText(R.id.tv_sure_order_name, item.getGoods_name());
helper.setText(R.id.tv_sure_order_goods_desc, item.getGoods_specs());
helper.setText(R.id.tv_sure_order_goods_price, UIUtile.stringToPrice(item.getUnit_price()));
helper.setText(R.id.tv_sure_order_goods_count, "×" + item.getNumber());
PicUtils.loadNormal(item.getSpecs_img_list(), helper.getView(R.id.iv_sure_order_image));
}
}
package cn.dankal.client.constants;
/**
* Created by zhengpeng on 2019/4/23.
*/
public class ConstantsHomeType {
/**
* 主页头部模块
*/
public static final int HOME_HEAD = 0;
/**
* 主页菜单模块
*/
public static final int HOME_MENU = 1;
/**
* 扫一扫
*/
public static final int SCAN = 306;
/**
* 扫码内容
*/
public static final String CODED_CONTENT = "codedContent";
public static final String LATITUDE = "latitude";
public static final String LONGITUDE = "longitude";
}
package cn.dankal.client.constants;
/**
* Created by zhengpeng on 2019/5/30.
*/
public class ConstantsRestaurantType {
public static final String UUID="uuid";
}
package cn.dankal.client.constants;
/**
* Created by zhengpeng on 2019/5/23.
*/
public class ConstantsShopType {
public static final String STORE_UUID = "storeUuid";
public static final String GOODS_UUID = "goodsUuid";
public static final String MALL_TYPE = "type";
public static final String SHOP_ENTITY = "shop_entity";
public static final String ORDER_ENTITY = "order_entity";
public static final String ORDER_UUID = "order_uuid";
}
package cn.dankal.client.ui.car
import android.content.Intent
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.view.View
import android.widget.TextView
import api.MallServiceFactory
import cn.dankal.basiclib.base.fragment.BaseFragment
import cn.dankal.basiclib.rx.AbstractDialogSubscriber
import cn.dankal.basiclib.util.ToastUtils
import cn.dankal.entities.car.CartGoodsListEntity
import cn.dankal.client.R
import cn.dankal.client.adapter.car.CarShopAdapter
import cn.dankal.entities.car.ShopCarEntity
import cn.dankal.entities.event.UpdateCarEvent
import cn.dankal.client.constants.ConstantsShopType
import cn.dankal.client.ui.shop.SureOrderActivity
import cn.dankal.client.util.UIUtile
import io.reactivex.disposables.Disposable
import kotlinx.android.synthetic.main.fragment_car.*
import kotlinx.android.synthetic.main.fragment_select_coupon.*
import okhttp3.ResponseBody
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import java.util.HashMap
class CarFragment : BaseFragment(), View.OnClickListener {
private val shopCarList = mutableListOf<ShopCarEntity.DataBean>()
private var adapter: CarShopAdapter? = null
private val selectShopList = mutableListOf<CartGoodsListEntity.SettleCartGoodsListBeanX>()//当前选中的商品列表
private val deleteList = mutableListOf<String>()//当前选中需要删除的商品
override fun onClick(v: View?) {
when (v?.id) {
R.id.btn_car_sure -> {
selectShopList.clear()
var listData = adapter?.data
if (listData != null && listData.size > 0) {
for (i in 0 until listData.size) {//遍历所有店铺
var storeData = listData[i]//拿到店铺数据
var settleCartGoodsListBean = CartGoodsListEntity.SettleCartGoodsListBeanX()//配置需要提交结算的参数
var goodsList = mutableListOf<CartGoodsListEntity.SettleCartGoodsListBeanX.SettleCartGoodsListBean>()
for (j in 0 until storeData.store_cart_goods_list.size) {//遍历所有商品
var shopData = storeData.store_cart_goods_list[j]//拿到商品数据
if (shopData.isShopSelect) {//当前商品是否选中
settleCartGoodsListBean.store_uuid = shopData.store_uuid
var shopInfo = CartGoodsListEntity.SettleCartGoodsListBeanX.SettleCartGoodsListBean()
shopInfo.uuid = shopData.uuid
shopInfo.goods_specs_uuid = shopData.goods_specs_uuid
shopInfo.store_goods_uuid = shopData.store_goods_uuid
goodsList.add(shopInfo)
}
}
if (goodsList != null && goodsList.size > 0) {
settleCartGoodsListBean.settle_cart_goods_list = goodsList
selectShopList.add(settleCartGoodsListBean)
}
}
if (selectShopList == null || selectShopList.size == 0) {
ToastUtils.showShort(getString(R.string.please_select_the_item_you_want_to_pay_first))
return
}
if (selectShopList.size > 1) {
ToastUtils.showShort(getString(R.string.different_businesses))
return
}
var entity = CartGoodsListEntity()
entity.settle_cart_goods_list = selectShopList
var intent = Intent(activity, SureOrderActivity::class.java)
var bundle = Bundle()
bundle.putSerializable(ConstantsShopType.ORDER_ENTITY, entity)
intent.putExtras(bundle)
startActivity(intent)
} else {
ToastUtils.showShort(getString(R.string.no_items_yet_no_billing_yet))
}
}
R.id.tv_car_delete -> {//删除
deleteList.clear()
var listData = adapter?.data
if (listData != null && listData.size > 0) {
for (i in 0 until listData.size) {//遍历所有店铺
var storeData = listData[i]//拿到店铺数据
for (j in 0 until storeData.store_cart_goods_list.size) {//遍历所有商品
var shopData = storeData.store_cart_goods_list[j]//拿到商品数据
if (shopData.isShopSelect) {//当前商品是否选中
deleteList.add(shopData.uuid)
}
}
}
if (deleteList == null || deleteList.size == 0) {
ToastUtils.showShort(getString(R.string.please_select_the_item_you_want_to_delete_first))
return
}
operateDeleteCart()
} else {
ToastUtils.showShort(getString(R.string.no_items_yet_no_operation_at_this_time))
}
}
}
}
override fun getLayoutId(): Int {
return R.layout.fragment_car
}
override fun initComponents() {
EventBus.getDefault().register(this)
rv_shop_car.layoutManager = LinearLayoutManager(activity)
adapter = CarShopAdapter(activity, R.layout.item_car_shop, shopCarList)
adapter?.setSelectShowListen {
adapter?.let {
if (it.data.size > 0) {
var count = 0
var totalPrice = 0.0
for (entity in it.data) {
var shopList = entity.store_cart_goods_list
for (shop in shopList) {
if (shop.isShopSelect) {
++count
totalPrice += shop.unit_price.toDouble() * shop.number
}
}
}
tv_car_price.text = UIUtile.stringToPrice(totalPrice.toString())
btn_car_sure.text = getString(R.string.settlement) + "($count)"
}
}
}
rv_shop_car.adapter = adapter
//requestCartList()
btn_car_sure.setOnClickListener(this)
tv_car_delete.setOnClickListener(this)
}
override fun onResume() {
super.onResume()
requestCartList()
}
private fun requestCartList() {
MallServiceFactory.getCartList(1, 50).subscribe(object : AbstractDialogSubscriber<ShopCarEntity>(this) {
override fun onSubscribe(d: Disposable) {
addNetworkRequest(d)
}
override fun onNext(t: ShopCarEntity) {
var count = 0
for (i in 0 until t.data.size) {
count += t.data[i].store_cart_goods_list.size
}
tv_car_count.text = getString(R.string.total) + count + getString(R.string.Items)
shopCarList.clear()
shopCarList.addAll(t.data)
if (t.data == null || t.data.size == 0) {
var view = UIUtile.getView(R.layout.adapter_layout_personal_empty_data, rv_coupon_list)
var textTip = view.findViewById<TextView>(R.id.tv_text_tip)
textTip.text = getString(R.string.shopping_cart_is_empty)
adapter?.emptyView = view
tv_car_price.text = UIUtile.stringToPrice("0")
btn_car_sure.text = getString(R.string.settlement)
}
adapter?.let {
it.notifyDataSetChanged()
}
}
})
}
/**
* 删除商品
*/
private fun operateDeleteCart() {
showDialog("", getString(R.string.do_you_want_to_delete_the_selected_item), {
val map = HashMap<String, Any>()
map["cart_goods_list"] = deleteList
map["type"] = 2
MallServiceFactory.operateCart(map).subscribe(object : AbstractDialogSubscriber<ResponseBody>(this) {
override fun onNext(responseBody: ResponseBody) {
ToastUtils.showShort(getString(R.string.successfully_deleted))
requestCartList()
}
})
}, false, true)
}
companion object {
fun getInstance(): CarFragment = CarFragment()
}
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public fun onEvent(event: UpdateCarEvent) {
adapter?.let {
requestCartList()
EventBus.getDefault().removeStickyEvent(event)
}
}
override fun onDestroy() {
super.onDestroy()
EventBus.getDefault().unregister(this)
}
}
package cn.dankal.client.ui.home
import android.content.Intent
import android.widget.ImageView
import android.widget.TextView
import api.HomeServiceFactory
import cn.dankal.basiclib.base.activity.BaseListActivity
import cn.dankal.basiclib.rx.AbstractDialogSubscriber
import cn.dankal.basiclib.util.SPUtils
import cn.dankal.basiclib.util.ToastUtils
import cn.dankal.basiclib.util.image.PicUtils
import cn.dankal.entities.home.BottomAroundEntity
import cn.dankal.client.R
import cn.dankal.client.constants.ConstantsHomeType
import cn.dankal.client.ui.home.details.MerchantDetailsActivity
import cn.dankal.client.util.UIUtile
import com.chad.library.adapter.base.BaseViewHolder
import com.scwang.smartrefresh.layout.api.RefreshLayout
import kotlinx.android.synthetic.main.activity_nearby_merchant.*
import java.util.HashMap
class NearbyMerchantActivity : BaseListActivity<BottomAroundEntity.DataBean>() {
override fun getItemLayout(): Int {
return R.layout.item_merchant
}
private var page = 1
override fun initComponents() {
super.initComponents()
addSingleTitleBar(getString(R.string.nearby_shops))
requestListData(true)
ll_see_map.setOnClickListener { finish() }
}
override fun getLayoutId(): Int {
return R.layout.activity_nearby_merchant
}
override fun onLoadMore(refreshLayout: RefreshLayout) {
requestListData(false)
}
override fun onRefresh(refreshLayout: RefreshLayout) {
requestListData(true)
}
override fun onBind(holder: BaseViewHolder?, item: BottomAroundEntity.DataBean?) {
holder?.setText(R.id.tv_recommend_name, item?.hotel_name)
holder?.setText(R.id.tv_recommend_distance, getString(R.string.distance) + item?.distance)
holder?.setText(R.id.tv_recommend_address, item?.address)
holder?.setText(R.id.tv_recommend_sale, getString(R.string.monthly_sale) + item?.sales_all)
val imageView = holder?.getView<ImageView>(R.id.iv_recommend_picture)
imageView?.let {
PicUtils.loadNormal(item?.img_list, it)
}
holder?.itemView?.setOnClickListener { v -> startActivity(Intent(this@NearbyMerchantActivity, MerchantDetailsActivity::class.java).putExtra(MerchantDetailsActivity.HOTELUUID, item?.uuid)) }
}
private fun requestListData(isRefreshing: Boolean) {
if (isRefreshing) {
page = 1
} else {
++page
}
val maps = HashMap<String, Any>()
maps["business_status"] = ""
maps["distance"] = "10"
maps["hotel_type_uuid"] = ""
maps["lat"] = SPUtils.get(ConstantsHomeType.LATITUDE, "")
maps["lng"] = SPUtils.get(ConstantsHomeType.LONGITUDE, "")
maps["page_index"] = page
maps["page_size"] = "20"
maps["queue_status"] = ""
maps["search"] = ""
HomeServiceFactory.aroundList(maps).subscribe(object : AbstractDialogSubscriber<BottomAroundEntity>(this) {
override fun onNext(t: BottomAroundEntity) {
if (isRefreshing) {
mDataList.clear()
if (t.data != null && t.data.size > 0) {
mDataList.addAll(t.data)
} else {
if (rvList != null && adapter != null) {
var view = UIUtile.getView(R.layout.adapter_layout_personal_empty_data, rvList)
var tvTip = view.findViewById<TextView>(R.id.tv_text_tip)
tvTip.text = getString(R.string.there_is_no_business_nearby)
adapter.emptyView = view
}
}
refreshComplete()
} else {
loadMoreComplete()
if (t.data == null || t.data.size == 0) {
ToastUtils.showShort(getString(R.string.no_more))
return
}
mDataList.addAll(t.data)
}
notifyDataSetChanged()
}
})
}
}
package cn.dankal.client.ui.home
import cn.dankal.basiclib.base.activity.BaseActivity
import cn.dankal.client.R
import kotlinx.android.synthetic.main.activity_scan_result.*
class ScanResultActivity : BaseActivity() {
override fun getLayoutId(): Int {
return R.layout.activity_scan_result
}
override fun initComponents() {
addSingleTitleBar(getString(R.string.result_page))
tv_button_result.setOnClickListener {
finish()
}
}
}
package cn.dankal.client.ui.home.details
import android.content.Intent
import android.os.Bundle
import android.view.View
import cn.dankal.basiclib.base.fragment.BaseFragment
import cn.dankal.basiclib.util.UIUtils
import cn.dankal.basiclib.util.WebViewUtil
import cn.dankal.basiclib.widget.dialog.CallDialog
import cn.dankal.entities.home.RestaurantDetailEntity
import cn.dankal.client.R
import cn.dankal.client.ui.home.map.GoogleMapsMerchantActivity
import kotlinx.android.synthetic.main.fragment_details_info.*
private const val ARG_PARAM1 = "param1"
class DetailsInfoFragment : BaseFragment(), View.OnClickListener, CallDialog.OnCenterItemClickListener {
private var phone: String = ""
override fun OnCenterItemClick(dialog: CallDialog?, view: View?) {
when (view?.id) {
R.id.tv_item_call -> UIUtils.call(phone)
}
}
private var callDialog: CallDialog? = null
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_info_call -> {
callDialog?.let {
it.show()
}
// startActivity(Intent(activity, OrderResultActivity::class.java))
}
R.id.iv_location -> {
toMaps()
}
R.id.tv_merchant_address -> {
toMaps()
}
}
}
private fun toMaps() {
var intent = Intent(activity, GoogleMapsMerchantActivity::class.java)
var bundle = Bundle()
bundle.putSerializable(ARG_PARAM1, param1)
intent.putExtras(bundle)
startActivity(intent)
}
override fun getLayoutId(): Int {
return R.layout.fragment_details_info
}
override fun initComponents() {
arguments?.let {
param1 = it.getSerializable(ARG_PARAM1) as RestaurantDetailEntity?
}
iv_info_call.setOnClickListener(this)
iv_location.setOnClickListener(this)
tv_merchant_address.setOnClickListener(this)
//设置数据
param1?.apply {
tv_merchant_address.text = address
phone = waiter_phone
showWebDetails(hotel_details)
}
callDialog = CallDialog(this!!.activity, R.layout.dialog_item_call, intArrayOf(R.id.tv_item_call, R.id.tv_cancel), R.id.tv_store_phone, phone)
callDialog?.setOnCenterItemClickListener(this)
}
private fun showWebDetails(hotel_details: String?) {
val linkCss = "<style type=\"text/css\"> " +
"html,body {padding:0;margin:0;}" +
"img {" +
"width:100%;" +
"height:auto;" +
"}" +
"</style>"
val html = "<html><header>$linkCss</header>$hotel_details</body></html>"
WebViewUtil.initWebViewSettings(wb_hotel_details, activity)
WebViewUtil.loadData(wb_hotel_details, html)
}
private var param1: RestaurantDetailEntity? = null
companion object {
@JvmStatic
fun newInstance(entity: RestaurantDetailEntity) =
DetailsInfoFragment().apply {
arguments = Bundle().apply {
putSerializable(ARG_PARAM1, entity)
}
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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