private void MVC_view_handler(String cmd) { try { int mapValue; switch (cmd) { case "FOLL": mapValue = appData.get("FOLL"); if (mapValue == MOVE_FOLLOW_OFF) mMoveFollow.setChecked(false); else if (mapValue == MOVE_FOLLOW_ON) mMoveFollow.setChecked(true); break; case "SMOD": MainActivity.setSpinnerSelect(mSampleMode, appData.get("SMOD")); break; case "FILT": MainActivity.setSpinnerSelect(mFilterSelecter, appData.get("FILT")); break; default: break; } } catch (NullPointerException e) { Log.i("ThirdFrament:handleCmd", "This Fragment NOT Attach Now"); } }
private void setToggles() { recentToggle.setChecked(false); nameToggle.setChecked(false); keywordsToggle.setChecked(false); descToggle.setChecked(false); interestsToggle.setChecked(false); switch (activeToggle) { case 0: recentToggle.setChecked(true); break; case 1: nameToggle.setChecked(true); break; case 2: keywordsToggle.setChecked(true); break; case 3: descToggle.setChecked(true); break; case 4: interestsToggle.setChecked(true); break; default: throw new RuntimeException("Invalid Toggle State: " + activeToggle); } }
// Use this method to read sms, when sms text is already know (already found // by another method) public void readMessages( String message, Calendar calendar, TextView tempr, TextView dateV, ToggleButton toggleButton) { // Making toggle button visible toggleButton.setVisibility(View.VISIBLE); // Taking required information from message String messageTemp = message.substring(message.indexOf("T=") + 2, message.indexOf("T=") + 6); tempr.setText(messageTemp); // Taking calendar object and getting date and time of incoming // message, the feeding information to view int smsDay = calendar.get(Calendar.DATE); int smsTime = calendar.get(Calendar.HOUR_OF_DAY); String smsReceived = smsDay + " - " + smsTime; dateV.setText(smsReceived); // If yes, check security status and change Toggle button information // Accordingly if (message.indexOf("Apsauga isjungta") > -1) { toggleButton.setChecked(false); } else { toggleButton.setChecked(true); } }
public void reInitFragment() { mLayout.setVisibility(View.VISIBLE); mTxtDuration.setVisibility(View.GONE); mTxtTitle.setText(Utility.sMovieObject.Title); mTxtOverview.setText(Utility.sMovieObject.Overview); mTxtVoteAverage.setText(Utility.sMovieObject.VoteAverage + "/10"); try { mTxtReleaseDate.setText(Utility.sMovieObject.ReleaseDate.split("-")[0]); } catch (Exception e) { } mTxtReviews.setText(""); lstTrailersUrl.clear(); lstReviewsContent.clear(); lstTrailersNames.clear(); adpTrailersUrl.notifyDataSetChanged(); configListViewHeight(lstTrailers); if (mUtility.isMovieExist(Utility.sMovieObject.Id)) { imgPoster.setImageBitmap(mUtility.getImageBitmap(Utility.sMovieObject.MoviePoster)); btnFavorite.setChecked(true); } else { Picasso.with(getActivity()) .load(mUtility.IMAGE_URL + Utility.sMovieObject.MoviePoster) .placeholder(getContext().getResources().getDrawable(R.drawable.imgdefaultmovie)) .error(getContext().getResources().getDrawable(R.drawable.imgdefaultmovie)) .into(imgPoster); btnFavorite.setChecked(false); } new FetchAttachments().execute(MOVIE_INFO); }
private void setWifiStatus(boolean onOff) { wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); if (onOff) { if (wifi.isWifiEnabled() == false) { Toast.makeText( getApplicationContext(), "Wifi is disabled. It is being enabled.", Toast.LENGTH_LONG) .show(); } wifi.setWifiEnabled(true); scanning_textView.setVisibility(View.GONE); wifiListview.setVisibility(View.VISIBLE); wifiOnOff.setChecked(true); wifiOnOff.setBackgroundColor(getResources().getColor(R.color.greenEnd)); } else { Toast.makeText(getApplicationContext(), "Wifi is disabled.", Toast.LENGTH_LONG).show(); wifi.setWifiEnabled(false); wifiOnOff.setChecked(false); wifiOnOff.setBackgroundColor(getResources().getColor(R.color.lightGrey)); scanning_textView.setVisibility(View.GONE); wifiListview.setVisibility(View.GONE); } }
private void setFromPrevBM(boolean isToggled, ToggleButton button) { if (isToggled) { button.setChecked(true); } else { button.setChecked(false); } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.irdi_suche: if (searchRunning != 0) { Toast.makeText(getActivity(), "Bitte auf Suchergebniss warten.", Toast.LENGTH_SHORT) .show(); break; } vollSuche = false; vollSucheButton.setChecked(false); irdiSucheButton.setChecked(true); break; case R.id.voll_suche: if (searchRunning != 0) { Toast.makeText(getActivity(), "Bitte auf Suchergebniss warten.", Toast.LENGTH_SHORT) .show(); break; } vollSuche = true; vollSucheButton.setChecked(true); irdiSucheButton.setChecked(false); break; } }
// This method is called when we select a other radio button // Ths method wil uncheck the other radio buttons // Write the default with the given one // update it in showloading fooddata private void updatedChecked(int newDefault) { try { // track we come here ActivityGroupSettings.group.parent.trackEvent( TrackingValues.eventCategorySettings, TrackingValues.eventCategorySettingsChangeFoodCompositionDefault); } catch (NullPointerException e) { } // set all radio buttons to unchecked rbCarb.setChecked(false); rbProt.setChecked(false); rbFat.setChecked(false); rbKcal.setChecked(false); try { // set the new default in showfooddata ActivityGroupMeal.group.getFoodData().defaultValue = newDefault; } catch (NullPointerException e) { } // set the default value on this page defaultValue = newDefault; // write to database DbAdapter db = new DbAdapter(this); db.open(); // set right radio button checked // and visible to true // and set the togle button on switch (newDefault) { case 1: tgCarb.setChecked(true); rbCarb.setChecked(true); break; case 2: tgProt.setChecked(true); rbProt.setChecked(true); break; case 3: tgFat.setChecked(true); rbFat.setChecked(true); break; case 4: tgKcal.setChecked(true); rbKcal.setChecked(true); break; } db.updateSettingsByName(DbSettings.setting_value_default, "" + newDefault); db.close(); // mark the new default as visible in database and on screen // togglebutton updateToggleButton(newDefault); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_crumb); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Register your receiver so that the Activity can be notified // when the JSON response came back IntentFilter filter = new IntentFilter(MyRequestReceiver6.PROCESS_RESPONSE); filter.addCategory(Intent.CATEGORY_DEFAULT); receiver = new MyRequestReceiver6(); registerReceiver(receiver, filter); // get references to the EditText, TextView and toggle fields crumbName = (EditText) findViewById(R.id.editcrumb_name); crumbComment = (EditText) findViewById(R.id.editcrumb_description); crumbTags = (EditText) findViewById(R.id.editcrumb_tags); toggle = (ToggleButton) findViewById(R.id.toggleButton2); isPrivate = getIntent().getBooleanExtra(MyCrumbsActivity.CRUMB_PRIVATE, true); if (isPrivate) toggle.setChecked(true); else toggle.setChecked(false); // populate EditTexts and TextViews fields with selected crumb attributes Intent intent3 = getIntent(); crumbName.setText(intent3.getStringExtra(MyCrumbsActivity.CRUMB_NAME)); crumbComment.setText(intent3.getStringExtra(MyCrumbsActivity.CRUMB_COMMENT)); crumbTags.setText(intent3.getStringExtra(MyCrumbsActivity.CRUMB_TAGS)); // get longitude and latitude of crumb to edit to mark on map fragment longitude = intent3.getDoubleExtra(MyCrumbsActivity.CRUMB_LONGITUDE, 0.0); latitude = intent3.getDoubleExtra(MyCrumbsActivity.CRUMB_LATITUDE, 0.0); // setup Google map to mark where crumb is SupportMapFragment supportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); map = supportMapFragment.getMap(); // get location of crumb, set to a LatLng object LatLng location = new LatLng(latitude, longitude); // mark crumb location on map map.setMyLocationEnabled(true); map.setMapType(GoogleMap.MAP_TYPE_NORMAL); map.moveCamera(CameraUpdateFactory.newLatLng(location)); map.animateCamera(CameraUpdateFactory.zoomTo(14)); map.addMarker( new MarkerOptions() .position(location) .title(intent3.getStringExtra(MyCrumbsActivity.CRUMB_NAME))); CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(location, 12); map.animateCamera(yourLocation); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); altBoard = (ToggleButton) findViewById(R.id.toggleAltBoard); altBoard.setChecked(AppPreferences.alternativeBoard()); hideActionBar = (ToggleButton) findViewById(R.id.toggleActionBar); hideActionBar.setChecked(AppPreferences.hideActionBar()); timeLimit = (EditText) findViewById(R.id.editTimeLimit); timeLimit.setText(String.valueOf(AppPreferences.timeLimit())); ((TextView) findViewById(R.id.textDbPath)).setText(Global.dbDir); }
public void chooseServiceSearch(View view) { searchChooser = 2; searchView.setQueryHint("Search for Service"); ToggleButton personButton = (ToggleButton) findViewById(R.id.personTab); personButton.setChecked(false); ToggleButton buildingButton = (ToggleButton) findViewById(R.id.buildingTab); buildingButton.setChecked(false); ToggleButton departmentButton = (ToggleButton) findViewById(R.id.departmentTab); departmentButton.setChecked(false); ToggleButton serviceTab = (ToggleButton) findViewById(R.id.serviceTab); serviceTab.setChecked(true); search(" "); }
private void updateStatus() { if (_service != null && _service.isStarted()) { _txtView.setText("Started"); _startStopButton.setText(getText(R.string.stop)); _debugButton.setEnabled(true); } else { _txtView.setText("Stopped"); _startStopButton.setText(getText(R.string.start)); _debugButton.setEnabled(false); } if (_service != null) _debugButton.setChecked(_service._debug); else _debugButton.setChecked(false); }
private void updateIncomeExpenseType() { if (category.getParentId() > 0) { if (category.parent.isIncome()) { incomeExpenseButton.setChecked(true); } else { incomeExpenseButton.setChecked(false); } incomeExpenseButton.setEnabled(false); } else { incomeExpenseButton.setChecked(category.isIncome()); incomeExpenseButton.setEnabled(true); } }
// for initialize when parse configure xml. public void refreshFragment() { try { int tempValue = appData.get("FOLL"); if (tempValue == MOVE_FOLLOW_OFF) mMoveFollow.setChecked(false); else if (tempValue == MOVE_FOLLOW_ON) mMoveFollow.setChecked(true); MainActivity.setSpinnerSelect(mSampleMode, appData.get("SMOD")); MainActivity.setSpinnerSelect(mFilterSelecter, appData.get("FILT")); } catch (NullPointerException e) { Log.i( "secondFragment:refreshFragment", "first refresh secondFragment will cause nullException"); } }
// This method will set right value on the togle buttons private void setToggleButtons() { DbAdapter db = new DbAdapter(this); db.open(); // carb togle button Cursor cSettingCarb = db.fetchSettingByName(DbSettings.setting_value_carb_onoff); if (cSettingCarb.getCount() > 0) { cSettingCarb.moveToFirst(); if (cSettingCarb.getInt(cSettingCarb.getColumnIndexOrThrow(DbAdapter.DATABASE_SETTINGS_VALUE)) == 1) { tgCarb.setChecked(true); } else { tgCarb.setChecked(false); } } cSettingCarb.close(); // prot togle button Cursor cSettingProt = db.fetchSettingByName(DbSettings.setting_value_prot_onoff); if (cSettingProt.getCount() > 0) { cSettingProt.moveToFirst(); if (cSettingProt.getInt(cSettingProt.getColumnIndexOrThrow(DbAdapter.DATABASE_SETTINGS_VALUE)) == 1) { tgProt.setChecked(true); } else { tgProt.setChecked(false); } } cSettingProt.close(); // fat togle button Cursor cSettingFat = db.fetchSettingByName(DbSettings.setting_value_fat_onoff); if (cSettingFat.getCount() > 0) { cSettingFat.moveToFirst(); if (cSettingFat.getInt(cSettingFat.getColumnIndexOrThrow(DbAdapter.DATABASE_SETTINGS_VALUE)) == 1) { tgFat.setChecked(true); } else { tgFat.setChecked(false); } } cSettingFat.close(); // kcal togle button Cursor cSettingKcal = db.fetchSettingByName(DbSettings.setting_value_kcal_onoff); if (cSettingKcal.getCount() > 0) { cSettingKcal.moveToFirst(); if (cSettingKcal.getInt(cSettingKcal.getColumnIndexOrThrow(DbAdapter.DATABASE_SETTINGS_VALUE)) == 1) { tgKcal.setChecked(true); } else { tgKcal.setChecked(false); } } cSettingKcal.close(); db.close(); }
@Override public void onResume() { final SharedPreferences settings = getActivity().getSharedPreferences(getString(R.string.settingsFile), Context.MODE_PRIVATE); ToggleButton startStop = (ToggleButton) getView().findViewById(R.id.startStop); // preserve state if (settings.getInt(getString(R.string.mode), -1) == 1) { startStop.setChecked(true); } else { startStop.setChecked(false); } Log.w("reloading pace", "mode =" + settings.getInt(getString(R.string.mode), -1)); super.onResume(); }
public void addSegment(String title) { DisplayMetrics metrics = new DisplayMetrics(); ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics); ToggleButton b = new ToggleButton(getContext()); b.setText(title); b.setTextOff(title); b.setTextOn(title); b.setTextColor(Color.WHITE); b.setTypeface(Typeface.DEFAULT_BOLD); b.setMinimumWidth((int) (40 * metrics.density)); if (mSwitches.size() == 0) { b.setBackgroundResource(mLeftDrawable); b.setEnabled(false); b.setChecked(true); } else { if (mSwitches.size() > 1) { ToggleButton temp = mSwitches.get(mSwitches.size() - 1); temp.setBackgroundResource(mMidDrawable); } b.setBackgroundResource(mRightDrawable); } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.weight = 0.1f; params.gravity = Gravity.CENTER; b.setLayoutParams(params); b.setOnCheckedChangeListener(this); mSwitches.add(b); addView(b); }
private void toggleCamera(boolean isNeedEnableCam) { // TODO temporary insertion will be removed when GLVideoView will be fixed DisplayMetrics displaymetrics = new DisplayMetrics(); displaymetrics.setToDefaults(); ViewGroup.LayoutParams layoutParams = imgMyCameraOff.getLayoutParams(); layoutParams.height = localVideoView.getHeight(); layoutParams.width = localVideoView.getWidth(); imgMyCameraOff.setLayoutParams(layoutParams); Log.d( TAG, "Width is: " + imgMyCameraOff.getLayoutParams().width + " height is:" + imgMyCameraOff.getLayoutParams().height); if (SessionManager.getCurrentSession() != null) { SessionManager.getCurrentSession().setVideoEnabled(isNeedEnableCam); cameraToggle.setChecked(isNeedEnableCam); if (isNeedEnableCam) { Log.d(TAG, "Camera is on"); switchCameraToggle.setVisibility(View.VISIBLE); imgMyCameraOff.setVisibility(View.INVISIBLE); } else { Log.d(TAG, "Camera is off"); switchCameraToggle.setVisibility(View.INVISIBLE); imgMyCameraOff.setVisibility(View.VISIBLE); } } }
void populateFrom(final int position) { final Profile account = getItem(position); Protocol p = RosterHelper.getInstance().getProtocol(account); if (null != p) { ImageView icProtocol = getImageProtocol(); Icon ic = p.getStatusInfo().getIcon((byte) 0); if (ic != null) { icProtocol.setVisibility(ImageView.VISIBLE); icProtocol.setImageDrawable(ic.getImage()); } else { icProtocol.setVisibility(ImageView.GONE); } } getTextLogin().setText(account.userId); ToggleButton tb = getToggleButton(); tb.setChecked(account.isActive); tb.setFocusableInTouchMode(false); tb.setFocusable(false); tb.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { ToggleButton t = (ToggleButton) v.findViewById(R.id.toggle_button); account.isActive = t.isChecked(); RosterHelper.getInstance().setCurrentProtocol(); Options.saveAccount(account); notifyDataSetChanged(); } }); }
@Override public void onServiceConnected(ComponentName className, IBinder serviceBinder) { Log.d("MainActivity", "service connected"); // bound with Service. get Service instance MediaPlayerService.MediaPlayerBinder binder = (MediaPlayerService.MediaPlayerBinder) serviceBinder; mService = binder.getService(); // send this instance to the service, so it can make callbacks on // this instance as a client mService.setClient(ListenFragment.this); mBound = true; // Set play/pause button to reflect state of the service's contained // player final ToggleButton playPauseButton = (ToggleButton) rootView.findViewById(R.id.playPauseButton); playPauseButton.setChecked(mService.getMediaPlayer().isPlaying()); // Set station Picker to show currently set stream station Spinner stationPicker = (Spinner) rootView.findViewById(R.id.stationPicker); if (mService.getMediaPlayer() != null && mService.getMediaPlayer().getStreamStation() != null) { for (int i = 0; i < RadioList.ALl_STATIONS.length; i++) { if (mService.getMediaPlayer().getStreamStation().equals(RadioList.ALl_STATIONS[i])) { stationPicker.setSelection(i); mSelectedStream = (StreamStation) stationPicker.getItemAtPosition(i); } } } }
@Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row == null) { LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.channelsitem, parent, false); } Channel channel = getItem(position); TextView channelName = (TextView) row.findViewById(R.id.txtName); TextView channelCreated = (TextView) row.findViewById(R.id.txtCreated); ToggleButton tg = (ToggleButton) row.findViewById(R.id.toggleButton1); tg.setOnClickListener(myCheckChangList); tg.setTag(position); if (channel.name != null) { channelName.setText(channel.name); } if (channel.created != null) { channelCreated.setText(channel.created); } if (channel.send != null) { tg.setChecked(channel.send); channelName.setTextColor(Color.BLACK); } return row; }
private void toggleWifiRepeater(final ToggleButton button) { startBlinkingImage((ImageView) findViewById(R.id.wifiRepeaterArrow)); if (button.isChecked()) { final File flagFile = new File("/data/data/fq.router2/etc/wifi-repeater-risk-notified"); if (flagFile.exists()) { startWifiRepater(); } else { new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(R.string.wifi_repeater_risk_alert_title) .setMessage(R.string.wifi_repeater_risk_alert_message) .setPositiveButton(R.string.wifi_repeater_risk_alert_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { IOUtils.writeToFile(flagFile, "OK"); startWifiRepater(); button.setChecked(true); } }) .setNegativeButton(R.string.wifi_repeater_risk_alert_cancel, null) .show(); button.setChecked(false); } } else { startBlinkingStatus(_(R.string.status_wifi_repeater_stopping)); disableWifiRepeaterButton(); StopWifiRepeaterService.execute(this); } }
@Override public void onLoadFinished(Loader<HttpRequestResult> arg0, HttpRequestResult result) { if (result.getResponseCode() == 0) { try { WTApplication application = WTApplication.getInstance(); JSONObject json = new JSONObject(result.getStrResponseCon()); application.session = json.getString("Session"); AccountManager am = AccountManager.get(this); Account[] ac = am.getAccountsByType(WTApplication.ACCOUNT_TYPE); am.setAuthToken(ac[0], WTApplication.AUTHTOKEN_TYPE, application.session); Toast.makeText( this, getResources().getString(R.string.update_password_success), Toast.LENGTH_SHORT) .show(); btnConfirm.setChecked(false); ApiHelper.getInstance(this).setSession(application.session); finish(); } catch (JSONException e) { e.printStackTrace(); } } else { ExceptionToast.show(this, result.getResponseCode()); } }
@Override protected final void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MainActivityMenu menuView = new MainActivityMenu(this); layout_ = menuView.getLayout(); name_ = (EditText) layout_.findViewById(R.id.name); name_.addTextChangedListener(new NameListener(this)); text_ = (TextView) layout_.findViewById(R.id.text); text_.setText(""); menuButton_ = (ToggleButton) layout_.findViewById(R.id.menuButton); menuButton_.setChecked(true); menuButton_.setOnClickListener(new MenuButtonListener(layout_, menuButton_)); validButton_ = (Button) layout_.findViewById(R.id.nameButton); // Add an animation on start up Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.view_animation); validButton_.startAnimation(animation); // Add touch listener validButton_.setOnTouchListener(new ValidButtonListener(text_, name_, validButton_)); // Set keyboard hidden by default getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // Set theme according to preferences setTheme(); setContentView(layout_); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_server); // init sPref = PreferenceManager.getDefaultSharedPreferences(this); ipView = (TextView) findViewById(R.id.IPField); portView = (TextView) findViewById(R.id.portField); startStop = (ToggleButton) findViewById(R.id.start_stop); // initialise with the correct value first, so that a started server will definitely be killed // again startStop.setChecked(sPref.getBoolean("SERVER_STARTED", false)); startStop.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sPref.edit().putBoolean("SERVER_STARTED", true).commit(); startServer(); } else { stopServer(); sPref.edit().putBoolean("SERVER_STARTED", false).commit(); } } }); address = getWiFiIP(); ipView.setText(address.getHostAddress()); portView.setText(String.valueOf(port)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.settings); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences.Editor editor = prefs.edit(); if (prefs.getBoolean(PREF_LANDSCAPE, false)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } ToggleButton toggleLandscape = (ToggleButton) findViewById(R.id.toggle_landscape_mode); toggleLandscape.setChecked(prefs.getBoolean(PREF_LANDSCAPE, false)); toggleLandscape.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { editor.putBoolean(PREF_LANDSCAPE, isChecked); editor.apply(); } }); setResult(BACK_FROM_SETTINGS); }
private void clearFormatBarButtons() { for (ToggleButton button : mTagToggleButtonMap.values()) { if (button != null) { button.setChecked(false); } } }
public ToggleMenuItem( Context context, String label, int imgRes, boolean isToggle, OnCheckedChangeListener listener) { super(context); View.inflate(context, R.layout.sw_menu_item_toggle, this); itemLabel = (TextView) findViewById(R.id.textLabel); itemIcon = (ImageView) findViewById(R.id.imageView); toggleButton = (ToggleButton) findViewById(R.id.toggleButton); if (imgRes != 0) { itemIcon.setImageResource(imgRes); itemIcon.setVisibility(VISIBLE); } else { itemIcon.setVisibility(GONE); } itemLabel.setText(label); toggleButton.setChecked(isToggle); toggleButton.setOnCheckedChangeListener(listener); }
// 初始化歌曲列表 private void initLocalMusicList() { // fileInfos = MediaUtil.getFileInfos(getApplicationContext()); //获取歌曲对象集合 setListAdpter(MediaUtil.getMusicMaps(fileInfos)); // 显示歌曲列表 music_siger_tv.setText(fileInfos.get(listPosition).getArtist()); music_name_tv.setText(fileInfos.get(listPosition).getTitle()); music_play_bt.setPressed(play_bt_press); music_play_bt.setChecked(play_bt_check); anim = ObjectAnimator.ofFloat(music_album_iv, "rotation", 0, 360); lin = new LinearInterpolator(); anim.setDuration(6000); anim.setRepeatCount(-1); anim.setRepeatMode(ObjectAnimator.RESTART); anim.setInterpolator(lin); // 匀速 PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("alpha", 1f, 0f, 1f); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("scaleX", 1f, 0, 1f); PropertyValuesHolder pvhZ = PropertyValuesHolder.ofFloat("scaleY", 1f, 0, 1f); animSongName = ObjectAnimator.ofPropertyValuesHolder(music_name_tv, pvhX, pvhY, pvhZ); // 渐现 animSongName.setDuration(1000); animSongName.setRepeatCount(0); animSongName.setRepeatMode(ObjectAnimator.RESTART); animSongSinger = ObjectAnimator.ofPropertyValuesHolder(music_siger_tv, pvhX, pvhY, pvhZ); // 渐现 animSongSinger.setDuration(1000); animSongSinger.setRepeatCount(0); animSongSinger.setRepeatMode(ObjectAnimator.RESTART); }
@Override protected void onResume() { super.onResume(); if (isMyServiceRunning(LocationService.class)) { startButton.setChecked(true); } }