private void connect() { fab.setBackgroundTintList(TINT_CONNECTING); fab.setImageResource(R.drawable.ic_connected); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); String connectionType = prefs.getString( getString(R.string.prefs_conn_type), getString(R.string.prefs_bt_connection)); if (getString(R.string.prefs_bt_connection).equals(connectionType)) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter == null || !adapter.isEnabled()) { Toast.makeText(MainActivity.this, R.string.bluetooth_is_not_available, Toast.LENGTH_LONG) .show(); return; } showDevices(); } else { String host = prefs.getString("tcp_host", null); int port = 0; try { port = Integer.parseInt(prefs.getString("tcp_port", "0")); } catch (NumberFormatException nfe) { } if (host == null || port <= 0 || port > 0xFFFF) { Toast.makeText( MainActivity.this, String.format(Locale.US, "%s/%d: Illegal host/port combination.", host, port), Toast.LENGTH_LONG) .show(); return; } connect(host, port); } }
protected void setupFab() { FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); fab.setBackgroundTintList( ColorStateList.valueOf(Color.parseColor(mColors[GridActivity.ACCENT]))); }
/** * Sets the primary and ripple colors of a {@link * android.support.design.widget.FloatingActionButton}. * * @param fab floating action button to adjust * @param primaryColor primary color of action button * @param rippleColor color of action button on press */ public static void setFloatingActionButtonColors( FloatingActionButton fab, int primaryColor, int rippleColor) { if (fab == null) return; int[][] states = { {android.R.attr.state_enabled}, {android.R.attr.state_pressed}, }; int[] colors = { primaryColor, rippleColor, }; ColorStateList colorStateList = new ColorStateList(states, colors); fab.setBackgroundTintList(colorStateList); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (savedInstanceState != null) { // TODO save } mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.layout_swipe_refresh); mSwipeRefreshLayout.setOnRefreshListener(this); mSwipeRefreshLayout.setColorSchemeResources( R.color.indicator_red, R.color.indicator_green, R.color.indicator_blue, R.color.indicator_orange); mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); mAdapter = new TwitterFeedRecyclerAdapter(mTweetList); mAdapter.setOnClickTweetListener(mOnClickTweetListener); mAdapter.setOnClickMoreButtonListener( new View.OnClickListener() { @Override public void onClick(View v) { if (mOnClickTweetListener != null) { mOnClickTweetListener.onClickMoreButton(); } } }); mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity())); mRecyclerView.setAdapter(mAdapter); FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.floating_action_button); fab.setVisibility(View.VISIBLE); fab.setBackgroundTintList( ColorStateList.valueOf(getResources().getColor(R.color.background_fab_gray_blue))); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (mOnClickTweetListener != null) { mOnClickTweetListener.onClickPostTweet(); } } }); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_favorites, container, false); favList = (ListView) view.findViewById(R.id.favoritesList); if (favs.size() > 0) { // Finally set up adapter and ListView favAdapter = new FavoritesItemsAdapter(getActivity(), android.R.layout.simple_list_item_1, favs); favList.setAdapter(favAdapter); // Set up on click listeners favList.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { FavoritesDataContainer fav = (FavoritesDataContainer) parent.getItemAtPosition(position); if (fav.favType.toLowerCase().equals("station".toLowerCase())) { Intent intent = new Intent(getActivity(), StationActivity.class); intent.putExtra("ID", ((StationFavContainer) fav).StationId); startActivity(intent); } } }); } // Floating action button for adding a favorite FloatingActionButton addFav = (FloatingActionButton) view.findViewById(R.id.addFavButton); addFav.setBackgroundTintList(getResources().getColorStateList(R.color.primary_UI_blue)); addFav.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { LoadingDialogManager.getInstance().ShowLoading(getContext()); // Start search activity for adding favorites Intent searchIntent = new Intent(getActivity(), SearchActivity.class); LoadingDialogManager.getInstance().DismissLoading(); startActivity(searchIntent); } }); return view; }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.layout_main_about, container, false); setHasOptionsMenu(false); ((AppCompatActivity) getActivity()).getSupportActionBar().setSubtitle("Acerca de"); drawerLayout = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout); actionButton = (FloatingActionButton) v.findViewById(R.id.layout_main_fab); actionButton.setBackgroundTintList(getResources().getColorStateList(R.color.fab_main)); actionButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { drawerLayout.openDrawer(GravityCompat.START); } }); return v; }
@Nullable @Override public View onCreateView( LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View res = inflater.inflate(R.layout.fragment_fab, container, false); FloatingActionButton fabRoot = (FloatingActionButton) res.findViewById(R.id.fab); fabRoot.setImageResource(R.drawable.ic_edit_white_24dp); fabRoot.setBackgroundTintList( new ColorStateList( new int[][] { new int[] {android.R.attr.state_pressed}, StateSet.WILD_CARD, }, new int[] { ActorSDK.sharedActor().style.getFabPressedColor(), ActorSDK.sharedActor().style.getFabColor(), })); fabRoot.setRippleColor(ActorSDK.sharedActor().style.getFabPressedColor()); fabRoot.setOnClickListener( v -> startActivity(new Intent(getActivity(), ComposeActivity.class))); return res; }
@Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); setContentView(R.layout.activity_settings); toolbar = (Toolbar) findViewById(R.id.toolbar); SP = PreferenceManager.getDefaultSharedPreferences(this); // region TESTING fabMoreThemeOptions = (FloatingActionButton) findViewById(R.id.fab_more_theme_options); fabMoreGeneralOptions = (FloatingActionButton) findViewById(R.id.fab_more_general_options); fabMoreGeneralOptions.setBackgroundTintList(ColorStateList.valueOf(getSubTextColor())); fabMoreGeneralOptions.setImageDrawable( new IconicsDrawable(this) .icon(GoogleMaterial.Icon.gmd_keyboard_arrow_up) .sizeDp(16) .color(getCardBackgroundColor())); fabMoreGeneralOptions.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { LinearLayout llMoreOptions = (LinearLayout) findViewById(R.id.ll_more_options_general); boolean visible = llMoreOptions.getVisibility() == View.VISIBLE; llMoreOptions.setVisibility(visible ? View.GONE : View.VISIBLE); fabMoreGeneralOptions.setImageDrawable( new IconicsDrawable(SettingsActivity.this) .icon( visible ? GoogleMaterial.Icon.gmd_keyboard_arrow_up : GoogleMaterial.Icon.gmd_keyboard_arrow_down) .sizeDp(16) .color(getCardBackgroundColor())); } }); fabMoreThemeOptions.setBackgroundTintList(ColorStateList.valueOf(getSubTextColor())); fabMoreThemeOptions.setImageDrawable( new IconicsDrawable(this) .icon(GoogleMaterial.Icon.gmd_keyboard_arrow_up) .sizeDp(16) .color(getCardBackgroundColor())); fabMoreThemeOptions.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { LinearLayout llMoreOptions = (LinearLayout) findViewById(R.id.ll_more_options_theme); boolean visible = llMoreOptions.getVisibility() == View.VISIBLE; llMoreOptions.setVisibility(visible ? View.GONE : View.VISIBLE); fabMoreThemeOptions.setImageDrawable( new IconicsDrawable(SettingsActivity.this) .icon( visible ? GoogleMaterial.Icon.gmd_keyboard_arrow_up : GoogleMaterial.Icon.gmd_keyboard_arrow_down) .sizeDp(16) .color(getCardBackgroundColor())); } }); // endregion securityObj = new SecurityHelper(SettingsActivity.this); txtTT = (TextView) findViewById(R.id.theme_setting_title); txtGT = (TextView) findViewById(R.id.general_setting_title); txtPT = (TextView) findViewById(R.id.picture_setting_title); txtVT = (TextView) findViewById(R.id.video_setting_title); scr = (ScrollView) findViewById(R.id.settingAct_scrollView); /** * EXCLUDED ALBUMS ** */ findViewById(R.id.ll_basic_theme) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { baseThemeDialog(); } }); /** * SECURITY ** */ findViewById(R.id.ll_security) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (!securityObj.isActiveSecurity()) startActivity(new Intent(getApplicationContext(), SecurityActivity.class)); else askPasswordDialog(); } }); /** * PRIMARY COLOR PIKER ** */ findViewById(R.id.ll_primaryColor) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { primaryColorPiker(); } }); /** * ACCENT COLOR PIKER ** */ findViewById(R.id.ll_accentColor) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { accentColorPiker(); } }); /** * EXCLUDED ALBUMS INTENT ** */ findViewById(R.id.ll_excluded_album) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(SettingsActivity.this, ExcludedAlbumsActivity.class)); } }); /** * CUSTOMIZE PICTURE VIEWER DIALOG ** */ findViewById(R.id.ll_custom_thirdAct) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { customizePictureViewer(); } }); /** * MAP PROVIDER DIALOG ** */ findViewById(R.id.ll_map_provider) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mapProviderDialog(); } }); /** * SW Internal Player ** */ swInternalBrowser = (SwitchCompat) findViewById(R.id.set_internal_player); swInternalBrowser.setChecked( SP.getBoolean(getString(R.string.preference_internal_player), false)); swInternalBrowser.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor editor = SP.edit(); editor.putBoolean(getString(R.string.preference_internal_player), isChecked); editor.apply(); new Thread( new Runnable() { @Override public void run() { ((MyApplication) getApplicationContext()).updateAlbums(); } }) .start(); updateSwitchColor(swInternalBrowser, getAccentColor()); } }); updateSwitchColor(swInternalBrowser, getAccentColor()); /** * SW INCLUDE VIDEO ** */ swIncludeVideo = (SwitchCompat) findViewById(R.id.set_include_video); swIncludeVideo.setChecked(SP.getBoolean(getString(R.string.preference_include_video), true)); swIncludeVideo.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor editor = SP.edit(); editor.putBoolean(getString(R.string.preference_include_video), isChecked); editor.apply(); updateSwitchColor(swIncludeVideo, getAccentColor()); } }); updateSwitchColor(swIncludeVideo, getAccentColor()); /** * SW SWIPE DIRECTION ** */ swSwipeDirection = (SwitchCompat) findViewById(R.id.Set_media_viewer_swipe_direction); swSwipeDirection.setChecked( SP.getBoolean(getString(R.string.preference_swipe_direction_inverted), false)); swSwipeDirection.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor editor = SP.edit(); editor.putBoolean(getString(R.string.preference_swipe_direction_inverted), isChecked); editor.apply(); updateSwitchColor(swSwipeDirection, getAccentColor()); } }); updateSwitchColor(swSwipeDirection, getAccentColor()); /** * SW AUTO UPDATE MEDIA ** */ swAutoUpdate = (SwitchCompat) findViewById(R.id.SetAutoUpdateMedia); swAutoUpdate.setChecked(SP.getBoolean(getString(R.string.preference_auto_update_media), false)); swAutoUpdate.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor editor = SP.edit(); editor.putBoolean(getString(R.string.preference_auto_update_media), isChecked); editor.apply(); updateSwitchColor(swAutoUpdate, getAccentColor()); } }); updateSwitchColor(swAutoUpdate, getAccentColor()); /** * SW DELAY FULL-SIZE IMAGE ** */ swDelayFullImage = (SwitchCompat) findViewById(R.id.set_full_resolution); swDelayFullImage.setChecked( SP.getBoolean(getString(R.string.preference_delay_full_image), true)); swDelayFullImage.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor editor = SP.edit(); editor.putBoolean(getString(R.string.preference_delay_full_image), isChecked); editor.apply(); updateSwitchColor(swDelayFullImage, getAccentColor()); } }); updateSwitchColor(swDelayFullImage, getAccentColor()); /** * SW PICTURE ORIENTATION ** */ swPictureOrientation = (SwitchCompat) findViewById(R.id.set_picture_orientation); swPictureOrientation.setChecked( SP.getBoolean(getString(R.string.preference_auto_rotate), false)); swPictureOrientation.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor editor = SP.edit(); editor.putBoolean(getString(R.string.preference_auto_rotate), isChecked); editor.apply(); updateSwitchColor(swPictureOrientation, getAccentColor()); } }); updateSwitchColor(swPictureOrientation, getAccentColor()); /** * SW MAX LUMINOSITA ** */ swMaxLuminosita = (SwitchCompat) findViewById(R.id.set_max_luminosita); swMaxLuminosita.setChecked(SP.getBoolean(getString(R.string.preference_max_brightness), false)); swMaxLuminosita.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor editor = SP.edit(); editor.putBoolean(getString(R.string.preference_max_brightness), isChecked); editor.apply(); updateSwitchColor(swMaxLuminosita, getAccentColor()); } }); updateSwitchColor(swMaxLuminosita, getAccentColor()); /** * SW TRANSLUCENT STATUS BAR ** */ swStatusBar = (SwitchCompat) findViewById(R.id.SetTraslucentStatusBar); swStatusBar.setChecked(isTranslucentStatusBar()); swStatusBar.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor editor = SP.edit(); editor.putBoolean(getString(R.string.preference_translucent_status_bar), isChecked); editor.apply(); updateTheme(); setStatusBarColor(); updateSwitchColor(swStatusBar, getAccentColor()); } }); updateSwitchColor(swStatusBar, getAccentColor()); /** * SW COLORED NAV BAR ** */ swNavBar = (SwitchCompat) findViewById(R.id.SetColoredNavBar); swNavBar.setChecked(isNavigationBarColored()); swNavBar.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences.Editor editor = SP.edit(); editor.putBoolean(getString(R.string.preference_colored_nav_bar), isChecked); editor.apply(); updateTheme(); updateSwitchColor(swNavBar, getAccentColor()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getWindow() .setNavigationBarColor( isNavigationBarColored() ? getPrimaryColor() : ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000)); } }); updateSwitchColor(swNavBar, getAccentColor()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_record); chronometer = (Chronometer) findViewById(R.id.chrono); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); int fileformat = Integer.parseInt(sharedPref.getString(SettingsActivity.KEY_FILE_FORMAT, "")); int codec = Integer.parseInt(sharedPref.getString(SettingsActivity.KEY_CODEC, "")); // Setting up chart setupTopChart(); final String TAG = "test"; mLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout); mLayout.setTouchEnabled(false); mLayout.setMinFlingVelocity(100); mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); mLayout.setPanelHeight(600); ((TextView) findViewById(R.id.codec)) .setText(sharedPref.getString(SettingsActivity.KEY_CODEC, "")); myAudioRecorder = new MediaRecorder(); myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); myAudioRecorder.setOutputFormat(fileformat); myAudioRecorder.setAudioEncoder(codec); myAudioRecorder.setAudioEncodingBitRate(100000); FloatingActionButton mic = (FloatingActionButton) findViewById(R.id.record); mic.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor("#ffffff"))); mic.setRippleColor(getResources().getColor(R.color.colorAccent)); (findViewById(R.id.pause_record)) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (!drawDisplayed) { mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); (findViewById(R.id.pause_record)) .animate() .rotationBy(180) .setDuration(400) .setInterpolator(new AccelerateDecelerateInterpolator()) .start(); drawDisplayed = true; } else { mLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); (findViewById(R.id.pause_record)) .animate() .rotationBy(180) .setInterpolator(new AccelerateDecelerateInterpolator()) .setDuration(400) .start(); drawDisplayed = false; } } }); // Spinner spinner = (Spinner) findViewById(R.id.fileTypeSpinner); // Create an ArrayAdapter using the string array and a default spinner layout // ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, // R.array.filetypes, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears // adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner // spinner.setAdapter(adapter); (findViewById(R.id.stop_record)) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { stopRecording(v); } }); final LinearLayout bottomBar = (LinearLayout) findViewById(R.id.bottomBar); mic.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { stopRecording(v); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_favourites_select); getSupportActionBar() .setBackgroundDrawable( new ColorDrawable(ContextCompat.getColor(getApplication(), R.color.luas_purple))); /* * Build arrays for Red Line and Green Line stops from resources, then create Lists * from those arrays. Finally, build a List of all stops by concatenating the first * two Lists. */ String[] redLineArrayStops = getResources().getStringArray(R.array.array_stops_redline); String[] greenLineArrayStops = getResources().getStringArray(R.array.array_stops_greenline); List<String> redLineListStops = Arrays.asList(redLineArrayStops); List<String> greenLineListStops = Arrays.asList(greenLineArrayStops); List<String> listAllStops = new ArrayList<>(redLineListStops); listAllStops.addAll(greenLineListStops); /* Remove the two "Select a stop..." entries from the List. */ for (int i = 0; i < 2; i++) { listAllStops.remove(getResources().getString(R.string.select_a_stop)); } /* ArrayAdapter for favourite stops. */ adapterFavouriteStops = new ArrayAdapter<>(getApplicationContext(), R.layout.checkedtextview_stops, listAllStops); /* * Populate ListView with all stops on both lines. */ final ListView listViewStops = (ListView) findViewById(R.id.listview_stops); listViewStops.setAdapter(adapterFavouriteStops); listViewStops.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { /* * When a list item is clicked, it is graphically "checked" and also added * to a List of all currently selected stops. */ checkedItems = listViewStops.getCheckedItemPositions(); selectedItems = new ArrayList<>(); for (int i = 0; i < checkedItems.size(); i++) { int pos = checkedItems.keyAt(i); if (checkedItems.valueAt(i)) { selectedItems.add(adapterFavouriteStops.getItem(pos)); } } } }); /* * Use a Floating Action Button (FAB) to save the selected Favourites. */ FloatingActionButton fabFavouritesSave = (FloatingActionButton) findViewById(R.id.fab_favourites_save); fabFavouritesSave.setBackgroundTintList( ColorStateList.valueOf(ContextCompat.getColor(this, R.color.message_success))); fabFavouritesSave.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { saveFavourites(); } }); /* * Keep the FavouritesSelectActivity in sync with the favourites file by ensuring * all favourite stops are already checked in the ListView. */ try { /* * Open the "favourites" file and read in the List object of favourite stops * contained within. */ InputStream fileInput = openFileInput(FILE_FAVOURITES); InputStream buffer = new BufferedInputStream(fileInput); ObjectInput objectInput = new ObjectInputStream(buffer); @SuppressWarnings("unchecked") List<CharSequence> listFavouriteStops = (List<CharSequence>) objectInput.readObject(); /* * Programmatically check the boxes of already-favourited stops. */ for (int i = 0; i < listFavouriteStops.size(); i++) { if (listAllStops.contains(listFavouriteStops.get(i).toString())) { listViewStops.setItemChecked( listAllStops.indexOf(listFavouriteStops.get(i).toString()), true); } } } catch (FileNotFoundException e) { Log.i(LOG_TAG, "Favourites file doesn't exist."); } catch (ClassNotFoundException | IOException e) { Log.e(LOG_TAG, Log.getStackTraceString(e)); } }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.layout_main_por_ano, container, false); setHasOptionsMenu(false); ((AppCompatActivity) getActivity()).getSupportActionBar().setSubtitle("Simulacro por año"); final ListView listview = (ListView) v.findViewById(R.id.lista_anos); final String[] anos = getResources().getStringArray(R.array.anos); final String[] string_ano = getResources().getStringArray(R.array.numero_de_preguntas_anos); context = getActivity().getApplicationContext(); listview.setAdapter(new ListViewAdapter_Por_Ano(context, anos, string_ano)); listview.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); listview.setClickable(true); listview.setFocusable(true); listview.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { color_a = R.color.color_ano_a; color_b = R.color.color_ano_b; string_asignatura = anos[i]; int_asignatura = (i + 1); img_asignatura = R.drawable.por_ano; switch (i) { case 0: xml_asignatura = R.raw.eir_2015; break; case 1: xml_asignatura = R.raw.eir_2014; break; case 2: xml_asignatura = R.raw.eir_2013; break; case 3: xml_asignatura = R.raw.eir_2012; break; case 4: xml_asignatura = R.raw.eir_2011; break; case 5: xml_asignatura = R.raw.eir_2010; break; case 6: xml_asignatura = R.raw.eir_2009; break; case 7: xml_asignatura = R.raw.eir_2008; break; case 8: xml_asignatura = R.raw.eir_2007; break; case 9: xml_asignatura = R.raw.eir_2006; break; case 10: xml_asignatura = R.raw.eir_2005; break; case 11: xml_asignatura = R.raw.eir_2004; break; case 12: xml_asignatura = R.raw.eir_2003; break; case 13: xml_asignatura = R.raw.eir_2002; break; case 14: xml_asignatura = R.raw.eir_2001; break; case 15: xml_asignatura = R.raw.eir_2000; break; case 16: xml_asignatura = R.raw.eir_1999; break; case 17: xml_asignatura = R.raw.eir_1998; break; case 18: xml_asignatura = R.raw.eir_1997; break; case 19: xml_asignatura = R.raw.eir_1996; break; case 20: xml_asignatura = R.raw.eir_1995; break; case 21: xml_asignatura = R.raw.eir_1994; break; } } }); actionButton = (FloatingActionButton) v.findViewById(R.id.layout_main_por_ano_fab); // Crear el Floating Action Button actionButton.setBackgroundTintList(getResources().getColorStateList(R.color.fab_main)); actionButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (int_asignatura >= 1) { Intent intent = new Intent(getActivity(), Activity_Pre_simulacro.class); intent.putExtra("color_a", color_a); intent.putExtra("color_b", color_b); intent.putExtra("xml_asignatura", xml_asignatura); intent.putExtra("string_asignatura", string_asignatura); intent.putExtra("img_asignatura", img_asignatura); intent.putExtra("int_asignatura", int_asignatura); intent.putExtra("es_ano", true); Global.color_a = color_a; Global.color_b = color_b; startActivity(intent); } else { Snackbar.make(actionButton, "Elige un año.", Snackbar.LENGTH_LONG).show(); } } }); return v; }
private void updateConnectButton() { fab.setBackgroundTintList(ecm.isConnected() ? TINT_CONNECTED : TINT_DISCONNECTED); fab.setImageResource(ecm.isConnected() ? R.drawable.ic_connected : R.drawable.ic_disconnected); }