android:duration="2000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />
private TextView tv;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.myanim);
tv.setAnimation(animation);
animation.start();
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
handler.sendEmptyMessageDelayed(2, 2000);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
break;
case 2:
Intent intent = new Intent(MainActivity.this, InFoActivity.class);
startActivity(intent);
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
initData();
}
private void initData() {
handler.sendEmptyMessageDelayed(1, 0);
}
private void initView() {
tv = (TextView) findViewById(R.id.tv);
public class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<MyBean.DataBean.ObjectsBean> beanList;
private Context context;
private final static int ITEM_ONE = 1;
private final static int ITEM_TWO = 2;
private OnItemClickListener listener;
public MyAdapter(List<MyBean.DataBean.ObjectsBean> beanList, Context context) {
this.beanList = beanList;
this.context = context;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(context);
View view;
RecyclerView.ViewHolder hdd;
if (viewType == ITEM_ONE) {
view = inflater.inflate(R.layout.item_view_one, parent, false);
hdd = new HolderOne(view);
} else {
view = inflater.inflate(R.layout.item_view_two, parent, false);
hdd = new HolderTwo(view);
}
return hdd;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
MyBean.DataBean.ObjectsBean bean = beanList.get(position);
if (holder instanceof HolderOne) {
((HolderOne) holder).tvviewone.setText(bean.getGmall_product().getTitle());
Picasso.with(context).load(bean.getGmall_product().getPic_url()).into(((HolderOne) holder).imgviewone);
((HolderOne) holder).linear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onItemClick(position);
}
});
} else {
((HolderTwo) holder).tvviewtwo.setText(bean.getGmall_product().getStart_time());
Picasso.with(context).load(bean.getGmall_product().getPic_url()).into(((HolderTwo) holder).imgviewtwo);
((HolderTwo) holder).linear1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onItemClick(position);
}
});
}
}
@Override
public int getItemCount() {
return beanList.isEmpty() ? 0 : beanList.size();
}
@Override
public int getItemViewType(int position) {
if (position % 2 == 0) {
return ITEM_ONE;
} else {
return ITEM_TWO;
}
}
class HolderOne extends RecyclerView.ViewHolder {
private LinearLayout linear;
private TextView tvviewone;
private ImageView imgviewone;
public HolderOne(View itemView) {
super(itemView);
imgviewone = (ImageView) itemView.findViewById(R.id.imgviewone);
tvviewone = (TextView) itemView.findViewById(R.id.tvviewone);
linear = (LinearLayout) itemView.findViewById(R.id.linear);
}
}
class HolderTwo extends RecyclerView.ViewHolder {
private LinearLayout linear1;
private TextView tvviewtwo;
private ImageView imgviewtwo;
public HolderTwo(View itemView) {
super(itemView);
imgviewtwo = (ImageView) itemView.findViewById(R.id.imgviewtwo);
tvviewtwo = (TextView) itemView.findViewById(R.id.tvviewtwo);
linear1 = (LinearLayout) itemView.findViewById(R.id.linear1);
}
}
public interface OnItemClickListener {
void onItemClick(int pos);
}
public void setOnItemClickListener(OnItemClickListener listener) {
this.listener = listener;
}
}
private Toolbar toolbar;
private RecyclerView recycler;
private String murl = "http://huixinguiyu.cn/Assets/js/competitive.js";
private List<MyBean.DataBean.ObjectsBean> beans;
private MyAdapter adapter;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
String str = (String) msg.obj;
Gson gson = new Gson();
MyBean myBean = gson.fromJson(str, MyBean.class);
beans = myBean.getData().getObjects();
adapter = new MyAdapter(beans,InFoActivity.this);
recycler.setAdapter(adapter);
adapter.setOnItemClickListener(new MyAdapter.OnItemClickListener() {
@Override
public void onItemClick(int pos) {
Intent intent1=new Intent(InFoActivity.this,AnAnActivity.class);
intent1.putExtra("qwe",beans.get(pos).getGmall_product().getTitle());
intent1.putExtra("aaa",beans.get(pos).getGmall_product().getPic_url());
startActivity(intent1);
}
});
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_in_fo);
initView();
initData();
}
private void initData() {
new Thread(new Runnable() {
@Override
public void run() {
try {
OkHttpClient okhttp = new OkHttpClient();
Request request = new Request.Builder().url(murl).build();
Response response = okhttp.newCall(request).execute();
String ss = response.body().string();
Message message = new Message();
message.obj = ss;
handler.sendMessage(message);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
private void initView() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("多布局");
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
recycler = (RecyclerView) findViewById(R.id.recycler);
LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
recycler.setLayoutManager(manager);
}
private ImageView image;
private TextView tvv;
private String imgee;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_an_an);
initView();
Intent intent = getIntent();
String title = intent.getStringExtra("qwe");
imgee = intent.getStringExtra("aaa");
tvv.setText(title);
Picasso.with(AnAnActivity.this).load(imgee).into(image);
}
private void initView() {
image = (ImageView) findViewById(R.id.image);
tvv = (TextView) findViewById(R.id.tvv);
}