依赖
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.jcodecraeer:xrecyclerview:1.3.2'
compile 'com.facebook.fresco:fresco:0.14.1'
compile 'com.android.support:design:26+'
compile 'com.xhb:xbanner:1.3.0'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'org.greenrobot:greendao:3.2.2'
权限
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
amin
notify_in
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--平移-->
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="50%p"
android:toYDelta="0"/>
<!--渐变-->
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
</set>
notify_out
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--平移-->
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="0"
android:toYDelta="-50%p"/>
<!--渐变-->
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0"/>
</set>
layout
activity_feileishow
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.administrator.jingdong.view.Feileishow">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_gravity="center_vertical"
android:layout_width="70px"
android:layout_height="70px"
android:src="@drawable/leftjiantou"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="80px"
android:layout_weight="1"
android:background="@drawable/home_title_bar_search_corner_bg"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="40px"
android:layout_height="40px"
android:layout_marginLeft="5dp"
android:src="@drawable/ss" />
<TextView
android:id="@+id/fl_sousuo"
android:layout_width="0dp"
android:layout_height="90px"
android:layout_marginLeft="3dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="1"
android:text="你好啊 我来啦 快跑啊"
android:textColor="#ffffff"
android:textSize="15sp" />
<ImageView
android:layout_width="40px"
android:layout_height="40px"
android:layout_marginRight="5dp"
android:src="@drawable/root" />
</LinearLayout>
<ImageView
android:id="@+id/qie"
android:layout_gravity="center_vertical"
android:layout_width="70px"
android:layout_height="70px"
android:src="@drawable/kind_grid"
/>
</LinearLayout>
<RadioGroup
android:id="@+id/rg"
android:layout_marginTop="20px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:textColor="@drawable/sousuo_bg"
android:checked="true"
android:textSize="70px"
android:button="@null"
android:gravity="center_horizontal"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:id="@+id/rb"
android:text="综合"/>
<RadioButton
android:textColor="@drawable/sousuo_bg"
android:id="@+id/rb1"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:gravity="center_horizontal"
android:text="销量"
android:textSize="70px" />
<RadioButton
android:textColor="@drawable/sousuo_bg"
android:textSize="70px"
android:button="@null"
android:gravity="center_horizontal"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:id="@+id/rb2"
android:text="价格"/>
</RadioGroup>
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/xrc"></com.jcodecraeer.xrecyclerview.XRecyclerView>
</LinearLayout>
activity_lunbotu
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.administrator.jingdong.view.Lunbotu">
<TextView
android:layout_marginTop="100px"
android:textSize="50px"
android:layout_marginLeft="620px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv"/>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/vp"></android.support.v4.view.ViewPager>
</LinearLayout>
activity_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.administrator.jingdong.MainActivity">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:id="@+id/viewpager"></android.support.v4.view.ViewPager>
<View
android:layout_width="match_parent"
android:layout_height="1.5dp"
android:background="#E3E0DA"></View>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/rg">
<RadioButton
android:checked="true"
android:background="@drawable/shouye_bg"
android:gravity="center_horizontal"
android:button="@null"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="180px"
android:id="@+id/shouye"/>
<RadioButton
android:background="@drawable/fenlei_bg"
android:gravity="center_horizontal"
android:button="@null"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="180px"
android:id="@+id/fenlei"/>
<RadioButton
android:background="@drawable/faxian_bg"
android:gravity="center_horizontal"
android:button="@null"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="180px"
android:id="@+id/faxian"/>
<RadioButton
android:background="@drawable/gouwuche"
android:gravity="center_horizontal"
android:button="@null"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="180px"
android:id="@+id/gouwuche"/>
<RadioButton
android:background="@drawable/wode_bg"
android:gravity="center_horizontal"
android:button="@null"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="180px"
android:id="@+id/wode"/>
</RadioGroup>
</LinearLayout>
activity_sousuo
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="300px"
android:layout_height="300px"
android:id="@+id/sd"></com.facebook.drawee.view.SimpleDraweeView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_marginTop="30px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/xiangqing_tv"/>
<TextView
android:textColor="#ff0000"
android:layout_marginTop="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/xiangqing_tv1"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
activity_sousuo1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_marginLeft="50dp"
android:layout_width="300px"
android:layout_height="300px"
android:id="@+id/sd"></com.facebook.drawee.view.SimpleDraweeView>
<TextView
android:layout_marginLeft="50px"
android:layout_marginTop="30px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/xiangqing_tv"/>
<TextView
android:layout_marginLeft="50px"
android:textColor="#ff0000"
android:layout_marginTop="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/xiangqing_tv1"/>
</LinearLayout>
activity_zhuce
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.administrator.jingdong.view.Zhuce">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="手机号:"
/>
<EditText
android:layout_width="0px"
android:layout_weight="8"
android:layout_height="wrap_content"
android:id="@+id/zhuce_tel"
android:hint="请输入手机号"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="密码:"
/>
<EditText
android:layout_width="0px"
android:layout_weight="8"
android:layout_height="wrap_content"
android:id="@+id/zhuce_pwd"
android:hint="请输入密码"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="30px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0px"
android:layout_weight="1.5"
android:layout_height="wrap_content"
android:text="手机验证码:"
/>
<EditText
android:layout_width="0px"
android:layout_weight="6"
android:layout_height="wrap_content"
android:id="@+id/zhuce_ed1"
android:hint="请输入验证码"/>
<Button
android:layout_width="0px"
android:layout_weight="3"
android:layout_height="wrap_content"
android:id="@+id/zhuce_bt"
android:text="获取验证码"/>
</LinearLayout>
<Button
android:layout_marginTop="20px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/zhuce_bt1"
android:text="立即注册"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
denglu
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.administrator.jingdong.view.Denglu">
<TextView
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40px"
android:text="京东登录"/>
<LinearLayout
android:layout_marginTop="50px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:gravity="center_horizontal"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="帐号"/>
<EditText
android:hint="请输入帐号"
android:id="@+id/ed"
android:layout_width="0px"
android:layout_weight="7"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:gravity="center_horizontal"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="密码"/>
<EditText
android:hint="请输入密码"
android:id="@+id/ed1"
android:layout_width="0px"
android:layout_weight="7"
android:layout_height="wrap_content" />
</LinearLayout>
<Button
android:layout_marginTop="20px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/wode_bt"
android:text="登录"
android:gravity="center_horizontal"/>
<TextView
android:layout_marginTop="30px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/wode_zhuce"
android:text="手机号快速注册"/>
</LinearLayout>
dengluchenggong
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300px"
android:orientation="horizontal"
android:background="@drawable/reg_bg"
>
<com.facebook.drawee.view.SimpleDraweeView
android:layout_marginTop="80px"
android:layout_width="150px"
android:layout_height="150px"
app:roundAsCircle="true"
android:id="@+id/sd"></com.facebook.drawee.view.SimpleDraweeView>
<TextView
android:id="@+id/wode_tv"
android:textColor="#ffffff"
android:layout_marginTop="130px"
android:layout_marginLeft="30px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40px"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/wode_iv1"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one1"/>
<ImageView
android:id="@+id/wode_iv2"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one2"/>
<ImageView
android:id="@+id/wode_iv3"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one3"/>
<ImageView
android:id="@+id/wode_iv4"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one4"/>
<ImageView
android:id="@+id/wode_iv5"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one5"/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="退出登录"
android:id="@+id/tui"/>
</LinearLayout>
f1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300px"
android:orientation="horizontal"
android:background="@drawable/b5a"
>
<com.facebook.drawee.view.SimpleDraweeView
android:layout_marginTop="80px"
android:layout_width="150px"
android:layout_height="150px"
app:roundAsCircle="true"
android:id="@+id/sd"></com.facebook.drawee.view.SimpleDraweeView>
<TextView
android:id="@+id/wode_tv"
android:textColor="#ffffff"
android:layout_marginTop="130px"
android:layout_marginLeft="30px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40px"
android:text="登录/注册"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/wode_iv1"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one1"/>
<ImageView
android:id="@+id/wode_iv2"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one2"/>
<ImageView
android:id="@+id/wode_iv3"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one3"/>
<ImageView
android:id="@+id/wode_iv4"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one4"/>
<ImageView
android:id="@+id/wode_iv5"
android:layout_width="0px"
android:layout_weight="1"
android:layout_height="wrap_content"
android:src="@drawable/main_one5"/>
</LinearLayout>
</LinearLayout>
faxian
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/scanning_img"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="15dp"
android:src="@drawable/scanning_cmmon" />
<ImageView
android:layout_centerInParent="true"
android:layout_width="64dp"
android:layout_height="32dp"
android:src="@drawable/find_icon"
/>
<ImageView
android:layout_alignParentRight="true"
android:id="@+id/advisory_img"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="15dp"
android:src="@drawable/advisory_common" />
<ImageView
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/advisory_img"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/my_care"
/>
</RelativeLayout>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tab"></android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:id="@+id/vp"/>
</LinearLayout>
feilei_left_zi
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="你猜"
android:layout_gravity="center_horizontal"
android:textSize="40px"
android:id="@+id/feilei_zuo_tv"
android:padding="30px"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
feilei_right
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="10dp"
android:layout_height="match_parent"
android:background="#fb9301" />
<TextView
android:id="@+id/right_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="10dp"
android:text="分类"
android:textColor="#f23005"
android:textSize="60px" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/right_rc"></android.support.v7.widget.RecyclerView>
</LinearLayout>
feilei_right_zi
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="170px"
android:layout_height="170px"
app:roundAsCircle="true"
android:id="@+id/sd"></com.facebook.drawee.view.SimpleDraweeView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="40px"
android:id="@+id/feilei_right_zi_tv"/>
</LinearLayout>
feileixiangqing
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tab"></android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:id="@+id/vp"/>
</LinearLayout>
feileixiangqing_fragment
<?xml version="1.0" encoding="utf-8"?>
<com.example.administrator.jingdong.myview.PageContainer
android:id="@+id/container"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.example.administrator.jingdong.myview.Page
android:id="@+id/pageOne"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.stx.xhb.xbanner.XBanner
android:id="@+id/xbnr"
app:AutoPlayTime="1000"
android:layout_width="match_parent"
android:layout_height="500px"></com.stx.xhb.xbanner.XBanner>
<TextView
android:textSize="50px"
android:text="你猜"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/feilei_xiangqing_fragment_title"/>
<TextView
android:textSize="50px"
android:layout_marginTop="30px"
android:text="85"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:id="@+id/feilei_xiangqing_fragment_price"/>
</LinearLayout>
</com.example.administrator.jingdong.myview.Page>
<com.example.administrator.jingdong.myview.Page
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/pageBehavior">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/web"></WebView>
</com.example.administrator.jingdong.myview.Page>
<include layout="@layout/rg"></include>
</com.example.administrator.jingdong.myview.PageContainer>
fenlei_left
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:padding="20px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="60px"
android:id="@+id/fenlei_tv"/>
</LinearLayout>
fenlei_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/fenlei_main_title"></include>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.v7.widget.RecyclerView
android:layout_width="0px"
android:layout_weight="3"
android:id="@+id/fenlei_left"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:layout_width="0px"
android:layout_weight="8"
android:id="@+id/fenlei_right"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
fenlei_main_title
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_gravity="center_vertical"
android:layout_width="70px"
android:layout_height="70px"
android:src="@drawable/leftjiantou"/>
<EditText
android:layout_marginLeft="20px"
android:layout_marginRight="20px"
android:drawableRight="@drawable/root"
android:drawableLeft="@drawable/ss"
android:hint="手机"
android:layout_gravity="center_vertical"
android:background="@drawable/edit_shape"
android:layout_width="0px"
android:layout_weight="3"
android:layout_height="90px"
android:id="@+id/sou"
/>
<TextView
android:id="@+id/sousuo"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="80px"
android:text="搜索"/>
</LinearLayout>
</LinearLayout>
fragment2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_width="300px"
android:layout_height="300px"
app:roundAsCircle="true"
android:id="@+id/sd"></com.facebook.drawee.view.SimpleDraweeView>
<LinearLayout
android:layout_marginLeft="100px"
android:layout_marginTop="100px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:text="你猜"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv"/>
<TextView
android:layout_marginTop="50px"
android:text="你好啊"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv1"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
gouwuche
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="购物车"
android:textSize="60px"
android:gravity="center"/>
<ExpandableListView
android:groupIndicator="@null"
android:id="@+id/edlv"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"></ExpandableListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:textSize="50px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cb"
android:text="全选/反选"/>
<TextView
android:textSize="50px"
android:layout_marginLeft="100px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="合计:"/>
<TextView
android:textSize="50px"
android:layout_marginLeft="30px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/hj"
android:text="0"/>
</LinearLayout>
</LinearLayout>
gouwuche_chiled
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:focusable="false"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/child_ck"/>
<com.facebook.drawee.view.SimpleDraweeView
android:layout_marginLeft="50px"
android:layout_width="150px"
android:layout_height="150px"
android:id="@+id/child_sd"/>
<LinearLayout
android:layout_marginLeft="20px"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cjild_name"
android:text="你好啊我来拉别跑啊"/>
<TextView
android:layout_marginTop="60px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cjild_price"
android:text="你好啊我来拉别跑啊"/>
</LinearLayout>
<LinearLayout
android:layout_marginLeft="-150dp"
android:layout_marginTop="180px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:focusable="false"
android:id="@+id/jian"
android:layout_width="40px"
android:layout_height="40px"
android:src="@drawable/shopcart_minus_grey"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ed"
android:background="@drawable/shopcart_add_btn"
android:paddingBottom="2dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="2dp"
/>
<ImageView
android:focusable="false"
android:id="@+id/jia"
android:layout_width="40px"
android:layout_height="40px"
android:src="@drawable/shopcart_add_red"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
gouwuche_prenter
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/prenter_cb"/>
<TextView
android:layout_marginLeft="20px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/prenter_tv"/>
</LinearLayout>
</LinearLayout>
popupwindow
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:background="#ffffff"
android:layout_gravity="center_horizontal"
android:text="拍照"
android:id="@+id/bt"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#DFDCD7"></View>
<Button
android:background="#ffffff"
android:layout_gravity="center_horizontal"
android:text="从相册选取"
android:id="@+id/bt1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:background="#ffffff"
android:layout_gravity="center_horizontal"
android:text="取消"
android:id="@+id/bt2"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
rg
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:background="#ffffff"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
>
<RadioGroup
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:textSize="40px"
android:gravity="center_horizontal"
android:button="@null"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="供应商"/>
<RadioButton
android:textSize="40px"
android:gravity="center_horizontal"
android:button="@null"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="店铺"/>
<RadioButton
android:textSize="40px"
android:gravity="center_horizontal"
android:button="@null"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="关注"/>
<RadioButton
android:textSize="40px"
android:gravity="center_horizontal"
android:button="@null"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="购物车"/>
<RadioButton
android:textSize="40px"
android:gravity="center_horizontal"
android:background="#ff0000"
android:button="@null"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="2"
android:id="@+id/addgou"
android:text="加入购物车"/>
</RadioGroup>
</LinearLayout>
shouye
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/shouye_xrc"></com.jcodecraeer.xrecyclerview.XRecyclerView>
<include layout="@layout/shouye_title"></include>
</RelativeLayout>
shouye_jiugongge
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:padding="5px"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_gravity="center_horizontal"
android:layout_width="150px"
android:layout_height="150px"
android:id="@+id/sd"></com.facebook.drawee.view.SimpleDraweeView>
<TextView
android:layout_gravity="center_horizontal"
android:text="你好啊"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/jiugongge_tv"/>
</LinearLayout>
shouye_title
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="@+id/fg"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:gravity="center_horizontal"
android:orientation="vertical"
android:id="@+id/f1_erweima"
android:layout_width="60dp"
android:layout_height="wrap_content">
<ImageView
android:background="#ffffff"
android:src="@drawable/sao1"
android:layout_width="24dp"
android:layout_height="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="#ffffff"
android:text="扫啊扫"/>
</LinearLayout>
<LinearLayout
android:layout_marginLeft="3px"
android:layout_marginRight="3px"
android:background="@drawable/home_title_bar_search_corner_bg"
android:gravity="center_vertical"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="40dp">
<ImageView
android:layout_marginLeft="5dp"
android:src="@drawable/order_find"
android:layout_width="20dp"
android:layout_height="20dp" />
<TextView
android:id="@+id/sousuo"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="30dp"
android:textSize="15dp"
android:text="运动户外超级品牌类日 跨店铺"
/>
<ImageView
android:layout_marginRight="5dp"
android:src="@drawable/root"
android:layout_width="20dp"
android:layout_height="20dp" />
</LinearLayout>
<LinearLayout
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_width="50dp"
android:layout_height="wrap_content">
<ImageView
android:background="#ffffff"
android:src="@drawable/order_msg"
android:layout_width="20dp"
android:layout_height="20dp" />
<TextView
android:textColor="#ffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:text="消息"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
shouye_tuijian
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_marginTop="30px"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:textSize="40px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/shouye_tuijian_tv"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/shouye_tuijian_rc"></android.support.v7.widget.RecyclerView>
</LinearLayout>
shouye_tuijian_zi
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:padding="15px"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:layout_gravity="center_horizontal"
android:layout_width="300px"
android:layout_height="300px"
android:id="@+id/sd"></com.facebook.drawee.view.SimpleDraweeView>
<TextView
android:layout_gravity="center_horizontal"
android:text="你好啊"
android:textSize="30px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/jiugongge_tv"/>
</LinearLayout>
shouye_xbanner
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.stx.xhb.xbanner.XBanner
android:layout_width="match_parent"
android:layout_height="300px"
app:AutoPlayTime="2000"
android:id="@+id/myxbanner"></com.stx.xhb.xbanner.XBanner>
</LinearLayout>
shouyemiaosha_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:textColor="#ff0000"
android:textSize="60px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/shouue_miaosha_tv"/>
<TextView
android:layout_gravity="center_vertical"
android:textSize="40px"
android:id="@+id/shouue_miaosha_tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60px" />
<LinearLayout
android:layout_gravity="center_vertical"
android:layout_marginLeft="50px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_hour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:background="#000000"
android:textColor="@android:color/white"
android:textSize="12sp"
android:text="02"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:textColor="@android:color/black"
android:text=":"/>
<TextView
android:background="#000000"
android:id="@+id/tv_minute"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:textColor="@android:color/white"
android:textSize="12sp"
android:text="15"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:textColor="@android:color/black"
android:text=":"/>
<TextView
android:background="#000000"
android:id="@+id/tv_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:textColor="@android:color/white"
android:textSize="12sp"
android:text="36"/>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/miaosha_rv"></android.support.v7.widget.RecyclerView>
</LinearLayout>
shouyerc
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/shouye_rc"></android.support.v7.widget.RecyclerView>
<LinearLayout
android:layout_marginTop="30px"
android:layout_width="match_parent"
android:layout_height="56dp">
<TextView
android:textSize="30px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:text="京东"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="快报"
android:background="#ff0000"
android:textColor="#ffffffff"
android:textSize="30px"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="45px"
android:textColor="#989898"
android:text=" : "/>
<com.example.administrator.jingdong.myview.NoticeView
android:id="@+id/notice_view"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<View
android:layout_width="1dp"
android:layout_height="18dp"
android:layout_marginRight="8dp"
android:alpha="0.3"
android:background="#666666"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="50px"
android:gravity="center"
android:text="更多"
android:textColor="#666666"
android:textSize="45px"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="40px"></View>
</LinearLayout>
sousuo
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/fenlei_main_title"></include>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="热搜"
android:textSize="50px"/>
<com.example.administrator.jingdong.view.Myview
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mv"></com.example.administrator.jingdong.view.Myview>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="历史记录"
android:textSize="50px"/>
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"></ListView>
<TextView
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:text="清空历史记录"
android:gravity="center_horizontal"
android:id="@+id/qingkong"/>
</LinearLayout>
tanchu
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_gravity="center_horizontal"
android:textSize="40px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入要修改的名字"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/updata"/>
</LinearLayout>
wode
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragment"></FrameLayout>
</LinearLayout>
xrc
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content"
android:layout_height="match_parent">
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/xrc1"></com.jcodecraeer.xrecyclerview.XRecyclerView>
</LinearLayout>
bean
public class Sousuobean {}
public class Shouyebean {}
public class Shop_xiangqing {}
public class Gouwuchebean {}
public class Good_xiangqing {}
public class Good_right {}
public class Good {}
public class Getuser {}
public class Denglubean {}
public class Addgood {
/**
* msg : 加购成功
* code : 0
*/
public String msg;
public String code;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
public class Zhucebean {
/**
* msg : 密码格式有问题,不能少于6位数
* code : 1
* data : {}
*/
private String msg;
private String code;
private String data;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
public class Userbean implements Serializable{
private String tel;
private String pwd;
public Userbean(String tel, String pwd) {
this.tel = tel;
this.pwd = pwd;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
}
public class User {}
public class Upname {
/**
* msg : 昵称修改成功
* code : 0
*/
private String msg;
private String code;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
public class Sqluser {
private String name;
@Generated(hash = 1057046941)
public Sqluser(String name) {
this.name = name;
}
@Generated(hash = 1614800003)
public Sqluser() {
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
fragment
public class Feilei1 extends Fragment implements IFeileixiangqing{
@BindView(R.id.xbnr)
XBanner xbnr;
@BindView(R.id.feilei_xiangqing_fragment_title)
TextView title;
@BindView(R.id.feilei_xiangqing_fragment_price)
TextView price;
@BindView(R.id.addgou)
Button addgou;
@BindView(R.id.web)
WebView web;
private String pid;
List<String> list=new ArrayList<>();
private Shop_xiangqing.DataBean data;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.feileixiangqing_fragment, container, false);
ButterKnife.bind(this, inflate);
Bundle bundle = getArguments();//从activity传过来的Bundle
if(bundle!=null){
pid = bundle.getString("str");
}
final Mypresenter mypresenter=new Mypresenter();
mypresenter.getfeileixiangqiang1(pid,this,new Mymode());
addgou.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int pid = (int) data.getPid();
Mypresenter mypresenter1=new Mypresenter();
mypresenter.addshop(pid+"",Feilei1.this,new Mymode());
}
});
return inflate;
}
@Override
public void settablayou(Shop_xiangqing.DataBean data) {
this.data=data;
String images = data.getImages();
String[] split = images.split("\\|");
for (int i = 0; i <split.length ; i++) {
list.add(split[i]);
}
xbnr.setData(list, null);
xbnr.setmAdapter(new XBanner.XBannerAdapter() {
@Override
public void loadBanner(XBanner banner, Object model, View view, int position) {
Glide.with(getActivity()).load(list.get(position)).into((ImageView) view);
}
});
title.setText(data.getTitle());
price.setText(data.getPrice()+"");
web.loadUrl(data.getDetailUrl());
web.setWebViewClient(new WebViewClient());
//xbanner的点击事件
xbnr.setOnItemClickListener(new XBanner.OnItemClickListener() {
@Override
public void onItemClick(XBanner banner, int position) {
Intent intent=new Intent(getActivity(), Lunbotu.class);
String s = list.get(position);
intent.putStringArrayListExtra("list", (ArrayList<String>) list);
intent.putExtra("name",position);
startActivity(intent);
}
});
}
@Override
public String getpid() {
return pid;
}
@Override
public void chenggong(String cheng) {
Toast.makeText(getActivity(),cheng,Toast.LENGTH_SHORT).show();
}
}
public class Faxianfragment extends Fragment {
List<Fragment> list=new ArrayList<>();
List<String> listtile=new ArrayList<>();
@BindView(R.id.tab)
TabLayout tb;
@BindView(R.id.vp)
ViewPager vp;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.faxian, container, false);
ButterKnife.bind(this, view);
initdata();
return view;
}
public void initdata() {
list.add(new Feilei2());
list.add(new Feilei3());
listtile.add("相亲");
listtile.add("评价");
tb.setTabMode(TabLayout.MODE_FIXED);
tb.setupWithViewPager(vp);
vp.setAdapter(new Myadapter(getChildFragmentManager()));
}
class Myadapter extends FragmentPagerAdapter {
public Myadapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return list.get(position);
}
@Override
public int getCount() {
return 2;
}
@Override
public CharSequence getPageTitle(int position) {
return listtile.get(position);
}
}
}
public class F2 extends Basefragment implements If2{
@BindView(R.id.sd)
SimpleDraweeView sd;
@BindView(R.id.wode_tv)
TextView wode_tv;
@BindView(R.id.tui)
Button tui;
private SharedPreferences ji;
private EditText updata;
private View inflate;
private PopupWindow popupWindow;
private static String path = "/sdcard/myHead/";// sd路径
private Uri uri;
private String fileName;
@Override
int getCintentview() {
return R.layout.dengluchenggong;
}
@Override
void initData() {
ji = getActivity().getSharedPreferences("ji", Context.MODE_PRIVATE);
String uid = ji.getString("uid", "");
Mypresenter mypresenter=new Mypresenter();
mypresenter.getusermv(uid,this,new Mymode());
}
@Override
void onclick() {
tui.setOnClickListener(this);
wode_tv.setOnClickListener(this);
sd.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.tui:
ji.edit().clear().commit();
F1 f1 = new F1();
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment, f1).commit();
break;
case R.id.wode_tv:
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
inflate = View.inflate(getContext(), R.layout.tanchu, null);
builder.setView(inflate);
updata = inflate.findViewById(R.id.updata);
builder.setNegativeButton("取消",null);
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String upname = updata.getText().toString();
if (!upname.equals("")&&upname!=null){
Mypresenter mypresenter=new Mypresenter();
mypresenter.upnamemv(ji.getString("uid",""),upname,F2.this,new Mymode());
}
}
});
builder.show();
break;
case R.id.sd:
View view = View.inflate(getContext(), R.layout.popupwindow, null);
//view为xml布局文件
popupWindow = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
//必须设置
popupWindow.setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
popupWindow.setOutsideTouchable(true);
//显示在底部 main为activity_main布局控件中 最大的LinearLayout 的id
popupWindow.showAtLocation(getView().findViewById(R.id.main), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
Button bt = view.findViewById(R.id.bt);
Button bt1 = view.findViewById(R.id.bt1);
Button bt2 = view.findViewById(R.id.bt2);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent2 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent2.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "head.jpg")));
startActivityForResult(intent2, 2);// 采用ForResult打开
popupWindow.dismiss();
}
});
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, 1);
popupWindow.dismiss();
}
});
bt2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
});
break;
}
}
@Override
public void chenggong(Getuser getuser) {
String icon = (String) getuser.getData().getIcon();
String nickname = (String) getuser.getData().getNickname();
if (icon!=null||nickname!=null){
wode_tv.setText(nickname);
if (icon==null){
sd.setImageURI(Uri.parse("res://com.example.wode/" + R.drawable.user));
}else {
sd.setImageURI(icon);
}
}
else {
sd.setImageURI(Uri.parse("res://com.example.wode/" + R.drawable.user));
Random random = new Random();
int i = random.nextInt(100) + 1000;
wode_tv.setText("jdsczh" + i);
}
}
@Override
public void upnamechenggong() {
wode_tv.setText(updata.getText().toString());
}
@Override
public void uptouxiangchenggong() {
sd.setImageURI(uri);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
//图库照片的路径
if (requestCode==1) {
//裁剪
cropPhoto(data.getData());
}
//相机的路径为f File f=new File(Environment.getExternalStorageDirectory(),"ni.jpg");
if (requestCode==2){
File temp = new File(Environment.getExternalStorageDirectory() + "/head.jpg");
cropPhoto(Uri.fromFile(temp));// 裁剪图片
}
if (requestCode==3){
if (data != null) {
Bundle extras = data.getExtras();
Bitmap head = extras.getParcelable("data");
if (head != null) {
setPicToView(head);// 保存在SD卡中
uri = Uri.parse(MediaStore.Images.Media.insertImage(getContext().getContentResolver(), head, null,null));
Mypresenter mypresenter=new Mypresenter();
File f=new File(fileName);
mypresenter.updatatouxiangmv(ji.getString("uid", ""),f,this,new Mymode());
}
}
}
super.onActivityResult(requestCode, resultCode, data);
}
public void cropPhoto(Uri uri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri, "image/*");
intent.putExtra("crop", "true");
// aspectX aspectY 是宽高的比例
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
// outputX outputY 是裁剪图片宽高
intent.putExtra("outputX", 150);
intent.putExtra("outputY", 150);
intent.putExtra("return-data", true);
startActivityForResult(intent, 3);
}
private void setPicToView(Bitmap mBitmap) {
String sdStatus = Environment.getExternalStorageState();
if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { // 检测sd是否可用
return;
}
FileOutputStream b = null;
File file = new File(path);
file.mkdirs();// 创建文件夹
fileName = path + "head.jpg";// 图片名字
try {
b = new FileOutputStream(fileName);
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, b);// 把数据写入文件
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
try {
// 关闭流
b.flush();
b.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public class F1 extends Basefragment {
@BindView(R.id.sd)
SimpleDraweeView sd;
@BindView(R.id.wode_tv)
TextView wode_tv;
@BindView(R.id.wode_iv1)
ImageView wode_iv1;
@BindView(R.id.wode_iv2)
ImageView wode_iv2;
@BindView(R.id.wode_iv3)
ImageView wode_iv3;
@BindView(R.id.wode_iv4)
ImageView wode_iv4;
@BindView(R.id.wode_iv5)
ImageView wode_iv5;
private SharedPreferences ji;
private F2 fragment2;
private F1 fragment1;
@Override
int getCintentview() {
return R.layout.f1;
}
@Override
void initData() {
sd.setImageURI(Uri.parse("res://com.example.f1/"+R.drawable.user));
ji = getContext().getSharedPreferences("ji", MODE_PRIVATE);
fragment1 = new F1();
fragment2 = new F2();
}
@Override
void onclick() {
sd.setOnClickListener(this);
wode_tv.setOnClickListener(this);
wode_iv1.setOnClickListener(this);
wode_iv2.setOnClickListener(this);
wode_iv3.setOnClickListener(this);
wode_iv4.setOnClickListener(this);
wode_iv5.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent = new Intent(getContext(), Denglu.class);
startActivityForResult(intent,1);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode==2){
String uid = data.getStringExtra("uid");
ji.edit().putString("uid",uid).commit();
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment, fragment2).commit();
ji.edit().putBoolean("flog",true).commit();
}
}
}
public abstract class Basefragment extends Fragment implements View.OnClickListener{
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(getCintentview(), container, false);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initData();
onclick();
}
abstract int getCintentview();
//初始化数据
abstract void initData();
//初始化点击事件
abstract void onclick();
public void Tost(String s){
Toast.makeText(getActivity(),s,Toast.LENGTH_SHORT).show();
}
public void startintent(Class<?> c){
startActivity(new Intent(getActivity(),c));
}
}
public class Wodefragment extends Basefragment {
private SharedPreferences ji;
private F2 fragment2;
private F1 fragment1;
@Override
int getCintentview() {
return R.layout.wode;
}
@Override
void initData() {
fragment1 = new F1();
fragment2 = new F2();
ji = getContext().getSharedPreferences("ji", Context.MODE_PRIVATE);
boolean flog = ji.getBoolean("flog", false);
if (flog){
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment, fragment2).commit();
}else {
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment, fragment1).commit();
}
}
@Override
void onclick() {
}
@Override
public void onClick(View v) {
}
}
public class Shouyefragment extends Basefragment implements IShouye{
@BindView(R.id.shouye_xrc)
XRecyclerView shouye_xrc;
@BindView(R.id.fg)
FrameLayout fg;
@BindView(R.id.sousuo)
TextView sousuo;
private List<Good.DataBean> data;
private int mDistanceY;
Handler handler=new Handler();
private XBanner myxbanner;
List<String> list=new ArrayList<>();
@Override
int getCintentview() {
return R.layout.shouye;
}
@Override
void initData() {
/*if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT){
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}*/
Mypresenter mypresenter=new Mypresenter();
mypresenter.shouye1(this,new Mymode());
mypresenter.shouye(getContext(),this,new Mymode());
View view1 = View.inflate(getContext(), R.layout.shouye_xbanner, null);
shouye_xrc.addHeaderView(view1);
myxbanner = view1.findViewById(R.id.myxbanner);
//点击事件
myxbanner.setOnItemClickListener(new XBanner.OnItemClickListener() {
@Override
public void onItemClick(XBanner banner, int position) {
}
});
}
@Override
void onclick() {
sousuo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getActivity(), Sousuo.class));
}
});
}
@Override
public void setmyadapter(Context context, Shouyebean shouyebean) {
Myshouyeadapter myshouyeadapter=new Myshouyeadapter(context,shouyebean,data);
shouye_xrc.setAdapter(myshouyeadapter);
shouye_xrc.setLayoutManager(new LinearLayoutManager(context));
final List<Shouyebean.DataBean> data = shouyebean.getData();
for (int i = 0; i <data.size() ; i++) {
list.add(data.get(i).getIcon());
}
myxbanner.setData(list, null);
myxbanner.setmAdapter(new XBanner.XBannerAdapter() {
@Override
public void loadBanner(XBanner banner, Object model, View view, int position) {
Glide.with(getActivity()).load(list.get(position)).into((ImageView) view);
}
});
shouye_xrc.setLoadingMoreEnabled(false);
shouye_xrc.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
//滑动的距离
mDistanceY += dy;
//toolbar的高度
int toolbarHeight = fg.getBottom();
//当滑动的距离 <= toolbar高度的时候,改变Toolbar背景色的透明度,达到渐变的效果
if (mDistanceY <= 120) {
float scale = (float) mDistanceY / 120;
float alpha = scale * 255;
fg.setBackgroundColor(Color.argb((int) alpha, 255, 255, 255));
} else {
//将标题栏的颜色设置为完全不透明状态
fg.setBackgroundResource(R.color.colorAccent);
}
}
});
}
@Override
public void setmyadapter1(List<Good.DataBean> data) {
this.data=data;
}
@Override
public void shuaxinjiazai() {
shouye_xrc.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
fg.setVisibility(View.GONE);
handler.postDelayed(new Runnable() {
@Override
public void run() {
fg.setVisibility(View.VISIBLE);
shouye_xrc.refreshComplete();
}
},1000);
}
@Override
public void onLoadMore() {
}
});
}
@Override
public void onClick(View v) {
}
}
public interface If2 {
void chenggong(Getuser getuser);
void upnamechenggong();
//上传头像成功
void uptouxiangchenggong();
}
public class Gouwuchefragment extends Basefragment implements Igouwuche{
@BindView(R.id.edlv)
ExpandableListView edlv;
@BindView(R.id.hj)
TextView hj;
@BindView(R.id.cb)
CheckBox xb;
List<Gouwuchebean.DataBean> data;
private MyGouwucheadapter myGouwucheadapter;
@Override
int getCintentview() {
return R.layout.gouwuche;
}
@Override
void initData() {
final Mypresenter mypresenter=new Mypresenter();
mypresenter.gouwuche(getContext(),this,new Mymode());
xb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (int i = 0; i <data.size() ; i++) {
data.get(i).setPrenter(!data.get(i).isPrenter());
List<Gouwuchebean.Gouwu> list = data.get(i).getList();
for (int j = 0; j <list.size() ; j++) {
list.get(j).setChildflog(!list.get(j).isChildflog());
}
}
Mypresenter mypresenter1=new Mypresenter();
mypresenter.textcount(Gouwuchefragment.this,new Mymode(),data);
myGouwucheadapter.notifyDataSetChanged();
}
});
}
@Override
void onclick() {
}
@Override
public void setmyadapter(Context context,Gouwuchebean gouwuchebean) {
List<Gouwuchebean.DataBean> data = gouwuchebean.getData();
this.data=data;
myGouwucheadapter = new MyGouwucheadapter(context,gouwuchebean,data,this);
edlv.setAdapter(myGouwucheadapter);
}
@Override
public void settext(double he) {
hj.setText(he+"");
}
@Override
public void onClick(View v) {
}
}
public class Fenleifragment extends Basefragment implements IFenleiview{
@BindView(R.id.sousuo)
TextView sousuo;
@BindView(R.id.fenlei_left)
RecyclerView fenlei_left;
@BindView(R.id.fenlei_right)
RecyclerView fenlei_right;
private Mypresenter mypresenter;
@Override
int getCintentview() {
return R.layout.fenlei_main;
}
//初始化数据
@Override
void initData() {
mypresenter = new Mypresenter();
mypresenter.getmv(getActivity(),this,new Mymode());
mypresenter.getmvright("1",getActivity(),this,new Mymode());
}
//初始化点击事件
@Override
void onclick() {
sousuo.setOnClickListener(this);
}
//点击事件的方法
@Override
public void onClick(View v) {
}
@Override
public void mysetadapter(Context context, final List<Good.DataBean> data) {
Myfeileileftadapter myfeileileftadapter=new Myfeileileftadapter(context,data);
fenlei_left.setAdapter(myfeileileftadapter);
fenlei_left.setLayoutManager(new LinearLayoutManager(getActivity()));
myfeileileftadapter.huidiao(new Myfeileileftadapter.Itemclick() {
@Override
public void itemclick(View view, int position) {
int cid = data.get(position).getCid();
mypresenter.getmvright(cid+"",getActivity(),Fenleifragment.this,new Mymode());
}
});
}
@Override
public void mysetadapterright(Context context, List<Good_right.DataBean> data) {
Myadapterright myadapterright=new Myadapterright(context,data);
fenlei_right.setAdapter(myadapterright);
fenlei_right.setLayoutManager(new LinearLayoutManager(getActivity()));
}
}
public class Feilei3 extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return super.onCreateView(inflater, container, savedInstanceState);
}
}
public class Feilei2 extends Fragment implements Ifaxian{
@BindView(R.id.xrc1)
XRecyclerView xrc;
private Mypresenter mypresenter;
private Myfaxianadapter myfaxianadapter;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.xrc, container, false);
ButterKnife.bind(this, view);
mypresenter = new Mypresenter();
mypresenter.faxiangetuser(getActivity(),this,new Mymode());
return view;
}
@Override
public void setadapter(Context context, List<User.DataBean> data) {
myfaxianadapter = new Myfaxianadapter(context,data);
xrc.setAdapter(myfaxianadapter);
xrc.setLayoutManager(new LinearLayoutManager(getActivity()));
}
@Override
public void shuaxinjiazai() {
xrc.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
mypresenter.faxiangetuser(getActivity(),Feilei2.this,new Mymode());
xrc.refreshComplete();
}
@Override
public void onLoadMore() {
mypresenter.faxianjiazai(Feilei2.this,new Mymode());
xrc.refreshComplete();
}
});
}
@Override
public void jiazai(List<User.DataBean> data) {
List<User.DataBean> list = myfaxianadapter.getList();
list.addAll(data);
myfaxianadapter.notifyDataSetChanged();
}
}
gen
public class SqluserDao extends AbstractDao<Sqluser, Void> {
public static final String TABLENAME = "SQLUSER";
/**
* Properties of entity Sqluser.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Name = new Property(0, String.class, "name", false, "NAME");
}
public SqluserDao(DaoConfig config) {
super(config);
}
public SqluserDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"SQLUSER\" (" + //
"\"NAME\" TEXT);"); // 0: name
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"SQLUSER\"";
db.execSQL(sql);
}
@Override
protected final void bindValues(DatabaseStatement stmt, Sqluser entity) {
stmt.clearBindings();
String name = entity.getName();
if (name != null) {
stmt.bindString(1, name);
}
}
@Override
protected final void bindValues(SQLiteStatement stmt, Sqluser entity) {
stmt.clearBindings();
String name = entity.getName();
if (name != null) {
stmt.bindString(1, name);
}
}
@Override
public Void readKey(Cursor cursor, int offset) {
return null;
}
@Override
public Sqluser readEntity(Cursor cursor, int offset) {
Sqluser entity = new Sqluser( //
cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0) // name
);
return entity;
}
@Override
public void readEntity(Cursor cursor, Sqluser entity, int offset) {
entity.setName(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
}
@Override
protected final Void updateKeyAfterInsert(Sqluser entity, long rowId) {
// Unsupported or missing PK type
return null;
}
@Override
public Void getKey(Sqluser entity) {
return null;
}
@Override
public boolean hasKey(Sqluser entity) {
// TODO
return false;
}
@Override
protected final boolean isEntityUpdateable() {
return true;
}
}
public class DaoSession extends AbstractDaoSession {
private final DaoConfig sqluserDaoConfig;
private final SqluserDao sqluserDao;
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
daoConfigMap) {
super(db);
sqluserDaoConfig = daoConfigMap.get(SqluserDao.class).clone();
sqluserDaoConfig.initIdentityScope(type);
sqluserDao = new SqluserDao(sqluserDaoConfig, this);
registerDao(Sqluser.class, sqluserDao);
}
public void clear() {
sqluserDaoConfig.clearIdentityScope();
}
public SqluserDao getSqluserDao() {
return sqluserDao;
}
}
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 2;
/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
SqluserDao.createTable(db, ifNotExists);
}
/** Drops underlying database table using DAOs. */
public static void dropAllTables(Database db, boolean ifExists) {
SqluserDao.dropTable(db, ifExists);
}
/**
* WARNING: Drops all table on Upgrade! Use only during development.
* Convenience method using a {@link DevOpenHelper}.
*/
public static DaoSession newDevSession(Context context, String name) {
Database db = new DevOpenHelper(context, name).getWritableDb();
DaoMaster daoMaster = new DaoMaster(db);
return daoMaster.newSession();
}
public DaoMaster(SQLiteDatabase db) {
this(new StandardDatabase(db));
}
public DaoMaster(Database db) {
super(db, SCHEMA_VERSION);
registerDaoClass(SqluserDao.class);
}
public DaoSession newSession() {
return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
}
public DaoSession newSession(IdentityScopeType type) {
return new DaoSession(db, type, daoConfigMap);
}
/**
* Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
*/
public static abstract class OpenHelper extends DatabaseOpenHelper {
public OpenHelper(Context context, String name) {
super(context, name, SCHEMA_VERSION);
}
public OpenHelper(Context context, String name, CursorFactory factory) {
super(context, name, factory, SCHEMA_VERSION);
}
@Override
public void onCreate(Database db) {
Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
createAllTables(db, false);
}
}
/** WARNING: Drops all table on Upgrade! Use only during development. */
public static class DevOpenHelper extends OpenHelper {
public DevOpenHelper(Context context, String name) {
super(context, name);
}
public DevOpenHelper(Context context, String name, CursorFactory factory) {
super(context, name, factory);
}
@Override
public void onUpgrade(Database db, int oldVersion, int newVersion) {
Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
dropAllTables(db, true);
onCreate(db);
}
}
}
mode
public interface Getnetjson {
void getnetJson(List<Good.DataBean> data);
}
public interface Getjsonuser {
void getUser(List<User.DataBean> data);
}
public interface Getgouwuchejson {
void getgouwuche(Gouwuchebean gouwuchebean);
}
public interface Getdenglu {
void getDenglu(Denglubean denglubean);
}
public interface Addshop {
void getaddshop(Addgood addgood);
}
public interface Zhucelisteneter {
void zhucejson(Zhucebean zhucebean);
}
public interface Updatausername {
void upName(Upname upname);
}
public interface Sousuoxiangqing {
void getsousuoxaingqing(List<Sousuobean.DataBean> data);
}
public class Mymode implements IFeileimode {
@Override
public void getnet(final Getnetjson getnetjson) {
Observable<Good> good = Util.getmInstance().getnetjson(Getnet.fenlei).getGood();
good.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Good>() {
@Override
public void accept(Good good) throws Exception {
List<Good.DataBean> data = good.getData();
getnetjson.getnetJson(data);
}
});
}
@Override
public void getnetright(Map<String,String> map, final Getnetjsonright getnetjsonright) {
Observable<Good_right> usermap = Util.getmInstance().getnetjson(Getnet.fenleiright).postUsermap(map);
usermap.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Good_right>() {
@Override
public void accept(Good_right good_right) throws Exception {
List<Good_right.DataBean> data = good_right.getData();
getnetjsonright.getnetJsonright(data);
}
});
}
@Override
public void getnetxiangqing(Map<String, String> map, final Getxiangqing getxiangqing) {
Observable<Good_xiangqing> postshopmap = Util.getmInstance().getnetjson(Getnet.fenleixaingqing).postshopmap(map);
postshopmap.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Good_xiangqing>() {
@Override
public void accept(Good_xiangqing good_xiangqing) throws Exception {
List<Good_xiangqing.DataBean> data = good_xiangqing.getData();
getxiangqing.getxainagqing(data);
}
});
}
@Override
public void getnetxiangqing1(Map<String, String> map, final Getshop getshop) {
Observable<Shop_xiangqing> postgetshop = Util.getmInstance().getnetjson(Getnet.fenleixaingqing1).postgetshop(map);
postgetshop.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Shop_xiangqing>() {
@Override
public void accept(Shop_xiangqing shop_xiangqing) throws Exception {
getshop.getShop(shop_xiangqing);
}
});
}
@Override
public void addshop(Map<String, String> map, final Addshop addshop) {
Observable<Addgood> addshop1 = Util.getmInstance().getnetjson(Getnet.addgou).addshop(map);
addshop1.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Addgood>() {
@Override
public void accept(Addgood addgood) throws Exception {
addshop.getaddshop(addgood);
}
});
}
@Override
public void getuser(Map<String, String> map, final Getjsonuser getjsonuser) {
Observable<User> getuset = Util.getmInstance().getnetjson(Getnet.user).getuset(map);
getuset.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<User>() {
@Override
public void accept(User user) throws Exception {
List<User.DataBean> data = user.getData();
getjsonuser.getUser(data);
}
});
}
@Override
public void getsouxaingqing(Map<String, String> map, final Sousuoxiangqing sousuoxiangqing) {
final Observable<Sousuobean> getsouxaing = Util.getmInstance().getnetjson(Getnet.sousuoxaing).getsouxaing(map);
getsouxaing.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Sousuobean>() {
@Override
public void accept(Sousuobean sousuobean) throws Exception {
List<Sousuobean.DataBean> data = sousuobean.getData();
sousuoxiangqing.getsousuoxaingqing(data);
}
});
}
@Override
public void getshouye(final Getshouye getshouye) {
final Observable<Shouyebean> shouye = Util.getmInstance().getnetjson(Getnet.shouye).getShouye();
shouye.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Shouyebean>() {
@Override
public void accept(Shouyebean shouyebean) throws Exception {
getshouye.getshoyyelisteneter(shouyebean);
}
});
}
@Override
public void getgouwuche(final Getgouwuchejson getgouwuchejson) {
final Observable<Gouwuchebean> getgouwuche = Util.getmInstance().getnetjson(Getnet.shouye).getgouwuche();
getgouwuche.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Gouwuchebean>() {
@Override
public void accept(Gouwuchebean gouwuchebean) throws Exception {
getgouwuchejson.getgouwuche(gouwuchebean);
}
});
}
@Override
public double jisuan(List<Gouwuchebean.DataBean> data) {
double add = 0;
for (int i = 0; i <data.size() ; i++) {
List<Gouwuchebean.Gouwu> list = data.get(i).getList();
for (int j = 0; j <list.size() ; j++) {
if (list.get(j).isChildflog()){
double count1 = list.get(j).getMycount() + 1;
double mul = mul(list.get(j).getPrice(), count1);
add = add(add, mul);
}
}
}
return add;
}
@Override
public void getdenglu(Map<String, String> map, final Getdenglu getdenglu) {
Observable<Denglubean> getdenglu1 = Util.getmInstance().getnetjson(Getnet.shouye).getdenglu(map);
getdenglu1.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Denglubean>() {
@Override
public void accept(Denglubean denglubean) throws Exception {
getdenglu.getDenglu(denglubean);
}
});
}
@Override
public void getuser1(Map<String, String> map, final Getuserjson getuserjson) {
Observable<Getuser> getuserbean = Util.getmInstance().getnetjson(Getnet.shouye).getuserbean(map);
getuserbean.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Getuser>() {
@Override
public void accept(Getuser getuser) throws Exception {
getuserjson.getUser(getuser);
}
});
}
@Override
public void getzhuce(Map<String, String> map, final Zhucelisteneter zhucelisteneter) {
Observable<Zhucebean> getzhucebean = Util.getmInstance().getnetjson(Getnet.shouye).getzhucebean(map);
getzhucebean.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Zhucebean>() {
@Override
public void accept(Zhucebean zhucebean) throws Exception {
zhucelisteneter.zhucejson(zhucebean);
}
});
}
@Override
public void updataname(Map<String, String> map, final Updatausername updatausername) {
Observable<Upname> upname = Util.getmInstance().getnetjson(Getnet.shouye).upname(map);
upname.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Upname>() {
@Override
public void accept(Upname upname) throws Exception {
updatausername.upName(upname);
}
});
}
@Override
public void updatouxiang(String uid, File file, final Updatausername updatausername) {
MultipartBody.Part filePart = MultipartBody.Part.createFormData("file",file.getName(), RequestBody.create(
MediaType.parse("application/octet-stream"),file));
Observable<Upname> upload2 = Util.getmInstance().getnetjson(Getnet.shouye).upload2(uid, filePart);
upload2.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Upname>() {
@Override
public void accept(Upname upname) throws Exception {
updatausername.upName(upname);
}
});
}
//乘法
public static double mul(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.multiply(b2).doubleValue();
}
public static double add(double v1, double v2) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
}
public interface IFeileimode {
//左分类
void getnet(Getnetjson getnetjson);
//右分类
void getnetright(Map<String,String> map, Getnetjsonright getnetjsonright);
//分类的详情
void getnetxiangqing(Map<String,String> map,Getxiangqing getxiangqing);
//轮播
void getnetxiangqing1(Map<String,String> map,Getshop getshop);
//添加购物车
void addshop(Map<String,String> map, Addshop addshop);
//发现
void getuser(Map<String,String> map,Getjsonuser getjsonuser);
//搜索详情
void getsouxaingqing(Map<String,String> map,Sousuoxiangqing sousuoxiangqing);
//首页
void getshouye(Getshouye getshouye);
//购物车
void getgouwuche(Getgouwuchejson getgouwuchejson);
double jisuan(List<Gouwuchebean.DataBean> data );
//登录
void getdenglu(Map<String,String> map,Getdenglu getdenglu);
//获取用户信息
void getuser1(Map<String,String> map,Getuserjson getuserjson);
//注册
void getzhuce(Map<String,String> map,Zhucelisteneter zhucelisteneter);
//修改name
void updataname(Map<String,String> map,Updatausername updatausername);
//上传头像
void updatouxiang(String uid, File file,Updatausername updatausername);
}
public interface Getxiangqing {
void getxainagqing(List<Good_xiangqing.DataBean> data);
}
public interface Getuserjson {
void getUser(Getuser getuser);
}
public interface Getshouye {
void getshoyyelisteneter(Shouyebean shouyebean);
}
public interface Getshop {
void getShop(Shop_xiangqing shop_xiangqing);
}
public interface Getnetjsonright {
void getnetJsonright( List<Good_right.DataBean> data);
}
myview
public class PageContainer extends CoordinatorLayout implements Page.OnScrollListener {
private Page child;
private PageBehavior behavior;
public PageContainer(Context context) {
this(context, null);
}
public PageContainer(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public PageContainer(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void setOnPageChanged(
PageBehavior.OnPageChanged onPageChanged) {
if (behavior != null) {
behavior.setOnPageChanged(onPageChanged);
}
}
@Override
public void onScroll(float scrollY, float distance) {
if (scrollY == -10000) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
scrollTo(0, 0);
}
}, -10);
} else {
int y = (int) (getScrollY() - scrollY);
if (y < distance) {
return;
}
scrollTo(0, y);
if (behavior != null) {
behavior.setScrollY((int) (distance - y));
}
}
}
@Override
public void onViewAdded(View child) {
super.onViewAdded(child);
if (child instanceof Page) {
this.child = ((Page) child);
this.child.setScrollListener(this);
}
LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
if (layoutParams.getBehavior() != null && layoutParams.getBehavior() instanceof PageBehavior) {
behavior = (PageBehavior) layoutParams.getBehavior();
}
}
public void backToTop(){
if (behavior!=null){
behavior.backToTop();
}
}
public void scrollToBottom(){
if (behavior!=null){
behavior.scrollToBottom();
}
}
}
public class PageBehavior extends CoordinatorLayout.Behavior {
private static final int PAGE_ONE = 1;
private static final int PAGE_TWO = 2;
private WeakReference<View> dependentView,childView;
private Scroller scroller;
private Handler handler;
private int status = PAGE_ONE;//记录状态
private float gap;
private int totalOne = 0;
private int scrollY = 0;
private int mode = 0;
public OnPageChanged mOnPageChanged;
public void setOnPageChanged(
OnPageChanged onPageChanged) {
mOnPageChanged = onPageChanged;
}
public PageBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
scroller = new Scroller(context);
handler = new Handler();
gap = 100;
}
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
//设定依赖视图为id是R.id.pageOne的View
if (dependency.getId() == R.id.pageOne) {
dependentView = new WeakReference<>(dependency);
childView=new WeakReference<>(child);
return true;
}
return false;
}
@Override
public boolean onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection) {
//child的布局
child.layout(0, 0, parent.getWidth(), child.getMeasuredHeight());
return true;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
//让child随着依赖视图的属性变动而变动
child.setTranslationY(dependency.getMeasuredHeight() + dependency.getTranslationY());
return true;
}
@Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) {
//只监测Vertical方向的动作
scroller.abortAnimation();//停止动画
return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
}
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, View child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
if (status == PAGE_ONE) {
if (dyUnconsumed > 0) {
View dependentView = getDependentView();
totalOne = (totalOne - dyUnconsumed);
dependentView.setTranslationY(totalOne * 0.5f);
}
if (dependentView.get().getTranslationY() < 0 && dyConsumed < 0) {
mode = 1;
((Page) dependentView.get()).setScrollAble(false, dependentView.get().getTranslationY());
}
} else if (status == PAGE_TWO) {
if (dyUnconsumed < 0) {
View dependentView = getDependentView();
totalOne = (totalOne + dyUnconsumed);
int newTranslate = (int) (-dependentView.getMeasuredHeight() - (totalOne * 0.5));
dependentView.setTranslationY(newTranslate);
}
if (dependentView.get().getTranslationY() > -dependentView.get().getHeight() && dyConsumed > 0) {
mode = 1;
((Page) child).setScrollAble(false, dependentView.get().getTranslationY());
}
}
}
@Override
public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, View child, View target) {
super.onStopNestedScroll(coordinatorLayout, child, target);
totalOne = 0;
View dependentView = getDependentView();
float translationY = dependentView.getTranslationY();
if (status == PAGE_ONE) {
if (mode == 0) {
if (translationY < -gap) {
scroller.startScroll(0, (int) translationY, 0, (int) (-dependentView.getMeasuredHeight() - translationY));
status = PAGE_TWO;
if (mOnPageChanged!=null){
mOnPageChanged.toBottom();
}
} else {
scroller.startScroll(0, (int) translationY, 0, (int) (-translationY));
}
} else {
mode = 0;
if (scrollY < -gap) {
scroller.startScroll(0, scrollY, 0, -dependentView.getMeasuredHeight() - scrollY);
status = PAGE_TWO;
if (mOnPageChanged!=null){
mOnPageChanged.toBottom();
}
} else {
scroller.startScroll(0, scrollY, 0, -scrollY);
}
}
} else if (status == PAGE_TWO) {
if (mode == 0) {
if (translationY < -dependentView.getMeasuredHeight() + gap) {
scroller.startScroll(0, (int) translationY, 0, (int) (-dependentView.getMeasuredHeight() - translationY));
} else {
scroller.startScroll(0, (int) translationY, 0, (int) (-translationY));
status = PAGE_ONE;
if (mOnPageChanged!=null){
mOnPageChanged.toTop();
}
}
} else {
mode = 0;
if (scrollY < -dependentView.getMeasuredHeight() + gap) {
scroller.startScroll(0, scrollY, 0, -dependentView.getMeasuredHeight() - scrollY);
} else {
scroller.startScroll(0, scrollY, 0, -scrollY);
status = PAGE_ONE;
if (mOnPageChanged!=null){
mOnPageChanged.toTop();
}
}
}
}
handler.post(new Running());
}
private View getDependentView() {
return dependentView.get();
}
private class Running implements Runnable {
@Override
public void run() {
if (scroller.computeScrollOffset()) {
View dependentView = getDependentView();
dependentView.setTranslationY(scroller.getCurrY());
handler.post(this);
} else {
}
}
}
public void setScrollY(int scrollY) {
this.scrollY = scrollY;
}
public void backToTop(){
View dependentView = getDependentView();
float translationY = dependentView.getTranslationY();
if (status == PAGE_TWO) {
if (mode == 0) {
childView.get().setScrollY(0);
dependentView.setScrollY(0);
scroller.startScroll(0, (int) translationY, 0, (int) (-translationY));
status = PAGE_ONE;
if (mOnPageChanged!=null){
mOnPageChanged.toTop();
}
}
}
handler.post(new Running());
}
public void scrollToBottom(){
View dependentView = getDependentView();
float translationY = dependentView.getTranslationY();
dependentView.setScrollY(dependentView.getMeasuredHeight());
if (status == PAGE_ONE) {
if (mode == 0) {
scroller.startScroll(0, (int) translationY, 0, (int) (-dependentView.getMeasuredHeight() - translationY));
status = PAGE_TWO;
if (mOnPageChanged!=null){
mOnPageChanged.toBottom();
}
}
}
handler.post(new Running());
}
public interface OnPageChanged{
void toTop();
void toBottom();
}
}
public class Page extends NestedScrollView {
private boolean scrollAble = true;
private float y;
private float oldy = 0;
private OnScrollListener onScrollListener;
public Page(Context context) {
this(context, null);
}
public Page(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public Page(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
ViewConfiguration.getTouchSlop();
}
public void setScrollAble(boolean scrollAble) {
this.scrollAble = scrollAble;
}
public void setScrollAble(boolean scrollAble, float y) {
this.scrollAble = scrollAble;
this.y = y;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (scrollAble) {
return super.onTouchEvent(ev);
} else {
switch (ev.getAction()) {
case MotionEvent.ACTION_MOVE:
float distanceY = 0;
float newY = 0;
if (oldy == 0) {
distanceY = 1;
newY = ev.getRawY();
} else {
newY = ev.getRawY();
distanceY = newY - oldy;
}
oldy = newY;
if (onScrollListener != null) {
onScrollListener.onScroll(distanceY, y);
}
return true;
case MotionEvent.ACTION_UP:
if (onScrollListener != null) {
onScrollListener.onScroll(-10000, y);
}
scrollAble = true;
oldy = 0;
return true;
default:
return true;
}
}
}
public void setScrollListener(OnScrollListener onScrollListener) {
this.onScrollListener = onScrollListener;
}
public interface OnScrollListener {
void onScroll(float scrollY, float y);
}
}
public class NoticeView extends ViewFlipper implements View.OnClickListener {
private Context mContext;
private List<String> mNotices;
public NoticeView(Context context) {
super(context);
}
public NoticeView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
private void init(Context context) {
mContext = context;
// 轮播间隔时间为3s
setFlipInterval(3000);
// 内边距5dp
setPadding(dp2px(5f), dp2px(5f), dp2px(5f), dp2px(5f));
// 设置enter和leave动画
setInAnimation(AnimationUtils.loadAnimation(mContext, R.anim.notify_in));
setOutAnimation(AnimationUtils.loadAnimation(mContext, R.anim.notify_out));
}
/**
* 添加需要轮播展示的公告
*
* @param notices
*/
public void addNotice(List<String> notices) {
removeAllViews();
mNotices = notices;
for (int i = 0; i < notices.size(); i++) {
// 根据公告内容构建一个Tetview
String notice = notices.get(i);
TextView textView = new TextView(mContext);
textView.setSingleLine();
textView.setText(notice);
textView.setTextSize(30);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setTextColor(Color.parseColor("#666666"));
textView.setGravity(Gravity.CENTER_VERTICAL);
// 将公告的位置设置为textView的tag方便点击是回调给用户
textView.setTag(i);
textView.setOnClickListener(this);
// 添加到ViewFlipper
NoticeView.this.addView(textView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
}
@Override
public void onClick(View v) {
int position = (int) v.getTag();
String notice = mNotices.get(position);
if (mOnNoticeClickListener != null) {
mOnNoticeClickListener.onNotieClick(position, notice);
}
}
/**
* 通知点击监听接口
*/
public interface OnNoticeClickListener {
void onNotieClick(int position, String notice);
}
private OnNoticeClickListener mOnNoticeClickListener;
/**
* 设置通知点击监听器
*
* @param onNoticeClickListener 通知点击监听器
*/
public void setOnNoticeClickListener(OnNoticeClickListener onNoticeClickListener) {
mOnNoticeClickListener = onNoticeClickListener;
}
private int dp2px(float dpValue) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
dpValue,
mContext.getResources().getDisplayMetrics());
}
}
presenter
public class Mylistadapter extends BaseAdapter {
private Context context;
private List<Sqluser> list;
public Mylistadapter(Context context, List<Sqluser> list) {
this.context = context;
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView=new TextView(context);
textView.setTextSize(40);
textView.setText(list.get(position).getName());
return textView;
}
}
public class MyGouwucheadapter extends BaseExpandableListAdapter {
private Context context;
private Gouwuchebean gouwuchebean;
private List<Gouwuchebean.DataBean> data;
private Gouwuchefragment gouwuchefragment;
public MyGouwucheadapter(Context context, Gouwuchebean gouwuchebean, List<Gouwuchebean.DataBean> data, Gouwuchefragment gouwuchefragment) {
this.context = context;
this.gouwuchebean = gouwuchebean;
this.data = data;
this.gouwuchefragment = gouwuchefragment;
}
@Override
public int getGroupCount() {
return data.size();
}
@Override
public int getChildrenCount(int groupPosition) {
return data.get(groupPosition).getList().size();
}
@Override
public Object getGroup(int groupPosition) {
return data.get(groupPosition);
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return data.get(groupPosition).getList().get(childPosition);
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
Prenterhodler prenterhodler=null;
if (convertView==null){
convertView = View.inflate(context, R.layout.gouwuche_prenter, null);
CheckBox prenter_cb=convertView.findViewById(R.id.prenter_cb);
TextView prenter_tv=convertView.findViewById(R.id.prenter_tv);
prenterhodler=new Prenterhodler(prenter_cb,prenter_tv);
convertView.setTag(prenterhodler);
}else {
prenterhodler = (Prenterhodler) convertView.getTag();
}
prenterhodler.getPrenter_cb().setChecked(data.get(groupPosition).isPrenter());
prenterhodler.getPrenter_tv().setText(data.get(groupPosition).getSellerName());
prenterhodler.getPrenter_cb().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isCheked = data.get(groupPosition).isPrenter();
isCheked =!isCheked ;
data.get(groupPosition).setPrenter(isCheked);
List<Gouwuchebean.Gouwu> list = MyGouwucheadapter.this.data.get(groupPosition).getList();
for (int i = 0; i <list.size() ; i++) {
list.get(i).setChildflog(isCheked);
}
notifyDataSetChanged();
Mypresenter mypresenter=new Mypresenter();
mypresenter.textcount(gouwuchefragment,new Mymode(),data);
}
});
return convertView;
}
@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
Childhodler childhodler=null;
if (convertView==null){
convertView = View.inflate(context, R.layout.gouwuche_chiled, null);
CheckBox child_ck = convertView.findViewById(R.id.child_ck);
SimpleDraweeView child_sd = convertView.findViewById(R.id.child_sd);
TextView cjild_name = convertView.findViewById(R.id.cjild_name);
TextView cjild_price = convertView.findViewById(R.id.cjild_price);
ImageView jian = convertView.findViewById(R.id.jian);
ImageView jia = convertView.findViewById(R.id.jia);
EditText ed = convertView.findViewById(R.id.ed);
childhodler=new Childhodler(child_ck,child_sd,cjild_name,cjild_price,jian,jia,ed);
convertView.setTag(childhodler);
}else {
childhodler = (Childhodler) convertView.getTag();
}
Gouwuchebean.Gouwu gouwu = data.get(groupPosition).getList().get(childPosition);
childhodler.child_ck.setChecked(gouwu.isChildflog());
String images = gouwu.getImages();
String[] split = images.split(".jpg");
childhodler.child_sd.setImageURI(Uri.parse(split[0]+".jpg"));
childhodler.cjild_name.setText(gouwu.getTitle());
childhodler.cjild_price.setText(gouwu.getPrice()+"");
childhodler.ed.setText(gouwu.getMycount()+1+"");
childhodler.child_ck.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isCheked = data.get(groupPosition).getList().get(childPosition).isChildflog();
isCheked=!isCheked;
data.get(groupPosition).getList().get(childPosition).setChildflog(isCheked);
List<Gouwuchebean.Gouwu> gouwus = MyGouwucheadapter.this.data.get(groupPosition).getList();
boolean flag = true;
for (int i = 0; i <gouwus.size() ; i++) {
if (!gouwus.get(i).isChildflog()){
flag=false;
}
}
MyGouwucheadapter.this.data.get(groupPosition).setPrenter(flag);
notifyDataSetChanged();
Mypresenter mypresenter=new Mypresenter();
mypresenter.textcount(gouwuchefragment,new Mymode(),data);
}
});
childhodler.jia.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int mycount = data.get(groupPosition).getList().get(childPosition).getMycount();
data.get(groupPosition).getList().get(childPosition).setMycount(++mycount);
Mypresenter mypresenter=new Mypresenter();
mypresenter.textcount(gouwuchefragment,new Mymode(),data);
notifyDataSetChanged();
}
});
childhodler.jian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int mycount = data.get(groupPosition).getList().get(childPosition).getMycount();
if (mycount>0){
mycount--;
data.get(groupPosition).getList().get(childPosition).setMycount(mycount);
}else {
Toast.makeText(context,"不能再减了",Toast.LENGTH_SHORT).show();
}
Mypresenter mypresenter=new Mypresenter();
mypresenter.textcount(gouwuchefragment,new Mymode(),data);
notifyDataSetChanged();
}
});
return convertView;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
}
class Childhodler{
private CheckBox child_ck;
private SimpleDraweeView child_sd;
private TextView cjild_name;
private TextView cjild_price;
private ImageView jian;
private ImageView jia;
private EditText ed;
public CheckBox getChild_ck() {
return child_ck;
}
public void setChild_ck(CheckBox child_ck) {
this.child_ck = child_ck;
}
public SimpleDraweeView getChild_sd() {
return child_sd;
}
public void setChild_sd(SimpleDraweeView child_sd) {
this.child_sd = child_sd;
}
public TextView getCjild_name() {
return cjild_name;
}
public void setCjild_name(TextView cjild_name) {
this.cjild_name = cjild_name;
}
public TextView getCjild_price() {
return cjild_price;
}
public void setCjild_price(TextView cjild_price) {
this.cjild_price = cjild_price;
}
public ImageView getJian() {
return jian;
}
public void setJian(ImageView jian) {
this.jian = jian;
}
public ImageView getJia() {
return jia;
}
public void setJia(ImageView jia) {
this.jia = jia;
}
public EditText getEd() {
return ed;
}
public void setEd(EditText ed) {
this.ed = ed;
}
public Childhodler(CheckBox child_ck, SimpleDraweeView child_sd, TextView cjild_name, TextView cjild_price, ImageView jian, ImageView jia, EditText ed) {
this.child_ck = child_ck;
this.child_sd = child_sd;
this.cjild_name = cjild_name;
this.cjild_price = cjild_price;
this.jian = jian;
this.jia = jia;
this.ed = ed;
}
}
class Prenterhodler{
private CheckBox prenter_cb;
private TextView prenter_tv;
public Prenterhodler(CheckBox prenter_cb, TextView prenter_tv) {
this.prenter_cb = prenter_cb;
this.prenter_tv = prenter_tv;
}
public CheckBox getPrenter_cb() {
return prenter_cb;
}
public void setPrenter_cb(CheckBox prenter_cb) {
this.prenter_cb = prenter_cb;
}
public TextView getPrenter_tv() {
return prenter_tv;
}
public void setPrenter_tv(TextView prenter_tv) {
this.prenter_tv = prenter_tv;
}
}
}
public class Myfeileileftadapter extends RecyclerView.Adapter<Myfeileileftadapter.Myhodler> {
private Context context;
private List<Good.DataBean> data;
private Itemclick item;
public Myfeileileftadapter(Context context, List<Good.DataBean> data) {
this.context = context;
this.data = data;
}
@Override
public Myhodler onCreateViewHolder(ViewGroup parent, int viewType) {
View view = View.inflate(context, R.layout.feilei_left_zi, null);
Myhodler myhodler=new Myhodler(view);
return myhodler;
}
@Override
public void onBindViewHolder(final Myhodler holder, final int position) {
holder.feilei_zuo_tv.setText(data.get(position).getName());
//item为接口的变量名
if (item!=null){
//holder为Myhodler holder的参数
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//调用接口的方法
item.itemclick(holder.itemView,position);
}
});
}
}
@Override
public int getItemCount() {
return data.size();
}
class Myhodler extends RecyclerView.ViewHolder{
public TextView feilei_zuo_tv;
public Myhodler(View itemView) {
super(itemView);
this.feilei_zuo_tv=itemView.findViewById(R.id.feilei_zuo_tv);
}
}
//定义接口
public interface Itemclick{
void itemclick(View view,int position);
}
//定义方法 参数1为接口 2为接口的变量名
public void huidiao(Itemclick item){
this.item=item;
}
}
public class Myfaxianadapter extends RecyclerView.Adapter<Myfaxianadapter.Myfaxianhodler> {
private Context context;
private List<User.DataBean> list;
public Myfaxianadapter(Context context, List<User.DataBean> list) {
this.context = context;
this.list = list;
}
public List<User.DataBean> getList() {
return list;
}
public void setList(List<User.DataBean> list) {
this.list = list;
}
@Override
public Myfaxianhodler onCreateViewHolder(ViewGroup parent, int viewType) {
View view = View.inflate(context, R.layout.fragment2, null);
Myfaxianhodler myfaxianhodler=new Myfaxianhodler(view);
return myfaxianhodler;
}
@Override
public void onBindViewHolder(Myfaxianhodler holder, int position) {
holder.sd.setImageURI(Uri.parse(list.get(position).getUserImg()));
holder.tv.setText(list.get(position).getTitle());
holder.tv1.setText(list.get(position).getUserName());
}
@Override
public int getItemCount() {
return list.size();
}
class Myfaxianhodler extends RecyclerView.ViewHolder{
public SimpleDraweeView sd;
private TextView tv;
private TextView tv1;
public Myfaxianhodler(View itemView) {
super(itemView);
this.sd=itemView.findViewById(R.id.sd);
this.tv=itemView.findViewById(R.id.tv);
this.tv1=itemView.findViewById(R.id.tv1);
}
}
}
public class Myadapterxiangqing extends RecyclerView.Adapter<Myadapterxiangqing.MyViewHodler>{
private Context context;
private List<Good_xiangqing.DataBean> list;
private int i;
private Itemclick item;
public Myadapterxiangqing(Context context, List<Good_xiangqing.DataBean> list, int i) {
this.context = context;
this.list = list;
this.i = i;
}
public List<Good_xiangqing.DataBean> getList() {
return list;
}
public void setList(List<Good_xiangqing.DataBean> list) {
this.list = list;
}
@Override
public MyViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
View inflate = View.inflate(context,i,null);
MyViewHodler myViewHodler=new MyViewHodler(inflate);
return myViewHodler;
}
@Override
public void onBindViewHolder(final MyViewHodler holder, final int position) {
String url = list.get(position).getImages();
String[] split = url.split(".jpg");
holder.sd.setImageURI(Uri.parse(split[0]+".jpg"));
holder.xiangqing_tv.setText(list.get(position).getTitle());
holder.xiangqing_tv1.setText(list.get(position).getPrice()+"");
if (item!=null){
//holder为Myhodler holder的参数
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//调用接口的方法
item.itemclick(holder.itemView,position);
}
});
}
}
@Override
public int getItemCount() {
return list.size();
}
class MyViewHodler extends RecyclerView.ViewHolder{
public SimpleDraweeView sd;
public TextView xiangqing_tv;
public TextView xiangqing_tv1;
public MyViewHodler(View itemView) {
super(itemView);
this.sd=itemView.findViewById(R.id.sd);
this.xiangqing_tv=itemView.findViewById(R.id.xiangqing_tv);
this.xiangqing_tv1=itemView.findViewById(R.id.xiangqing_tv1);
}
}
//定义接口
public interface Itemclick{
void itemclick(View view,int position);
}
//定义方法 参数1为接口 2为接口的变量名
public void huidiao(Itemclick item){
this.item=item;
}
}
public class Myadapterright extends RecyclerView.Adapter<Myadapterright.Myhodlerright> {
private Context context;
private List<Good_right.DataBean> list;
public Myadapterright(Context context, List<Good_right.DataBean> list) {
this.context = context;
this.list = list;
}
@Override
public Myhodlerright onCreateViewHolder(ViewGroup parent, int viewType) {
View view = View.inflate(context, R.layout.feilei_right, null);
Myhodlerright myhodlerright = new Myhodlerright(view);
return myhodlerright;
}
@Override
public void onBindViewHolder(Myhodlerright holder, int position) {
holder.right_tv.setText(list.get(position).getName());
final List<Good_right.DataBean.ListBean> list1 = this.list.get(position).getList();
Myrightadapterzi myrightadapterzi=new Myrightadapterzi(context,list1);
holder.right_rc.setAdapter(myrightadapterzi);
holder.right_rc.setLayoutManager(new GridLayoutManager(context,3));
myrightadapterzi.huidiao(new Myrightadapterzi.Itemclick() {
@Override
public void itemclick(View view, int position) {
Intent intent = new Intent(context, Feileishow.class);
int pscid = list1.get(position).getPscid();
intent.putExtra("id",pscid+"");
context.startActivity(intent);
}
});
}
@Override
public int getItemCount() {
return list.size();
}
class Myhodlerright extends RecyclerView.ViewHolder{
public TextView right_tv;
public RecyclerView right_rc;
public Myhodlerright(View itemView) {
super(itemView);
this.right_tv= itemView.findViewById(R.id.right_tv);
this.right_rc= itemView.findViewById(R.id.right_rc);
}
}
}
public interface IFenleipresenter {
void getmv(Context context, IFenleiview iFenleiview, IFeileimode iFeileimode);
void getmvright(String cid,Context context, IFenleiview iFenleiview, IFeileimode iFeileimode);
void getfeileixiangqing(int p,Context context, IFeileimode iFeileimode, IFeileishow iFeileishow);
void getfeileixiangqingjiazai(int p,IFeileimode iFeileimode, IFeileishow iFeileishow);
void getfeileixiangqiang1(String pid,IFeileixiangqing iFeileixiangqing,IFeileimode iFeileimode);
void addshop(String pid,IFeileixiangqing iFeileixiangqing,IFeileimode iFeileimode);
//发现
void faxiangetuser(Context context,Ifaxian ifaxian,IFeileimode iFeileimode);
void faxianjiazai(Ifaxian ifaxian,IFeileimode iFeileimode);
//搜索详情
void sousuoxaingqingmv(int p,Context context, Isousuoxiangqing isousuoxiangqing,IFeileimode iFeileimode);
void sousuoxaingqingjiazaimv( int p,Isousuoxiangqing isousuoxiangqing,IFeileimode iFeileimode);
//首页
void shouye(Context context, IShouye iShouye,IFeileimode iFeileimode);
void shouye1( IShouye iShouye, IFeileimode iFeileimode);
//购物车
void gouwuche(Context context,Igouwuche igouwuche,IFeileimode iFeileimode);
void textcount(Igouwuche igouwuche,IFeileimode iFeileimode,List<Gouwuchebean.DataBean> data);
//登录
void getdenglumv(Userbean userbean, Idenglu idenglu, IFeileimode iFeileimode);
//获取用户信息
void getusermv(String uid, If2 if2,IFeileimode iFeileimode);
//注册
void getzhucemv(Userbean userbean, Izhuce izhuce,IFeileimode iFeileimode);
//修改名称
void upnamemv(String uid,String name,If2 if2,IFeileimode iFeileimode);
//上传头像
void updatatouxiangmv(String uid, File file,If2 if2,IFeileimode iFeileimode);
}
public class Shouyetuijianadapter extends RecyclerView.Adapter <Shouyetuijianadapter.Myshouyetuijianhodler>{
private Context context;
List<Shouyebean.TuijianBean.ListBean> list;
private Itemclick item;
public Shouyetuijianadapter(Context context, List<Shouyebean.TuijianBean.ListBean> list) {
this.context = context;
this.list = list;
}
@Override
public Myshouyetuijianhodler onCreateViewHolder(ViewGroup parent, int viewType) {
View inflate = View.inflate(context, R.layout.shouye_tuijian_zi, null);
Myshouyetuijianhodler myshouyetuijianhodler=new Myshouyetuijianhodler(inflate);
return myshouyetuijianhodler;
}
@Override
public void onBindViewHolder(final Myshouyetuijianhodler holder, final int position) {
String images = list.get(position).getImages();
String[] split = images.split(".jpg");
holder.sd.setImageURI(Uri.parse(split[0]+".jpg"));
holder.jiugongge_tv.setText(list.get(position).getPrice()+"");
//item为接口的变量名
if (item!=null){
//holder为Myhodler holder的参数
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//调用接口的方法
item.itemclick(holder.itemView,position);
}
});
}
}
@Override
public int getItemCount() {
return list.size();
}
class Myshouyetuijianhodler extends RecyclerView.ViewHolder{
public SimpleDraweeView sd;
public TextView jiugongge_tv;
public Myshouyetuijianhodler(View itemView) {
super(itemView);
this.sd=itemView.findViewById(R.id.sd);
this.jiugongge_tv=itemView.findViewById(R.id.jiugongge_tv);
}
}
//定义接口
public interface Itemclick{
void itemclick(View view,int position);
}
//定义方法 参数1为接口 2为接口的变量名
public void huidiao(Itemclick item){
this.item=item;
}
}
public class Shouyemiaoshaadapter extends RecyclerView.Adapter<Shouyemiaoshaadapter.Miaoshahodler> {
private Context context;
private List<Shouyebean.MiaoshaBean.ListBeanX> list;
private Itemclick item;
public Shouyemiaoshaadapter(Context context, List<Shouyebean.MiaoshaBean.ListBeanX> list) {
this.context = context;
this.list = list;
}
@Override
public Miaoshahodler onCreateViewHolder(ViewGroup parent, int viewType) {
View inflate = View.inflate(context, R.layout.shouye_tuijian_zi, null);
Miaoshahodler miaoshahodler=new Miaoshahodler(inflate);
return miaoshahodler;
}
@Override
public void onBindViewHolder(final Miaoshahodler holder, final int position) {
String images = list.get(position).getImages();
String[] split = images.split(".jpg");
holder.sd.setImageURI(Uri.parse(split[0]+".jpg"));
holder.jiugongge_tv.setText(list.get(position).getTitle());
//item为接口的变量名
if (item!=null){
//holder为Myhodler holder的参数
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//调用接口的方法
item.itemclick(holder.itemView,position);
}
});
}
}
@Override
public int getItemCount() {
return list.size();
}
class Miaoshahodler extends RecyclerView.ViewHolder{
public SimpleDraweeView sd;
public TextView jiugongge_tv;
public Miaoshahodler(View itemView) {
super(itemView);
this.sd=itemView.findViewById(R.id.sd);
this.jiugongge_tv=itemView.findViewById(R.id.jiugongge_tv);
}
}
//定义接口
public interface Itemclick{
void itemclick(View view,int position);
}
//定义方法 参数1为接口 2为接口的变量名
public void huidiao(Itemclick item){
this.item=item;
}
}
public class Shouyefeileiadapter extends RecyclerView.Adapter<Shouyefeileiadapter.Shouyefeileihodler> {
private List<Good.DataBean> data;
private Context context;
public Shouyefeileiadapter(List<Good.DataBean> data, Context context) {
this.data = data;
this.context = context;
}
@Override
public Shouyefeileihodler onCreateViewHolder(ViewGroup parent, int viewType) {
View view = View.inflate(context, R.layout.shouye_jiugongge, null);
Shouyefeileihodler shouyefeileihodler=new Shouyefeileihodler(view);
return shouyefeileihodler;
}
@Override
public void onBindViewHolder(Shouyefeileihodler holder, int position) {
holder.sd.setImageURI(Uri.parse(data.get(position).getIcon()));
holder.jiugongge_tv.setText(data.get(position).getName());
}
@Override
public int getItemCount() {
return data.size();
}
class Shouyefeileihodler extends RecyclerView.ViewHolder{
public SimpleDraweeView sd;
public TextView jiugongge_tv;
public Shouyefeileihodler(View itemView) {
super(itemView);
this.sd=itemView.findViewById(R.id.sd);
this.jiugongge_tv=itemView.findViewById(R.id.jiugongge_tv);
}
}
}
public class Mysousuoadapter extends RecyclerView.Adapter<Mysousuoadapter.Mysousuohodler>{
private Context context;
List<Sousuobean.DataBean> list;
private int i;
private Itemclick item;
public Mysousuoadapter(Context context, List<Sousuobean.DataBean> list, int i) {
this.context = context;
this.list = list;
this.i = i;
}
public List<Sousuobean.DataBean> getList() {
return list;
}
public void setList(List<Sousuobean.DataBean> list) {
this.list = list;
}
@Override
public Mysousuohodler onCreateViewHolder(ViewGroup parent, int viewType) {
View inflate = View.inflate(context,i,null);
Mysousuohodler mysousuohodler=new Mysousuohodler(inflate);
return mysousuohodler;
}
@Override
public void onBindViewHolder(final Mysousuohodler holder, final int position) {
String url = list.get(position).getImages();
String[] split = url.split(".jpg");
holder.sd.setImageURI(Uri.parse(split[0]+".jpg"));
holder.xiangqing_tv.setText(list.get(position).getTitle());
holder.xiangqing_tv1.setText(list.get(position).getPrice()+"");
if (item!=null){
//holder为Myhodler holder的参数
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//调用接口的方法
item.itemclick(holder.itemView,position);
}
});
}
}
@Override
public int getItemCount() {
return list.size();
}
class Mysousuohodler extends RecyclerView.ViewHolder{
public SimpleDraweeView sd;
public TextView xiangqing_tv;
public TextView xiangqing_tv1;
public Mysousuohodler(View itemView) {
super(itemView);
this.sd=itemView.findViewById(R.id.sd);
this.xiangqing_tv=itemView.findViewById(R.id.xiangqing_tv);
this.xiangqing_tv1=itemView.findViewById(R.id.xiangqing_tv1);
}
}
//定义接口
public interface Itemclick{
void itemclick(View view,int position);
}
//定义方法 参数1为接口 2为接口的变量名
public void huidiao(Itemclick item){
this.item=item;
}
}
public class Myshouyeadapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
//定义常量 确定多条目加载类型
final static int TYPE_ONE=1;
final static int TYPE_TWO=2;
final static int TYPE_THREE=3;
private Context context;
private Shouyebean shouyebean;
private List<Good.DataBean> data;
private ArrayList<String> notices;
private long mHour = 02;
private long mMin = 15;
private long mSecond = 36;
private boolean isRun = true;
private Handler timeHandler;
public Myshouyeadapter(Context context, Shouyebean shouyebean, List<Good.DataBean> data) {
this.context = context;
this.shouyebean = shouyebean;
this.data = data;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
switch (viewType) {
case TYPE_ONE:
View inflate = View.inflate(context, R.layout.shouyerc, null);
Feileihodler feileihodler=new Feileihodler(inflate);
return feileihodler;
case TYPE_TWO:
View inflate1 = View.inflate(context, R.layout.shouye_tuijian, null);
Shouyetuijianhodler shouyetuijianhodler=new Shouyetuijianhodler(inflate1);
return shouyetuijianhodler;
case TYPE_THREE:
View inflate2 = View.inflate(context, R.layout.shouyemiaosha_item, null);
Maoshahodler maoshahodler=new Maoshahodler(inflate2);
return maoshahodler;
}
return null;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
if (holder instanceof Feileihodler){
Shouyefeileiadapter shouyefeileiadapter=new Shouyefeileiadapter(data,context);
((Feileihodler) holder).xrc.setAdapter(shouyefeileiadapter);
((Feileihodler) holder).xrc.setLayoutManager(new GridLayoutManager(context,2,GridLayoutManager.HORIZONTAL,false));
final ArrayList<String> notices = new ArrayList<>();
notices.add("大促销下单拆福袋,亿万新年红包随便拿");
notices.add("家电五折团,抢十亿无门槛现金红包");
notices.add("星球大战剃须刀首发送200元代金券");
((Feileihodler) holder).noticeView.addNotice(notices);
((Feileihodler) holder).noticeView.startFlipping();
((Feileihodler) holder).noticeView.setOnNoticeClickListener(new NoticeView.OnNoticeClickListener() {
@Override
public void onNotieClick(int position, String notice) {
Toast.makeText(context, notices.get(position),Toast.LENGTH_SHORT).show();
}
});
}
if (holder instanceof Shouyetuijianhodler){
((Shouyetuijianhodler) holder).shouye_tuijian_tv.setText("京东推荐");
Shouyebean.TuijianBean tuijian = shouyebean.getTuijian();
final List<Shouyebean.TuijianBean.ListBean> list = tuijian.getList();
Shouyetuijianadapter shouyetuijianadapter=new Shouyetuijianadapter(context,list);
((Shouyetuijianhodler) holder).shouye_tuijian_rc.setAdapter(shouyetuijianadapter);
((Shouyetuijianhodler) holder).shouye_tuijian_rc.setLayoutManager(new GridLayoutManager(context,1,GridLayoutManager.HORIZONTAL,false));
shouyetuijianadapter.huidiao(new Shouyetuijianadapter.Itemclick() {
@Override
public void itemclick(View view, int position) {
int pid = (int) list.get(position).getPid();
Intent intent = new Intent(context, Feileixiangqing.class);
intent.putExtra("pid",pid+"");
context.startActivity(intent);
}
});
}
if (holder instanceof Maoshahodler){
Shouyebean.MiaoshaBean miaosha = shouyebean.getMiaosha();
final List<Shouyebean.MiaoshaBean.ListBeanX> miaoshaList = miaosha.getList();
((Maoshahodler) holder).shouue_miaosha_tv.setText("京东秒杀");
((Maoshahodler) holder).shouue_miaosha_tv1.setText("16点场");
Shouyemiaoshaadapter shouyemiaoshaadapter=new Shouyemiaoshaadapter(context,miaoshaList);
((Maoshahodler) holder).miaosha_rv.setAdapter(shouyemiaoshaadapter);
((Maoshahodler) holder).miaosha_rv.setLayoutManager(new GridLayoutManager(context,2));
shouyemiaoshaadapter.huidiao(new Shouyemiaoshaadapter.Itemclick() {
@Override
public void itemclick(View view, int position) {
int pid = (int) miaoshaList.get(position).getPid();
Intent intent = new Intent(context, Feileixiangqing.class);
intent.putExtra("pid",pid+"");
context.startActivity(intent);
}
});
startRun();
timeHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what==1) {
computeTime();
if (mHour<10){
((Maoshahodler) holder).tv_hour.setText("0"+mHour+"");
}else {
((Maoshahodler) holder).tv_hour.setText("0"+mHour+"");
}
if (mMin<10){
((Maoshahodler) holder).tv_minute.setText("0"+mMin+"");
}else {
((Maoshahodler) holder).tv_minute.setText(mMin+"");
}
if (mSecond<10){
((Maoshahodler) holder).tv_second.setText("0"+mSecond+"");
}else {
((Maoshahodler) holder).tv_second.setText(mSecond+"");
}
}
}
};
}
}
private void startRun() {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
while (isRun) {
try {
Thread.sleep(1000); // sleep 1000ms
Message message = Message.obtain();
message.what = 1;
timeHandler.sendMessage(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}).start();
}
/**
* 倒计时计算
*/
private void computeTime() {
mSecond--;
if (mSecond < 0) {
mMin--;
mSecond = 59;
if (mMin < 0) {
mMin = 59;
mHour--;
}
}
}
@Override
public int getItemCount() {
return 3;
}
class Maoshahodler extends RecyclerView.ViewHolder{
public TextView shouue_miaosha_tv;
public TextView shouue_miaosha_tv1;
public TextView tv_hour;
public TextView tv_minute;
public TextView tv_second;
public RecyclerView miaosha_rv;
public Maoshahodler(View itemView) {
super(itemView);
this.shouue_miaosha_tv=itemView.findViewById(R.id.shouue_miaosha_tv);
this.shouue_miaosha_tv1=itemView.findViewById(R.id.shouue_miaosha_tv1);
this.tv_hour=itemView.findViewById(R.id.tv_hour);
this.tv_minute=itemView.findViewById(R.id.tv_minute);
this.tv_second=itemView.findViewById(R.id.tv_second);
this.miaosha_rv=itemView.findViewById(R.id.miaosha_rv);
}
}
class Feileihodler extends RecyclerView.ViewHolder{
public RecyclerView xrc;
public NoticeView noticeView;
public Feileihodler(View itemView) {
super(itemView);
this.xrc=itemView.findViewById(R.id.shouye_rc);
this.noticeView=itemView.findViewById(R.id.notice_view);
}
}
@Override
public int getItemViewType(int position) {
if (position==0){
return TYPE_ONE;
}
if (position==1){
return TYPE_TWO;
}
if (position==2){
return TYPE_THREE;
}
return 0;
}
class Shouyetuijianhodler extends RecyclerView.ViewHolder{
public TextView shouye_tuijian_tv;
public RecyclerView shouye_tuijian_rc;
public Shouyetuijianhodler(View itemView) {
super(itemView);
this.shouye_tuijian_rc=itemView.findViewById(R.id.shouye_tuijian_rc);
this.shouye_tuijian_tv=itemView.findViewById(R.id.shouye_tuijian_tv);
}
}
}
public class Myrightadapterzi extends RecyclerView.Adapter<Myrightadapterzi.Myhodlerzi> {
private Context context;
private List<Good_right.DataBean.ListBean> list1;
private Itemclick item;
public Myrightadapterzi(Context context, List<Good_right.DataBean.ListBean> list1) {
this.context = context;
this.list1 = list1;
}
@Override
public Myhodlerzi onCreateViewHolder(ViewGroup parent, int viewType) {
View view = View.inflate(context, R.layout.feilei_right_zi, null);
Myhodlerzi myhodlerzi=new Myhodlerzi(view);
return myhodlerzi;
}
@Override
public void onBindViewHolder(final Myhodlerzi holder, final int position) {
holder.feilei_right_zi_tv.setText(list1.get(position).getName());
holder.sd.setImageURI(Uri.parse(list1.get(position).getIcon()));
if (item!=null){
//holder为Myhodler holder的参数
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//调用接口的方法
item.itemclick(holder.itemView,position);
}
});
}
}
@Override
public int getItemCount() {
return list1.size();
}
class Myhodlerzi extends RecyclerView.ViewHolder{
public TextView feilei_right_zi_tv;
public SimpleDraweeView sd;
public Myhodlerzi(View itemView) {
super(itemView);
this.feilei_right_zi_tv=itemView.findViewById(R.id.feilei_right_zi_tv);
this.sd=itemView.findViewById(R.id.sd);
}
}
//定义接口
public interface Itemclick{
void itemclick(View view,int position);
}
//定义方法 参数1为接口 2为接口的变量名
public void huidiao(Itemclick item){
this.item=item;
}
}
public class Mypresenter implements IFenleipresenter {
@Override
public void getmv(final Context context, final IFenleiview iFenleiview, IFeileimode iFeileimode) {
iFeileimode.getnet(new Getnetjson() {
@Override
public void getnetJson(List<Good.DataBean> data) {
iFenleiview.mysetadapter(context,data);
}
});
}
@Override
public void getmvright(String cid,final Context context, final IFenleiview iFenleiview, IFeileimode iFeileimode) {
Map<String,String> map=new HashMap<>();
map.put("cid",cid);
iFeileimode.getnetright(map, new Getnetjsonright() {
@Override
public void getnetJsonright( List<Good_right.DataBean> data) {
iFenleiview.mysetadapterright(context,data);
}
});
}
int i=1;
@Override
public void getfeileixiangqing(int p,final Context context, IFeileimode iFeileimode, final IFeileishow iFeileishow) {
Map<String,String> map=new HashMap<>();
String getscid = iFeileishow.getscid();
i=1;
map.put("pscid",getscid);
map.put("page",i+"");
map.put("sort",p+"");
iFeileimode.getnetxiangqing(map, new Getxiangqing() {
@Override
public void getxainagqing(List<Good_xiangqing.DataBean> data) {
iFeileishow.mysetadapter(context,data);
iFeileishow.shuaxinjiazai();
iFeileishow.dianji();
}
});
}
@Override
public void getfeileixiangqingjiazai(int p,IFeileimode iFeileimode, final IFeileishow iFeileishow) {
Map<String,String> map=new HashMap<>();
String getscid = iFeileishow.getscid();
i++;
map.put("pscid",getscid);
map.put("page",i+"");
map.put("sort",p+"");
iFeileimode.getnetxiangqing(map, new Getxiangqing() {
@Override
public void getxainagqing(List<Good_xiangqing.DataBean> data) {
iFeileishow.jiazai(data);
}
});
}
@Override
public void getfeileixiangqiang1(String pid,final IFeileixiangqing iFeileixiangqing, IFeileimode iFeileimode) {
Map<String,String> map=new HashMap<>();
map.put("pid",pid);
iFeileimode.getnetxiangqing1(map, new Getshop() {
@Override
public void getShop(Shop_xiangqing shop_xiangqing) {
Shop_xiangqing.DataBean data = shop_xiangqing.getData();
iFeileixiangqing.settablayou(data);
}
});
}
@Override
public void addshop(String pid, final IFeileixiangqing iFeileixiangqing, IFeileimode iFeileimode) {
Map<String,String> map=new HashMap<>();
map.put("pid",pid);
iFeileimode.addshop(map, new Addshop() {
@Override
public void getaddshop(Addgood addgood) {
iFeileixiangqing.chenggong(addgood.getMsg());
}
});
}
@Override
public void faxiangetuser(final Context context, final Ifaxian ifaxian, IFeileimode iFeileimode) {
i=1;
Map<String,String> map=new HashMap<>();
map.put("page",i+"");
iFeileimode.getuser(map, new Getjsonuser() {
@Override
public void getUser(List<User.DataBean> data) {
ifaxian.setadapter(context,data);
ifaxian.shuaxinjiazai();
}
});
}
@Override
public void faxianjiazai(final Ifaxian ifaxian, IFeileimode iFeileimode) {
i++;
Map<String,String> map=new HashMap<>();
map.put("page",i+"");
iFeileimode.getuser(map, new Getjsonuser() {
@Override
public void getUser(List<User.DataBean> data) {
ifaxian.jiazai(data);
}
});
}
@Override
public void sousuoxaingqingmv(int p,final Context context, final Isousuoxiangqing isousuoxiangqing, IFeileimode iFeileimode) {
String getname = isousuoxiangqing.getname();
i=1;
Map<String,String> map=new HashMap<>();
map.put("keywords",getname);
map.put("page",i+"");
map.put("sort",p+"");
iFeileimode.getsouxaingqing(map, new Sousuoxiangqing() {
@Override
public void getsousuoxaingqing(List<Sousuobean.DataBean> data) {
isousuoxiangqing.dianji();
isousuoxiangqing.setsousuoxiangqing(context,data);
isousuoxiangqing.shuaxinjizai();
}
});
}
@Override
public void sousuoxaingqingjiazaimv(int p, final Isousuoxiangqing isousuoxiangqing, IFeileimode iFeileimode) {
String getname = isousuoxiangqing.getname();
i++;
Map<String,String> map=new HashMap<>();
map.put("keywords",getname);
map.put("page",i+"");
map.put("sort",p+"");
iFeileimode.getsouxaingqing(map, new Sousuoxiangqing() {
@Override
public void getsousuoxaingqing(List<Sousuobean.DataBean> data) {
isousuoxiangqing.jiazai(data);
}
});
}
@Override
public void shouye(final Context context, final IShouye iShouye, IFeileimode iFeileimode) {
iFeileimode.getshouye(new Getshouye() {
@Override
public void getshoyyelisteneter(Shouyebean shouyebean) {
iShouye.setmyadapter(context,shouyebean);
iShouye.shuaxinjiazai();
}
});
}
@Override
public void shouye1(final IShouye iShouye, IFeileimode iFeileimode) {
iFeileimode.getnet(new Getnetjson() {
@Override
public void getnetJson(List<Good.DataBean> data) {
iShouye.setmyadapter1(data);
}
});
}
@Override
public void gouwuche(final Context context, final Igouwuche igouwuche, IFeileimode iFeileimode) {
iFeileimode.getgouwuche(new Getgouwuchejson() {
@Override
public void getgouwuche(Gouwuchebean gouwuchebean) {
igouwuche.setmyadapter(context,gouwuchebean);
}
});
}
@Override
public void textcount(Igouwuche igouwuche, IFeileimode iFeileimode, List<Gouwuchebean.DataBean> data) {
double jisuan = iFeileimode.jisuan(data);
igouwuche.settext(jisuan);
}
@Override
public void getdenglumv(Userbean userbean,final Idenglu idenglu, IFeileimode iFeileimode) {
Map<String,String> map=new HashMap<>();
map.put("mobile",userbean.getTel());
map.put("password",userbean.getPwd());
iFeileimode.getdenglu(map,new Getdenglu() {
@Override
public void getDenglu(Denglubean denglubean) {
if (denglubean.getCode().equals("0")){
idenglu.getbean(denglubean);
}else {
idenglu.shibai(denglubean.getMsg());
}
}
});
}
@Override
public void getusermv(String uid, final If2 if2, IFeileimode iFeileimode) {
Map<String,String> map=new HashMap<>();
map.put("uid",uid);
iFeileimode.getuser1(map, new Getuserjson() {
@Override
public void getUser(Getuser getuser) {
if2.chenggong(getuser);
}
});
}
@Override
public void getzhucemv(Userbean getuserbean, final Izhuce izhuce, IFeileimode iFeileimode) {
Map<String,String> map=new HashMap<>();
map.put("mobile",getuserbean.getTel());
map.put("password",getuserbean.getPwd());
iFeileimode.getzhuce(map, new Zhucelisteneter() {
@Override
public void zhucejson(Zhucebean zhucebean) {
if (zhucebean.getCode().equals("0")){
izhuce.chenggong();
}else {
izhuce.shibai(zhucebean.getMsg());
}
}
});
}
@Override
public void upnamemv(String uid, String name, final If2 if2, IFeileimode iFeileimode) {
Map<String,String> map=new HashMap<>();
map.put("uid",uid);
map.put("nickname",name);
iFeileimode.updataname(map, new Updatausername() {
@Override
public void upName(Upname upname) {
if (upname.getCode().equals("0")){
if2.upnamechenggong();
}
}
});
}
@Override
public void updatatouxiangmv(String uid, File file, final If2 if2, IFeileimode iFeileimode) {
iFeileimode.updatouxiang(uid, file, new Updatausername() {
@Override
public void upName(Upname upname) {
if (upname.getCode().equals("0")){
if2.uptouxiangchenggong();
}
}
});
}
}
util
public class Util {
private volatile static Util util=null;
private Util(){
}
public static Util getmInstance(){
if (util==null){
synchronized (Util.class){
if (util==null){
util=new Util();
}
}
}
return util;
}
public Testservice getnetjson(String uri) {
Retrofit retrofit = new Retrofit.Builder().baseUrl(uri)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
Testservice testservive = retrofit.create(Testservice.class);
return testservive;
}
}
public interface Testservice {
@GET("product/getCatagory")
Observable<Good> getGood();
@POST("product/getProductCatagory")
@FormUrlEncoded
Observable<Good_right> postUsermap(@FieldMap Map<String,String> map);
@POST("product/getProducts")
@FormUrlEncoded
Observable<Good_xiangqing> postshopmap(@FieldMap Map<String,String> map);
@POST("product/getProductDetail?source=android")
@FormUrlEncoded
Observable<Shop_xiangqing> postgetshop(@FieldMap Map<String,String> map);
@POST("product/addCart?source=android&uid=71")
@FormUrlEncoded
Observable<Addgood> addshop(@FieldMap Map<String,String> map);
@POST("a2a/impressApi/news/mergeList?pageSize=10")
@FormUrlEncoded
Observable<User> getuset(@FieldMap Map<String,String> map);
@POST("product/searchProducts?source=android")
@FormUrlEncoded
Observable<Sousuobean> getsouxaing(@FieldMap Map<String,String> map);
@GET("ad/getAd")
Observable<Shouyebean> getShouye();
@GET("product/getCarts?source=android&uid=71")
Observable<Gouwuchebean> getgouwuche();
@POST("user/login")
@FormUrlEncoded
Observable<Denglubean> getdenglu(@FieldMap Map<String,String> map);
@POST("user/getUserInfo")
@FormUrlEncoded
Observable<Getuser> getuserbean(@FieldMap Map<String,String> map);
@POST("user/reg")
@FormUrlEncoded
Observable<Zhucebean> getzhucebean(@FieldMap Map<String,String> map);
@POST("user/updateNickName")
@FormUrlEncoded
Observable<Upname> upname(@FieldMap Map<String,String> map);
//第二种方式上传头像
@POST("file/upload")
@Multipart
Observable<Upname> upload2(@Query("uid") String uid, @Part MultipartBody.Part file);
}
public class Myapp extends Application {
public static Context context;
@Override
public void onCreate() {
super.onCreate();
MobSDK.init(this);
Fresco.initialize(this);
context=getApplicationContext();
//调用工具包里面的方法
GreenDaoUtils.getmInstance().init();
}
}
public class GreenDaoUtils {
private volatile static GreenDaoUtils greenDaoUtils;
private DaoSession daoSession;
private SQLiteDatabase database;
private GreenDaoUtils(){
}
public static GreenDaoUtils getmInstance(){
if (greenDaoUtils==null){
synchronized (GreenDaoUtils.class){
if (greenDaoUtils==null){
greenDaoUtils=new GreenDaoUtils();
}
}
}
return greenDaoUtils;
}
//初始化数据 这个方法在Application里面调用
public void init(){
setDataBase();
}
private void setDataBase() {
//调用Application里面的上下文 参数二为数据库名字
DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(Myapp.context, "user.db", null);
database = helper.getWritableDatabase();
DaoMaster daoMaster= new DaoMaster(database);
daoSession = daoMaster.newSession();
}
public DaoSession getDaoSession(){
return daoSession;
}
public SQLiteDatabase getSQLiteDatabase(){
return database;
}
}
public interface Getnet {
public static String fenlei="http://120.27.23.105/";
public static String fenleiright="http://120.27.23.105/";
public static String fenleixaingqing="http://120.27.23.105/";
public static String fenleixaingqing1="http://120.27.23.105/";
public static String addgou="http://120.27.23.105/";
public static String user="http://www.yulin520.com/";
public static String sousuoxaing="http://120.27.23.105/";
public static String shouye="http://120.27.23.105/";
}
view
public interface IFeileishow {
String getscid();
void mysetadapter(Context context,List<Good_xiangqing.DataBean> data);
void shuaxinjiazai();
void jiazai(List<Good_xiangqing.DataBean> data);
void dianji();
}
public interface Ifaxian {
void setadapter(Context context, List<User.DataBean> data);
void shuaxinjiazai();
void jiazai(List<User.DataBean> data);
}
public interface Idenglu {
void getbean(Denglubean denglubean);
void shibai(String shi);
}
public class Feileixiangqing extends AppCompatActivity {
@BindView(R.id.tab)
TabLayout tb;
@BindView(R.id.vp)
ViewPager vp;
List<Fragment> list=new ArrayList<>();
List<String> listtile=new ArrayList<>();
private Feilei1 feilei1;
private String pid;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.feileixiangqing);
ButterKnife.bind(this);
getSupportActionBar().hide();
Intent intent =getIntent();
pid = intent.getStringExtra("pid");
settablayou();
}
public void settablayou() {
feilei1 = new Feilei1();
list.add(feilei1);
list.add(new Feilei2());
list.add(new Feilei3());
listtile.add("商品");
listtile.add("详情");
listtile.add("评价");
Bundle bundle = new Bundle();
bundle.putString("str", pid);
feilei1.setArguments(bundle);
tb.setTabMode(TabLayout.MODE_FIXED);
tb.setupWithViewPager(vp);
vp.setAdapter(new Myadapter(getSupportFragmentManager()));
}
class Myadapter extends FragmentPagerAdapter{
public Myadapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return list.get(position);
}
@Override
public int getCount() {
return list.size();
}
@Override
public CharSequence getPageTitle(int position) {
return listtile.get(position);
}
}
}
public class Feileishow extends AppCompatActivity implements IFeileishow{
private String id;
@BindView(R.id.xrc)
XRecyclerView xrc;
@BindView(R.id.rg)
RadioGroup rg;
@BindView(R.id.qie)
ImageView qie;
@BindView(R.id.fl_sousuo)
TextView fl_sousuo;
private Mypresenter mypresenter;
private Myadapterxiangqing myadapterxiangqing;
private int p;
private boolean flog=true;
private List<Good_xiangqing.DataBean> data;
private int i=R.layout.activity_sousuo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_feileishow);
ButterKnife.bind(this);
getSupportActionBar().hide();
Intent intent = getIntent();
id = intent.getStringExtra("id");
mypresenter = new Mypresenter();
mypresenter.getfeileixiangqing(p,Feileishow.this,new Mymode(),Feileishow.this);
fl_sousuo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(Feileishow.this,Sousuo.class);
startActivity(intent);
}
});
}
@Override
public String getscid() {
return id;
}
@Override
public void shuaxinjiazai() {
xrc.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
mypresenter.getfeileixiangqing(p,Feileishow.this,new Mymode(),Feileishow.this);
xrc.refreshComplete();
}
@Override
public void onLoadMore() {
mypresenter.getfeileixiangqingjiazai(p,new Mymode(),Feileishow.this);
xrc.refreshComplete();
}
});
}
@Override
public void mysetadapter(Context context, final List<Good_xiangqing.DataBean> data) {
this.data=data;
myadapterxiangqing = new Myadapterxiangqing(context,data,i);
xrc.setAdapter(myadapterxiangqing);
if (flog) {
xrc.setLayoutManager(new LinearLayoutManager(Feileishow.this));
}
myadapterxiangqing.huidiao(new Myadapterxiangqing.Itemclick() {
@Override
public void itemclick(View view, int position) {
int pid = (int) data.get(position).getPid();
Intent intent = new Intent(Feileishow.this, Feileixiangqing.class);
intent.putExtra("pid",pid+"");
startActivity(intent);
}
});
}
@Override
public void jiazai(List<Good_xiangqing.DataBean> data) {
List<Good_xiangqing.DataBean> list = myadapterxiangqing.getList();
list.addAll(data);
if (data.size()==0){
Toast.makeText(Feileishow.this,"没有数据了",Toast.LENGTH_SHORT).show();
}
myadapterxiangqing.notifyDataSetChanged();
}
@Override
public void dianji() {
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.rb:
p=0;
mypresenter.getfeileixiangqing(p,Feileishow.this,new Mymode(),Feileishow.this);
break;
case R.id.rb1:
p=1;
mypresenter.getfeileixiangqing(p,Feileishow.this,new Mymode(),Feileishow.this);
break;
case R.id.rb2:
p=2;
mypresenter.getfeileixiangqing(p,Feileishow.this,new Mymode(),Feileishow.this);
break;
}
}
});
qie.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (flog){
qie.setImageResource(R.drawable.kind_grid);
i=R.layout.activity_sousuo1;
myadapterxiangqing = new Myadapterxiangqing(Feileishow.this,data,i);
xrc.setAdapter(myadapterxiangqing);
xrc.setLayoutManager(new GridLayoutManager(Feileishow.this,2));
flog=false;
}else{
qie.setImageResource(R.drawable.kind_liner);
i=R.layout.activity_sousuo;
myadapterxiangqing = new Myadapterxiangqing(Feileishow.this,data,i);
xrc.setAdapter(myadapterxiangqing);
xrc.setLayoutManager(new LinearLayoutManager(Feileishow.this));
flog=true;
}
}
});
}
}
public class Denglu extends AppCompatActivity implements View.OnClickListener,Idenglu{
@BindView(R.id.wode_bt)
Button wode_bt;
@BindView(R.id.ed)
EditText ed;
@BindView(R.id.ed1)
EditText ed1;
@BindView(R.id.wode_zhuce)
TextView wode_zhuce;
private SharedPreferences ji;
private Intent intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.denglu);
ButterKnife.bind(this);
wode_bt.setOnClickListener(this);
wode_zhuce.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.wode_bt:
Mypresenter mypresenter=new Mypresenter();
String tel = ed.getText().toString();
String pwd = ed1.getText().toString();
Userbean userbean = new Userbean(tel, pwd);
mypresenter.getdenglumv(userbean,this,new Mymode());
break;
case R.id.wode_zhuce:
startActivityForResult(new Intent(Denglu.this,Zhuce.class),1);
break;
}
}
//登陆成功
@Override
public void getbean(Denglubean denglubean) {
int uid = denglubean.getData().getUid();
Intent intent = getIntent();
Intent intent1 = intent.putExtra("uid", uid+"");
setResult(2,intent1);
finish();
}
@Override
public void shibai(String shi) {
Toast.makeText(Denglu.this,shi,Toast.LENGTH_SHORT).show();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode==3){
Userbean zhuceuser = (Userbean) data.getSerializableExtra("zhuceuser");
Mypresenter mypresenter=new Mypresenter();
mypresenter.getdenglumv(zhuceuser,this,new Mymode());
}
}
}
public abstract class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentview());
ButterKnife.bind(this);
initData();
btclick();
}
abstract int getContentview();
//初始化数据
abstract void initData();
//设置点击事件的方法
protected abstract void btclick();
//跳转的方法
public void startActivity(Class<?> cla){
startActivity(new Intent(this,cla));
}
//吐司的方法
public void Tost(String s){
Toast.makeText(this,s,Toast.LENGTH_SHORT).show();
}
}
public class ZoomImageView extends android.support.v7.widget.AppCompatImageView implements ViewTreeObserver.OnGlobalLayoutListener, ScaleGestureDetector.OnScaleGestureListener, View.OnTouchListener {
private boolean mOnce;
/**
* 初始化时缩放的值
*/
private float mInitScale;
/**
* 双击放大值到达的值
*/
private float mMidScale;
/**
* 放大的最大值
*/
private float mMaxScale;
private Matrix mScaleMatrix;
/**
* 捕获用户多指触控时缩放的比例
*/
private ScaleGestureDetector mScaleGestureDetector;
// **********自由移动的变量***********
/**
* 记录上一次多点触控的数量
*/
private int mLastPointerCount;
private float mLastX;
private float mLastY;
private int mTouchSlop;
private boolean isCanDrag;
private boolean isCheckLeftAndRight;
private boolean isCheckTopAndBottom;
// *********双击放大与缩小*********
private GestureDetector mGestureDetector;
private boolean isAutoScale;
public ZoomImageView(Context context) {
this(context, null);
}
public ZoomImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ZoomImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// init
mScaleMatrix = new Matrix();
setScaleType(ScaleType.MATRIX);
setOnTouchListener(this);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mScaleGestureDetector = new ScaleGestureDetector(context, this);
mGestureDetector = new GestureDetector(context,
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
if (isAutoScale) {
return true;
}
float x = e.getX();
float y = e.getY();
if (getScale() < mMidScale) {
postDelayed(new AutoScaleRunnable(mMidScale, x, y), 16);
isAutoScale = true;
} else {
postDelayed(new AutoScaleRunnable(mInitScale, x, y), 16);
isAutoScale = true;
}
return true;
}
});
}
/**
* 自动放大与缩小
*
* @author [email protected]
*
*/
private class AutoScaleRunnable implements Runnable {
/**
* 缩放的目标值
*/
private float mTargetScale;
// 缩放的中心点
private float x;
private float y;
private final float BIGGER = 1.07f;
private final float SMALL = 0.93f;
private float tmpScale;
/**
* @param mTargetScale
* @param x
* @param y
*/
public AutoScaleRunnable(float mTargetScale, float x, float y) {
this.mTargetScale = mTargetScale;
this.x = x;
this.y = y;
if (getScale() < mTargetScale) {
tmpScale = BIGGER;
}
if (getScale() > mTargetScale) {
tmpScale = SMALL;
}
}
@Override
public void run() {
//进行缩放
mScaleMatrix.postScale(tmpScale, tmpScale, x, y);
checkBorderAndCenterWhenScale();
setImageMatrix(mScaleMatrix);
float currentScale = getScale();
if ((tmpScale >1.0f && currentScale <mTargetScale) ||(tmpScale<1.0f &¤tScale>mTargetScale)) {
//这个方法是重新调用run()方法
postDelayed(this, 16);
}else{
//设置为我们的目标值
float scale = mTargetScale/currentScale;
mScaleMatrix.postScale(scale, scale, x, y);
checkBorderAndCenterWhenScale();
setImageMatrix(mScaleMatrix);
isAutoScale = false;
}
}
}
/**
* 获取ImageView加载完成的图片
*/
@Override
public void onGlobalLayout() {
if (!mOnce) {
// 得到控件的宽和高
int width = getWidth();
int height = getHeight();
// 得到我们的图片,以及宽和高
Drawable drawable = getDrawable();
if (drawable == null) {
return;
}
int dh = drawable.getIntrinsicHeight();
int dw = drawable.getIntrinsicWidth();
float scale = 0.5f;
// 图片的宽度大于控件的宽度,图片的高度小于空间的高度,我们将其缩小
if (dw > width && dh < height) {
scale = width * 1.0f / dw;
}
// 图片的宽度小于控件的宽度,图片的高度大于空间的高度,我们将其缩小
if (dh > height && dw < width) {
scale = height * 1.0f / dh;
}
// 缩小值
if (dw > width && dh > height) {
scale = Math.min(width * 1.0f / dw, height * 1.0f / dh);
}
// 放大值
if (dw < width && dh < height) {
scale = Math.min(width * 1.0f / dw, height * 1.0f / dh);
}
/**
* 得到了初始化时缩放的比例
*/
mInitScale = scale;
mMaxScale = mInitScale * 4;
mMidScale = mInitScale * 2;
// 将图片移动至控件的中间
int dx = getWidth() / 2 - dw / 2;
int dy = getHeight() / 2 - dh / 2;
mScaleMatrix.postTranslate(dx, dy);
mScaleMatrix.postScale(mInitScale, mInitScale, width / 2,
height / 2);
setImageMatrix(mScaleMatrix);
mOnce = true;
}
}
/**
* 注册OnGlobalLayoutListener这个接口
*/
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
getViewTreeObserver().addOnGlobalLayoutListener(this);
}
/**
* 取消OnGlobalLayoutListener这个接口
*/
@SuppressWarnings("deprecation")
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
/**
* 获取当前图片的缩放值
*
* @return
*/
public float getScale() {
float[] values = new float[9];
mScaleMatrix.getValues(values);
return values[Matrix.MSCALE_X];
}
// 缩放区间时initScale maxScale
@Override
public boolean onScale(ScaleGestureDetector detector) {
float scale = getScale();
float scaleFactor = detector.getScaleFactor();
if (getDrawable() == null) {
return true;
}
// 缩放范围的控制
if ((scale < mMaxScale && scaleFactor > 1.0f)
|| (scale > mInitScale && scaleFactor < 1.0f)) {
if (scale * scaleFactor < mInitScale) {
scaleFactor = mInitScale / scale;
}
if (scale * scaleFactor > mMaxScale) {
scale = mMaxScale / scale;
}
// 缩放
mScaleMatrix.postScale(scaleFactor, scaleFactor,
detector.getFocusX(), detector.getFocusY());
checkBorderAndCenterWhenScale();
setImageMatrix(mScaleMatrix);
}
return true;
}
/**
* 获得图片放大缩小以后的宽和高,以及left,right,top,bottom
*
* @return
*/
private RectF getMatrixRectF() {
Matrix matrix = mScaleMatrix;
RectF rectF = new RectF();
Drawable d = getDrawable();
if (d != null) {
rectF.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
matrix.mapRect(rectF);
}
return rectF;
}
/**
* 在缩放的时候进行边界以及我们的位置的控制
*/
private void checkBorderAndCenterWhenScale() {
RectF rectF = getMatrixRectF();
float deltaX = 0;
float deltaY = 0;
int width = getWidth();
int height = getHeight();
// 缩放时进行边界检测,防止出现白边
if (rectF.width() >= width) {
if (rectF.left > 0) {
deltaX = -rectF.left;
}
if (rectF.right < width) {
deltaX = width - rectF.right;
}
}
if (rectF.height() >= height) {
if (rectF.top > 0) {
deltaY = -rectF.top;
}
if (rectF.bottom < height) {
deltaY = height - rectF.bottom;
}
}
/**
* 如果宽度或高度小于空间的宽或者高,则让其居中
*/
if (rectF.width() < width) {
deltaX = width / 2f - rectF.right + rectF.width() / 2f;
}
if (rectF.height() < height) {
deltaY = height / 2f - rectF.bottom + rectF.height() / 2f;
}
mScaleMatrix.postTranslate(deltaX, deltaY);
}
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
return true;
}
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
}
@Override
public boolean onTouch(View v, MotionEvent event) {
if (mGestureDetector.onTouchEvent(event)) {
return true;
}
mScaleGestureDetector.onTouchEvent(event);
float x = 0;
float y = 0;
// 拿到多点触控的数量
int pointerCount = event.getPointerCount();
for (int i = 0; i < pointerCount; i++) {
x += event.getX(i);
y += event.getY(i);
}
x /= pointerCount;
y /= pointerCount;
if (mLastPointerCount != pointerCount) {
isCanDrag = false;
mLastX = x;
mLastY = y;
}
mLastPointerCount = pointerCount;
RectF rectF = getMatrixRectF();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (rectF.width()>getWidth() +0.01|| rectF.height()>getHeight()+0.01) {
if(getParent() instanceof ViewPager)
getParent().requestDisallowInterceptTouchEvent(true);
}
break;
case MotionEvent.ACTION_MOVE:
if (rectF.width()>getWidth()+0.01 || rectF.height()>getHeight()+0.01) {
if(getParent() instanceof ViewPager){
Log.e("---","----+++");
getParent().requestDisallowInterceptTouchEvent(true);
}
}
float dx = x - mLastX;
float dy = y - mLastY;
if (!isCanDrag) {
isCanDrag = isMoveAction(dx, dy);
}
if (isCanDrag) {
if (getDrawable() != null) {
isCheckLeftAndRight = isCheckTopAndBottom = true;
// 如果宽度小于控件宽度,不允许横向移动
if (rectF.width() < getWidth()) {
isCheckLeftAndRight = false;
dx = 0;
}
// 如果高度小于控件高度,不允许纵向移动
if (rectF.height() < getHeight()) {
isCheckTopAndBottom = false;
dy = 0;
}
mScaleMatrix.postTranslate(dx, dy);
checkBorderWhenTranslate();
setImageMatrix(mScaleMatrix);
}
}
mLastX = x;
mLastY = y;
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mLastPointerCount = 0;
break;
default:
break;
}
return true;
}
/**
* 当移动时进行边界检查
*/
private void checkBorderWhenTranslate() {
RectF rectF = getMatrixRectF();
float deltaX = 0;
float deltaY = 0;
int width = getWidth();
int heigth = getHeight();
if (rectF.top > 0 && isCheckTopAndBottom) {
deltaY = -rectF.top;
}
if (rectF.bottom < heigth && isCheckTopAndBottom) {
deltaY = heigth - rectF.bottom;
}
if (rectF.left > 0 && isCheckLeftAndRight) {
deltaX = -rectF.left;
}
if (rectF.right < width && isCheckLeftAndRight) {
deltaX = width - rectF.right;
}
mScaleMatrix.postTranslate(deltaX, deltaY);
}
/**
* 判断是否是move
*
* @param dx
* @param dy
* @return
*/
private boolean isMoveAction(float dx, float dy) {
return Math.sqrt(dx * dx + dy * dy) > mTouchSlop;
}
}
public class Zhuce extends AppCompatActivity implements View.OnClickListener,Izhuce{
public static final String REGEX_MOBILE = "^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
@BindView(R.id.zhuce_tel)
EditText zhuce_tel;
@BindView(R.id.zhuce_pwd)
EditText zhuce_pwd;
@BindView(R.id.zhuce_ed1)
EditText zhuce_ed1;
@BindView(R.id.zhuce_bt1)
Button zhuce_bt1;
@BindView(R.id.zhuce_bt)
Button zhuce_bt;
private String tel;
@SuppressLint("HandlerLeak")
Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
int what = msg.what;
switch (what) {
case 1:
String zhuce_tel1 = zhuce_tel.getText().toString();
String zhuce_pwd1 = zhuce_pwd.getText().toString();
userbean = new Userbean(zhuce_tel1, zhuce_pwd1);
Mypresenter mypresenter=new Mypresenter();
mypresenter.getzhucemv(userbean,Zhuce.this,new Mymode());
break;
case 2:
Toast.makeText(Zhuce.this,"验证码输入错误",Toast.LENGTH_SHORT).show();
break;
}
}
};
private Userbean userbean;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zhuce);
ButterKnife.bind(this);
zhuce_bt.setOnClickListener(this);
zhuce_bt1.setOnClickListener(this);
}
public static boolean isMobile(String mobile) {
return Pattern.matches(REGEX_MOBILE, mobile);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.zhuce_bt:
tel = zhuce_tel.getText().toString();
boolean mobile = isMobile(tel);
if (!mobile){
Toast.makeText(this, "手机号不正确", Toast.LENGTH_SHORT).show();
}else {
sendCode("86", tel);
}
break;
case R.id.zhuce_bt1:
submitCode("86", tel,zhuce_ed1.getText().toString());
break;
}
}
// 请求验证码,其中country表示国家代码,如“86”;phone表示手机号码,如“13800138000”
public void sendCode(String country, String phone) {
// 注册一个事件回调,用于处理发送验证码操作的结果
SMSSDK.registerEventHandler(new EventHandler() {
public void afterEvent(int event, int result, Object data) {
if (result == SMSSDK.RESULT_COMPLETE) {
// TODO 处理成功得到验证码的结果
// 请注意,此时只是完成了发送验证码的请求,验证码短信还需要几秒钟之后才送达
} else{
// TODO 处理错误的结果
}
}
});
// 触发操作
SMSSDK.getVerificationCode(country, phone);
}
// 提交验证码,其中的code表示验证码,如“1357”
public void submitCode(String country, String phone, String code) {
// 注册一个事件回调,用于处理提交验证码操作的结果
SMSSDK.registerEventHandler(new EventHandler() {
public void afterEvent(int event, int result, Object data) {
if (result == SMSSDK.RESULT_COMPLETE) {
handler.sendEmptyMessage(1);
} else{
handler.sendEmptyMessage(2);
}
}
});
// 触发操作
SMSSDK.submitVerificationCode(country, phone, code);
}
@Override
public void chenggong() {
Intent intent = getIntent();
intent.putExtra("zhuceuser", userbean);
setResult(3,intent);
finish();
}
@Override
public void shibai(String shi) {
Toast.makeText(Zhuce.this,shi,Toast.LENGTH_SHORT).show();
}
}
public class Sousuoxiangqing extends AppCompatActivity implements Isousuoxiangqing{
private String name;
private int i=R.layout.activity_sousuo;
@BindView(R.id.xrc)
XRecyclerView xrc;
@BindView(R.id.rg)
RadioGroup rg;
@BindView(R.id.qie)
ImageView qie;
@BindView(R.id.fl_sousuo)
TextView fl_sousuo;
private boolean flog=true;
private Mypresenter mypresenter;
private int p;
private Mysousuoadapter mysousuoadapter;
private List<Sousuobean.DataBean> data;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_feileishow);
ButterKnife.bind(this);
Intent intent = getIntent();
name = intent.getStringExtra("name");
mypresenter = new Mypresenter();
mypresenter.sousuoxaingqingmv(p,this,this,new Mymode());
}
@Override
public String getname() {
return name;
}
@Override
public void setsousuoxiangqing(Context context, final List<Sousuobean.DataBean> data) {
this.data=data;
mysousuoadapter = new Mysousuoadapter(context,data,i);
xrc.setAdapter(mysousuoadapter);
if (flog) {
xrc.setLayoutManager(new LinearLayoutManager(Sousuoxiangqing.this));
}
mysousuoadapter.huidiao(new Mysousuoadapter.Itemclick() {
@Override
public void itemclick(View view, int position) {
int pid = (int) data.get(position).getPid();
Intent intent = new Intent(Sousuoxiangqing.this, Feileixiangqing.class);
intent.putExtra("pid",pid+"");
startActivity(intent);
}
});
}
@Override
public void shuaxinjizai() {
xrc.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
mypresenter.sousuoxaingqingmv(p,Sousuoxiangqing.this,Sousuoxiangqing.this,new Mymode());
xrc.refreshComplete();
}
@Override
public void onLoadMore() {
mypresenter.sousuoxaingqingjiazaimv(p,Sousuoxiangqing.this,new Mymode());
xrc.refreshComplete();
}
});
}
@Override
public void jiazai(List<Sousuobean.DataBean> data) {
List<Sousuobean.DataBean> list = mysousuoadapter.getList();
list.addAll(data);
if (data.size()==0){
Toast.makeText(Sousuoxiangqing.this,"没有数据了",Toast.LENGTH_SHORT).show();
}
mysousuoadapter.notifyDataSetChanged();
}
@Override
public void dianji() {
Log.d("哈哈11", "onCheckedChanged: ");
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.rb:
Log.d("哈哈", "onCheckedChanged: ");
p=0;
mypresenter.sousuoxaingqingmv(p,Sousuoxiangqing.this,Sousuoxiangqing.this,new Mymode());
break;
case R.id.rb1:
p=1;
mypresenter.sousuoxaingqingmv(p,Sousuoxiangqing.this,Sousuoxiangqing.this,new Mymode());
break;
case R.id.rb2:
p=2;
mypresenter.sousuoxaingqingmv(p,Sousuoxiangqing.this,Sousuoxiangqing.this,new Mymode());
break;
}
}
});
qie.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (flog){
qie.setImageResource(R.drawable.kind_grid);
i=R.layout.activity_sousuo1;
mysousuoadapter = new Mysousuoadapter(Sousuoxiangqing.this,data,i);
xrc.setAdapter(mysousuoadapter);
xrc.setLayoutManager(new GridLayoutManager(Sousuoxiangqing.this,2));
flog=false;
}else{
qie.setImageResource(R.drawable.kind_liner);
i=R.layout.activity_sousuo;
mysousuoadapter = new Mysousuoadapter(Sousuoxiangqing.this,data,i);
xrc.setAdapter(mysousuoadapter);
xrc.setLayoutManager(new LinearLayoutManager(Sousuoxiangqing.this));
flog=true;
}
}
});
}
}
public class Sousuo extends AppCompatActivity {
private String mNames[] = { "完美世界", "大主宰", "斗破苍穹", "绝世唐门", "你好啊", "遮天", "微微一笑很倾城", "何以笙箫默", "三生三世十里桃花", "琅琊榜",
"天下", "刀剑神皇", "大漠谣", "回到明朝当王爷", "兵临天下", "谁的青春不迷茫" };
@BindView(R.id.sou)
EditText sou;
@BindView(R.id.sousuo)
TextView sousuo;
@BindView(R.id.lv)
ListView lv;
@BindView(R.id.qingkong)
TextView qingkong;
private SqluserDao sqluserDao;
private List<Sqluser> list;
private Mylistadapter mylistadapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sousuo);
ButterKnife.bind(this);
initChildViews();
//搜索的点击事件
sousuobt();
}
private void sousuobt() {
DaoSession daoSession = GreenDaoUtils.getmInstance().getDaoSession();
//增删改查都用 userDao来操作
sqluserDao = daoSession.getSqluserDao();
Query<Sqluser> query = sqluserDao.queryBuilder().build();
list = query.list();
if (list.size()!=0) {
mylistadapter = new Mylistadapter(Sousuo.this, list);
lv.setAdapter(mylistadapter);
}
sousuo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String sou1 = sou.getText().toString();
Sqluser sqluser=new Sqluser(sou1);
sqluserDao.insert(sqluser);
if (!sou1.equals("手机")&&(!sou1.equals("笔记本"))){
Toast.makeText(Sousuo.this,"搜索的商品不存在,请输入笔记本或手机",Toast.LENGTH_SHORT).show();
}else{
Intent intent=new Intent(Sousuo.this,Sousuoxiangqing.class);
String sou2 = sou.getText().toString();
intent.putExtra("name",sou2);
startActivity(intent);
finish();
}
}
});
qingkong.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sqluserDao.deleteAll();
Query<Sqluser> query = sqluserDao.queryBuilder().build();
list = query.list();
mylistadapter = new Mylistadapter(Sousuo.this, list);
lv.setAdapter(mylistadapter);
}
});
}
private void initChildViews() {
Myview mv=findViewById(R.id.mv);
ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
//设置两个控件之间的距离
lp.leftMargin = 10;
lp.rightMargin = 10;
lp.topMargin = 10;
lp.bottomMargin = 10;
for (int i = 0; i < mNames.length; i++) {
TextView view = new TextView(this);
view.setText(mNames[i]);
view.setTextColor(Color.WHITE);
view.setBackgroundDrawable(getResources().getDrawable(R.drawable.textshap));
mv.addView(view, lp);
final int finalI = i;
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(Sousuo.this,mNames[finalI],Toast.LENGTH_SHORT).show();
}
});
}
}
}
public class Myview extends ViewGroup {
public Myview(Context context) {
this(context,null);
}
public Myview(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public Myview(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//测量模式
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
//测量ViewGroup的宽高
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
//ViewGroup的padding
int paddingTop = getPaddingTop();
int paddingBottom = getPaddingBottom();
int paddingLeft = getPaddingLeft();
int paddingRight = getPaddingRight();
//当前宽度
int curWidth = 0;
//当前高度
int curHeight = paddingTop + paddingBottom;
//最大宽度
int widthMax = 0;
for(int i = 0;i < getChildCount();){
View childView = getChildAt(i);
measureChild(childView, widthMeasureSpec, heightMeasureSpec);
MarginLayoutParams marginLayoutParams = (MarginLayoutParams) childView.getLayoutParams();
int childWidth = childView.getMeasuredWidth();
int childHeight = childView.getMeasuredHeight();
if(curWidth == 0 ){
curWidth = paddingLeft + paddingRight;
curHeight += marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + childHeight;
}
if(curWidth + marginLayoutParams.rightMargin + marginLayoutParams.leftMargin + childWidth <= widthSize){
//不换行
curWidth += marginLayoutParams.rightMargin + marginLayoutParams.leftMargin + childWidth;
i++;
}else{
//换行
widthMax = Math.max(widthMax, curWidth);
curWidth = 0;
}
//判断是否是最后一行
if(i == getChildCount()){
widthMax = Math.max(widthMax, curWidth);
curHeight += marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + childHeight;
}
}
setMeasuredDimension(widthMode == MeasureSpec.EXACTLY ? widthSize : widthMax ,
heightMode == MeasureSpec.EXACTLY ? heightSize : curHeight);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
//获取ViewGroup的padding
int paddingTop = getPaddingTop();
int paddingBottom = getPaddingBottom();
int paddingLeft = getPaddingLeft();
int paddingRight = getPaddingRight();
//当前宽度;
int curWidth = paddingLeft;
//当前高度
int curHeight = paddingTop;
for(int i = 0; i < getChildCount();){
View childView = getChildAt(i);
MarginLayoutParams marginLayoutParams = (MarginLayoutParams) childView.getLayoutParams();
int childWidth = childView.getMeasuredWidth();
int childHeight = childView.getMeasuredHeight();
if(curWidth + paddingRight + marginLayoutParams.rightMargin + marginLayoutParams.leftMargin + childWidth <= getWidth()){
//不换行
childView.layout(curWidth + marginLayoutParams.leftMargin,
curHeight + marginLayoutParams.topMargin,
curWidth + marginLayoutParams.leftMargin + childWidth,
curHeight + marginLayoutParams.topMargin + childHeight);
curWidth += marginLayoutParams.leftMargin + childWidth + marginLayoutParams.rightMargin;
i ++;
}else{
//换行
curHeight += marginLayoutParams.topMargin + childHeight + marginLayoutParams.bottomMargin;
curWidth = paddingLeft;
}
}
}
}
public class MainActivity extends com.example.administrator.jingdong.BaseActivity {
@BindView(R.id.viewpager)
ViewPager viewPager;
@BindView(R.id.rg)
RadioGroup rg;
@BindView(R.id.shouye)
RadioButton shouye;
@BindView(R.id.fenlei)
RadioButton fenlei;
@BindView(R.id.faxian)
RadioButton faxian;
@BindView(R.id.gouwuche)
RadioButton gouwuche;
@BindView(R.id.wode)
RadioButton wode;
private List<Fragment> fragmentList;
private Faxianfragment faxianfragment;
@Override
int getContentview() {
return R.layout.activity_main;
}
//初始化数据
@Override
void initData() {
getSupportActionBar().hide();
fragmentList = new ArrayList<>();
Shouyefragment shouyefragment=new Shouyefragment();
Fenleifragment fenleifragment=new Fenleifragment();
faxianfragment = new Faxianfragment();
Gouwuchefragment gouwuchefragment=new Gouwuchefragment();
Wodefragment wodefragment=new Wodefragment();
fragmentList.add(shouyefragment);
fragmentList.add(fenleifragment);
fragmentList.add(faxianfragment);
fragmentList.add(gouwuchefragment);
fragmentList.add(wodefragment);
//给viewpager设置适配器
viewPager.setAdapter(new Mypageradapter(getSupportFragmentManager()));
}
//点击事件的方法
@Override
protected void btclick() {
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
int q=0;
switch (checkedId) {
case R.id.shouye:
q=0;
break;
case R.id.fenlei:
q=1;
break;
case R.id.faxian:
q=2;
break;
case R.id.gouwuche:
q=3;
break;
case R.id.wode:
q=4;
break;
}
viewPager.setCurrentItem(q);
}
});
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
switch (position) {
case 0:
shouye.setChecked(true);
break;
case 1:
fenlei.setChecked(true);
break;
case 2:
faxian.setChecked(true);
break;
case 3:
gouwuche.setChecked(true);
break;
case 4:
wode.setChecked(true);
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
class Mypageradapter extends FragmentPagerAdapter{
public Mypageradapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
@Override
public int getCount() {
return fragmentList.size();
}
}
}
public class Lunbotu extends AppCompatActivity {
@BindView(R.id.vp)
ViewPager vp;
@BindView(R.id.tv)
TextView tv;
private ArrayList<String> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lunbotu);
ButterKnife.bind(this);
Intent intent = getIntent();
int i = intent.getIntExtra("name", 0);
list = intent.getStringArrayListExtra("list");
vp.setAdapter(new Myadapter());
vp.setCurrentItem(i);
tv.setText((i+1)+"/"+list.size());
vp.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
tv.setText((position+1)+"/"+list.size());
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
class Myadapter extends PagerAdapter{
@Override
public int getCount() {
return list.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view==object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ZoomImageView zoomImageView=new ZoomImageView(Lunbotu.this);
Glide.with(Lunbotu.this).load(list.get(position)).into(zoomImageView);
container.addView(zoomImageView);
return zoomImageView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
}
}
public interface Izhuce {
void chenggong();
void shibai(String shi);
}
public interface Isousuoxiangqing {
String getname();
void setsousuoxiangqing(Context context,List<Sousuobean.DataBean> data);
void shuaxinjizai();
void jiazai(List<Sousuobean.DataBean> data);
void dianji();
}
public interface IShouye {
void setmyadapter(Context context,Shouyebean shouyebean);
void setmyadapter1(List<Good.DataBean> data);
void shuaxinjiazai();
}
public interface Igouwuche {
void setmyadapter(Context context,Gouwuchebean gouwuchebean);
void settext(double he);
}
public interface IFenleiview {
void mysetadapter(Context context,List<Good.DataBean> data);
void mysetadapterright(Context context, List<Good_right.DataBean> data);
}
public interface IFeileixiangqing {
void settablayou(Shop_xiangqing.DataBean data);
String getpid();
void chenggong(String cheng);
}