Some tools that I used in Android Developing or life
read a json, and parse it to java classes : **Request, **Parser, **Response
- paster the json strings to the "test2.json" file
- run the command
groovy json_2_req_resp.groovy
Ok, now we have the java classes
this json2Request tool has a strong connnection with the network framework in your app.
different projects may have to adjust some code to generate the right Request/Response java class.
#1.3 Result
the script will auto generate three java classes: **Request, **Parser, **Response.
(If your project are not same as mine, you can custom the script for your own project.)
- the id of view should be "view_page_function". And the name of class member would be like "viewFunction".
For example:
<TextView android:id="@+id/tv_pay_bank_name" ... />
would be named :
private TextView tvBankName;
- if the id of view ends with
"_x"
, it means it will not be listed as a member in Class - if the id of view ends with
"_c"
, it means it will be listed as a member in Class, and it will be add the OnClickListener "android:id"
should be the first attribute of a View in the layout xml file
- paste your layout xml content to "layout.xml"
- run the "auto_findview.bat", or "auto_findview.bat"
private Button btnSendSms;
private TextView tvBankError;
private EditText etInputPwd;
etInputPwd = (EditText) findViewById(R.id.et_pay_input_pwd);
tvBankError = (TextView) findViewById(R.id.tv_pay_bank_error);
btnSendSms = (Button) findViewById(R.id.btn_pay_send_sms_c);
btnSendSms.setOnClickListener(this);
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_pay_send_sms_c:
break;
default:
break;
}
}
All you have to do is copy these lines to you own Activity file
This tool is similar with the "AutoFindViewById" tool. You input the layout xml, and it will generate the class file of Adapter for you.
This tool is also useful for xml -> Adapter
. However, it will generate different Adapter class for you. But this tool is deprecated.
Now, you only have to use the OneAdapter tool I wrote for RecyclerView. It's more convinent than this tool.
the short version of the first one(json2ReqRespParser)
It's a tool that count the lines of code. It's not for SVN, and it's only for my own project.
If you are using kotlin, that's fine. You can invoke Find Action and find "convert Java File to Kotlin" action, then use it. After the conversion, we should have an class written in Kotlin.
This will help you generate new Activities.
just put it into the directory:
%your Android Studio dir%\plugins\android\lib\templates\activities\
generate MVP class for you.
you may have loads of unused resouces after so many iterations. This tool will remove all the unused resouces for you. All you have to do is just set arguments and double click a executable file!
This time I fixed a couple of bug. And this script could generate a couple of response kotlin files for you, rather than java files.