91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何使用Android實現上拉吸頂效果

發布時間:2022-02-14 09:39:06 來源:億速云 閱讀:163 作者:小新 欄目:開發技術

這篇文章給大家分享的是有關如何使用Android實現上拉吸頂效果的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

具體內容如下

效果圖

如何使用Android實現上拉吸頂效果

1.home_layout.xml

此布局即可實現上拉標題固定在頂部

<?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">-->
 
 
    <!--中間內容-->
        <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"
                                    
                                    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_
                        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;//點文章不會到頂部其余都回到頂部
    private boolean isSame=true;//是否有不同tab 判斷后臺增加或者減少tab刷新 否者不刷新tab方便記錄點擊位置
    private boolean isFirstTab=true;//是否第一進入加載 第一次進入app時刷新tab 不是第一次需判斷后臺增加或者減少tab刷新 否者不刷新tab方便記錄點擊位置
    private boolean isHoutai=false;
    private int appbarState;
    private boolean isOther=false;
    private boolean isRemindTrue=false;
 
 
    @Override
    protected int getContentView() {
        // 加載系統默認設置,字體不隨用戶設置變化
        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();// 設置插入器(線性勻速)
        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); // 設置保持動畫最后的狀態
//        anim.setDuration(10000); // 設置動畫時間
//        anim.setInterpolator(new LinearInterpolator()); // 設置插入器(線性勻速)
//        mTitleBar.startAnimation(anim);
    }
 
 
 
    @Override
    public void initView(View view) {
//        setFullScreen();
//        changeStatusBarTextColor(true);
//        BarUtils.setColorNoTranslucent(getActivity(), getResources().getColor(R.color.transparent));
//        BarUtils.setRootViewFitsSystemWindows(getActivity(), false);
//        //此方法上下狀態欄都透明,狀態欄字體顏色為黑色
//        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由相關工具獲得,或者美工提供
        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);
        //狀態欄高度
        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);
 
