Skip to content

Commit

Permalink
Remove casts we no longer need
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-caryl committed Sep 16, 2017
1 parent ab468c6 commit 6bf9617
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ public void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
final String cheeseName = intent.getStringExtra(EXTRA_NAME);

final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

CollapsingToolbarLayout collapsingToolbar =
(CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapsing_toolbar);
collapsingToolbar.setTitle(cheeseName);

loadBackdrop();
Expand All @@ -54,7 +53,7 @@ public void onCreate(Bundle savedInstanceState) {
}

private void loadBackdrop() {
final ImageView imageView = (ImageView) findViewById(R.id.backdrop);
final ImageView imageView = findViewById(R.id.backdrop);
Glide.with(this).load(Cheeses.getRandomCheeseDrawable()).centerCrop().into(imageView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public static class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View view) {
super(view);
mView = view;
mImageView = (ImageView) view.findViewById(R.id.avatar);
mTextView = (TextView) view.findViewById(android.R.id.text1);
mImageView = view.findViewById(R.id.avatar);
mTextView = view.findViewById(android.R.id.text1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,26 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

final ActionBar ab = getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.ic_menu);
ab.setDisplayHomeAsUpEnabled(true);

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout = findViewById(R.id.drawer_layout);

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
NavigationView navigationView = findViewById(R.id.nav_view);
if (navigationView != null) {
setupDrawerContent(navigationView);
}

ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
ViewPager viewPager = findViewById(R.id.viewpager);
if (viewPager != null) {
setupViewPager(viewPager);
}

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -78,7 +78,7 @@ public void onClick(View view) {
}
});

TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
TabLayout tabLayout = findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);

nightModeUtils = NightModeUtils.from(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.support.android.designlibdemo;

import android.app.Activity;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatDelegate;
import android.view.Menu;
Expand Down Expand Up @@ -38,7 +37,7 @@ boolean checkNightMode(@NonNull Menu menu) {
return true;
}

public boolean onNightModeItemSelected(@NonNull MenuItem item) {
boolean onNightModeItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_night_mode_system:
setNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
Expand All @@ -61,9 +60,6 @@ public boolean onNightModeItemSelected(@NonNull MenuItem item) {
private void setNightMode(@AppCompatDelegate.NightMode int nightMode) {
AppCompatDelegate.setDefaultNightMode(nightMode);

if (Build.VERSION.SDK_INT >= 11) {
activity.recreate();
}
activity.recreate();
}

}

0 comments on commit 6bf9617

Please sign in to comment.