反编译学习

827 阅读2分钟

mori手帐编辑模块加纸逻辑,反编译后得到代码如下:

1.点击事件开始

/* renamed from: L */
    private View.OnClickListener f14273L = new View.OnClickListener() {
        public void onClick(View view) {
            if (EditorActivity.this.f14301o != null && EditorActivity.this.f14301o.mo25110l()) {
                int id = view.getId();
                int i = (int) ((((float) EditorActivity.this.f14270I) * 1.7786666f) / 2.0f);
                if (id == C2198R.C2200id.btnIncPage) {//加纸
                		//f14301o
                    view.setEnabled(EditorActivity.this.f14301o.mo25090a(i));
                    EditorActivity.this.findViewById(C2198R.C2200id.btnDecPage).setEnabled(true);
                } else if (id == C2198R.C2200id.btnDecPage) {
                    view.setEnabled(EditorActivity.this.f14301o.mo25096b(i));
                    EditorActivity.this.findViewById(C2198R.C2200id.btnIncPage).setEnabled(true);
                }
            }
        }
    };

找到最重要的一句话,是调用了

int i = (int) ((((float) EditorActivity.this.f14270I) * 1.7786666f) / 2.0f);
view.setEnabled(EditorActivity.this.f14301o.mo25090a(i)); 

疑问一:这里的f14270I是什么呢?来追踪一下

this.f14270I = getResources().getDisplayMetrics().widthPixels;//明白了,屏幕宽度

这里其实是计算要加纸的高度

疑问二:f14301o.mo25090a(i)

public Editor f14301o; //这是一个接口,

下面是Editor接口的该方法定义

/* renamed from: a */
    boolean mo25090a(int i)

那么我们要来寻找实现类

public class EditorController implements Editor 

来,核心的加纸方法代码出来了

/* renamed from: a */
    public boolean mo25090a(int i) {
    		//注释一
        if (this.f14621v == null || this.f14621v.mo25211s() == null) {
            return false;
        }
        float c = this.f14621v.mo25211s().mo25189c(PageData.C3774a.f14569b);
        //这里进行了判断,有一个最大高度,当前整个贴纸的的高度超过了最大高度,则不能进行加纸
        if (c >= EditorConfig.f9737j) {
            Lg.m13647a("EditorController", "incPage failed:maxPageHeight=" + EditorConfig.f9737j + ", current height=" + c);
            ToastUtil.m13584b(this.f14612m, this.f14612m.getString(C2198R.C2201string.msg_can_not_add_page));
            return false;
        }
        //这里也是,贴纸目前高度+加纸高度,不能超过最大高度
        float f = c + ((float) i);
        if (f >= EditorConfig.f9737j) {
            ToastUtil.m13584b(this.f14612m, this.f14612m.getString(C2198R.C2201string.msg_can_not_add_page));
            return false;
        }
        //这里进行加纸了吗?
        mo25099c((int) f);
        return true;
    } 

来分析这个方法

/* renamed from: c */
//感觉是把i负值到了ChangeAction里面,传给了m18336a方法
    public boolean mo25099c(int i) {
    		//分析m18336a()
        m18336a((ChangeAction) new AttributeChangeAction(this.f14621v, PageData.C3774a.f14569b, this.f14621v.mo25196a(PageData.C3774a.f14569b, Integer.valueOf(i)), Integer.valueOf(i)));
        return true;
    }
    
/* renamed from: a */
    private void m18336a(ChangeAction bVar) {
        mo25063B();//继续跟进,头都要大了
        
        //f14615p = new HistoryManager();
        this.f14615p.mo25568b(bVar);//这里分析不走了,代码没反编译出来,报错了
        Lg.m13647a("EditorController", "addHistory:" + bVar);
        mo25093b(this.f14598K);//这里没啥看的,mo25093b(Runnable runnable),移除了runnable
        mo25085a(this.f14598K, 100);
    }

/* renamed from: B */
    public void mo25063B() {
        if (this.f14600M) {//一个布尔值,在某个方法里赋值为true,this.f14600M = true;
            this.f14588A = true;
            this.f14599L = false;
            this.f14589B = true;
            if (this.f14594G == null) {
                return;
            }
            if (this.f14594G.isSaved() || this.f14594G.isResourceUploaded()) {
                this.f14594G.setSaved(false);
                this.f14594G.setResourceUploaded(false);
                Api.m11108d().mo18608f(this.f14594G);
            }
        }
    }   

遇到报错了

jadx UnsupportedOperationException

Code decompiled incorrectly, please refer to instructions dump 

还是不死心啊,从XML文件来分析,

xml中的主要控件,感觉应该是editorPageScrollView,是一个XScrollView,什么时候初始化的呢?

public void onContentChanged() {
        super.onContentChanged();
        m17892G();
        mo17534c();
        this.f14274M = (EditorToolbar) findViewById(C2198R.C2200id.editor_toolbar);
        this.f14274M.setEditor(this.f14301o);
        this.f14305s = findViewById(C2198R.C2200id.editorPageScrollView);//这里
        if (this.f14305s instanceof XScrollView) {
            ((XScrollView) this.f14305s).setOnScrollChangedListener(new XScrollView.C3929a() {
                /* renamed from: a */
                public void mo25000a(int i, int i2, int i3, int i4) {
                		//这个方法,得到了f14305s.getScrollY()
                    EditorActivity.this.mo24972A();
                    if (EditorActivity.this.f14301o == null) {
                    }
                }
            });
        }
        
        if (this.f14274M != null) {
            this.f14274M.post(new Runnable() {
                public void run() {
                    int measuredHeight = EditorActivity.this.f14274M.getMeasuredHeight();
                    ((ViewGroup.MarginLayoutParams) EditorActivity.this.f14305s.getLayoutParams()).topMargin = measuredHeight;
                    ((ViewGroup.MarginLayoutParams) EditorActivity.this.findViewById(C2198R.C2200id.titleBottomLine).getLayoutParams()).topMargin = measuredHeight;
                    EditorActivity.this.f14262A.mo19332d(EditorActivity.this.f14274M.getPaddingTop());
                }
            });
        }          

发现了这句话

 //这里的 f14305s就是XScrollView
     //f14274M   public EditorToolbar f14274M;
      int measuredHeight = EditorActivity.this.f14274M.getMeasuredHeight();
                ((ViewGroup.MarginLayoutParams) EditorActivity.this.f14305s.getLayoutParams()).topMargin = measuredHeight;