//        //獲取當前控件的布局對象
        ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) container.getLayoutParams();
        params.width = getScreenWidth();//設置當前控件布局的寬度
        params.height = getScreenWidth() * 1 / 2;//設置當前控件布局的高度
        container.setLayoutParams(params);//將設置好的布局參數應用到控件中
 
        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);
 
 
        // 設置輪播圖屬性
        loopLayout.setLoop_ms(4000);//輪播的速度(毫秒)
        loopLayout.setLoop_duration(400);//滑動的速率(毫秒)
        loopLayout.setScaleAnimation(false);// 設置是否需要動畫
        loopLayout.setLoop_style(LoopStyle.Empty);//輪播的樣式-默認empty
        loopLayout.setIndicatorLocation(IndicatorLocation.Center);//指示器位置-中Center
        loopLayout.initializeData(mContext);
 
 
        // 設置監聽
        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("滾動高度--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("滾動高度--tt", "移動");
                        if (getActivity() != null) {
                            Glide.with(getActivity()).load(R.mipmap.huadong)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact);
                        }
                        break;
                    case MotionEvent.ACTION_UP:
                        Log.i("滾動高度--tt", "抬起");
                        break;
                }
                return false;
            }
        });
        appbar.addOnOffsetChangedListener(new AppBarStateChangeListener() {
            @Override
            public void onStateChanged(AppBarLayout appBarLayout, State state) {
 
                if (state == State.EXPANDED) {
 
                    Log.i("滾動高度--", "展開");
 
 
                } else if (state == State.COLLAPSED) {
 
                    Log.i("滾動高度--", "折疊");
 
                    setpopLoad();
                } else {
 
 
                    Log.i("滾動高度--", "中間");
 
                }
            }
        });
        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("滑動高度--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由相關工具獲得,或者美工提供
 
                    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();
                //獲取當前可見條目得索引
                int firstVisibleItemPosition = manager.findFirstVisibleItemPosition();
                int lastVisibleItemPosition = manager.findLastCompletelyVisibleItemPosition();
 
                //獲取當前可見條目得itemView
                View firstView = manager.findViewByPosition(firstVisibleItemPosition);
                //獲取當前可見條目得itemView得高度
                height = firstView.getHeight();
                //獲取當前可見條目得偏移量
                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("滑動高度--" + 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由相關工具獲得,或者美工提供
                    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);//設置狀態欄黑色字體
            } else {
                getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);//恢復狀態欄白色字體
            }
        }
    }
 
    /**
     * 判斷是否是全面屏
     */
    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的,都不會是全面屏。。。
        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已經停止滾動");
 
                        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正在依靠慣性滾動");
 
                        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,中文翻譯為國際移動裝備辨識碼, 即??常所說的手機序列號,
     * 用于在手機網絡中識別每一部獨立的手機,是國際上公認的手機標志序號,相當于移動電話的身份證。序列號共有15位數字,??位(TAC)是型號核準號碼??
     * 代表手機類型。接??位(FAC)是????裝配號,代表產地。后6位(SNR)是串號,代表生產順序號。最??位(SP)一般為0,是????碼,備用??
     * 國際移動裝備辨識碼一般貼于機身背面與外包裝上,同時也存在于手機記憶體中,通過輸入*#06#即可查詢??
     *
     * @param
     * @return
     */
 
    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (!hidden) {
            hidden2 = hidden;
            LogUtil2.log("==========================>>>onHiddenChangedHome" + hidden);
 
 
            loopLayout.stopLoop();// 頁面銷毀時需要停止
            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由相關工具獲得,或者美工提供
 
                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();// 頁面銷毀時需要停止
            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, "手機IMEI權限未開啟!", 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://精選產品
                setRecommendData(response);
                break;
 
            case 700:
                LogUtil2.log("=========================>>>700" + response.toString());
                setHomeBeanADV(response);
                break;
            case 800://提醒中心
                setHomeBeanRemind(response);
                break;
            case 601://云學院推薦櫥窗列表
                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://滾動頭條
                LogUtil2.log("首頁文章--滾動條" + response.toString());
                setHomeAdviance(response);
                break;
            case 605://文章標題
                LogUtil2.log("首頁文章--文章標題" + 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("滾動高度--onPause", "展開");
    }
 
    @Override
    public void onStop() {
        super.onStop();
        Log.i("滾動高度--onStop", "展開");
        if (isRemind){
            isOther=true;
        }
        if (appbarState == 1) {
            Log.i("滾動高度--", "展開");
            //展開狀態
 
        } else if (appbarState == 2) {
            Log.i("滾動高度--", "折疊");
            //折疊狀態
 
        }  else if (appbarState ==3){
 
            Log.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;//標示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;
        }
        //這個就不說了
        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;
        }
        //根據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) {
        // 準備數據
        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);// 設置輪播數據
        if (bgList != null && mContext != null) {
            container.setBannerBackBg(mContext, bgList);// 背景容器設置輪播圖片
        }
        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");
    }
 
 
    /**
     * 生成一個0 到 count 之間的隨機數
     *
     * @param endNum
     * @return
     */
    public int getNum(int endNum) {
        if (endNum > 0) {
            Random random = new Random();
            return random.nextInt(endNum);
        }
        return 0;
    }
 
    /**
     * banner點擊事件
     *
     * @param position position
     */
    @Override
    public void onItemClick(int position) {
    }
 
    @Override
    public void onDestroy() {
        super.onDestroy();
        EventManager.unregister(this);
        loopLayout.stopLoop();// 頁面銷毀時需要停止
        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滾動輪播
     *
     * @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已經停止滾動");
 
                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正在依靠慣性滾動");
 
                if (getActivity() != null) {
                    Glide.with(getActivity()).load(R.mipmap.huadong)/*.asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE)*/.into(iv_contact);
                }
                break;
        }
    }
 
}

感謝各位的閱讀!關于“如何使用Android實現上拉吸頂效果”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

兴和县| 穆棱市| 应城市| 赤峰市| 化州市| 钦州市| 商河县| 兴文县| 天全县| 襄汾县| 酒泉市| 离岛区| 常州市| 西林县| 嘉黎县| 广饶县| 凤山县| 屯门区| 库尔勒市| 凌源市| 平顶山市| 甘洛县| 泽普县| 刚察县| 万盛区| 中方县| 大田县| 庆元县| 清苑县| 无极县| 永靖县| 轮台县| 滦平县| 武鸣县| 迭部县| 长顺县| 南通市| 特克斯县| 中山市| 永吉县| 思茅市|