Aqara Home v2.4.1版本的 MD5 值为:529779ac2bc0131db52a1fc3098d2b35
以下内容为反编译后的 RecommendedAutoActivity.java 源代码,内容仅作参考
package com.lumiunited.aqara.device.adddevicepage.gateway.guide;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.alibaba.fastjson.JSON;
import com.lumiunited.aqara.application.base.BaseActivity;
import com.lumiunited.aqara.common.ui.titlebar.TitleBar;
import com.lumiunited.aqara.device.adddevicepage.bean.AutoTemplate;
import com.lumiunited.aqarahome.R;
import java.util.ArrayList;
import java.util.List;
import k.e.a.c;
import k.e.a.u.h;
import k.u.c.d.a.p;
import k.u.c.d.j.i0;
import r.a.a.a.l;
public class RecommendedAutoActivity extends BaseActivity implements TitleBar.l {
public static final int T = p.a().getResources().getDimensionPixelOffset(R.dimen.px12);
public TitleBar H;
public TextView I;
public ViewPager J;
public TextView K;
public TextView L;
public ConstraintLayout M;
public View N;
public int R = p.a().getResources().getDimensionPixelOffset(R.dimen.px8);
public List<AutoTemplate> S = new ArrayList();
public class a implements ViewPager.OnPageChangeListener {
public a() {
}
@Override
public void onPageScrollStateChanged(int i2) {
}
@Override
public void onPageScrolled(int i2, float f2, int i3) {
RecommendedAutoActivity.this.N.setTranslationX(((i2 - 1) + f2) * (RecommendedAutoActivity.T + RecommendedAutoActivity.this.R));
}
@Override
public void onPageSelected(int i2) {
RecommendedAutoActivity.this.D(i2);
}
}
public class b extends PagerAdapter {
public List<ImageView> a;
public l b = new l((int) p.a().getResources().getDimension(R.dimen.px15), 0, l.b.ALL);
public b(List<ImageView> list) {
this.a = list;
}
@Override
public void destroyItem(@NonNull ViewGroup viewGroup, int i2, @NonNull Object obj) {
viewGroup.removeView(this.a.get(i2));
}
@Override
public int getCount() {
List<ImageView> list = this.a;
if (list == null) {
return 0;
}
return list.size();
}
@Override
@NonNull
public Object instantiateItem(@NonNull ViewGroup viewGroup, int i2) {
View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.layout_recommanded_auto_item, viewGroup, false);
ImageView imageView = (ImageView) inflate.findViewById(R.id.image_view);
c.a(imageView).load(RecommendedAutoActivity.this.S.get(i2).getPicUrl()).a((k.e.a.u.a<?>) h.c(this.b)).a((k.e.a.u.a<?>) h.j(R.drawable.shape_corner_bg_placeholder)).a(imageView);
viewGroup.addView(inflate);
return inflate;
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object obj) {
return view == obj;
}
}
public void D(int i2) {
if (i2 < 0 || i2 > this.S.size() - 1) {
return;
}
this.K.setText(this.S.get(i2).getTitleName());
this.L.setText(this.S.get(i2).getViceTitleName());
}
private void f1() {
if (this.S != null) {
for (int i2 = 0; i2 < this.S.size(); i2++) {
View view = new View(this);
view.setBackgroundResource(R.drawable.welcome_round_shape);
int i3 = this.R;
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(i3, i3);
layoutParams.leftToLeft = 0;
((ViewGroup.MarginLayoutParams) layoutParams).leftMargin = (this.R + T) * i2;
view.setLayoutParams(layoutParams);
this.M.addView(view);
}
if (this.S.size() > 0) {
View view2 = new View(this);
this.N = view2;
view2.setBackgroundResource(R.drawable.welcome_indicator_checked);
int i4 = this.R;
ConstraintLayout.LayoutParams layoutParams2 = new ConstraintLayout.LayoutParams(i4, i4);
layoutParams2.leftToLeft = 0;
((ViewGroup.MarginLayoutParams) layoutParams2).leftMargin = this.R + T;
this.N.setLayoutParams(layoutParams2);
this.M.addView(this.N);
}
}
}
private void g1() {
this.S.addAll(JSON.parseArray("[\n {\n \"viceTitleName\": \"사람은 움직이고, 문과 창문을 열리면 알람이 뜨면서 통보할 것이다.\",\n \"picUrl\": \"http://cnbj2.fds.api.xiaomi.com/lumiaiot/ifttt/template-pic/recommend_auto_a_korea@3x.png\",\n \"titleName\": \"밖에서 지키다\",\n \"linkageTemplateId\": \"lt.212\",\n \"name\": \"경보중\"\n },\n {\n \"viceTitleName\": \"집 가출 수호를 시작한다\",\n \"picUrl\": \"http://cnbj2.fds.api.xiaomi.com/lumiaiot/ifttt/template-pic/recommend_auto_b_korea@3x.png\",\n \"titleName\": \"가출 시 무선 스위치 더블 클릭\",\n \"linkageTemplateId\": \"lt.213\",\n \"name\": \"더블클릭-경보설정\"\n },\n {\n \"viceTitleName\": \"집 가출 수호 닫음\",\n \"picUrl\": \"http://cnbj2.fds.api.xiaomi.com/lumiaiot/ifttt/template-pic/recommend_auto_c_korea@3x.png\",\n \"titleName\": \"집에 갈 때 무선 스위치를 길게 누른다.\",\n \"linkageTemplateId\": \"lt.214\",\n \"name\": \"길게누름-경보해제\"\n },\n {\n \"viceTitleName\": \"스마트 콘센트 켜기/끄기\",\n \"picUrl\": \"http://cnbj2.fds.api.xiaomi.com/lumiaiot/ifttt/template-pic/recommend_auto_d_korea@3x.png\",\n \"titleName\": \"무선 스위치 클릭하기\",\n \"linkageTemplateId\": \"lt.215\",\n \"name\": \"한번 누름-플러그 끄기/켜기\"\n }\n ]", AutoTemplate.class));
}
private List<ImageView> h1() {
ArrayList arrayList = new ArrayList();
if (this.S != null) {
for (int i2 = 0; i2 < this.S.size(); i2++) {
ImageView imageView = new ImageView(this);
imageView.setLayoutParams(new LinearLayout.LayoutParams(getResources().getDimensionPixelOffset(R.dimen.px297), getResources().getDimensionPixelOffset(R.dimen.px330)));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
arrayList.add(imageView);
}
}
return arrayList;
}
private void i1() {
ArrayList parcelableArrayListExtra = getIntent().getParcelableArrayListExtra("templates");
this.S = parcelableArrayListExtra;
if (parcelableArrayListExtra == null) {
this.S = new ArrayList();
}
}
private void j1() {
TitleBar titleBar = (TitleBar) findViewById(R.id.title_bar);
this.H = titleBar;
titleBar.getIvLeft().setVisibility(8);
this.H.setOnRightClickListener(this);
this.I = (TextView) findViewById(R.id.tv_title);
this.J = (ViewPager) findViewById(R.id.vp_image);
this.K = (TextView) findViewById(R.id.tv_auto_name);
this.L = (TextView) findViewById(R.id.tv_auto_desc);
this.M = (ConstraintLayout) findViewById(R.id.layout_indicator);
this.I.setText(getString(R.string.tips_recommended_auto));
D(0);
f1();
this.J.setAdapter(new b(h1()));
this.J.setCurrentItem(0);
this.J.setOffscreenPageLimit(3);
this.J.setPageMargin(getResources().getDimensionPixelOffset(R.dimen.px18));
this.J.addOnPageChangeListener(new a());
}
@Override
public void c() {
finish();
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_recommanded_auto);
i1();
j1();
}
public static void a(Context context, ArrayList<AutoTemplate> arrayList) {
Intent intent = new Intent(context, RecommendedAutoActivity.class);
intent.putParcelableArrayListExtra("templates", arrayList);
i0.a(context, intent);
}
}