My Angular应用程序是用TypeScript编写的。我添加了一个clang-config
文件来建立代码的一致性。在探索选项后,我有以下块:
Language: JavaScript
BasedOnStyle: WebKit
AllowShortFunctionsOnASingleLine: false
BreakBeforeBraces: Attach
ColumnLimit: 250
IndentWidth: 2
JavaScriptQuotes: Single
MaxEmptyLinesToKeep: 1
我喜欢在备用线上编码。因此,需要在两个有效的JS语句之间存在一个新行。 MaxEmptyLinesToKeep
在关闭作用域的大括号之前删除换行符(但保留开头的大括号)。我该如何设置?
装饰器选项现在只有一行:@Component({ selector : 'in... })
如何将每行连接到一个键?
将BasedOnStyle
设置更改为Mozilla
时,内部范围,即:Observable.subscribe(()=>{ // This region. })
,缩进为2个空格而不是4个。这个设置是否适用于此?
下一行关闭空函数。如何在同一行上关闭它,例如:function foo() { }
而不是。function foo() {
}
public class PhotoCommnFragment extends android.support.v4.app.Fragment {
EditText rechargeMobileNumber, rechargeAmount;
Spinner selectMenu;
int flags[] = {R.drawable.airteltv, R.drawable.aircel, R.drawable.dishtv, R.drawable.sundirect, R.drawable.tatasky, R.drawable.videocon};
List<SpinnerMenu> selectedNetwork = new ArrayList<>();
Fragment_DTH_Main_Spinner_Adapter customAdapter;
public PhotoCommnFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_tab_mobile, container, false);
mobileRecahrgeHistory();
rechargeMobileNumber = (EditText) rootView.findViewById(R.id.recharge_mobile_number);
rechargeAmount = (EditText) rootView.findViewById(R.id.recharge_amount);
selectMenu = (Spinner) rootView.findViewById(R.id.selectNetwork);
settingSpinnerDropDown();
customAdapter = new Fragment_DTH_Main_Spinner_Adapter(getActivity(), R.layout.fragment_dth_main_spinner_items, R.id.serviceName, selectedNetwork);
return rootView;
}
public void mobileRecahrgeHistory() {
Ion.with(this)
.load("http://192.168.1.105/TotalRecharge/?api=ol&uid=1")
.asJsonObject().withResponse()
.setCallback(new FutureCallback<Response<JsonObject>>() {
@Override
public void onCompleted(Exception e, Response<JsonObject> result) {
JSONObject json = null;
try {
json = new JSONObject(result.getResult().toString());
} catch (JSONException e1) {
e1.printStackTrace();
}
// Create the root JSONObject from the JSON string.
JSONObject jsonRootObject = null;
jsonRootObject = json.optJSONObject("DS");
//Get the instance of JSONArray that contains JSONObjects
JSONArray jsonArray = jsonRootObject.optJSONArray("LST");
//Iterate the jsonArray and print the info of JSONObjects
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = null;
try {
jsonObject = jsonArray.getJSONObject(i);
} catch (JSONException e1) {
e1.printStackTrace();
}
String iph = null;
String oid = jsonObject.optString("OID").toString();
String ocd = jsonObject.optString("OCD").toString();
String opd = jsonObject.optString("OPE").toString();
String mil = jsonObject.optString("MIL").toString();
String mxl = jsonObject.optString("MXL").toString();
try {
iph = jsonObject.getString("IPH").toString();
} catch (JSONException e1) {
e1.printStackTrace();
}
String urldisplay = "http://192.168.1.105/TotalRecharge/" + iph;
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e3) {
e3.printStackTrace();
}
SpinnerMenu spinnerData = new SpinnerMenu();
spinnerData.setOid(oid);
spinnerData.setOcd(ocd);
spinnerData.setOpd(opd);
spinnerData.setMil(mil);
spinnerData.setMix(mxl);
spinnerData.setImage(mIcon11);
selectedNetwork.add(spinnerData);
customAdapter.notifyDataSetChanged();
}
}
});
}
public void settingSpinnerDropDown() {
selectMenu.setAdapter(customAdapter);
}
谢谢!