parent
a3154e6e54
commit
f2b6a240c3
|
@ -0,0 +1,66 @@
|
|||
Writing clean and understandable code is GitNex core value from the start. Here are the few standards when writing code for GitNex.
|
||||
|
||||
```
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
*/
|
||||
```
|
||||
|
||||
The 1st line in above code is the package class. After that is new blank line and then the import starts. Import packages should not have any blank lines in between.
|
||||
After import lines there is one more blank line and after that is the author of the template/code.
|
||||
|
||||
If you have copied the template code from another file, then the author section should be:
|
||||
|
||||
```
|
||||
package org.mian.gitnex.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
/**
|
||||
* Template Author M M Arif
|
||||
* Author 6543
|
||||
*/
|
||||
```
|
||||
|
||||
Next is the main class,
|
||||
```
|
||||
public class ExploreRepositoriesFragment extends Fragment {
|
||||
|
||||
private static String repoNameF = "param2";
|
||||
private static String repoOwnerF = "param1";
|
||||
private ProgressBar mProgressBar;
|
||||
private RecyclerView mRecyclerView;
|
||||
private TextView noData;
|
||||
private TextView searchKeyword;
|
||||
private Boolean repoTypeInclude = true;
|
||||
private String sort = "updated";
|
||||
private String order = "desc";
|
||||
private int limit = 50;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Note the blank line before declaring any variables and functions.
|
||||
|
||||
Usage of if statements:
|
||||
```
|
||||
if (response.isSuccessful()) {
|
||||
assert response.body() != null;
|
||||
getReposList(response.body().getSearchedData(), context);
|
||||
}
|
||||
else {
|
||||
Log.i("onResponse", String.valueOf(response.code()));
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue