Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
tweaks based on @LukasPaczos ' findings
Browse files Browse the repository at this point in the history
  • Loading branch information
Langston Smith authored and langsmith committed Oct 9, 2019
1 parent 1002e5b commit 6678f8f
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -201,6 +200,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private ExampleAdapter adapter;
private RecyclerView recyclerView;
private TextView noExamplesTv;
private ItemClickSupport itemClickSupport;

private boolean loggedIn;
private int currentCategory = R.id.nav_basics;
Expand All @@ -211,7 +211,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG, "onCreate: ");

loggedIn = PreferenceManager.getDefaultSharedPreferences(getApplicationContext())
.getBoolean(TOKEN_SAVED_KEY, false);
Expand Down Expand Up @@ -248,7 +247,8 @@ protected void onCreate(Bundle savedInstanceState) {
}

// Item click listener
ItemClickSupport.addTo(recyclerView).setOnItemClickListener(this);
itemClickSupport = ItemClickSupport.addTo(recyclerView);
itemClickSupport.setOnItemClickListener(this);

DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
Expand Down Expand Up @@ -283,7 +283,6 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void onItemClicked(RecyclerView recyclerView, int position, View view) {
Log.d(TAG, "onItemClicked: ");
ExampleItemModel model = adapter.getItemAt(position);

// in case it's an info tile
Expand All @@ -297,22 +296,19 @@ public void onItemClicked(RecyclerView recyclerView, int position, View view) {

analytics.clickedOnIndividualExample(getString(model.getTitle()), loggedIn);
analytics.viewedScreen(getString(model.getTitle()), loggedIn);

}
}

@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "onResume: ");
ItemClickSupport.addTo(recyclerView).setOnItemClickListener(this);
itemClickSupport.setOnItemClickListener(this);
}

@Override
protected void onPause() {
super.onPause();
Log.d(TAG, "onPause: ");
ItemClickSupport.removeFrom(recyclerView);
itemClickSupport.setOnItemClickListener(null);
}

@Override
Expand Down

0 comments on commit 6678f8f

Please sign in to comment.