Browse Source

Getting rid of unnecessary casts in findViewById!!!

master
anthony restaino 8 years ago
parent
commit
395c967381
  1. 6
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 2
      app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java
  3. 4
      app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java
  4. 6
      app/src/main/java/acr/browser/lightning/dialog/BrowserDialog.java
  5. 6
      app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java
  6. 2
      app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java
  7. 4
      app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java
  8. 2
      app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java
  9. 6
      app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java
  10. 14
      app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java
  11. 6
      app/src/main/java/acr/browser/lightning/search/SuggestionsAdapter.java
  12. 2
      app/src/main/java/acr/browser/lightning/utils/IntentUtils.java
  13. 6
      app/src/main/java/acr/browser/lightning/view/LightningWebClient.java

6
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -327,8 +327,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -327,8 +327,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
lp.height = LayoutParams.MATCH_PARENT;
customView.setLayoutParams(lp);
mArrowImage = (ImageView) customView.findViewById(R.id.arrow);
FrameLayout arrowButton = (FrameLayout) customView.findViewById(R.id.arrow_button);
mArrowImage = customView.findViewById(R.id.arrow);
FrameLayout arrowButton = customView.findViewById(R.id.arrow_button);
if (mShowTabsInDrawer) {
if (mArrowImage.getWidth() <= 0) {
mArrowImage.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
@ -366,7 +366,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -366,7 +366,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
arrowButton.setOnClickListener(this);
// create the search EditText in the ToolBar
mSearch = (SearchView) customView.findViewById(R.id.search);
mSearch = customView.findViewById(R.id.search);
mSearchBackground = customView.findViewById(R.id.search_container);
// initialize search background color

2
app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java

@ -297,7 +297,7 @@ public class ReadingActivity extends AppCompatActivity { @@ -297,7 +297,7 @@ public class ReadingActivity extends AppCompatActivity {
case R.id.text_size_item:
View view = LayoutInflater.from(this).inflate(R.layout.dialog_seek_bar, null);
final SeekBar bar = (SeekBar) view.findViewById(R.id.text_size_seekbar);
final SeekBar bar = view.findViewById(R.id.text_size_seekbar);
bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override

4
app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java

@ -29,7 +29,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -29,7 +29,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// this is a workaround for the Toolbar in PreferenceActitivty
ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
ViewGroup root = findViewById(android.R.id.content);
LinearLayout content = (LinearLayout) root.getChildAt(0);
LinearLayout toolbarContainer = (LinearLayout) View.inflate(this, R.layout.toolbar_settings, null);
@ -38,7 +38,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -38,7 +38,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
root.addView(toolbarContainer);
// now we can set the Toolbar using AppCompatPreferenceActivity
Toolbar toolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar);
Toolbar toolbar = toolbarContainer.findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

6
app/src/main/java/acr/browser/lightning/dialog/BrowserDialog.java

@ -82,8 +82,8 @@ public class BrowserDialog { @@ -82,8 +82,8 @@ public class BrowserDialog {
View layout = LayoutInflater.from(activity).inflate(R.layout.list_dialog, null);
TextView titleView = (TextView) layout.findViewById(R.id.dialog_title);
ListView listView = (ListView) layout.findViewById(R.id.dialog_list);
TextView titleView = layout.findViewById(R.id.dialog_title);
ListView listView = layout.findViewById(R.id.dialog_list);
ArrayAdapter<String> adapter = new ArrayAdapter<>(activity,
android.R.layout.simple_list_item_1);
@ -136,7 +136,7 @@ public class BrowserDialog { @@ -136,7 +136,7 @@ public class BrowserDialog {
@StringRes int action,
@NonNull final EditorListener listener) {
View dialogView = LayoutInflater.from(activity).inflate(R.layout.dialog_edit_text, null);
final EditText editText = (EditText) dialogView.findViewById(R.id.dialog_edit_text);
final EditText editText = dialogView.findViewById(R.id.dialog_edit_text);
editText.setHint(hint);
if (currentText != null) {

6
app/src/main/java/acr/browser/lightning/dialog/LightningDialogBuilder.java

@ -191,12 +191,12 @@ public class LightningDialogBuilder { @@ -191,12 +191,12 @@ public class LightningDialogBuilder {
final AlertDialog.Builder editBookmarkDialog = new AlertDialog.Builder(activity);
editBookmarkDialog.setTitle(R.string.title_edit_bookmark);
final View dialogLayout = View.inflate(activity, R.layout.dialog_edit_bookmark, null);
final EditText getTitle = (EditText) dialogLayout.findViewById(R.id.bookmark_title);
final EditText getTitle = dialogLayout.findViewById(R.id.bookmark_title);
getTitle.setText(item.getTitle());
final EditText getUrl = (EditText) dialogLayout.findViewById(R.id.bookmark_url);
final EditText getUrl = dialogLayout.findViewById(R.id.bookmark_url);
getUrl.setText(item.getUrl());
final AutoCompleteTextView getFolder =
(AutoCompleteTextView) dialogLayout.findViewById(R.id.bookmark_folder);
dialogLayout.findViewById(R.id.bookmark_folder);
getFolder.setHint(R.string.folder);
getFolder.setText(item.getFolder());

2
app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java

@ -495,7 +495,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref @@ -495,7 +495,7 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
public void onComplete() {
Activity activity = getActivity();
if (activity != null) {
String message = activity.getResources().getString(R.string.message_import);
String message = activity.getString(R.string.message_import);
Utils.showSnackbar(activity, importList.size() + " " + message);
}
}

4
app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java

@ -320,10 +320,10 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, @@ -320,10 +320,10 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
}
private void setupNavigationButton(@NonNull View view, @IdRes int buttonId, @IdRes int imageId) {
FrameLayout frameButton = (FrameLayout) view.findViewById(buttonId);
FrameLayout frameButton = view.findViewById(buttonId);
frameButton.setOnClickListener(this);
frameButton.setOnLongClickListener(this);
ImageView buttonImage = (ImageView) view.findViewById(imageId);
ImageView buttonImage = view.findViewById(imageId);
buttonImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
}

2
app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java

@ -152,7 +152,7 @@ public class DisplaySettingsFragment extends LightningPreferenceFragment impleme @@ -152,7 +152,7 @@ public class DisplaySettingsFragment extends LightningPreferenceFragment impleme
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_seek_bar, null);
final SeekBar bar = (SeekBar) view.findViewById(R.id.text_size_seekbar);
final SeekBar bar = view.findViewById(R.id.text_size_seekbar);
final TextView sample = new TextView(getActivity());
sample.setText(R.string.untitled);
sample.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT));

6
app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java

@ -257,8 +257,8 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme @@ -257,8 +257,8 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
private void manualProxyPicker() {
View v = mActivity.getLayoutInflater().inflate(R.layout.dialog_manual_proxy, null);
final EditText eProxyHost = (EditText) v.findViewById(R.id.proxyHost);
final EditText eProxyPort = (EditText) v.findViewById(R.id.proxyPort);
final EditText eProxyHost = v.findViewById(R.id.proxyHost);
final EditText eProxyPort = v.findViewById(R.id.proxyPort);
// Limit the number of characters since the port needs to be of type int
// Use input filters to limite the EditText length and determine the max
@ -519,7 +519,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme @@ -519,7 +519,7 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
private void downPicker() {
View dialogView = LayoutInflater.from(mActivity).inflate(R.layout.dialog_edit_text, null);
final EditText getDownload = (EditText) dialogView.findViewById(R.id.dialog_edit_text);
final EditText getDownload = dialogView.findViewById(R.id.dialog_edit_text);
final int errorColor = ContextCompat.getColor(mActivity, R.color.error_red);
final int regularColor = ThemeUtils.getTextColor(mActivity);

14
app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java

@ -130,7 +130,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View @@ -130,7 +130,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
} else {
view = inflater.inflate(R.layout.tab_strip, container, false);
layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
ImageView newTab = (ImageView) view.findViewById(R.id.new_tab_button);
ImageView newTab = view.findViewById(R.id.new_tab_button);
newTab.setColorFilter(ThemeUtils.getIconDarkThemeColor(getActivity()));
newTab.setOnClickListener(new View.OnClickListener() {
@Override
@ -183,7 +183,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View @@ -183,7 +183,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
private void setupFrameLayoutButton(@NonNull final View root, @IdRes final int buttonId,
@IdRes final int imageId) {
final View frameButton = root.findViewById(buttonId);
final ImageView buttonImage = (ImageView) root.findViewById(imageId);
final ImageView buttonImage = root.findViewById(imageId);
frameButton.setOnClickListener(this);
frameButton.setOnLongClickListener(this);
buttonImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
@ -399,11 +399,11 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View @@ -399,11 +399,11 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
public LightningViewHolder(@NonNull View view) {
super(view);
txtTitle = (TextView) view.findViewById(R.id.textTab);
favicon = (ImageView) view.findViewById(R.id.faviconTab);
exit = (ImageView) view.findViewById(R.id.deleteButton);
layout = (LinearLayout) view.findViewById(R.id.tab_item_background);
exitButton = (FrameLayout) view.findViewById(R.id.deleteAction);
txtTitle = view.findViewById(R.id.textTab);
favicon = view.findViewById(R.id.faviconTab);
exit = view.findViewById(R.id.deleteButton);
layout = view.findViewById(R.id.tab_item_background);
exitButton = view.findViewById(R.id.deleteAction);
exit.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
exitButton.setOnClickListener(this);

6
app/src/main/java/acr/browser/lightning/search/SuggestionsAdapter.java

@ -136,9 +136,9 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable { @@ -136,9 +136,9 @@ public class SuggestionsAdapter extends BaseAdapter implements Filterable {
private static class SuggestionHolder {
SuggestionHolder(@NonNull View view) {
mTitle = (TextView) view.findViewById(R.id.title);
mUrl = (TextView) view.findViewById(R.id.url);
mImage = (ImageView) view.findViewById(R.id.suggestionIcon);
mTitle = view.findViewById(R.id.title);
mUrl = view.findViewById(R.id.url);
mImage = view.findViewById(R.id.suggestionIcon);
}
@NonNull final ImageView mImage;

2
app/src/main/java/acr/browser/lightning/utils/IntentUtils.java

@ -1,14 +1,12 @@ @@ -1,14 +1,12 @@
package acr.browser.lightning.utils;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.FileUriExposedException;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;

6
app/src/main/java/acr/browser/lightning/view/LightningWebClient.java

@ -135,9 +135,9 @@ public class LightningWebClient extends WebViewClient { @@ -135,9 +135,9 @@ public class LightningWebClient extends WebViewClient {
View dialogView = LayoutInflater.from(mActivity).inflate(R.layout.dialog_auth_request, null);
final TextView realmLabel = (TextView) dialogView.findViewById(R.id.auth_request_realm_textview);
final EditText name = (EditText) dialogView.findViewById(R.id.auth_request_username_edittext);
final EditText password = (EditText) dialogView.findViewById(R.id.auth_request_password_edittext);
final TextView realmLabel = dialogView.findViewById(R.id.auth_request_realm_textview);
final EditText name = dialogView.findViewById(R.id.auth_request_username_edittext);
final EditText password = dialogView.findViewById(R.id.auth_request_password_edittext);
realmLabel.setText(mActivity.getString(R.string.label_realm, realm));

Loading…
Cancel
Save