@Override public void onResume() { super.onResume(); ActivityMonitor.getInstance().setCurrentActivity(this); if (!(preferences.getEmail().equals("") || preferences.getPassword().equals("") || preferences.getDid().equals(""))) { preRecentUpdate(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string.conversations_first_run_dialog_text)); builder.setPositiveButton( getString(R.string.preferences_name), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent preferencesIntent = new Intent(conversationsActivity, PreferencesActivity.class); startActivity(preferencesIntent); } }); builder.setNegativeButton( getString(R.string.help_name), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent helpIntent = new Intent(conversationsActivity, HelpActivity.class); startActivity(helpIntent); } }); builder.setCancelable(false); builder.show(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.conversations); gcm = Gcm.getInstance(getApplicationContext()); billing = Billing.getInstance(getApplicationContext()); database = Database.getInstance(getApplicationContext()); preferences = Preferences.getInstance(getApplicationContext()); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); ViewCompat.setElevation(toolbar, getResources().getDimension(R.dimen.toolbar_elevation)); setSupportActionBar(toolbar); LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); adapter = new ConversationsRecyclerViewAdapter(this, layoutManager); recyclerView = (RecyclerView) findViewById(R.id.list); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); actionMode = null; actionModeEnabled = false; SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { preFullUpdate(); } }); swipeRefreshLayout.setColorSchemeResources(R.color.accent); ImageButton button = (ImageButton) findViewById(R.id.new_button); ViewCompat.setElevation(button, getResources().getDimension(R.dimen.fab_elevation)); button.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (!preferences.getEmail().equals("") && !preferences.getPassword().equals("") && !preferences.getDid().equals("")) { Intent intent = new Intent(conversationsActivity, NewConversationActivity.class); startActivity(intent); } } }); SynchronizationIntervalReceiver.setupSynchronizationInterval(getApplicationContext()); }