| | |
| | | import android.content.pm.PackageInfo; |
| | | import android.content.pm.PackageManager; |
| | | import android.graphics.Color; |
| | | import android.graphics.Typeface; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.text.TextPaint; |
| | | import android.view.LayoutInflater; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | | import android.view.Window; |
| | |
| | | import com.tejia.lijin.app.ui.invite.ShareBrowserActivity; |
| | | import com.tejia.lijin.app.ui.mine.ShoppingTrolleyActivity; |
| | | import com.tejia.lijin.app.ui.recommend.RecommendCategoryFragment; |
| | | import com.tejia.lijin.app.ui.recommend.RecommendFragment; |
| | | import com.tejia.lijin.app.ui.recommend.SearchActivity; |
| | | import com.tejia.lijin.app.ui.subview.HomeRecommendNavIndicator; |
| | | import com.tejia.lijin.app.updateApp.UpdateApp; |
| | | import com.tejia.lijin.app.util.JumpActivityUtil; |
| | | import com.tejia.lijin.app.util.SystemParamsUtil; |
| | | import com.tejia.lijin.app.util.ToolUtil; |
| | | import com.tejia.lijin.app.util.ui.HomeUIUtil; |
| | | import com.tejia.lijin.app.util.umengCustomEvent.CategoryCustomEvent; |
| | |
| | | import com.wpc.library.util.NetUtils; |
| | | import com.wpc.library.util.SystemCommon; |
| | | import com.wpc.library.util.cache.DiskLruCache; |
| | | import com.wpc.library.util.common.DimenUtils; |
| | | import com.wpc.library.util.common.StorageUtils; |
| | | import com.wpc.library.util.common.StringUtils; |
| | | import com.tejia.lijin.app.ui.recommend.RecommendFragment; |
| | | |
| | | import net.lucode.hackware.magicindicator.MagicIndicator; |
| | | import net.lucode.hackware.magicindicator.ViewPagerHelper; |
| | | import net.lucode.hackware.magicindicator.buildins.UIUtil; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ClipPagerTitleView; |
| | | import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.CommonPagerTitleView; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | contentView.findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | |
| | | |
| | | contentView.findViewById(R.id.tv_course).setOnClickListener(this); |
| | | recommend_top_img = contentView.findViewById(R.id.recommend_top_img);//热门功能 |
| | | fl_search_content = contentView.findViewById(R.id.fl_search_content); |
| | | fl_search_content.setOnClickListener(this); |
| | |
| | | }, false);//强制检测更新-否. |
| | | |
| | | //设置背景色 |
| | | contentView.findViewById(R.id.apl_search).setBackground(HomeUIUtil.getHomeTopBg("#FF227B", "#FF2A3E")); |
| | | magic_indicator.setBackground(HomeUIUtil.getHomeTopBg("#FF227B", "#FF2A3E")); |
| | | contentView.findViewById(R.id.apl_search).setBackground(HomeUIUtil.getHomeTopBg(getContext())); |
| | | magic_indicator.setBackground(HomeUIUtil.getHomeTopBg(getContext())); |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | private CommonNavigatorAdapter n1 = new CommonNavigatorAdapter() { |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return mList == null ? 0 : mList.size(); |
| | | } |
| | | |
| | | @Override |
| | | public IPagerTitleView getTitleView(final Context context, final int index) { |
| | | CommonPagerTitleView commonPagerTitleView = new CommonPagerTitleView(getContext()); |
| | | //设置自定义布局文件及view赋值 |
| | | commonPagerTitleView.setContentView(R.layout.item_recommend_nav); |
| | | commonPagerTitleView.setHovered(false); |
| | | final TextView tvTitle = commonPagerTitleView.findViewById(R.id.tv_title); |
| | | tvTitle.setHighlightColor(context.getResources().getColor(android.R.color.transparent)); |
| | | tvTitle.setText(mList.get(index).getName()); |
| | | tvTitle.setBackground(null); |
| | | |
| | | //tab切换监听 |
| | | commonPagerTitleView.setOnPagerTitleChangeListener(new CommonPagerTitleView.OnPagerTitleChangeListener() { |
| | | @Override |
| | | public void onSelected(int index, int totalCount) { |
| | | tvTitle.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); |
| | | } |
| | | |
| | | @Override |
| | | public void onDeselected(int index, int totalCount) { |
| | | tvTitle.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL)); |
| | | } |
| | | |
| | | @Override |
| | | public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) { |
| | | |
| | | } |
| | | }); |
| | | |
| | | //tab单个item点击事件监听 |
| | | commonPagerTitleView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | pager.setCurrentItem(index); |
| | | } |
| | | }); |
| | | |
| | | return commonPagerTitleView; |
| | | } |
| | | |
| | | //此为tab指示器回调 |
| | | @Override |
| | | public IPagerIndicator getIndicator(Context context) { |
| | | int height = magic_indicator.getLayoutParams().height; //UIUtil.dip2px(context, 40); |
| | | HomeRecommendNavIndicator indicator = new HomeRecommendNavIndicator(context); |
| | | float navigatorHeight = DimenUtils.sp2px(context, 25); //context.getResources().getDimension(R.dimen.dp_130); |
| | | float borderWidth = UIUtil.dip2px(context, 1); |
| | | float lineHeight = navigatorHeight - 2 * borderWidth; |
| | | indicator.setLineHeight(lineHeight); |
| | | indicator.setRoundRadius(lineHeight / 2); |
| | | indicator.setXOffset(UIUtil.dip2px(context, 5)); |
| | | indicator.setYOffset((height - navigatorHeight) / 2); |
| | | indicator.setColors(Color.parseColor("#FFFFFF")); |
| | | return indicator; |
| | | } |
| | | }; |
| | | |
| | | |
| | | private CommonNavigatorAdapter n2 = new CommonNavigatorAdapter() { |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return mList == null ? 0 : mList.size(); |
| | | } |
| | | |
| | | @Override |
| | | public IPagerTitleView getTitleView(Context context, final int index) { |
| | | ClipPagerTitleView clipPagerTitleView = new ClipPagerTitleView(context); |
| | | clipPagerTitleView.setText(mList.get(index).getName()); |
| | | clipPagerTitleView.setTextColor(Color.parseColor("#FFFFFF")); |
| | | clipPagerTitleView.setClipColor(Color.WHITE); |
| | | clipPagerTitleView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | pager.setCurrentItem(index); |
| | | } |
| | | }); |
| | | return clipPagerTitleView; |
| | | } |
| | | |
| | | //此为tab指示器回调 |
| | | @Override |
| | | public IPagerIndicator getIndicator(Context context) { |
| | | int height = magic_indicator.getLayoutParams().height; //UIUtil.dip2px(context, 40); |
| | | LinePagerIndicator indicator = new LinePagerIndicator(context); |
| | | float navigatorHeight = DimenUtils.sp2px(context, 25); //context.getResources().getDimension(R.dimen.dp_130); |
| | | float borderWidth = UIUtil.dip2px(context, 1); |
| | | float lineHeight = navigatorHeight - 2 * borderWidth; |
| | | indicator.setLineHeight(lineHeight); |
| | | indicator.setRoundRadius(lineHeight / 2); |
| | | indicator.setYOffset((height - navigatorHeight) / 2); |
| | | indicator.setColors(Color.parseColor("#bc2a2a")); |
| | | return indicator; |
| | | } |
| | | }; |
| | | |
| | | |
| | | private void loadHomeNavData() { |
| | | if (adapter == null) { |
| | |
| | | |
| | | if (commonNavigator == null) { |
| | | commonNavigator = new CommonNavigator(getContext()); |
| | | commonNavigator.setAdapter(new CommonNavigatorAdapter() { |
| | | |
| | | @Override |
| | | public int getCount() { |
| | | return mList == null ? 0 : mList.size(); |
| | | } |
| | | |
| | | @Override |
| | | public IPagerTitleView getTitleView(Context context, final int index) { |
| | | CommonPagerTitleView commonPagerTitleView = new CommonPagerTitleView(getContext()); |
| | | //设置自定义布局文件及view赋值 |
| | | commonPagerTitleView.setContentView(R.layout.item_recommend_nav); |
| | | final TextView tvTitle = commonPagerTitleView.findViewById(R.id.tv_title); |
| | | tvTitle.setText(mList.get(index).getName()); |
| | | |
| | | //tab切换监听 |
| | | commonPagerTitleView.setOnPagerTitleChangeListener(new CommonPagerTitleView.OnPagerTitleChangeListener() { |
| | | @Override |
| | | public void onSelected(int index, int totalCount) { |
| | | tvTitle.setBackground(getResources().getDrawable(R.drawable.shape_recommend_nav_highlight_bg)); |
| | | TextPaint paint = tvTitle.getPaint(); |
| | | paint.setFakeBoldText(true); |
| | | } |
| | | |
| | | @Override |
| | | public void onDeselected(int index, int totalCount) { |
| | | tvTitle.setBackground(null); |
| | | TextPaint paint = tvTitle.getPaint(); |
| | | paint.setFakeBoldText(false); |
| | | } |
| | | |
| | | @Override |
| | | public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) { |
| | | |
| | | } |
| | | }); |
| | | |
| | | //tab单个item点击事件监听 |
| | | commonPagerTitleView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View view) { |
| | | pager.setCurrentItem(index); |
| | | } |
| | | }); |
| | | |
| | | return commonPagerTitleView; |
| | | } |
| | | |
| | | //此为tab指示器回调 |
| | | @Override |
| | | public IPagerIndicator getIndicator(Context context) { |
| | | // LinePagerIndicator indicator = new LinePagerIndicator(context); |
| | | // indicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT); |
| | | return null; |
| | | } |
| | | }); |
| | | commonNavigator.setAdapter(n1); |
| | | //设置给magicIndicator |
| | | magic_indicator.setNavigator(commonNavigator); |
| | | ViewPagerHelper.bind(magic_indicator, pager); |
| | |
| | | } |
| | | }, 1000); |
| | | |
| | | boolean isLogin = sp.getBoolean("isLogin", false); |
| | | boolean isLogin = UserUtil.isLogin(getContext()); |
| | | if (isLogin) { |
| | | getUserInfo(UserUtil.getUid(ShoppingApplication.application)); |
| | | if (accountLogin && floatImgDetail != null) {//弹框需要登陆 |
| | |
| | | startActivity(intent1); |
| | | } |
| | | } |
| | | break; |
| | | case R.id.tv_course: |
| | | //教程 |
| | | startActivity(new Intent(getContext(), ShareBrowserActivity.class).putExtra("url", SystemParamsUtil.getNewerCourse(getContext()))); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | builder.setPositiveButton(new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | final boolean isLogin = getContext().getSharedPreferences("user", |
| | | MODE_PRIVATE).getBoolean("isLogin", false); |
| | | final boolean isLogin = UserUtil.isLogin(getContext()); |
| | | if (accountLogin && !isLogin) { |
| | | clickState = 3; |
| | | UserUtil.jumpLogin(getContext()); |
| | |
| | | builder.setPositiveButton(new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | final boolean isLogin = getContext().getSharedPreferences("user", |
| | | MODE_PRIVATE).getBoolean("isLogin", false); |
| | | final boolean isLogin = UserUtil.isLogin(getContext()); |
| | | if (accountLogin && !isLogin) { |
| | | clickState = 4; |
| | | UserUtil.jumpLogin(getContext()); |