Skip to content

Commit

Permalink
Reformated the code and optimized imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Mihalachi committed Sep 28, 2013
1 parent fca3410 commit 474ce28
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class HomeActivity extends Activity {
*/
protected DrawerLayout mDrawerLayout;


/**
* {@inheritDoc}
*/
Expand All @@ -78,7 +79,7 @@ protected void onCreate(Bundle savedInstanceState) {
// Replace fragment
getFragmentManager()
.beginTransaction()
.replace(R.id.fragment_editor, new NoFileOpenedFragment())
.replace(R.id.fragment_editor, new NoFileOpenedFragment())
.commit();
/* First Time we open this activity */
if (savedInstanceState == null) {
Expand All @@ -102,6 +103,7 @@ protected final void onPostCreate(Bundle savedInstanceState) {
mDrawerToggle.syncState();
}


/**
* {@inheritDoc}
*/
Expand All @@ -112,6 +114,7 @@ public void onResume() {
EventBus.getDefault().register(this);
}


/**
* {@inheritDoc}
*/
Expand All @@ -122,6 +125,7 @@ public void onPause() {
EventBus.getDefault().unregister(this);
}


/**
* {@inheritDoc}
*/
Expand All @@ -135,6 +139,7 @@ protected void onDestroy() {
super.onDestroy();
}


/**
* {@inheritDoc}
*/
Expand All @@ -144,6 +149,7 @@ public final void onConfigurationChanged(Configuration newConfig) {
mDrawerToggle.onConfigurationChanged(newConfig);
}


/**
* {@inheritDoc}
*/
Expand All @@ -153,6 +159,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
return super.onCreateOptionsMenu(menu);
}


/**
* {@inheritDoc}
*/
Expand All @@ -161,7 +168,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
/* If we clicked on the Navigation Drawer Menu item */
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
} else switch (item.getItemId()){
} else switch (item.getItemId()) {
case R.id.im_open:
startActivityForResult(new Intent(HomeActivity.this, SelectFileActivity.class)
.putExtra("path", "")
Expand All @@ -176,46 +183,50 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
}


/**
* {@inheritDoc}
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK && requestCode == SELECT_FILE_CODE) {
String path = data.getStringExtra("path");
if(!TextUtils.isEmpty(path)){
EventBus.getDefault().postSticky(new NewFileOpened(path));
String path = data.getStringExtra("path");
if (!TextUtils.isEmpty(path)) {
EventBus.getDefault().postSticky(new NewFileOpened(path));
}
}
}

/**
* {@inheritDoc}
*/
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
parseIntent(intent);
}

/**
*
* @param event
*/
public void onEvent(FileSelectedEvent event){
public void onEvent(FileSelectedEvent event) {
// Close the drawer
mDrawerLayout.closeDrawer(Gravity.LEFT);
// Replace fragment
getFragmentManager()
.beginTransaction()
.replace(R.id.fragment_editor, EditorFragment.newInstance(event.getPath()))
.replace(R.id.fragment_editor, EditorFragment.newInstance(event.getPath()))
.commit();
}

/**
* When a file is saved
* Invoked by the EditorFragment
*
* @param event The event called
*/
public void onEvent(FileSavedEvent event){
public void onEvent(FileSavedEvent event) {
try {
closeKeyBoard();
} catch (NullPointerException e) {
Expand Down Expand Up @@ -244,25 +255,26 @@ public void onEvent(FileSavedEvent event){
// Replace fragment
getFragmentManager()
.beginTransaction()
.replace(R.id.fragment_editor, new NoFileOpenedFragment())
.replace(R.id.fragment_editor, new NoFileOpenedFragment())
.commit();
}
}

/**
* When a file can't be opened
* Invoked by the EditorFragment
*
* @param event The event called
*/
public void onEvent(ErrorOpeningFileEvent event){
public void onEvent(ErrorOpeningFileEvent event) {
//
mDrawerLayout.openDrawer(Gravity.LEFT);
//
getActionBar().setTitle(getString(R.string.nome_app_turbo_editor));
// Replace fragment
getFragmentManager()
.beginTransaction()
.replace(R.id.fragment_editor, new NoFileOpenedFragment())
.replace(R.id.fragment_editor, new NoFileOpenedFragment())
.commit();
}

Expand All @@ -284,7 +296,7 @@ private void closeKeyBoard() throws NullPointerException {
/**
* Setup the navigation drawer
*/
private void setupNavigationDrawer(){
private void setupNavigationDrawer() {
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
/* Action Bar */
final ActionBar ab = getActionBar();
Expand All @@ -299,11 +311,17 @@ private void setupNavigationDrawer(){
R.string.nome_app_turbo_editor,
R.string.nome_app_turbo_editor) {

/**
* {@inheritDoc}
*/
@Override
public void onDrawerClosed(View view) {
invalidateOptionsMenu();
}

/**
* {@inheritDoc}
*/
@Override
public void onDrawerOpened(View drawerView) {
invalidateOptionsMenu();
Expand All @@ -316,7 +334,7 @@ public void onDrawerOpened(View drawerView) {
/**
* Show a dialog with the changelog
*/
private void showChangeLog(){
private void showChangeLog() {
final String currentVersion = AppInfoHelper.getCurrentVersion(this);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final String lastVersion = preferences.getString("last_version", currentVersion);
Expand All @@ -329,7 +347,7 @@ private void showChangeLog(){
/**
* Parses the intent
*/
private void parseIntent(Intent intent){
private void parseIntent(Intent intent) {
final String action = intent.getAction();
final String type = intent.getType();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import com.vmihalachi.turboeditor.R;

public class LicensesActivity extends Activity implements AdapterView.OnItemClickListener{
public class LicensesActivity extends Activity implements AdapterView.OnItemClickListener {


/**
* {@inheritDoc}
Expand All @@ -27,21 +28,22 @@ protected void onCreate(Bundle savedInstanceState) {
listView.setAdapter(adapter);
}


/**
* {@inheritDoc}
*/
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String openSourceLib = ((TextView) view.findViewById(android.R.id.text1)).getText().toString();
Intent browserIntent = null;
if(openSourceLib.equals("ChangeLog Library")){
if (openSourceLib.equals("ChangeLog Library")) {
browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/gabrielemariotti/changeloglib?source=c#license"));
} else if(openSourceLib.equals("EventBus")){
} else if (openSourceLib.equals("EventBus")) {
browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/greenrobot/EventBus?source=c#license"));
} else if(openSourceLib.equals("commons-io")){
} else if (openSourceLib.equals("commons-io")) {
browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://commons.apache.org/proper/commons-io/"));
}
if(browserIntent != null){
if (browserIntent != null) {
startActivity(browserIntent);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import com.vmihalachi.turboeditor.helper.AppInfoHelper;

public class PreferenceAbout extends PreferenceActivity {
/**
* {@inheritDoc}
*/
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -44,6 +47,9 @@ public void setupClickablePreferences() {
market = findPreference("aboutactivity_authormarket");
if (email != null) {
email.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
/**
* {@inheritDoc}
*/
@Override
public boolean onPreferenceClick(final Preference preference) {
Intent i = new Intent(Intent.ACTION_SEND);
Expand All @@ -61,6 +67,9 @@ public boolean onPreferenceClick(final Preference preference) {
}
if (changelog != null) {
changelog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
/**
* {@inheritDoc}
*/
@Override
public boolean onPreferenceClick(final Preference preference) {
ChangelogDialogFragment.showChangeLogDialog(getFragmentManager());
Expand All @@ -70,6 +79,9 @@ public boolean onPreferenceClick(final Preference preference) {
}
if (open_source_licenses != null) {
open_source_licenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
/**
* {@inheritDoc}
*/
@Override
public boolean onPreferenceClick(final Preference preference) {
startActivity(new Intent(PreferenceAbout.this, LicensesActivity.class));
Expand All @@ -79,6 +91,9 @@ public boolean onPreferenceClick(final Preference preference) {
}
if (market != null) {
market.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
/**
* {@inheritDoc}
*/
@Override
public boolean onPreferenceClick(final Preference preference) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class SelectFileActivity extends Activity implements AdapterView.OnItemCl
.getAbsolutePath();


/**
* {@inheritDoc}
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -85,6 +88,9 @@ void returnData(String path) {
finish();
}

/**
* {@inheritDoc}
*/
@Override
public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
Expand All @@ -106,6 +112,9 @@ public void onItemClick(AdapterView<?> parent,
}
}

/**
* {@inheritDoc}
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_select_file, menu);
Expand All @@ -114,6 +123,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
return super.onCreateOptionsMenu(menu);
}

/**
* {@inheritDoc}
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int i = item.getItemId();
Expand Down Expand Up @@ -145,6 +157,9 @@ void vaiIndietro() {
private class UpdateList extends
AsyncTask<String, Void, LinkedList<AdapterDetailedList.FileDetail>> {

/**
* {@inheritDoc}
*/
@Override
protected LinkedList<AdapterDetailedList.FileDetail> doInBackground(final String... params) {
try {
Expand Down Expand Up @@ -196,6 +211,9 @@ protected LinkedList<AdapterDetailedList.FileDetail> doInBackground(final String
}
}

/**
* {@inheritDoc}
*/
@Override
protected void onPostExecute(final LinkedList<AdapterDetailedList.FileDetail> names) {
boolean isRoot = currentFolder.equals("/");
Expand All @@ -207,6 +225,9 @@ protected void onPostExecute(final LinkedList<AdapterDetailedList.FileDetail> na

public final Comparator<File> getFileNameComparator() {
return new AlphanumComparator() {
/**
* {@inheritDoc}
*/
@Override
public String getTheString(Object obj) {
return ((File) obj).getName()
Expand Down

0 comments on commit 474ce28

Please sign in to comment.