Android實(shí)現(xiàn)上拉吸頂效果
本文實(shí)例為大家分享了Android實(shí)現(xiàn)上拉吸頂效果的具體代碼,供大家參考,具體內(nèi)容如下
效果圖
1.home_layout.xml
此布局即可實(shí)現(xiàn)上拉標(biāo)題固定在頂部
<?xml version="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" ? ? xmlns:app="http://schemas.android.com/apk/res-auto" ? ? xmlns:rvp="http://schemas.android.com/apk/res-auto" ? ? xmlns:tools="http://schemas.android.com/tools" ? ? xmlns:tl="http://schemas.android.com/tools" ? ? android:layout_width="match_parent" ? ? android:layout_height="match_parent" ? ? android:id="@+id/ll_base" ? ? android:background="@drawable/bg_f8f8f8" ? ? > ? ? ?<!-- <android.support.v4.widget.SwipeRefreshLayout ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="wrap_content">--> ? ? ? ? <!--中間內(nèi)容--> ? ? ? ? <LinearLayout ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? android:orientation="vertical" ? ? ? ? ? ? > ? ? ? ? ? ? ? <FrameLayout ? ? ? ? ? ? ? ? android:focusableInTouchMode="true" ? ? ? ? ? ? ? ? android:focusable="true" ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? android:visibility="gone" ? ? ? ? ? ? ? ? android:layout_height="205dp"> ? ? ? ? ? ? ? ? ? <com.broker.liming.banner.view.BannerBgContainer ? ? ? ? ? ? ? ? ? ? android:id="@+id/banner_bg_container" ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? android:layout_height="205dp" /> ? ? ? ? ? ? ? ? ? <com.broker.liming.banner.LoopLayout ? ? ? ? ? ? ? ? ? ? android:id="@+id/loop_layout" ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? android:layout_height="120dp" ? ? ? ? ? ? ? ? ? ? android:layout_gravity="bottom" ? ? ? ? ? ? ? ? ? ? android:layout_marginTop="@dimen/lay_85" /> ? ? ? ? ? ? </FrameLayout> ? ? ? ? ? ? <android.support.design.widget.CoordinatorLayout ? ? ? ? ? ? ? ? android:id="@+id/main_content" ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? android:layout_height="wrap_content"> ? ? ? ? ? ? ? ? ? <android.support.design.widget.AppBarLayout ? ? ? ? ? ? ? ? ? ? android:id="@+id/appbar" ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? app:elevation="0dp" ? ? ? ? ? ? ? ? ? ? app:layout_behavior="com.broker.liming.widget.AppBarLayoutBehavior" ? ? ? ? ? ? ? ? ? ? ? > ? ? ? ? ? ? ? ? ? ? ? <android.support.design.widget.CollapsingToolbarLayout ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/main.collapsing" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? app:layout_scrollFlags="scroll|exitUntilCollapsed"> ? ? ? ? ? ? ? ? ? ? ? ?<!-- android:fitsSystemWindows="true" ? ? ? ? ? ? ? ? ? ? ? ? app:contentScrim="?attr/colorPrimary" ? ? ? ? ? ? ? ? ? ? ? ? app:expandedTitleMarginEnd="64dp" ? ? ? ? ? ? ? ? ? ? ? ? app:expandedTitleMarginStart="48dp"--> ? ? ? ? ? ? ? ? ? ? ? <!-- ?<android.support.constraint.ConstraintLayout ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:fitsSystemWindows="true" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:scaleType="centerCrop" ? ? ? ? ? ? ? ? ? ? ? ? ? ? app:layout_collapseMode="parallax">--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <RelativeLayout ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:orientation="vertical" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:background="@drawable/bg_f8f8f8" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--app:layout_constraintTop_toTopOf="parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? app:layout_constraintLeft_toLeftOf="parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? app:layout_constraintRight_toRightOf="parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? app:layout_constraintBottom_toBottomOf="parent"--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <com.jcodecraeer.xrecyclerview.XRecyclerView ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/xrv_product" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? style="@style/match_view" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:nestedScrollingEnabled="false" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:scrollbars="none" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:visibility="visible" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? /> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <android.support.v7.widget.RecyclerView ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/recycler" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:visibility="gone" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:overScrollMode="never" /> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--<com.yi.haigou.shop.view.ShopInfoView ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/shop_inof_view" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? app:layout_constraintTop_toTopOf="parent" /> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <com.yi.haigou.shop.view.ShopAddressView ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/shop_address_view" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? app:layout_constraintBottom_toBottomOf="parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? app:layout_constraintTop_toTopOf="parent" />--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? </RelativeLayout> ? ? ? ? ? ? ? ? ? ? ? ? <!-- ?</android.support.constraint.ConstraintLayout>--> ? ? ? ? ? ? ? ? ? ? ? ? <android.support.v7.widget.Toolbar ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/toolbar" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="@dimen/lay_60" ? ? ? ? ? ? ? ? ? ? ? ? ? ? > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--<android.support.constraint.ConstraintLayout--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--android:layout_width="match_parent"--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--android:layout_height="match_parent">--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--<com.yi.shop.shop.view.ShopSearchBar--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--android:id="@+id/search_bar_view"--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--android:layout_width="match_parent"--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--android:layout_height="wrap_content"--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--android:background="@drawable/ic_shop_title"--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--app:layout_constraintTop_toTopOf="parent"/>--> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <!--</android.support.constraint.ConstraintLayout>--> ? ? ? ? ? ? ? ? ? ? ? ? </android.support.v7.widget.Toolbar> ? ? ? ? ? ? ? ? ? ? ? ? </android.support.design.widget.CollapsingToolbarLayout> ? ? ? ? ? ? ? ? ? </android.support.design.widget.AppBarLayout> ? ? ? ? ? ? ? ? <!--吸頂tab--> ? ? ? ? ? ? ? ? <LinearLayout ? ? ? ? ? ? ? ? ? ? android:id="@+id/ll_tab" ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? android:layout_height="match_parent" ? ? ? ? ? ? ? ? ? ? android:orientation="vertical" ? ? ? ? ? ? ? ? ? ? android:visibility="gone" ? ? ? ? ? ? ? ? ? ? app:layout_behavior="@string/appbar_scrolling_view_behavior"> ? ? ? ? ? ? ? ? ? ? ? <com.broker.liming.widget.SlidingTabLayout ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/tl_9" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="@dimen/lay_45" ? ? ? ? ? ? ? ? ? ? ? ? android:paddingLeft="12dp" ? ? ? ? ? ? ? ? ? ? ? ? android:paddingRight="12dp" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginTop="@dimen/lay_20" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_indicator_anim_duration="100" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_indicator_anim_enable="true" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_indicator_bounce_enable="false" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_indicator_color="@color/name_1A75FF" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_indicator_margin_left="2dp" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_indicator_margin_right="2dp" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_indicator_style="BLOCK" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_textSelectColor="@color/white" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_textUnselectColor="@color/text_000000" ? ? ? ? ? ? ? ? ? ? ? ? tl:tl_textsize="@dimen/font_13" ? ? ? ? ? ? ? ? ? ? ? ? /> ? ? ? ? ? ? ? ? ? ? <android.support.v4.view.ViewPager ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/viewpager" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginTop="@dimen/lay_12" ? ? ? ? ? ? ? ? ? ? ? ? /> ? ? ? ? ? ? ? ? ? ? <!--公司信息--> ? ? ? ? ? ? ? ? ? ? <LinearLayout ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? android:orientation="vertical" ? ? ? ? ? ? ? ? ? ? ? ? android:layout_alignParentBottom="true" ? ? ? ? ? ? ? ? ? ? ? ? android:visibility="gone" ? ? ? ? ? ? ? ? ? ? ? ? > ? ? ? ? ? ? ? ? ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/tv_phone" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginLeft="@dimen/lay_12" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginRight="@dimen/lay_12" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginTop="@dimen/lay_34" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:gravity="center" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:text="1569796696" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:textColor="@color/color_c7c7c7" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:textSize="@dimen/font_13" /> ? ? ? ? ? ? ? ? ? ? ? ? ? <LinearLayout ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginBottom="@dimen/font_16" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginLeft="@dimen/lay_12" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginRight="@dimen/lay_12" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginTop="@dimen/lay_12" ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:gravity="center"> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/tv_email" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:textColor="@color/color_c7c7c7" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:textSize="@dimen/font_13" /> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <ImageView ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:id="@+id/iv_copy" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:layout_marginLeft="@dimen/lay_6" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? android:background="@mipmap/home_copy" /> ? ? ? ? ? ? ? ? ? ? ? ? </LinearLayout> ? ? ? ? ? ? ? ? ? ? </LinearLayout> ? ? ? ? ? ? ? ? </LinearLayout> ? ? ? ? ? ? ? </android.support.design.widget.CoordinatorLayout> ? ? ? ? ? ? </LinearLayout> ? <!-- ?</android.support.v4.widget.SwipeRefreshLayout>--> ? ? ? ? <!--搜索--> ? ? <RelativeLayout ? ? ? ? android:id="@+id/rl_top" ? ? ? ? android:layout_width="match_parent" ? ? ? ? android:layout_height="@dimen/lay_70" ? ? ? ? android:background="@color/transparent" ? ? ? ? android:gravity="bottom"> ? ? ? ? ? <RelativeLayout ? ? ? ? ? ? android:id="@+id/rl_title" ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? android:layout_height="@dimen/lay_45" ? ? ? ? ? ? android:gravity="center_vertical" ? ? ? ? ? ? android:paddingLeft="@dimen/lay_12"> ? ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? android:id="@+id/tv_title" ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? android:layout_centerVertical="true" ? ? ? ? ? ? ? ? android:layout_marginRight="@dimen/lay_12" ? ? ? ? ? ? ? ? android:text="日月保盒" ? ? ? ? ? ? ? ? android:textColor="@color/white" ? ? ? ? ? ? ? ? android:textSize="@dimen/font_18" ? ? ? ? ? ? ? ? android:textStyle="bold" /> ? ? ? ? ? ? ? <LinearLayout ? ? ? ? ? ? ? ? android:id="@+id/ll_search" ? ? ? ? ? ? ? ? android:layout_width="match_parent" ? ? ? ? ? ? ? ? android:layout_height="@dimen/lay_31" ? ? ? ? ? ? ? ? android:layout_centerVertical="true" ? ? ? ? ? ? ? ? android:layout_marginRight="@dimen/lay_57" ? ? ? ? ? ? ? ? android:layout_toRightOf="@+id/tv_title" ? ? ? ? ? ? ? ? android:background="@drawable/shape_search_product" ? ? ? ? ? ? ? ? android:gravity="center_vertical"> ? ? ? ? ? ? ? ? ? <ImageView ? ? ? ? ? ? ? ? ? ? android:id="@+id/iv_search" ? ? ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? android:layout_centerVertical="true" ? ? ? ? ? ? ? ? ? ? android:layout_marginLeft="@dimen/lay_12" ? ? ? ? ? ? ? ? ? ? android:layout_marginRight="@dimen/lay_5" ? ? ? ? ? ? ? ? ? ? android:background="@mipmap/home_search" /> ? ? ? ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? ? ? android:id="@+id/tv_search" ? ? ? ? ? ? ? ? ? ? android:layout_width="0dp" ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? android:layout_weight="1" ? ? ? ? ? ? ? ? ? ? android:ellipsize="end" ? ? ? ? ? ? ? ? ? ? android:paddingRight="@dimen/lay_12" ? ? ? ? ? ? ? ? ? ? android:singleLine="true" ? ? ? ? ? ? ? ? ? ? android:text="" ? ? ? ? ? ? ? ? ? ? android:textColor="@color/color_c7c7c7" ? ? ? ? ? ? ? ? ? ? android:textSize="@dimen/lay_14" /> ? ? ? ? ? ? </LinearLayout> ? ? ? ? ? ? ? <RelativeLayout ? ? ? ? ? ? ? ? android:id="@+id/rl_msg" ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? android:layout_height="match_parent" ? ? ? ? ? ? ? ? android:layout_alignParentRight="true" ? ? ? ? ? ? ? ? android:layout_marginEnd="@dimen/lay_12" ? ? ? ? ? ? ? ? android:gravity="center_vertical"> ? ? ? ? ? ? ? ? ? <ImageView ? ? ? ? ? ? ? ? ? ? android:id="@+id/iv_msg" ? ? ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? android:layout_marginTop="@dimen/lay_5" ? ? ? ? ? ? ? ? ? ? android:background="@mipmap/home_message_white" /> ? ? ? ? ? ? ? ? ? <TextView ? ? ? ? ? ? ? ? ? ? android:id="@+id/tv_msgnum" ? ? ? ? ? ? ? ? ? ? android:layout_width="wrap_content" ? ? ? ? ? ? ? ? ? ? android:layout_height="wrap_content" ? ? ? ? ? ? ? ? ? ? android:layout_marginStart="11dp" ? ? ? ? ? ? ? ? ? ? android:layout_marginTop="@dimen/lay_2" ? ? ? ? ? ? ? ? ? ? android:background="@drawable/yuandianred" ? ? ? ? ? ? ? ? ? ? android:gravity="center" ? ? ? ? ? ? ? ? ? ? android:minWidth="14dp" ? ? ? ? ? ? ? ? ? ? android:paddingLeft="3dp" ? ? ? ? ? ? ? ? ? ? android:paddingRight="3dp" ? ? ? ? ? ? ? ? ? ? android:singleLine="true" ? ? ? ? ? ? ? ? ? ? android:textColor="@android:color/white" ? ? ? ? ? ? ? ? ? ? android:textSize="@dimen/font_10" ? ? ? ? ? ? ? ? ? ? android:visibility="visible" /> ? ? ? ? ? ? </RelativeLayout> ? ? ? ? ? </RelativeLayout> ? ? ? </RelativeLayout> ? ? ?? </RelativeLayout>
2.fragment
package com.broker.liming.fragment; ? import android.Manifest; import android.app.Activity; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Point; import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CoordinatorLayout; import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentTransaction; import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.text.Html; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.Display; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; ? import com.bigkoo.convenientbanner.ConvenientBanner; import com.bigkoo.convenientbanner.holder.CBViewHolderCreator; import com.bigkoo.convenientbanner.listener.OnItemClickListener; import com.broker.liming.R; import com.broker.liming.activity.AgreementActivity; import com.broker.liming.activity.SplashActivity; import com.broker.liming.activity.WebViewActivity; import com.broker.liming.adapter.ArticleAdapter; import com.broker.liming.adapter.HomeAdapter; import com.broker.liming.api.HttpParams; import com.broker.liming.api.WebHttpParams; import com.broker.liming.application.LoadBugClass; import com.broker.liming.banner.IndicatorLocation; import com.broker.liming.banner.LoopLayout; import com.broker.liming.banner.LoopStyle; import com.broker.liming.banner.OnDefaultImageViewLoader; import com.broker.liming.banner.bean.BannerInfo; import com.broker.liming.banner.listener.OnBannerItemClickListener; import com.broker.liming.banner.view.BannerBgContainer; import com.broker.liming.base.BaseFragment; import com.broker.liming.bean.ColorInfo; import com.broker.liming.bean.CompanyBaseBean; import com.broker.liming.bean.HeadHomeBean; import com.broker.liming.bean.HomeBannerBean; import com.broker.liming.bean.HomeBean; import com.broker.liming.bean.HomeProductBean; import com.broker.liming.bean.MineBean; import com.broker.liming.bean.RecommendListBean; import com.broker.liming.bean.SettingBean; import com.broker.liming.bean.UserBean; import com.broker.liming.bean.UserInfoBean; import com.broker.liming.college.bean.ArticleClassifyListBean; import com.broker.liming.college.bean.FaXianListsBean; import com.broker.liming.college.bean.FindClassifysBean; import com.broker.liming.college.bean.KaoShiStatussBean; import com.broker.liming.constant.Constants; import com.broker.liming.dao.UserBeanDao; import com.broker.liming.editview.FunctionItem; import com.broker.liming.editview.SFUtils; import com.broker.liming.event.ChangXianLogin; import com.broker.liming.event.ELoginSuccess; import com.broker.liming.event.EventManager; import com.broker.liming.event.LongRiskEvent; import com.broker.liming.event.RefreshHomeArticleEvent; import com.broker.liming.interf.OnBottomTabReselectListener; import com.broker.liming.interfaclisetener.ArticleHomeClickLisener; import com.broker.liming.utils.AccountUtils; import com.broker.liming.utils.CommonUtils; import com.broker.liming.utils.DensityUtil; import com.broker.liming.utils.GsonUtils; import com.broker.liming.utils.LogUtil; import com.broker.liming.utils.LogUtil2; import com.broker.liming.utils.SPUtils; import com.broker.liming.utils.SobotUtils; import com.broker.liming.utils.StatusBarUtil; import com.broker.liming.utils.StringUtil; import com.broker.liming.utils.ToastUtil; import com.broker.liming.utils.UIHelper; import com.broker.liming.utils.Utils; import com.broker.liming.utils.ViewFindUtils; import com.broker.liming.viewholder.NetworkImageHolderView; import com.broker.liming.viewholder.TabViewHolder; import com.broker.liming.widget.AppBarStateChangeListener; import com.broker.liming.widget.CustomDialog; import com.broker.liming.widget.MyScrollView; import com.broker.liming.widget.OnTabSelectListener; import com.broker.liming.widget.RecyclerviewScrollLisetener; import com.broker.liming.widget.SetOnclickInterface; import com.broker.liming.widget.SlidingTabLayout; import com.broker.liming.widget.TitleBar; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.resource.bitmap.CenterCrop; import com.bumptech.glide.load.resource.bitmap.RoundedCorners; import com.bumptech.glide.request.RequestOptions; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import com.jcodecraeer.xrecyclerview.ProgressStyle; import com.jcodecraeer.xrecyclerview.XRecyclerView; import com.scwang.smartrefresh.layout.SmartRefreshLayout; ? import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.json.JSONException; ? import java.util.ArrayList; import java.util.List; import java.util.Random; ? import lecho.lib.hellocharts.model.Line; ? import static com.broker.liming.constant.Constants.flag; import static com.broker.liming.utils.SystemInfoUtils.getScreenWidth; import static com.umeng.socialize.utils.ContextUtil.getPackageName; ? /** ?* Description: ?* Creator: Chenqiang ?* DatePopAdapter: 2018/2/24 ?*/ public class HomeFragment extends BaseFragment implements OnBottomTabReselectListener, OnItemClickListener, XRecyclerView.LoadingListener, OnBannerItemClickListener, RecyclerviewScrollLisetener,ArticleHomeClickLisener { ? ? public static ConvenientBanner mConvenientBanner; ? ? private List<HomeBannerBean> mHomePagePlatAdList; ? ? private HomeAdapter mHomeAdapter; ? ? private XRecyclerView mXrvProduct; ? ? private SmartRefreshLayout refreshLayout; ? ? private XRecyclerView xRecyclerView; ? ? private ImageView iv_center; ? ? private RelativeLayout rl_wallet; ? ? private RelativeLayout rl_msg; ? ? private TextView tv_msgnum; ? ? private HomeBean.PopUpEntity popUp; ? ? private TitleBar mTitleBar; ? ? private TextView tv_statusBar_slide; ? ? ? private BannerBgContainer container; ? ? private LoopLayout loopLayout; ? ? private int imageHeight; ? ? private RelativeLayout rl_title; ? ? private String longRiskUrl; ? ? private String longCenterUrl; ? ? private String longCenterUrl2; ? ? private String longCenterNew;//新版 ? ? ? private String longCenterUrl3; ? ? public static boolean canClick; ? ? public static boolean canClick2; ? ? private RelativeLayout rl_top; ? ? private ImageView iv_search; ? ? private String customerLevel; ? ? public static String flag3; ? ? public static String certifiedState; ? ? public static String flag2; ? ? private ImageView iv_contact; ? ? private int duration; ? ? public static boolean canClick3; ? ? // ? ?private MoveImage iv_contact2; ? ? private TextView tv_245; ? ? private TextView tv_247; ? ? private TextView tv_chang_commit; ? ? private EditText edit_logoin; ? ? private EditText edit_screen; ? ? private EditText edit_riyuebaohe; ? ? private TextView tv_tinker; ? ? private TextView tv_title; ? ? private LinearLayout ll_search; ? ? private ImageView iv_msg; ? ? private int position; ? ? private TextView tv_search; ? ? ? private ImageView ivBannerHeadBg; ? ? private int count; ? ? private boolean isInit = true; ? ? private List<String> bannerList = new ArrayList<>(); ? ? private List<ColorInfo> colorList = new ArrayList<>(); ? ? private int mDistanceY; ? ? private LinearLayoutManager layoutManager; ? ? private int y; ? ? private int height; ? ? private String localVersion; ? ? private String key; ? ? private PopupWindow popWindow; ? ? private boolean hidden2 = false; ? ? private SFUtils sfUtils; ? ? private List<FunctionItem> allData; ? ? private List<FunctionItem> selData; ? ? private ImageView iv_back_top; ? ? private String localVersionLoad; ? ? private RecyclerView recycler; ? ? private /*ViewPagerForScrollView*/ ViewPager viewpager; ? ? private SlidingTabLayout tl_9; ? ? private Toolbar toolbar; ? ? private List<String> mTitles=new ArrayList<>(); ? ? private ArrayList<Fragment> mFragments = new ArrayList<>(); ? ? // ? ?private MyPagerAdapter mAdapter; ? ? private FragmentManager fragmentManager; ? ? private View pagerview; ? ? private SlidingTabLayout tab_head; ? ? private MyScrollView scrollowview; ? ? private int[] location2; ? ? private int[] location3; ? ? private int yrecycler; ? ? private TextView tv_phone; ? ? private TextView tv_email; ? ? private ImageView iv_copy; ? ? private AppBarLayout appbar; ? ? private CoordinatorLayout main_content; ? ? private CustomDialog dialog; ? ? private boolean isFirstLay = true; ? ? private List<ArticleClassifyListBean> articleClassifyList; ? ? private LinearLayout ll_tab; ? ? private RelativeLayout ll_base; ? ? public static SettingBean settingBean; ? ? private CompanyBaseBean companyBaseBean; ? ? private MyPagerAdapter mAdapter; ? ? private boolean isRemind=false;//點(diǎn)文章不會(huì)到頂部其余都回到頂部 ? ? private boolean isSame=true;//是否有不同tab 判斷后臺(tái)增加或者減少tab刷新 否者不刷新tab方便記錄點(diǎn)擊位置 ? ? private boolean isFirstTab=true;//是否第一進(jìn)入加載 第一次進(jìn)入app時(shí)刷新tab 不是第一次需判斷后臺(tái)增加或者減少tab刷新 否者不刷新tab方便記錄點(diǎn)擊位置 ? ? private boolean isHoutai=false; ? ? private int appbarState; ? ? private boolean isOther=false; ? ? private boolean isRemindTrue=false; ? ? ? ? @Override ? ? protected int getContentView() { ? ? ? ? // 加載系統(tǒng)默認(rèn)設(shè)置,字體不隨用戶設(shè)置變化 ? ? ? ? Resources res = mContext.getResources(); ? ? ? ? Configuration config = new Configuration(); ? ? ? ? config.setToDefaults(); ? ? ? ? res.updateConfiguration(config, res.getDisplayMetrics()); ? ? ? ? ? return R.layout./*fragment_home*/home_fragment_two; ? ? } ? ? ? @Override ? ? protected void initTitleBar(View view) { // ? ? ? ?mTitleBar = (TitleBar) view.findViewById(R.id.title_bar); // ? ? ? ?mTitleBar.setTitle(""); // ? ? ? ?setStateBar(); // ? ? ? ?mTitleBar.setTitleBarBg(android.R.color.transparent); ? ? ? ? ?/* mTitleBar.setLeftBackground(R.mipmap.home_left); ? ? ? ? mTitleBar.setLeftClickListener(new View.OnClickListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onClick(View v) { ? ? ? ? ? ? ? ? if (!isLogin()) { ? ? ? ? ? ? ? ? ? ? UIHelper.showLogin(mContext); ? ? ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? UserBean query = UserBeanDao.query(); ? ? ? ? ? ? ? ? UIHelper.showInvite(mContext, WebHttpParams.showInviting(query.customerImageUrl)); // ? ? ? ? ? ? ? ?ToastUtil.showToast(mContext, "分享"); // ? ? ? ? ? ? ? ?((BaseActivity) getActivity()) // ? ? ? ? ? ? ? ? ? ? ? ?.getShareAction("", "", "", "").open(); ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? mTitleBar.setRightBackground(R.mipmap.home_right); ? ? ? ? mTitleBar.setRightClickListener(new View.OnClickListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onClick(View v) { ? ? ? ? ? ? ? ? if (!isLogin()) { ? ? ? ? ? ? ? ? ? ? UIHelper.showLogin(mContext); ? ? ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? UIHelper.showWebView(mContext, WebHttpParams.showMyNews()); ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? mTitleBar.setTitleBarBg(android.R.color.transparent);*/ ? ? ? ? ? ? iv_search = (ImageView) view.findViewById(R.id.iv_search); ? // ? ? ? ?rl_wallet = (RelativeLayout) view.findViewById(R.id.rl_wallet); // ? ? ? ?rl_wallet.setOnClickListener(new View.OnClickListener() { // ? ? ? ? ? ?@Override // ? ? ? ? ? ?public void onClick(View view) { // ? ? ? ? ? ? ? ?if (!isLogin()) { // ? ? ? ? ? ? ? ? ? ?UIHelper.showLogin(mContext); // ? ? ? ? ? ? ? ? ? ?return; // ? ? ? ? ? ? ? ?} // // ? ? ? ? ? ? ? ?UserBean query = UserBeanDao.query(); // ? ? ? ? ? ? ? ?if (AccountUtils.isAuthentication(query.certifiedState)) { // ? ? ? ? ? ? ? ? ? ?UIHelper.showMyWallet(mContext); // ? ? ? ? ? ? ? ?} else { // ? ? ? ? ? ? ? ? ? ?UIHelper.showWebView(mContext, WebHttpParams.showCredentials()); // ? ? ? ? ? ? ? ?} // ? ? ? ? ? ?} // ? ? ? ?}); ? ? ? ? rl_msg = (RelativeLayout) view.findViewById(R.id.rl_msg); ? ? ? ? rl_msg.setOnClickListener(new View.OnClickListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onClick(View view) { ? ? ? ? ? ? ? ? if (!isLogin()) { ? ? ? ? ? ? ? ? ? ? UIHelper.showLogin(mContext); ? ? ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? UIHelper.showWebView2(mContext, WebHttpParams.showMyNews()); ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? tv_msgnum = (TextView) view.findViewById(R.id.tv_msgnum); ? // ? ? ? ?iv_center = (ImageView) view.findViewById(R.id.iv_center); ? ? ? ? /*Animation anim = AnimationUtils.loadAnimation(mContext, R.anim.rotate); ? ? ? ? LinearInterpolator lir = new LinearInterpolator();// 設(shè)置插入器(線性勻速) ? ? ? ? anim.setInterpolator(lir); ? ? ? ? iv_center.startAnimation(anim);*/ ? // ? ? ? ?iv_center.setVisibility(View.VISIBLE); // ? ? ? ?Animation anim =new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // ? ? ? ?anim.setFillAfter(true); // 設(shè)置保持動(dòng)畫最后的狀態(tài) // ? ? ? ?anim.setDuration(10000); // 設(shè)置動(dòng)畫時(shí)間 // ? ? ? ?anim.setInterpolator(new LinearInterpolator()); // 設(shè)置插入器(線性勻速) // ? ? ? ?mTitleBar.startAnimation(anim); ? ? } ? ? ? ? ? @Override ? ? public void initView(View view) { // ? ? ? ?setFullScreen(); // ? ? ? ?changeStatusBarTextColor(true); // ? ? ? ?BarUtils.setColorNoTranslucent(getActivity(), getResources().getColor(R.color.transparent)); // ? ? ? ?BarUtils.setRootViewFitsSystemWindows(getActivity(), false); // ? ? ? ?//此方法上下狀態(tài)欄都透明,狀態(tài)欄字體顏色為黑色 // ? ? ? ?BarUtils.setTranslucentForCoordinatorLayout(getActivity(),0); ? ? ? ? pagerview = view; ? ? ? ? StatusBarUtil.setTranslucentStatus(getActivity()); ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), false); ? ? ? ? ? if (!EventManager.isRegistered(this)) { ? ? ? ? ? ? EventManager.register(this); ? ? ? ? } ? ? ? ? tv_tinker = (TextView) view.findViewById(R.id.tv_tinker); ? ? ? ? tv_245 = (TextView) view.findViewById(R.id.tv_245); ? ? ? ? tv_247 = (TextView) view.findViewById(R.id.tv_247); ? ? ? ? tv_chang_commit = (TextView) view.findViewById(R.id.tv_chang_commit); ? ? ? ? edit_logoin = (EditText) view.findViewById(R.id.edit_logoin); ? ? ? ? edit_screen = (EditText) view.findViewById(R.id.edit_screen); ? ? ? ? edit_riyuebaohe = (EditText) view.findViewById(R.id.edit_riyuebaohe); ? ? ? ? tv_title = (TextView) view.findViewById(R.id.tv_title); ? ? ? ? ll_search = (LinearLayout) view.findViewById(R.id.ll_search); ? ? ? ? iv_msg = (ImageView) view.findViewById(R.id.iv_msg); ? ? ? ? rl_top = (RelativeLayout) view.findViewById(R.id.rl_top); ? ? ? ? iv_contact = (ImageView) view.findViewById(R.id.iv_contact); ? ? ? ? tv_search = (TextView) view.findViewById(R.id.tv_search); ? ? ? ? iv_back_top = (ImageView) view.findViewById(R.id.iv_back_top); ? ? ? ? recycler = (RecyclerView) view.findViewById(R.id.recycler); // ? ? ? ?refreshLayout = (SmartRefreshLayout) view.findViewById(R.id.refreshLayout); ? ? ? ? viewpager = (ViewPager) view.findViewById(R.id.viewpager); ? ? ? ? tl_9 = (SlidingTabLayout) view.findViewById(R.id.tl_9); ? ? ? ? toolbar = (Toolbar) view.findViewById(R.id.toolbar); ? ? ? ? appbar = (AppBarLayout) view.findViewById(R.id.appbar); // ? ? ? ?tab_head=(SlidingTabLayout)view.findViewById(R.id.tab_head); // ? ? ? ?scrollowview=(MyScrollView) view.findViewById(R.id.scrollowview); ? ? ? ? ? tv_phone = (TextView) view.findViewById(R.id.tv_phone); ? ? ? ? tv_email = (TextView) view.findViewById(R.id.tv_email); ? ? ? ? iv_copy = (ImageView) view.findViewById(R.id.iv_copy); ? ? ? ? main_content = (CoordinatorLayout) view.findViewById(R.id.main_content); ? ? ? ? ll_tab = (LinearLayout) view.findViewById(R.id.ll_tab); ? ? ? ? ll_base = (RelativeLayout) view.findViewById(R.id.ll_base); ? ? ? ? edit_riyuebaohe.setText(flag + ""); ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.yuanjiao24whire)); ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_white)); ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));//AGB由相關(guān)工具獲得,或者美工提供 ? ? ? ? ArticleHomeFragment.setScrollListener(this); ? ? ? ? ArticleHomeFragment.setArticleListener(this); ? ? ? ? Constants.isHoutai=false; ? ? ? ? ? mAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager()); ? ? ? ? ? mXrvProduct = (XRecyclerView) view.findViewById(R.id.xrv_product); ? ? ? ? mXrvProduct.setLoadingMoreEnabled(false); ? ? ? ? ? mXrvProduct.setPullRefreshEnabled(true); ? ? ? ? mXrvProduct.setLoadingListener(this); ? ? ? ? mXrvProduct.setArrowImageView(R.mipmap.iconfont_downgrey); ? ? ? ? mXrvProduct.setRefreshProgressStyle(ProgressStyle.SysProgress); ? ? ? ? mXrvProduct.setNestedScrollingEnabled(true); ? ? ? ? ? final View headerView = mInflater.inflate(R.layout.fragment_home_banner/*fragmen_home_header*/, (ViewGroup) view.findViewById(android.R.id.content), false); ? ? ? ? LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); ? ? ? ? layoutParams.gravity = Gravity.CENTER_HORIZONTAL; ? ? ? ? headerView.setLayoutParams(layoutParams); ? ? ? ? ? container = (BannerBgContainer) headerView.findViewById(R.id.banner_bg_container); ? ? ? ? loopLayout = (LoopLayout) headerView.findViewById(R.id.loop_layout); ? ? ? ? //狀態(tài)欄高度 ? ? ? ? int statusBarHeight = 0; ? ? ? ? int resourceId = getResources().getIdentifier("status_bar_height", "dimen", ? ? ? ? ? ? ? ? "android"); ? ? ? ? if (resourceId > 0) { ? ? ? ? ? ? statusBarHeight = getResources().getDimensionPixelSize(resourceId); ? ? ? ? } ? ? ? ? //屏幕高度 ? ? ? ? DisplayMetrics dm = mContext.getApplicationContext().getResources().getDisplayMetrics(); ? ? ? ? ? final float scale = dm.density; ? ? ? ? int i = (int) (54 * scale + 0.5f) + DensityUtil.dp2px(100); ? // ? ? ? ?//獲取當(dāng)前控件的布局對(duì)象 ? ? ? ? ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) container.getLayoutParams(); ? ? ? ? params.width = getScreenWidth();//設(shè)置當(dāng)前控件布局的寬度 ? ? ? ? params.height = getScreenWidth() * 1 / 2;//設(shè)置當(dāng)前控件布局的高度 ? ? ? ? container.setLayoutParams(params);//將設(shè)置好的布局參數(shù)應(yīng)用到控件中 ? ? ? ? ? layoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false); ? ? ? ? ? mXrvProduct.setLayoutManager(layoutManager); ? ? ? ? mXrvProduct.addHeaderView(headerView); ? ? ? ? mHomeAdapter = new HomeAdapter(mContext, getActivity().getSupportFragmentManager(), getActivity(), dm.heightPixels - statusBarHeight - i + DensityUtil.dip2px(mContext, 50)); ? ? ? ? mXrvProduct.setAdapter(mHomeAdapter); ? ? ? ? ? ? // 設(shè)置輪播圖屬性 ? ? ? ? loopLayout.setLoop_ms(4000);//輪播的速度(毫秒) ? ? ? ? loopLayout.setLoop_duration(400);//滑動(dòng)的速率(毫秒) ? ? ? ? loopLayout.setScaleAnimation(false);// 設(shè)置是否需要?jiǎng)赢? ? ? ? ? loopLayout.setLoop_style(LoopStyle.Empty);//輪播的樣式-默認(rèn)empty ? ? ? ? loopLayout.setIndicatorLocation(IndicatorLocation.Center);//指示器位置-中Center ? ? ? ? loopLayout.initializeData(mContext); ? ? ? ? ? ? // 設(shè)置監(jiān)聽 ? ? ? ? loopLayout.setOnLoadImageViewListener(new OnDefaultImageViewLoader() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onLoadImageView(ImageView view, Object object, int point) { ? ? ? ? ? ? ? /* ?Glide.with(view.getContext()) ? ? ? ? ? ? ? ? ? ? ? ? .load(object) ? ? ? ? ? ? ? ? ? ? ? ? .into(view);*/ ? ? ? ? ? ? ? ? Glide.with(mContext) ? ? ? ? ? ? ? ? ? ? ? ? .load(object) ? ? ? ? ? ? ? ? ? ? ? ? .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(DensityUtil.dp2px(12)))) ? ? ? ? ? ? ? ? ? ? ? ? .into(view); ? ? ? ? ? ? ? ? ? LogUtil2.log("position--" + point + ""); ? ? ? ? ? ? ? } ? ? ? ? ? }); ? ? ? ? ? loopLayout.setOnBannerItemClickListener(this); ? ? ? ? ? setScroll(); ? ? ? ? ? ? RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE);//只緩存最終的圖片 ? ? ? ? //!isDestroy(getActivity() ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.jingzhi)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.apply(options).into(iv_contact); ? ? ? ? } ? ? ? ? ? iv_contact.setOnClickListener(new View.OnClickListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onClick(View view) { ? ? ? ? ? ? ? ? ? if (!AccountUtils.isLogin()) { ? ? ? ? ? ? ? ? ? ? UIHelper.showLogin(mContext); ? ? ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? SobotUtils.startSobot(getActivity()); ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) { ? ? ? ? ? ? RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) rl_top.getLayoutParams(); ? ? ? ? ? ? layoutParams2.height = dip2px(getActivity(), 80); ? ? ? ? ? ? rl_top.setLayoutParams(layoutParams2); ? ? ? ? ? } else { ? ? ? ? ? ? RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) rl_top.getLayoutParams(); ? ? ? ? ? ? layoutParams2.height = dip2px(getActivity(), 70); ? ? ? ? ? ? rl_top.setLayoutParams(layoutParams2); ? ? ? ? } ? ? ? ? ? ? imageHeight = dip2px(getActivity(), 200); ? ? ? ? rl_title = (RelativeLayout) view.findViewById(R.id.rl_title); ? ? ? ? initListeners(); ? ? ? } ? ? ? public void setScroll() { ? ? ? ? ? main_content.setOnTouchListener(new View.OnTouchListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public boolean onTouch(View v, MotionEvent event) { ? ? ? ? ? ? ? ? switch (event.getAction()) { ? ? ? ? ? ? ? ? ? ? case MotionEvent.ACTION_DOWN: ? ? ? ? ? ? ? ? ? ? ? ? Log.i("滾動(dòng)高度--tt", "按下"); ? ? ? ? ? ? ? ? ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.huadong2)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? ? ? ? ? ? ? new Handler().postDelayed(new Runnable() { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? @Override ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? public void run() { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.jingzhi)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? }, 1500); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? case MotionEvent.ACTION_MOVE: ? ? ? ? ? ? ? ? ? ? ? ? Log.i("滾動(dòng)高度--tt", "移動(dòng)"); ? ? ? ? ? ? ? ? ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.huadong)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? case MotionEvent.ACTION_UP: ? ? ? ? ? ? ? ? ? ? ? ? Log.i("滾動(dòng)高度--tt", "抬起"); ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? return false; ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? appbar.addOnOffsetChangedListener(new AppBarStateChangeListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onStateChanged(AppBarLayout appBarLayout, State state) { ? ? ? ? ? ? ? ? ? if (state == State.EXPANDED) { ? ? ? ? ? ? ? ? ? ? ? Log.i("滾動(dòng)高度--", "展開"); ? ? ? ? ? ? ? ? ? ? } else if (state == State.COLLAPSED) { ? ? ? ? ? ? ? ? ? ? ? Log.i("滾動(dòng)高度--", "折疊"); ? ? ? ? ? ? ? ? ? ? ? setpopLoad(); ? ? ? ? ? ? ? ? } else { ? ? ? ? ? ? ? ? ? ? ? ? Log.i("滾動(dòng)高度--", "中間"); ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onOffsetChanged(AppBarLayout appBarLayout, int i) { ? ? ? ? ? ? ? ? height = dip2px(mContext, 170); ? ? ? ? ? ? ? ? y = Math.abs(i); ? ? ? ? ? ? ? ? int alpha = 255 * y / (height); ? ? ? ? ? ? ? ? if (alpha > 255) { ? ? ? ? ? ? ? ? ? ? alpha = 255; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? if (alpha < 5) { ? ? ? ? ? ? ? ? ? ? alpha = 0; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? LogUtil2.log("滑動(dòng)高度--off" + y + "--" + height + "--"); ? ? ? ? ? ? ? ? if (y <= height) { ? ? ? ? ? ? ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.yuanjiao24whire)); ? ? ? ? ? ? ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_white)); ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));//AGB由相關(guān)工具獲得,或者美工提供 ? ? ? ? ? ? ? ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), false); ? ? ? ? ? ? ? ? } else if (y > height && y < height * 1.5) { ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000)); ? ? ? ? ? ? ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product)); ? ? ? ? ? ? ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black)); ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 127, 255, 255, 255)); ? ? ? ? ? ? ? ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), true); ? ? ? ? ? ? ? ? } else if (y > height * 1.5) { ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000)); ? ? ? ? ? ? ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product)); ? ? ? ? ? ? ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black)); ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 255, 255, 255, 255)); ? ? ? ? ? ? ? ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), true); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? mXrvProduct.addOnScrollListener(new RecyclerView.OnScrollListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { ? ? ? ? ? ? ? ? super.onScrolled(recyclerView, dx, dy); ? ? ? ? ? ? ? ? LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager(); ? ? ? ? ? ? ? ? //獲取當(dāng)前可見條目得索引 ? ? ? ? ? ? ? ? int firstVisibleItemPosition = manager.findFirstVisibleItemPosition(); ? ? ? ? ? ? ? ? int lastVisibleItemPosition = manager.findLastCompletelyVisibleItemPosition(); ? ? ? ? ? ? ? ? ? //獲取當(dāng)前可見條目得itemView ? ? ? ? ? ? ? ? View firstView = manager.findViewByPosition(firstVisibleItemPosition); ? ? ? ? ? ? ? ? //獲取當(dāng)前可見條目得itemView得高度 ? ? ? ? ? ? ? ? height = firstView.getHeight(); ? ? ? ? ? ? ? ? //獲取當(dāng)前可見條目得偏移量 ? ? ? ? ? ? ? ? y = (firstVisibleItemPosition) * height - firstView.getTop(); ? ? ? ? ? ? ? ? ? int alpha = 255 * y / (height); ? ? ? ? ? ? ? ? if (alpha > 255) { ? ? ? ? ? ? ? ? ? ? alpha = 255; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? if (alpha < 5) { ? ? ? ? ? ? ? ? ? ? alpha = 0; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? float scale = (float) dy / height; ? ? ? ? ? ? ? ? float alphat = (255 * scale); ? ? ? ? ? ? ? ? LogUtil2.log("滑動(dòng)高度--" + y + "--" + height + "--"); ? ? ? ? ? ? ? ? if (y == height) { ? ? ? ? ? ? ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.yuanjiao24whire)); ? ? ? ? ? ? ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_white)); ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));//AGB由相關(guān)工具獲得,或者美工提供 ? ? ? ? ? ? ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), false); ? ? ? ? ? ? ? ? } else if (y > height && y < height * 1.5) { ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000)); ? ? ? ? ? ? ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product)); ? ? ? ? ? ? ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black)); ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 127, 255, 255, 255)); ? ? ? ? ? ? ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), true); ? ? ? ? ? ? ? ? } else if (y > height * 1.5) { ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000)); ? ? ? ? ? ? ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product)); ? ? ? ? ? ? ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black)); ? ? ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 255, 255, 255, 255)); ? ? ? ? ? ? ? ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), true); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? }); ? ? ? } ? ? ? ? ? public void setpopLoad() { ? ? ? ? try { ? ? ? ? ? ? localVersionLoad = Utils.getVersionName(mContext); ? ? ? ? } catch (Exception e) { ? ? ? ? ? ? e.printStackTrace(); ? ? ? ? } ? ? ? ? ? key = "show_home_load" + localVersion; ? ? ? ? LogUtil2.log("=========================>>>key" + key); ? ? ? ? LogUtil2.log("=========================>>>AccountUtils.getVersioncode()" + AccountUtils.getVersioncode()); ? ? ? ? //是否是安裝的第一次 ? ? ? ? if (!AccountUtils.getVersioncodeHomeLoad().equals(key)) { ? ? ? ? ? ? AccountUtils.putVersioncodeHomeLoad(key); ? ? ? ? ? ? ? ? dialog = new CustomDialog(mContext, R.layout.pop_home_load, R.style.CustomDialogTheme); ? ? ? ? ? ? dialog.setCancelable(false); ? ? ? ? ? ? dialog.setCanceledOnTouchOutside(false); ? ? ? ? ? ? ? ImageView iv_one_button = (ImageView) dialog.findViewById(R.id.iv_one_button); ? ? ? ? ? ? ? iv_one_button.setOnClickListener(new View.OnClickListener() { ? ? ? ? ? ? ? ? @Override ? ? ? ? ? ? ? ? public void onClick(View v) { ? ? ? ? ? ? ? ? ? ? // TODO Auto-generated method stub ? ? ? ? ? ? ? ? ? ? dialog.dismiss(); ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? }); ? ? ? ? ? ? dialog.show(); ? ? ? ? } ? ? ? } ? ? ? ? private void changeStatusBarTextColor(boolean isBlack) { ? ? ? ? if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { ? ? ? ? ? ? if (isBlack) { ? ? ? ? ? ? ? ? getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);//設(shè)置狀態(tài)欄黑色字體 ? ? ? ? ? ? } else { ? ? ? ? ? ? ? ? getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);//恢復(fù)狀態(tài)欄白色字體 ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? ? /** ? ? ?* 判斷是否是全面屏 ? ? ?*/ ? ? private volatile static boolean mHasCheckAllScreen; ? ? private volatile static boolean mIsAllScreenDevice; ? ? ? public static boolean isAllScreenDevice(Context context) { ? ? ? ? if (mHasCheckAllScreen) { ? ? ? ? ? ? return mIsAllScreenDevice; ? ? ? ? } ? ? ? ? mHasCheckAllScreen = true; ? ? ? ? mIsAllScreenDevice = false; ? ? ? ? // 低于 API 21的,都不會(huì)是全面屏。。。 ? ? ? ? if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { ? ? ? ? ? ? return false; ? ? ? ? } ? ? ? ? WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); ? ? ? ? if (windowManager != null) { ? ? ? ? ? ? Display display = windowManager.getDefaultDisplay(); ? ? ? ? ? ? Point point = new Point(); ? ? ? ? ? ? display.getRealSize(point); ? ? ? ? ? ? float width, height; ? ? ? ? ? ? if (point.x < point.y) { ? ? ? ? ? ? ? ? width = point.x; ? ? ? ? ? ? ? ? height = point.y; ? ? ? ? ? ? } else { ? ? ? ? ? ? ? ? width = point.y; ? ? ? ? ? ? ? ? height = point.x; ? ? ? ? ? ? } ? ? ? ? ? ? if (height / width >= 1.97f) { ? ? ? ? ? ? ? ? mIsAllScreenDevice = true; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? return mIsAllScreenDevice; ? ? } ? ? ? private int dip2px(Context context, float dipValue) { ? ? ? ? Resources r = context.getResources(); ? ? ? ? return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, r.getDisplayMetrics()); ? ? } ? ? ? //判斷Activity是否Destroy ? ? public static boolean isDestroy(Activity activity) { ? ? ? ? if (activity == null || activity.isFinishing() || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed())) { ? ? ? ? ? ? return true; ? ? ? ? } else { ? ? ? ? ? ? return false; ? ? ? ? } ? ? } ? ? ? private void initListeners() { ? ? ? ? mXrvProduct.addOnScrollListener(new RecyclerView.OnScrollListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onScrollStateChanged(RecyclerView recyclerView, int newState) { ? ? ? ? ? ? ? ? super.onScrollStateChanged(recyclerView, newState); ? ? ? ? ? ? ? ? switch (newState) { ? ? ? ? ? ? ? ? ? ? case 0: ? ? ? ? ? ? ? ? ? ? ? ? LogUtil2.log("recyclerview已經(jīng)停止?jié)L動(dòng)"); ? ? ? ? ? ? ? ? ? ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.huadong2)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? ? ? ? ? ? ? new Handler().postDelayed(new Runnable() { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? @Override ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? public void run() { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.jingzhi)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? }, 1500); ? ? ? ? ? ? ? ? ? ? ? ? } ? // ? ? ? ? ? ? ? ? ? ? ? ?Glide.with(getActivity()).load(R.mipmap.jingzhi).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(iv_contact); ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? case 1: ? ? ? ? ? ? ? ? ? ? ? ? LogUtil2.log("recyclerview正在被拖拽"); ? ? ? ? ? ? ? ? ? ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.huadong)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? case 2: ? ? ? ? ? ? ? ? ? ? ? ? LogUtil2.log("recyclerview正在依靠慣性滾動(dòng)"); ? ? ? ? ? ? ? ? ? ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.huadong)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onScrolled(RecyclerView recyclerView, int dx, int dy) { ? ? ? ? ? ? ? ? super.onScrolled(recyclerView, dx, dy); ? ? ? ? ? ? ? } ? ? ? ? }); ? ? ? } ? ? ? @Override ? ? public void initData() { ? ? ? ? super.initData(); ? ? } ? ? ? ? @Override ? ? public void onResume() { ? ? ? ? super.onResume(); ? ? ? } ? ? ? ? /** ? ? ?* IMEI 全稱??International Mobile Equipment Identity,中文翻譯為國際移動(dòng)裝備辨識(shí)碼, 即??常所說的手機(jī)序列號(hào), ? ? ?* 用于在手機(jī)網(wǎng)絡(luò)中識(shí)別每一部獨(dú)立的手機(jī),是國際上公認(rèn)的手機(jī)標(biāo)志序號(hào),相當(dāng)于移動(dòng)電話的身份證。序列號(hào)共有15位數(shù)字,??位(TAC)是型號(hào)核準(zhǔn)號(hào)碼?? ? ? ?* 代表手機(jī)類型。接??位(FAC)是????裝配號(hào),代表產(chǎn)地。后6位(SNR)是串號(hào),代表生產(chǎn)順序號(hào)。最??位(SP)一般為0,是????碼,備用?? ? ? ?* 國際移動(dòng)裝備辨識(shí)碼一般貼于機(jī)身背面與外包裝上,同時(shí)也存在于手機(jī)記憶體中,通過輸入*#06#即可查詢?? ? ? ?* ? ? ?* @param ? ? ?* @return ? ? ?*/ ? ? ? @Override ? ? public void onHiddenChanged(boolean hidden) { ? ? ? ? super.onHiddenChanged(hidden); ? ? ? ? if (!hidden) { ? ? ? ? ? ? hidden2 = hidden; ? ? ? ? ? ? LogUtil2.log("==========================>>>onHiddenChangedHome" + hidden); ? ? ? ? ? ? ? ? loopLayout.stopLoop();// 頁面銷毀時(shí)需要停止 ? ? ? ? ? ? loopLayout.startLoop(); ? ? ? ? ? ? StatusBarUtil.setTranslucentStatus(getActivity()); ? ? ? ? ? ? if (y <= height) { ? ? ? ? ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.yuanjiao24whire)); ? ? ? ? ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_white)); ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));//AGB由相關(guān)工具獲得,或者美工提供 ? ? ? ? ? ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), false); ? ? ? ? ? ? } else if (y > height && y < height * 1.5) { ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000)); ? ? ? ? ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product)); ? ? ? ? ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black)); ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 127, 255, 255, 255)); // ? ? ? ? ? ? ? ? ? ? ? ?changeStatusBarTextColor(false); // ? ? ? ? ? ? ? ? ? ? ? ?BarUtils.setColorNoTranslucent(getActivity(), getResources().getColor(R.color.transparent)); // ? ? ? ? ? ? ? ? ? ? ? ?BarUtils.setRootViewFitsSystemWindows(getActivity(), false); ? ? ? ? ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), true); ? ? ? ? ? ? } else if (y > height * 1.5) { ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(mContext.getResources().getColor(R.color.white)); ? ? ? ? ? ? ? ? tv_title.setTextColor(mContext.getResources().getColor(R.color.text_000000)); ? ? ? ? ? ? ? ? ll_search.setBackground(mContext.getResources().getDrawable(R.drawable.shape_search_product)); ? ? ? ? ? ? ? ? iv_msg.setBackground(mContext.getResources().getDrawable(R.mipmap.home_message_black)); ? ? ? ? ? ? ? ? rl_top.setBackgroundColor(Color.argb((int) 255, 255, 255, 255)); // ? ? ? ? ? ? ? ? ? ? ? ?changeStatusBarTextColor(true); // ? ? ? ? ? ? ? ? ? ? ? ?BarUtils.setColorNoTranslucent(getActivity(), getResources().getColor(R.color.transparent)); // ? ? ? ? ? ? ? ? ? ? ? ?BarUtils.setRootViewFitsSystemWindows(getActivity(), false); ? ? ? ? ? ? ? ? StatusBarUtil.setStatusBarDarkTheme(getActivity(), true); ? ? ? ? ? ? } ? ? ? ? ? } else { ? ? ? ? ? ? hidden2 = hidden; ? ? ? ? ? ? LogUtil2.log("==========================>>>onHiddenChanged" + hidden); ? ? ? ? ? ? loopLayout.stopLoop();// 頁面銷毀時(shí)需要停止 ? ? ? ? ? ? mHomeAdapter.setIsStop(true); ? ? ? ? } ? ? } ? ? ? @Override ? ? public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { ? ? ? ? if (requestCode == 1000) { ? ? ? ? ? ? if ((grantResults.length > 0) && (grantResults[0] == PackageManager.PERMISSION_GRANTED)) { ? ? ? ? ? ? ? ? UserBean query = UserBeanDao.query(); ? ? ? ? ? ? ? } else { ? ? ? ? ? ? ? ? Toast.makeText(mContext, "手機(jī)IMEI權(quán)限未開啟!", Toast.LENGTH_LONG).show(); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? ? public boolean checkIme() { ? ? ? ? int permissionCheck = ContextCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE); ? ? ? ? ? if (permissionCheck != PackageManager.PERMISSION_GRANTED) { ? ? ? ? ? ? ActivityCompat.requestPermissions((Activity) mContext, new String[]{Manifest.permission.READ_PHONE_STATE}, 1000); ? ? ? ? ? ? return false; ? ? ? ? } else { ? ? ? ? ? ? //TODO ? ? ? ? ? ? return true; ? ? ? ? } ? ? } ? ? ? @Override ? ? protected void initListener() { ? ? ? ? super.initListener(); ? ? ? ? iv_back_top.setOnClickListener(new View.OnClickListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onClick(View v) { ? ? ? ? ? ? ? ? appbar.setExpanded(true, false); ? ? ? ? ? ? ? ? iv_back_top.setVisibility(View.GONE); ? ? ? ? ? ? ? ? EventManager.post(new RefreshHomeArticleEvent()); ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? ll_search.setOnClickListener(new View.OnClickListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onClick(View view) { ? ? ? ? ? ? ? ? if (!isLogin()) { ? ? ? ? ? ? ? ? ? ? UIHelper.showLogin(mContext); ? ? ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? UIHelper.showProductSearch(mContext); ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? ? } ? ? ? ? @Override ? ? protected void onSuccess(String response, int id) { ? ? ? ? super.onSuccess(response, id); ? ? ? ? switch (id) { ? ? ? ? ? ? case 100: ? ? ? ? ? ? ? ? LogUtil2.log("=========================>>>100" + response.toString()); ? ? ? ? ? ? ? ? mXrvProduct.refreshComplete(); // ? ? ? ? ? ? ? ?refreshLayout.finishRefresh(2000/*,false*/);//傳入false表示刷新失敗 ? ? ? ? ? ? ? ? HomeBean homeBean = GsonUtils.toObject(response, HomeBean.class); ? ? ? ? ? ? ? ? mHomePagePlatAdList = homeBean.homePagePlatAdList; ? ? ? ? ? ? ? ? if (null != mHomePagePlatAdList && !mHomePagePlatAdList.isEmpty()) { ? ? ? ? ? ? ? ? ? ? ? setBannerLoop(mHomePagePlatAdList); ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? case 600://精選產(chǎn)品 ? ? ? ? ? ? ? ? setRecommendData(response); ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? case 700: ? ? ? ? ? ? ? ? LogUtil2.log("=========================>>>700" + response.toString()); ? ? ? ? ? ? ? ? setHomeBeanADV(response); ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? case 800://提醒中心 ? ? ? ? ? ? ? ? setHomeBeanRemind(response); ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? case 601://云學(xué)院推薦櫥窗列表 ? ? ? ? ? ? ? ? setRecommendDatas(response); ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? case 603: ? ? ? ? ? ? ? ? RecommendListBean recommendListBean = GsonUtils.toObject(response, RecommendListBean.class); ? ? ? ? ? ? ? ? if (recommendListBean.recommendList != null) { ? ? ? ? ? ? ? ? ? ? if (recommendListBean.recommendList.size() > 0) { ? ? ? ? ? ? ? ? ? ? ? ? tv_search.setText(recommendListBean.recommendList.get(0)); ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? case 604://滾動(dòng)頭條 ? ? ? ? ? ? ? ? LogUtil2.log("首頁文章--滾動(dòng)條" + response.toString()); ? ? ? ? ? ? ? ? setHomeAdviance(response); ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? case 605://文章標(biāo)題 ? ? ? ? ? ? ? ? LogUtil2.log("首頁文章--文章標(biāo)題" + response.toString()); ? ? ? ? ? ? ? ? ll_tab.setVisibility(View.VISIBLE); ? ? ? ? ? ? ? ? setHomeArticle(response); ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? } ? ? } ? ? ? private void setHomeArticle(String response) { ? ? ? ? if (TextUtils.isEmpty(response)) { ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? ? final FindClassifysBean bean = GsonUtils.toObject(response, FindClassifysBean.class); ? ? ? ? if (bean!=null){ ? ? ? ? ? ? ? if (!isFirstTab) { ? ? ? ? ? ? ? ? if (articleClassifyList != null && bean.articleClassifyList.size() == articleClassifyList.size()) { ? ? ? ? ? ? ? ? ? ? for (int i = 0; i < bean.articleClassifyList.size(); i++) { ? ? ? ? ? ? ? ? ? ? ? ? for (int j = 0; j < articleClassifyList.size(); j++) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (bean.articleClassifyList.get(i).uuid.equals(articleClassifyList.get(j).uuid)) { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? isSame = false; ? ? ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? } ? ? ? ? ? ? LogUtil2.log("第一次加載--"+isSame+"---"+isFirstTab+"--"+isRemind+"---"+isHoutai); ? ? ? ? ? ? if (isRemind) { ? ? ? ? ? ? ? ? isRemind=false; ? ? ? ? ? ? ? ? if (!isSame) { ? ? ? ? ? ? ? ? ? ? isSame = true; ? ? ? ? ? ? ? ? ? ? return; ? ? ? ? ? ? ? ? } ? ? ? ? ? ? }else { ? ? ? ? ? ? ? ? ? ? appbar.setExpanded(true, false); ? ? ? ? ? ? ? ? iv_back_top.setVisibility(View.GONE); ? ? ? ? ? ? } ? ? ? ? ? } ? ? ? ? ? ? isFirstTab=false; ? ? ? ? articleClassifyList = bean.articleClassifyList; ? // ? ? ? ?mHomeAdapter.setHomeArticle(bean); ? ? ? ? if (bean.articleClassifyList != null && bean.articleClassifyList.size() > 0) { ? ? ? ? ? ? mFragments.clear(); ? ? ? ? ? ? mTitles.clear(); ? ? ? ? ? ? for (int i = 0; i < bean.articleClassifyList.size(); i++) { ? ? ? ? ? ? ? ? ArticleClassifyListBean bean2 = bean.articleClassifyList.get(i); ? ? ? ? ? ? ? ? ? mTitles.add(bean2.name); ? ? ? ? ? ? ? ? Bundle b = new Bundle(); ? ? ? ? ? ? ? ? b.putSerializable("bean", bean.articleClassifyList.get(i)); ? ? ? ? ? ? ? ? b.putInt("positionClick", i); ? ? ? ? ? ? ? ? b.putSerializable("company",companyBaseBean); ? ? ? ? ? ? ? ? Fragment f = new ArticleHomeFragment()/*ArticleHomeFragment()*/; ? ? ? ? ? ? ? ? f.setArguments(b); ? ? ? ? ? ? ? ? mFragments.add(f); ? ? ? ? ? ? } ? ? ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? ? ? ? viewpager.setAdapter(mAdapter); ? ? ? ? ? ? ? ? tl_9.setViewPager(viewpager,mTitles); ? ? ? ? ? ? ? ? tl_9.setCurrentTab(0); ? ? ? ? ? ? ? ? viewpager.setCurrentItem(0); ? ? ? ? ? ? ? ? ? setTab(); ? ? ? ? ? ? ? ? if (!isFirstLay){ ? ? ? ? ? ? ? ? ? ? LogUtil2.log("刷新--"); ? ? ? ? ? ? ? ? ? ? mAdapter.setNewFragments(); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? isFirstLay = false; ? ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? } ? ? ? @Override ? ? public void onPause() { ? ? ? ? super.onPause(); ? ? ? ? Log.i("滾動(dòng)高度--onPause", "展開"); ? ? } ? ? ? @Override ? ? public void onStop() { ? ? ? ? super.onStop(); ? ? ? ? Log.i("滾動(dòng)高度--onStop", "展開"); ? ? ? ? if (isRemind){ ? ? ? ? ? ? isOther=true; ? ? ? ? } ? ? ? ? if (appbarState == 1) { ? ? ? ? ? ? Log.i("滾動(dòng)高度--", "展開"); ? ? ? ? ? ? //展開狀態(tài) ? ? ? ? ? } else if (appbarState == 2) { ? ? ? ? ? ? Log.i("滾動(dòng)高度--", "折疊"); ? ? ? ? ? ? //折疊狀態(tài) ? ? ? ? ? } ?else if (appbarState ==3){ ? ? ? ? ? ? ? Log.i("滾動(dòng)高度--", "中間"); ? ? ? ? ? ? //中間狀態(tài) ? ? ? ? ? } ? ? } ? ? ? public void setTab() { ? ? ? ? ? ? tl_9.setTextUnselectColor(getResources().getColor(R.color.text_000000)); ? ? ? ? tl_9.setTextSelectColor(getResources().getColor(R.color.white)); ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF)); ? ? ? ? tl_9.setOnTabSelectListener(new OnTabSelectListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onTabSelect(int position) { ? ? ? ? ? ? ? ? if (position % 9 == 0) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF)); ? ? ? ? ? ? ? ? } else if (position % 9 == 1) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_F05F12)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_F05F12)); ? ? ? ? ? ? ? ? } else if (position % 9 == 2) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_DD8033)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_DD8033)); ? ? ? ? ? ? ? ? } else if (position % 9 == 3) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_14BEDF)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_14BEDF)); ? ? ? ? ? ? ? ? } else if (position % 9 == 4) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_2B2EF5)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_2B2EF5)); ? ? ? ? ? ? ? ? } else if (position % 9 == 5) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_EEB01F)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_EEB01F)); ? ? ? ? ? ? ? ? } else if (position % 9 == 6) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_E92A4B)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_E92A4B)); ? ? ? ? ? ? ? ? } else if (position % 9 == 7) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_00C99E)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_00C99E)); ? ? ? ? ? ? ? ? } else if (position % 9 == 8) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_299BF5)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_299BF5)); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onTabReselect(int position) { ? ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onPageScrolled(int i, float v, int i1) { ? ? ? ? ? ? ? } ? ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onPageSelected(int position) { // ? ? ? ? ? ?tab_head.setCurrentTab(position); // ? ? ? ? ? ? ? ?if (!isFirstLay){ ? ? ? ? ? ? ? ? if (mFragments != null && mFragments.size() > 0 && articleClassifyList != null && articleClassifyList.size() > 0) { ? ? ? ? ? ? ? ? ? ? ArticleHomeFragment fragment = (ArticleHomeFragment) mFragments.get(position); ? ? ? ? ? ? ? ? ? ? fragment.setRefresh(position, articleClassifyList.get(position)); ? ? ? ? ? ? ? ? } // ? ? ? ? ? ? ? ?} // ? ? ? ? ? ? ? ? if (position % 9 == 0) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_1A75FF)); ? ? ? ? ? ? ? ? } else if (position % 9 == 1) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_F05F12)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_F05F12)); ? ? ? ? ? ? ? ? } else if (position % 9 == 2) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_DD8033)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_DD8033)); ? ? ? ? ? ? ? ? } else if (position % 9 == 3) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_14BEDF)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_14BEDF)); ? ? ? ? ? ? ? ? } else if (position % 9 == 4) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_2B2EF5)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_2B2EF5)); ? ? ? ? ? ? ? ? } else if (position % 9 == 5) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_EEB01F)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_EEB01F)); ? ? ? ? ? ? ? ? } else if (position % 9 == 6) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_E92A4B)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_E92A4B)); ? ? ? ? ? ? ? ? } else if (position % 9 == 7) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_00C99E)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_00C99E)); ? ? ? ? ? ? ? ? } else if (position % 9 == 8) { ? ? ? ? ? ? ? ? ? ? tl_9.setIndicatorColor(mContext.getResources().getColor(R.color.name_299BF5)); // ? ? ? ? ? ? ? ?tab_head.setIndicatorColor(mContext.getResources().getColor(R.color.name_299BF5)); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? } ? ? ? ? ? ? ? @Override ? ? ? ? ? ? public void onPageScrollStateChanged(int i) { ? ? ? ? ? ? ? } ? ? ? ? }); ? ? ? ? ? } ? ? ? @Override ? ? public void onClickArticle(boolean isremind) { ? ? ? ? LogUtil2.log("isRemind----"+isremind); ? ? ? ? isRemind=isremind; ? ? } ? ? ? private class MyPagerAdapter extends FragmentPagerAdapter { ? ? ? ? ? private List<String> tags;//標(biāo)示fragment的tag ? ? ? ? private FragmentManager fragmentManager; ? ? ? ? ? public MyPagerAdapter(FragmentManager fm) { ? ? ? ? ? ? super(fm); ? ? ? ? ? ? this.tags = new ArrayList<>(); ? ? ? ? ? ? this.fragmentManager = fm; ? ? ? ? } // ? ? ? ?public MyPagerAdapter(FragmentManager fm) { // ? ? ? ? ? ?super(fm); // ? ? ? ?} ? ? ? ? ? @Override ? ? ? ? public int getCount() { ? ? ? ? ? ? return mFragments.size(); ? ? ? ? } ? ? ? ? ? @Override ? ? ? ? public CharSequence getPageTitle(int position) { ? ? ? ? ? ? return mTitles.get(position); ? ? ? ? } ? ? ? ? ? @Override ? ? ? ? public Fragment getItem(int position) { ? ? ? ? ? ? return mFragments.get(position); ? ? ? ? } ? ? ? ? ? @Override ? ? ? ? public int getItemPosition(@NonNull Object object) { ? ? ? ? ? ? return POSITION_NONE; ? ? ? ? } ? ? ? ? //這個(gè)就不說了 ? ? ? ? private String makeFragmentName(int viewId, long id) { ? ? ? ? ? ? return "android:switcher:" + viewId + ":" + id; ? ? ? ? } ? ? ? ? @NonNull ? ? ? ? @Override ? ? ? ? public Object instantiateItem(@NonNull ViewGroup container, int position) { ? ? ? ? ? ? tags.add(makeFragmentName(container.getId(), getItemId(position))); ? ? ? ? ? ? Fragment fragment = (Fragment) super.instantiateItem(container, position); ? ? ? ? ? ? this.fragmentManager.beginTransaction().show(fragment).commitAllowingStateLoss(); ? ? ? ? ? ? return fragment; ? ? ? ? } ? ? ? ? //根據(jù)tag查找緩存的fragment,移除緩存的fragment,替換成新的 ? ? ? ? public void setNewFragments() { ? ? ? ? ? ? if (this.tags != null) { ? ? ? ? ? ? ? ? FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); ? ? ? ? ? ? ? ? for (int i = 0; i < tags.size(); i++) { ? ? ? ? ? ? ? ? ? ? fragmentTransaction.remove(fragmentManager.findFragmentByTag(tags.get(i))); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? fragmentTransaction.commitAllowingStateLoss(); ? ? ? ? ? ? ? ? fragmentManager.executePendingTransactions(); ? ? ? ? ? ? ? ? tags.clear(); ? ? ? ? ? ? } ? ? ? ? ? ? notifyDataSetChanged(); ? ? ? ? } ? ? } ? ? ? private void setBannerLoop(List<HomeBannerBean> mHomePagePlatAdList) { ? ? ? ? // 準(zhǔn)備數(shù)據(jù) ? ? ? ? ArrayList<BannerInfo> bannerInfos = new ArrayList<>(); ? ? ? ? List<String> bgList = new ArrayList<>(); ? ? ? ? for (int i = 0; i < mHomePagePlatAdList.size(); i++) { ? ? ? ? ? ? bannerInfos.add(new BannerInfo(mHomePagePlatAdList.get(i).imageUrl, mHomePagePlatAdList.get(i).url)); ? ? ? ? ? ? bgList.add(mHomePagePlatAdList.get(i).imageColour); ? ? ? ? } ? ? ? ? ? if (bannerInfos.size() == 0) { ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? if (bgList.size() == 0) { ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? loopLayout.setLoopData(bannerInfos);// 設(shè)置輪播數(shù)據(jù) ? ? ? ? if (bgList != null && mContext != null) { ? ? ? ? ? ? container.setBannerBackBg(mContext, bgList);// 背景容器設(shè)置輪播圖片 ? ? ? ? } ? ? ? ? loopLayout.setBannerBgContainer(container); ? ? ? ? loopLayout.stopLoop(); ? ? ? ? loopLayout.startLoop(); ? ? } ? ? ? private void setRecommendDatas(String response) { ? ? ? ? if (TextUtils.isEmpty(response)) { ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? FaXianListsBean bean = GsonUtils.toObject(response, FaXianListsBean.class); // ? ? ? ?KeChengRecommendsBean recommendsBean=bean.courseRecommends.get(0); ? ? ? ? mHomeAdapter.setHomeKeCheng(bean); ? ? } ? ? ? public static <T> List<T> getObjectList(String jsonString, Class<T> cls) { ? ? ? ? List<T> list = new ArrayList<T>(); ? ? ? ? try { ? ? ? ? ? ? Gson gson = new Gson(); ? ? ? ? ? ? JsonArray arry = new JsonParser().parse(jsonString).getAsJsonArray(); ? ? ? ? ? ? for (JsonElement jsonElement : arry) { ? ? ? ? ? ? ? ? list.add(gson.fromJson(jsonElement, cls)); ? ? ? ? ? ? } ? ? ? ? } catch (Exception e) { ? ? ? ? ? ? e.printStackTrace(); ? ? ? ? } ? ? ? ? return list; ? ? } ? ? ? private void setRecommendData(String response) { ? ? ? ? if (TextUtils.isEmpty(response)) { ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? HomeProductBean homeProductBean = GsonUtils.toObject(response, HomeProductBean.class); // ? ? ? ?List<HomeBottomProductBean> homeBean =/*GsonUtils.toList*/getObjectList(response, HomeBottomProductBean.class); ? ? ? ? ? mHomeAdapter.setHomeBean(homeProductBean); ? ? } ? ? ? private void setHomeBeanADV(String response) { ? ? ? ? HomeBean homeBean2 = GsonUtils.toObject(response, HomeBean.class); ? ? ? ? mHomeAdapter.setHomeBeanADV(homeBean2); ? ? } ? ? ? private void setHomeBeanRemind(String response) { ? ? ? ? if (TextUtils.isEmpty(response)) { ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? final KaoShiStatussBean bean = GsonUtils.toObject(response, KaoShiStatussBean.class); ? ? ? ? mHomeAdapter.setHomeRemind(bean); ? ? } ? ? ? private void setHomeAdviance(String response) { ? ? ? ? if (TextUtils.isEmpty(response)) { ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? ? final HeadHomeBean bean = GsonUtils.toObject(response, HeadHomeBean.class); ? ? ? ? ? mHomeAdapter.setHomeAdviance(bean); ? ? } ? ? ? ? ? @Override ? ? public void onTabReselect() { ? ? ? ? LogUtil.e(LogUtil.CQ, "onTabReselect HomeFragment"); ? ? } ? ? ? ? /** ? ? ?* 生成一個(gè)0 到 count 之間的隨機(jī)數(shù) ? ? ?* ? ? ?* @param endNum ? ? ?* @return ? ? ?*/ ? ? public int getNum(int endNum) { ? ? ? ? if (endNum > 0) { ? ? ? ? ? ? Random random = new Random(); ? ? ? ? ? ? return random.nextInt(endNum); ? ? ? ? } ? ? ? ? return 0; ? ? } ? ? ? /** ? ? ?* banner點(diǎn)擊事件 ? ? ?* ? ? ?* @param position position ? ? ?*/ ? ? @Override ? ? public void onItemClick(int position) { ? ? } ? ? ? @Override ? ? public void onDestroy() { ? ? ? ? super.onDestroy(); ? ? ? ? EventManager.unregister(this); ? ? ? ? loopLayout.stopLoop();// 頁面銷毀時(shí)需要停止 ? ? ? ? mHomeAdapter.setIsStop(true); ? ? ? ? ? if(iv_contact != null && ?!getActivity().isDestroyed()){ ? ? ? ? ? ? Glide.with(getContext()).clear(iv_contact); ? ? ? ? ? ? iv_contact = null; ? ? ? ? } ? ? } ? ? ? @Override ? ? public void onDestroyView() { ? ? ? ? super.onDestroyView(); ? ? ? } ? ? ? public static SetOnclickInterface listenersTOP; ? ? ? ? @Override ? ? public void onRefresh() { ? ? } ? ? ? @Override ? ? public void onLoadMore() { ? ? ? } ? ? ? /** ? ? ?* banner滾動(dòng)輪播 ? ? ?* ? ? ?* @param position ? ? ?* @param banner ? ? ?*/ ? ? @Override ? ? public void onBannerClick(int position, ArrayList<BannerInfo> banner) { ? ? ? } ? ? ? @Override ? ? public void onChildScroll(RecyclerView recyclerView, int newState) { ? ? ? ? switch (newState) { ? ? ? ? ? ? case 0: ? ? ? ? ? ? ? ? LogUtil2.log("recyclerview已經(jīng)停止?jié)L動(dòng)"); ? ? ? ? ? ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.huadong2)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? ? ? new Handler().postDelayed(new Runnable() { ? ? ? ? ? ? ? ? ? ? ? ? @Override ? ? ? ? ? ? ? ? ? ? ? ? public void run() { ? ? ? ? ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.jingzhi)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? }, 1500); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? case 1: ? ? ? ? ? ? ? ? LogUtil2.log("recyclerview正在被拖拽"); ? ? ? ? ? ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.huadong)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? case 2: ? ? ? ? ? ? ? ? LogUtil2.log("recyclerview正在依靠慣性滾動(dòng)"); ? ? ? ? ? ? ? ? ? if (getActivity() != null) { ? ? ? ? ? ? ? ? ? ? Glide.with(getActivity()).load(R.mipmap.huadong)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? break; ? ? ? ? } ? ? } ? }
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android ViewPager實(shí)現(xiàn)頁面左右切換效果
- 基于Android實(shí)現(xiàn)一個(gè)常用的布局吸頂效果
- Android進(jìn)階CoordinatorLayout協(xié)調(diào)者布局實(shí)現(xiàn)吸頂效果
- Android進(jìn)階NestedScroll嵌套滑動(dòng)機(jī)制實(shí)現(xiàn)吸頂效果詳解
- Android RecyclerView實(shí)現(xiàn)懸浮吸頂、分隔線、到底提示效果
- android中RecyclerView懸浮吸頂效果
- Android吸頂效果并有著ViewPager左右切換功能
相關(guān)文章
Android 三行代碼實(shí)現(xiàn)高斯模糊效果
這篇文章主要介紹了Android 三行代碼實(shí)現(xiàn)高斯模糊效果,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-09-09Android新建水平節(jié)點(diǎn)進(jìn)度條示例
這篇文章主要為大家介紹了Android新建水平節(jié)點(diǎn)進(jìn)度條示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06Android apk完整性檢測的實(shí)現(xiàn)思路和代碼實(shí)現(xiàn)
這篇文章主要介紹了Android apk完整性檢測的實(shí)現(xiàn)思路和代碼實(shí)現(xiàn),本文通過示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2023-12-12Jetpack Compose按鈕組件使用實(shí)例詳細(xì)講解
這篇文章主要介紹了Jetpack Compose按鈕組件使用實(shí)例,按鈕組件Button是用戶和系統(tǒng)交互的重要組件之一,它按照Material Design風(fēng)格實(shí)現(xiàn),我們先看下Button的參數(shù)列表,通過參數(shù)列表了解下Button的整體功能2023-04-04Android TextView字體顏色設(shè)置方法小結(jié)
這篇文章主要介紹了Android TextView字體顏色設(shè)置方法,結(jié)合實(shí)例形式總結(jié)分析了Android開發(fā)中TextView設(shè)置字體顏色的常用技巧,需要的朋友可以參考下2016-02-02Android嵌套滾動(dòng)的傳統(tǒng)方法與思路
Android嵌套滾動(dòng)是在開發(fā)中經(jīng)常遇到的一個(gè)需求,這篇文章主要介紹了Android嵌套滾動(dòng)的傳統(tǒng)方法與思路的相關(guān)資料,對(duì)各位Android開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-05-05Android中利用zxing實(shí)現(xiàn)自己的二維碼掃描識(shí)別詳解
這篇文章主要給大家介紹了關(guān)于Android中利用zxing實(shí)現(xiàn)自己的二維碼掃描識(shí)別的相關(guān)資料,文中通過圖文介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用zxing具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧。2017-09-09Android編程之客戶端通過socket與服務(wù)器通信的方法
這篇文章主要介紹了Android編程之客戶端通過socket與服務(wù)器通信的方法,結(jié)合實(shí)例形式分析了Android基于socket通訊的具體步驟與相關(guān)使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11Spinner在Dialog中的使用效果實(shí)例代碼詳解
這篇文章主要介紹了Spinner在Dialog中的使用效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-05-05