Commit 0ef0f1f0 by wjg

add update

parent 52c48c55
package com.ihaoin.hooloo.device.component;
import android.content.Context;
import android.view.animation.Interpolator;
import android.widget.Scroller;
public class FixedSpeedScroller extends Scroller {
private int mDuration = 1500;
public FixedSpeedScroller(Context context) {
super(context);
}
public FixedSpeedScroller(Context context, Interpolator interpolator) {
super(context, interpolator);
}
@Override
public void startScroll(int startX, int startY, int dx, int dy, int duration) {
// Ignore received duration, use fixed one instead
super.startScroll(startX, startY, dx, dy, mDuration);
}
@Override
public void startScroll(int startX, int startY, int dx, int dy) {
// Ignore received duration, use fixed one instead
super.startScroll(startX, startY, dx, dy, mDuration);
}
public void setmDuration(int time) {
mDuration = time;
}
public int getmDuration() {
return mDuration;
}
}
\ No newline at end of file
...@@ -51,20 +51,21 @@ public class IntroViewPager extends ViewPager { ...@@ -51,20 +51,21 @@ public class IntroViewPager extends ViewPager {
if (CollectionUtils.isEmpty(introViews)) { if (CollectionUtils.isEmpty(introViews)) {
return null; return null;
} }
return introViews.get(index); return introViews.get(index % introViews.size());
} }
public int getCount() { public int getCount() {
if (pagerAdapter == null) { return Integer.MAX_VALUE;
return 0; // if (pagerAdapter == null) {
} // return 0;
return pagerAdapter.getCount(); // }
// return pagerAdapter.getCount();
} }
private PagerAdapter pagerAdapter = new PagerAdapter() { private PagerAdapter pagerAdapter = new PagerAdapter() {
@Override @Override
public int getCount() { public int getCount() {
return CollectionUtils.isEmpty(introViews) ? 0 : introViews.size(); return CollectionUtils.isEmpty(introViews) ? 0 : Integer.MAX_VALUE;
} }
@Override @Override
...@@ -74,7 +75,7 @@ public class IntroViewPager extends ViewPager { ...@@ -74,7 +75,7 @@ public class IntroViewPager extends ViewPager {
@Override @Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
View view = introViews.get(position); View view = getView(position);
container.removeView(view); container.removeView(view);
} }
...@@ -84,7 +85,7 @@ public class IntroViewPager extends ViewPager { ...@@ -84,7 +85,7 @@ public class IntroViewPager extends ViewPager {
if (CollectionUtils.isEmpty(introViews)) { if (CollectionUtils.isEmpty(introViews)) {
return null; return null;
} }
View view = introViews.get(position); View view = getView(position);
container.addView(view); container.addView(view);
return view; return view;
} }
......
...@@ -27,11 +27,10 @@ import androidx.viewpager.widget.ViewPager; ...@@ -27,11 +27,10 @@ import androidx.viewpager.widget.ViewPager;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.ihaoin.hooloo.device.HLApplication; import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.component.AutoWrapLayout;
import com.ihaoin.hooloo.device.component.IntroViewPager;
import com.ihaoin.hooloo.device.network.NetworkHandler;
import com.ihaoin.hooloo.device.base.AppConfig; import com.ihaoin.hooloo.device.base.AppConfig;
import com.ihaoin.hooloo.device.base.Base; import com.ihaoin.hooloo.device.base.Base;
import com.ihaoin.hooloo.device.component.AutoWrapLayout;
import com.ihaoin.hooloo.device.component.IntroViewPager;
import com.ihaoin.hooloo.device.data.enums.SkuState; import com.ihaoin.hooloo.device.data.enums.SkuState;
import com.ihaoin.hooloo.device.data.vo.Goods; import com.ihaoin.hooloo.device.data.vo.Goods;
import com.ihaoin.hooloo.device.data.vo.GoodsRule; import com.ihaoin.hooloo.device.data.vo.GoodsRule;
...@@ -40,6 +39,7 @@ import com.ihaoin.hooloo.device.data.vo.SkuRule; ...@@ -40,6 +39,7 @@ import com.ihaoin.hooloo.device.data.vo.SkuRule;
import com.ihaoin.hooloo.device.data.vo.SkuStateChangedVo; import com.ihaoin.hooloo.device.data.vo.SkuStateChangedVo;
import com.ihaoin.hooloo.device.home.view.LauncherActivity; import com.ihaoin.hooloo.device.home.view.LauncherActivity;
import com.ihaoin.hooloo.device.network.HttpUtil; import com.ihaoin.hooloo.device.network.HttpUtil;
import com.ihaoin.hooloo.device.network.NetworkHandler;
import com.ihaoin.hooloo.device.util.CollectionUtils; import com.ihaoin.hooloo.device.util.CollectionUtils;
import com.ihaoin.hooloo.device.util.JsonUtils; import com.ihaoin.hooloo.device.util.JsonUtils;
import com.ihaoin.hooloo.device.util.StringUtils; import com.ihaoin.hooloo.device.util.StringUtils;
......
...@@ -15,6 +15,7 @@ import android.util.DisplayMetrics; ...@@ -15,6 +15,7 @@ import android.util.DisplayMetrics;
import android.view.Display; import android.view.Display;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
...@@ -23,12 +24,15 @@ import androidx.annotation.NonNull; ...@@ -23,12 +24,15 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller; import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import com.ihaoin.hooloo.device.HLApplication; import com.ihaoin.hooloo.device.HLApplication;
import com.ihaoin.hooloo.device.R; import com.ihaoin.hooloo.device.R;
import com.ihaoin.hooloo.device.component.IntroViewPager;
import com.ihaoin.hooloo.device.base.Base; import com.ihaoin.hooloo.device.base.Base;
import com.ihaoin.hooloo.device.component.FixedSpeedScroller;
import com.ihaoin.hooloo.device.component.IntroViewPager;
import com.ihaoin.hooloo.device.data.MainData; import com.ihaoin.hooloo.device.data.MainData;
import com.ihaoin.hooloo.device.data.vo.Images;
import com.ihaoin.hooloo.device.data.vo.KDSMsg; import com.ihaoin.hooloo.device.data.vo.KDSMsg;
import com.ihaoin.hooloo.device.data.vo.KDSOrder; import com.ihaoin.hooloo.device.data.vo.KDSOrder;
import com.ihaoin.hooloo.device.kds.KDSSocket; import com.ihaoin.hooloo.device.kds.KDSSocket;
...@@ -37,7 +41,9 @@ import com.ihaoin.hooloo.device.util.CollectionUtils; ...@@ -37,7 +41,9 @@ import com.ihaoin.hooloo.device.util.CollectionUtils;
import com.ihaoin.hooloo.device.util.StringUtils; import com.ihaoin.hooloo.device.util.StringUtils;
import com.ihaoin.hooloo.device.util.Utils; import com.ihaoin.hooloo.device.util.Utils;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class MenuPresentation extends Presentation { public class MenuPresentation extends Presentation {
...@@ -121,10 +127,25 @@ public class MenuPresentation extends Presentation { ...@@ -121,10 +127,25 @@ public class MenuPresentation extends Presentation {
AnimationDrawable anim = (AnimationDrawable) getContext().getDrawable(R.drawable.menu_avatar); AnimationDrawable anim = (AnimationDrawable) getContext().getDrawable(R.drawable.menu_avatar);
imgAvatar.setBackground(anim); imgAvatar.setBackground(anim);
anim.start(); anim.start();
try {
Field field = ViewPager.class.getDeclaredField("mScroller");
field.setAccessible(true);
FixedSpeedScroller scroller = new FixedSpeedScroller(imagePager.getContext(), new LinearInterpolator());
field.set(imagePager, scroller);
scroller.setmDuration(500);
} catch (Exception e) {
e.printStackTrace();
}
} }
private void showImages() { private void showImages() {
MainData mainData = HLApplication.getMainData(); MainData mainData = HLApplication.getMainData();
// TODO TEST
List<String> imgs = Arrays.asList("https://hooloo-saas-test.oss-cn-beijing.aliyuncs.com/hooloo/2022/07/04/%E7%82%B9%E5%8D%95%E5%B1%8F%E5%86%85%E5%AE%B9%E5%9B%BE3.png", "https://hooloo-saas-test.oss-cn-beijing.aliyuncs.com/hooloo/2022/07/04/%E7%82%B9%E5%8D%95%E5%B1%8F%E5%86%85%E5%AE%B9%E5%9B%BE3.png", "https://hooloo-saas-test.oss-cn-beijing.aliyuncs.com/hooloo/2022/07/04/%E7%82%B9%E5%8D%95%E5%B1%8F%E5%86%85%E5%AE%B9%E5%9B%BE3.png");
Images img = new Images();
img.setLeft(imgs);
mainData.setImages(img);
if (mainData == null || mainData.getImages() == null) { if (mainData == null || mainData.getImages() == null) {
return; return;
} }
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
<dimen name="goods_price_margin">5px</dimen> <dimen name="goods_price_margin">5px</dimen>
<dimen name="category_padding_top">17px</dimen> <dimen name="category_padding_top">17px</dimen>
<dimen name="category_padding_bottom">32px</dimen> <dimen name="category_padding_bottom">32px</dimen>
<dimen name="category_padding_top_noimg">28px</dimen> <dimen name="category_padding_top_noimg">56px</dimen>
<dimen name="category_padding_bottom_noimg">33px</dimen> <dimen name="category_padding_bottom_noimg">70px</dimen>
<dimen name="category_padding_hor">35px</dimen> <dimen name="category_padding_hor">35px</dimen>
<dimen name="category_drawable_padding">10px</dimen> <dimen name="category_drawable_padding">10px</dimen>
<dimen name="category_drawable_width">100px</dimen> <dimen name="category_drawable_width">100px</dimen>
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
<dimen name="goods_price_margin">5px</dimen> <dimen name="goods_price_margin">5px</dimen>
<dimen name="category_padding_top">17px</dimen> <dimen name="category_padding_top">17px</dimen>
<dimen name="category_padding_bottom">32px</dimen> <dimen name="category_padding_bottom">32px</dimen>
<dimen name="category_padding_top_noimg">28px</dimen> <dimen name="category_padding_top_noimg">20px</dimen>
<dimen name="category_padding_bottom_noimg">33px</dimen> <dimen name="category_padding_bottom_noimg">70px</dimen>
<dimen name="category_padding_hor">35px</dimen> <dimen name="category_padding_hor">35px</dimen>
<dimen name="category_drawable_padding">10px</dimen> <dimen name="category_drawable_padding">10px</dimen>
<dimen name="category_drawable_width">100px</dimen> <dimen name="category_drawable_width">100px</dimen>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment