Skip to content
This repository has been archived by the owner on Jan 6, 2019. It is now read-only.

Commit

Permalink
code refactor and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarvperes committed Feb 6, 2016
1 parent fca923d commit 8c0272c
Showing 1 changed file with 27 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,18 @@ public class SearchActivity extends Activity
private Comparator<LaunchableActivity> mPinToTopComparator;
private Comparator<LaunchableActivity> mRecentOrderComparator;
private Comparator<LaunchableActivity> mAlphabeticalOrderComparator;

private InputMethodManager mInputMethodManager;
private AdapterView mAppListView;
private PackageManager mPm;
private View mOverflowButtonTopleft;
private int mColumnCount;
//used only in function getAllSubwords. they are here as class fields to avoid
// object re-allocation.
private StringBuilder mWordSinceLastSpaceBuilder;
private StringBuilder mWordSinceLastCapitalBuilder;
private int mGridViewTopRowHeight;
private int mGridViewBottomRowHeight;
private boolean mShouldOrderByRecents;
private final TextWatcher mTextWatcher = new TextWatcher() {

@Override
Expand All @@ -138,24 +149,9 @@ public void afterTextChanged(Editable s) {


};
private InputMethodManager mInputMethodManager;
private AdapterView mAppListView;
private PackageManager mPm;
private View mOverflowButtonTopleft;
private int mColumnCount;

//used only in function getAllSubwords. they are here as class fields to avoid
// object re-allocation.
private StringBuilder mWordSinceLastSpaceBuilder;
private StringBuilder mWordSinceLastCapitalBuilder;


private int mGridViewTopRowHeight;
private int mGridViewBottomRowHeight;
private boolean shouldOrderByRecents;
private boolean disableIcons;
private boolean autoKeyboard;
private boolean mCacheClear;
private boolean mDisableIcons;
private boolean mAutoKeyboard;
private boolean mIsCacheClear;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -249,10 +245,10 @@ private void loadShareableApps() {
@Override
protected void onResume() {
super.onResume();
mCacheClear = false;
mIsCacheClear = false;
mSearchEditText.setText("");
mSearchEditText.clearFocus();
if (autoKeyboard) {
if (mAutoKeyboard) {
mSearchEditText.requestFocus();
}
}
Expand Down Expand Up @@ -284,7 +280,7 @@ public int setPaddingHeights() {
protected void onPostResume() {
super.onPostResume();

if (autoKeyboard) {
if (mAutoKeyboard) {
showKeyboard();

//HACK putting showKeyboard event to the end of the Ui Thread running queue
Expand Down Expand Up @@ -379,11 +375,11 @@ private void setupPreferences() {
final int priority = ShortcutNotificationManager.getPriorityFromString(strPriority);
shortcutNotificationManager.showNotification(this, priority);
}
shouldOrderByRecents =
mShouldOrderByRecents =
mSharedPreferences.getString("pref_app_preferred_order", "recent").equals("recent");
disableIcons =
mDisableIcons =
mSharedPreferences.getBoolean("pref_disable_icons", false);
autoKeyboard =
mAutoKeyboard =
mSharedPreferences.getBoolean("pref_autokeyboard", false);
}

Expand Down Expand Up @@ -495,7 +491,7 @@ private void updateVisibleApps() {

private void sortApps() {
Collections.sort(mActivityInfos, mAlphabeticalOrderComparator);
if (shouldOrderByRecents) {
if (mShouldOrderByRecents) {
Collections.sort(mActivityInfos, mRecentOrderComparator);
}
Collections.sort(mActivityInfos, mPinToTopComparator);
Expand Down Expand Up @@ -652,14 +648,14 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
if (key.equals("package_changed_name") && !sharedPreferences.getString(key, "").isEmpty()) {
handlePackageChanged();
} else if (key.equals("pref_app_preferred_order")) {
shouldOrderByRecents =
mShouldOrderByRecents =
mSharedPreferences.getString("pref_app_preferred_order", "recent").equals("recent");
sortApps();
mArrayAdapter.notifyDataSetChanged();
} else if (key.equals("pref_disable_icons")) {
recreate();
} else if (key.equals("pref_autokeyboard")) {
autoKeyboard = mSharedPreferences.getBoolean("pref_autokeyboard", false);
mAutoKeyboard = mSharedPreferences.getBoolean("pref_autokeyboard", false);
}


Expand All @@ -676,13 +672,13 @@ public boolean onKeyUp(int keyCode, KeyEvent event) {
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
if (!mCacheClear && level == TRIM_MEMORY_COMPLETE)
if (!mIsCacheClear && level == TRIM_MEMORY_COMPLETE)
clearCaches();

}

private void clearCaches() {
mCacheClear = true;
mIsCacheClear = true;
for (LaunchableActivity launchableActivity : mActivityInfos) {
launchableActivity.deleteActivityIcon();
}
Expand Down Expand Up @@ -860,7 +856,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
appIconView.setTag(launchableActivity);
if (!launchableActivity.isIconLoaded()) {
appIconView.setImageDrawable(mDefaultAppIcon);
if (!disableIcons)
if (!mDisableIcons)
mImageLoadingConsumersManager.addTask(
new ImageLoadingTask(appIconView, launchableActivity,
mImageTasksSharedData));
Expand Down

0 comments on commit 8c0272c

Please sign in to comment.