Android Question How do I make use of the decompiled Dex

Discussion in 'Android Questions' started by Scantech, Jul 8, 2015.

  1. Scantech

    Scantech Active Member Licensed User

    Hello everyone,

    I have lost most of my B4A Class libraries. So, I ended up using a program to decompile my Dex file. I am trying to make use of these Java Class. I am still uncertain how to use Java Object.

    See below sample of Java Class which was decompiled. Can it be reused with B4A? Thanks in advance

    Code:
    package scantech.dragmove;

    import android.view.View;
    import anywheresoftware.b4a.B4AClass.ImplB4AClass;
    import anywheresoftware.b4a.BA;
    import anywheresoftware.b4a.BA.SubDelegator;
    import anywheresoftware.b4a.agraham.reflection.Reflection;
    import anywheresoftware.b4a.keywords.Common;
    import anywheresoftware.b4a.keywords.constants.Colors;
    import anywheresoftware.b4a.objects.ActivityWrapper;
    import anywheresoftware.b4a.objects.ConcreteViewWrapper;
    import anywheresoftware.b4a.objects.PanelWrapper;
    import java.lang.reflect.Method;
    import java.util.HashMap;

    public class dragmove extends B4AClass.ImplB4AClass
      implements BA.SubDelegator
    {
      
    private static HashMap<String, Method> htSubs;
      
    public Common __c = null;
      
    public int _action_down = 0;
      
    public int _action_move = 0;
      
    public int _action_up = 0;
      
    public PanelWrapper _bgpanel = null;
      
    public boolean _blnallowmove = false;
      
    public boolean _blnsnaptogrid = false;
      
    public Object _callback = null;
      
    public int _downx = 0;
      
    public int _downy = 0;
      
    public String _eventname = "";
      
    public ConcreteViewWrapper _innerview = null;
      
    public ConcreteViewWrapper _innerview2 = null;
      
    public ConcreteViewWrapper _innerview3 = null;
      
    public PanelWrapper _panel1 = null;

      
    private void innerInitialize(BA paramBA)
        throws 
    Exception
      {
        
    if (this.ba == null)
        {
          this.ba = new BA(paramBA, this, htSubs, 
    "scantech.dragmove.dragmove");
          
    if (htSubs == null)
          {
            this.ba.loadHtSubs(getClass());
            htSubs = this.ba.htSubs;
          
    }
        }
        _class_globals();
      }

      public String _class_globals()
        throws Exception
      {
        this._innerview = new ConcreteViewWrapper();
        this._innerview2 = new ConcreteViewWrapper();
        this._innerview3 = new ConcreteViewWrapper();
        this._panel1 = new PanelWrapper();
        this._bgpanel = new PanelWrapper();
        this._downx = 0;
        this._downy = 0;
        this._action_down = 0;
        this._action_move = 0;
        this._action_up = 0;
        this._blnallowmove = false;
        this._blnsnaptogrid = false;
        this._eventname = "";
        this._callback = new Object();
        return "";
      }

      public String _destroyobjects()
        throws Exception
      {
        this._bgpanel.RemoveAllViews();
        this._bgpanel.RemoveView();
        this._panel1.RemoveAllViews();
        this._panel1.RemoveView();
        return "";
      }

      public String _initialize(BA paramBA, ActivityWrapper paramActivityWrapper, ConcreteViewWrapper paramConcreteViewWrapper1, ConcreteViewWrapper paramConcreteViewWrapper2, ConcreteViewWrapper paramConcreteViewWrapper3, Object paramObject, String paramString)
        throws Exception
      {
        innerInitialize(paramBA);
        this._innerview = paramConcreteViewWrapper1;
        this._innerview2 = paramConcreteViewWrapper2;
        this._innerview3 = paramConcreteViewWrapper3;
        this._panel1.Initialize(this.ba, "");
        this._bgpanel.Initialize(this.ba, "PanelBG");
        paramBA = this._panel1;
        paramConcreteViewWrapper1 = this.__c;
        paramConcreteViewWrapper1 = Common.Colors;
        paramBA.setColor(Colors.ARGB(125, 0, 0, 50));
        paramBA = this._bgpanel;
        paramConcreteViewWrapper1 = this.__c;
        paramConcreteViewWrapper1 = Common.Colors;
        paramBA.setColor(0);
        paramBA = (View)this._bgpanel.getObject();
        paramConcreteViewWrapper1 = this.__c;
        int i = Common.PerXToCurrent(100.0F, this.ba);
        paramConcreteViewWrapper1 = this.__c;
        paramActivityWrapper.AddView(paramBA, 0, 0, i, Common.PerYToCurrent(100.0F, this.ba));
        this._bgpanel.AddView((View)this._panel1.getObject(), paramConcreteViewWrapper2.getLeft(), paramConcreteViewWrapper2.getTop(), paramConcreteViewWrapper2.getWidth(), paramConcreteViewWrapper2.getHeight());
        this._action_down = 0;
        this._action_move = 2;
        this._action_up = 1;
        this._eventname = paramString;
        this._callback = paramObject;
        paramBA = new Reflection();
        paramBA.Target = this._panel1.getObject();
        paramBA.SetOnTouchListener(this.ba, "Panel1_Touch");
        return "";
      }

      public boolean _panel1_touch(Object paramObject1, int paramInt, float paramFloat1, float paramFloat2, Object paramObject2)
        throws Exception
      {
        _panel_move(paramInt, paramFloat1, paramFloat2);
        int i;
        if (paramInt == this._action_down)
        {
          paramObject1 = this.__c;
          Common.Log("DOWN");
          bool = this._blnsnaptogrid;
          paramObject1 = this.__c;
          if (bool == true)
          {
            paramInt = (int)paramFloat1;
            i = (int)paramFloat2;
            paramObject1 = this.__c;
            this._downx = (int)(Common.Floor(paramInt / 10.0D + 0.5D) * 10.0D);
            paramObject1 = this.__c;
            this._downy = (int)(Common.Floor(i / 10.0D + 0.5D) * 10.0D);
            paramObject1 = this._innerview;
            paramObject2 = this.__c;
            paramObject1.setLeft((int)(Common.Floor(this._innerview.getLeft() / 10.0D + 0.5D) * 10.0D));
            this._innerview2.setLeft(this._innerview.getLeft());
            this._innerview3.setLeft(this._innerview.getLeft());
            paramObject1 = this._innerview;
            paramObject2 = this.__c;
            paramObject1.setTop((int)(Common.Floor(this._innerview.getTop() / 10.0D + 0.5D) * 10.0D));
            this._innerview2.setTop(this._innerview.getTop());
            this._innerview3.setTop(this._innerview.getTop());
          }
        }
        do
        {
          while (true)
          {
            paramObject1 = this.__c;
            return true;
            this._downx = (int)paramFloat1;
            this._downy = (int)paramFloat2;
            continue;
            if (paramInt != this._action_up)
              break;
            paramObject1 = this.__c;
            Common.Log("UP");
            paramObject1 = this.__c;
            this._blnallowmove = false;
            _destroyobjects();
          }
          paramObject1 = this.__c;
          Common.Log("MOVE");
          bool = this._blnallowmove;
          paramObject1 = this.__c;
        }
        while (bool != true);
        boolean bool = this._blnsnaptogrid;
        paramObject1 = this.__c;
        if (bool == true)
        {
          i = (int)paramFloat1;
          paramInt = (int)paramFloat2;
          paramObject1 = this.__c;
          i = (int)(Common.Floor(i / 10.0D + 0.5D) * 10.0D);
          paramObject1 = this.__c;
          paramInt = (int)(Common.Floor(paramInt / 10.0D + 0.5D) * 10.0D);
          this._innerview.setLeft(i + this._innerview.getLeft() - this._downx);
          this._innerview.setTop(paramInt + this._innerview.getTop() - this._downy);
        }
        while (true)
        {
          this._innerview2.setLeft(this._innerview.getLeft());
          this._innerview2.setTop(this._innerview.getTop());
          this._innerview3.setLeft(this._innerview.getLeft());
          this._innerview3.setTop(this._innerview.getTop());
          this._panel1.setLeft(this._innerview.getLeft());
          this._panel1.setTop(this._innerview.getTop());
          break;
          this._innerview.setLeft((int)(this._innerview.getLeft() + paramFloat1 - this._downx));
          this._innerview.setTop((int)(this._innerview.getTop() + paramFloat2 - this._downy));
        }
      }

      public String _panel_longclick()
        throws Exception
      {
        Common localCommon = this.__c;
        if (Common.SubExists(this.ba, this._callback, this._eventname + "_LongClick"))
        {
          localCommon = this.__c;
          Common.CallSubNew(this.ba, this._callback, this._eventname + "_LongClick");
        }
        return "";
      }

      public String _panel_move(int paramInt, float paramFloat1, float paramFloat2)
        throws Exception
      {
        Common localCommon = this.__c;
        if (Common.SubExists(this.ba, this._callback, this._eventname + "_Move"))
        {
          localCommon = this.__c;
          Common.CallSubNew(this.ba, this._callback, this._eventname + "_Move");
        }
        return "";
      }

      public String _panelbg_touch(int paramInt, float paramFloat1, float paramFloat2)
        throws Exception
      {
        if (paramInt == this._action_down)
        {
          Common localCommon = this.__c;
          this._blnallowmove = false;
          _destroyobjects();
        }
        return "";
      }

      public String _tmrtime_tick()
        throws Exception
      {
        boolean bool = this._blnallowmove;
        Common localCommon = this.__c;
        if (bool == true)
          return "";
        _panel_longclick();
        return "";
      }

      public Object callSub(String paramString, Object paramObject, Object[] paramArrayOfObject)
        throws Exception
      {
        this.ba.sharedProcessBA.sender = paramObject;
        return BA.SubDelegator.SubNotFound;
      }
    }
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    There is no automatic way to convert it to B4A code.
     
  3. Scantech

    Scantech Active Member Licensed User

    Is it possible using #If Java in b4a? I'm getting some errors.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Unless you are experienced with Java, it will be difficult to use this Java code.
     
Loading...