android.widget.ViewSwitcher Java Examples
The following examples show how to use
android.widget.ViewSwitcher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SingleInputFormActivity.java From material-singleinputform with MIT License | 6 votes |
private void setupDetails(){ detailsSwitcher.setInAnimation(getAnimation(R.anim.alpha_in, true)); detailsSwitcher.setOutAnimation(getAnimation(R.anim.alpha_out, false)); detailsSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_details, titleSwitcher, false); if (view != null && detailsTextColor != -1) { view.setTextColor(detailsTextColor); } return view; } }); detailsSwitcher.setText(""); }
Example #2
Source File: ViewSwitcherWrapper.java From Android-Notification with Apache License 2.0 | 6 votes |
private void updateAnimation() { View view = getView(); if (view == null) { return; } ViewSwitcher viewSwitcher = (ViewSwitcher) view; if (viewSwitcher.getInAnimation() != mInAnimation || mInAnimation == null) { if (mInAnimation == null) { mInAnimation = AnimationFactory.pushDownIn(); } if (viewSwitcher instanceof TextSwitcher) { mInAnimation.setAnimationListener(mTextViewInAnimationListener); } mInAnimation.setDuration(mInDuration); viewSwitcher.setInAnimation(mInAnimation); } if (viewSwitcher.getOutAnimation() != mOutAnimation || mOutAnimation == null) { if (mOutAnimation == null) { mOutAnimation = AnimationFactory.pushDownOut(); } mOutAnimation.setDuration(mOutDuration); viewSwitcher.setOutAnimation(mOutAnimation); } }
Example #3
Source File: MainActivity.java From NFCard with GNU General Public License v3.0 | 6 votes |
private void initViews() { board = (ViewSwitcher) findViewById(R.id.switcher); Typeface tf = ThisApplication.getFontResource(R.string.font_oem1); TextView tv = (TextView) findViewById(R.id.txtAppName); tv.setTypeface(tf); tf = ThisApplication.getFontResource(R.string.font_oem2); tv = getFrontPage(); tv.setMovementMethod(LinkMovementMethod.getInstance()); tv.setTypeface(tf); tv = getBackPage(); tv.setMovementMethod(LinkMovementMethod.getInstance()); tv.setTypeface(tf); toolbar = new Toolbar((ViewGroup) findViewById(R.id.toolbar)); }
Example #4
Source File: DropInActivityUnitTest.java From braintree-android-drop-in with MIT License | 6 votes |
@Test public void onActivityResult_vaultedPaymentEditedReturnsToDropIn() { setup(mock(BraintreeFragment.class)); PayPalAccountNonce paypalNonce = mock(PayPalAccountNonce.class); when(paypalNonce.getDescription()).thenReturn("paypal-nonce"); ArrayList<Parcelable> paymentMethodNonces = new ArrayList<Parcelable>(); paymentMethodNonces.add(paypalNonce); assertEquals(0, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher)).getDisplayedChild()); mActivity.onActivityResult(DELETE_PAYMENT_METHOD_NONCE_CODE, RESULT_OK, new Intent() .putExtra("com.braintreepayments.api.EXTRA_PAYMENT_METHOD_NONCES", paymentMethodNonces)); assertEquals(1, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher)).getDisplayedChild()); }
Example #5
Source File: ToastersAdapter.java From SectionCursorAdapter with Apache License 2.0 | 6 votes |
@Override protected void bindItemView(View convertView, Context context, Cursor cursor) { final ToasterModel toaster = new ToasterModel(); toaster.loadFromCursor(cursor); final ViewHolder holder = (ViewHolder) convertView.getTag(); holder.txtName.setText(toaster.name); holder.txtJob.setText(toaster.jobDescription); Picasso.with(context).load(toaster.imageUrl) .error(R.drawable.toaster_backup).transform(mToasterTrans) .into(holder.imgToaster); Picasso.with(context).load(toaster.imageUrl) .error(R.drawable.toaster_backup).transform(mHumanTrans) .into(holder.imgHuman); // Reseting the view our switcher is showing. switchWithoutAnimation(holder.switcher); holder.switcher.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((ViewSwitcher) v).showNext(); } }); }
Example #6
Source File: MainActivity.java From nfcard with GNU General Public License v3.0 | 6 votes |
private void initViews() { board = (ViewSwitcher) findViewById(R.id.switcher); Typeface tf = ThisApplication.getFontResource(R.string.font_oem1); TextView tv = (TextView) findViewById(R.id.txtAppName); tv.setTypeface(tf); tf = ThisApplication.getFontResource(R.string.font_oem2); tv = getFrontPage(); tv.setMovementMethod(LinkMovementMethod.getInstance()); tv.setTypeface(tf); tv = getBackPage(); tv.setMovementMethod(LinkMovementMethod.getInstance()); tv.setTypeface(tf); toolbar = new Toolbar((ViewGroup) findViewById(R.id.toolbar)); }
Example #7
Source File: ListContentFragment.java From BatteryFu with GNU General Public License v2.0 | 6 votes |
public void setContent(Fragment content) { Fragment last = mCurrentContent; mCurrentContent = content; FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); if (last != null) ft.replace(R.id.content, mCurrentContent); else ft.add(R.id.content, mCurrentContent); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); if (mContainer instanceof ViewSwitcher) { ViewSwitcher switcher = (ViewSwitcher)mContainer; if (mContent != switcher.getCurrentView()) switcher.showNext(); } ft.commit(); }
Example #8
Source File: WebFragment.java From materialistic with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { if (isNewInstance()) { mFragmentView = inflater.inflate(R.layout.fragment_web, container, false); mFullscreenView = (ViewGroup) mFragmentView.findViewById(R.id.fullscreen); mScrollViewContent = (ViewGroup) mFragmentView.findViewById(R.id.scroll_view_content); mScrollView = (NestedScrollView) mFragmentView.findViewById(R.id.nested_scroll_view); mControls = (ViewSwitcher) mFragmentView.findViewById(R.id.control_switcher); mWebView = (WebView) mFragmentView.findViewById(R.id.web_view); mButtonRefresh = (ImageButton) mFragmentView.findViewById(R.id.button_refresh); mButtonMore = mFragmentView.findViewById(R.id.button_more); mButtonNext = mFragmentView.findViewById(R.id.button_next); mButtonNext.setEnabled(false); mEditText = (EditText) mFragmentView.findViewById(R.id.edittext); setUpWebControls(mFragmentView); setUpWebView(mFragmentView); } return mFragmentView; }
Example #9
Source File: WelcomeToSummonerRift.java From Theogony with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.welcome_to_summoner_rift); ButterKnife.bind(this); mProcessTv.setInAnimation(this, R.anim.bottom_in); mProcessTv.setOutAnimation(this, R.anim.top_out); mProcessTv.setFactory(new ViewSwitcher.ViewFactory() { @Override public TextView makeView() { TextView textView = (TextView) LayoutInflater.from(WelcomeToSummonerRift.this) .inflate(R.layout.progress_text, null); return textView; } }); }
Example #10
Source File: CommonXlistEmptyViews.java From BaseProject with Apache License 2.0 | 6 votes |
private void initViews(Context context) { //与梦想列表同布局 inflate(context, R.layout.common_empty_xlistview_layout, this); llContainerView = (LinearLayout)findViewById(R.id.ll_contaner_view); vsLayout = (ViewSwitcher)findViewById(R.id.vs_view_switcher); emptyLayout = (EmptyLayout)findViewById(R.id.empty_layout_4_loading); emptyLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { emptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING); onRefresh(); } }); xListView = (XListView) findViewById(R.id.activity_searchfriends_data_listview); xListView.setXListViewListener(this); }
Example #11
Source File: AddCardActivityUnitTest.java From braintree-android-drop-in with MIT License | 6 votes |
@Test public void configurationChangeReturnsToEditCardView() { BraintreeUnitTestHttpClient httpClient = new BraintreeUnitTestHttpClient() .configuration(new TestConfigurationBuilder() .creditCards(getSupportedCardConfiguration()) .build()); setup(httpClient); setText(mAddCardView, R.id.bt_card_form_card_number, VISA); assertThat(mEditCardView).isVisible(); assertThat(mAddCardView).isGone(); assertEquals(1, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher)) .getDisplayedChild()); assertThat(mEnrollmentCardView).isGone(); triggerConfigurationChange(httpClient); assertThat(mEditCardView).isVisible(); assertThat(mAddCardView).isGone(); assertEquals(1, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher)) .getDisplayedChild()); assertThat(mEnrollmentCardView).isGone(); }
Example #12
Source File: AddCardActivityUnitTest.java From braintree-android-drop-in with MIT License | 6 votes |
@Test public void addingACardRemainsOnEditCardView() { setup(new BraintreeUnitTestHttpClient().configuration(new TestConfigurationBuilder() .creditCards(getSupportedCardConfiguration()) .build())); setText(mAddCardView, R.id.bt_card_form_card_number, VISA); mAddCardView.findViewById(R.id.bt_button).performClick(); setText(mEditCardView, R.id.bt_card_form_expiration, ExpirationDate.VALID_EXPIRATION); mEditCardView.findViewById(R.id.bt_button).performClick(); assertThat(mEditCardView).isVisible(); assertThat(mEditCardView.findViewById(R.id.bt_animated_button_loading_indicator)).isVisible(); assertThat(mEditCardView.findViewById(R.id.bt_button)).isGone(); assertEquals(1, ((ViewSwitcher) mActivity.findViewById(R.id.bt_loading_view_switcher)) .getDisplayedChild()); assertThat(mAddCardView).isGone(); assertThat(mEnrollmentCardView).isGone(); }
Example #13
Source File: LockActivity.java From GankLock with GNU General Public License v3.0 | 6 votes |
@Override protected void initView() { getWindow().addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD); getWindow().addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED); setUI(); SwipeUnLockLayout swipeUnLockLayout = (SwipeUnLockLayout) findViewById( R.id.slide_layout); swipeUnLockLayout.setOnSwipeListener(this); mViewSwitcher = (ViewSwitcher) findViewById(R.id.lock_view_switcher); mTitle = (TextView) findViewById(R.id.lock_view_gank_title); TextView mLockViewDate = (TextView) findViewById(R.id.lock_view_date); final String lockDateText = DateUtil.getLockDateText(); mLockViewDate.setText(lockDateText); mImg = (ImageView) findViewById(R.id.lock_view_img); url = PreferenceUtil.getString("url"); if (url.isEmpty()) { mImg.setImageResource(R.drawable.test_image); } else { getBitmap(); } mImg.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewSwitcher.showNext(); } }); }
Example #14
Source File: MainActivity.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageSwitcher = findViewById(R.id.is); imageSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView iv = new ImageView(MainActivity.this); iv.setScaleType(ImageView.ScaleType.CENTER);//居中显示 //ViewSwitcher 默认给子控件设置match parent,所以此处不设置LayoutParams Log.d("realmo","make View"); //从源码得知,会触发2次(ViewSwitcher : only two child views) return iv; } }); imageSwitcher.setImageResource(resIds[index]);//初始化时显示,必须放在工厂后面,否则会报NullPointerException imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));//设置动画 imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));//设置动画 }
Example #15
Source File: Id3Writer.java From QuickLyric with GNU General Public License v3.0 | 6 votes |
@Override public void onPreExecute() { MainActivity activity = (MainActivity) mActivity.get(); ((DrawerLayout) activity.drawer).setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); mFragment.get().enablePullToRefresh(true); activity.findViewById(R.id.refresh_fab).setEnabled(true); ((RefreshIcon) activity.findViewById(R.id.refresh_fab)).show(); activity.invalidateOptionsMenu(); ViewSwitcher viewSwitcher = activity.findViewById(R.id.switcher); EditText newLyrics = activity.findViewById(R.id.edit_lyrics); viewSwitcher.setVisibility(View.VISIBLE); newLyrics.setVisibility(View.GONE); }
Example #16
Source File: TheHubActivity.java From ToDay with MIT License | 6 votes |
/** * Hides the Options Menu and uses a ViewSwitcher to quick turn the exisiting TextView with the * Flow's name into an EditText for the user to rename. * * @param cardPosition position of cardview in adapter * @param cardViewClicked the cardview view object clicked */ private void renameFlow(final int cardPosition, final View cardViewClicked) { menuState = AppConstants.MENU_ITEMS_HIDE; invalidateOptionsMenu(); final ViewSwitcher switcher = (ViewSwitcher) cardViewClicked.findViewById(R.id.hub_rename_switcher); final EditText rename = (EditText) switcher.findViewById(R.id.hub_item_flow_rename); AppUtils.setNameInputFilters(rename); rename.setOnFocusChangeListener(new View.OnFocusChangeListener() { @RequiresApi(api = Build.VERSION_CODES.KITKAT) @Override public void onFocusChange(View v, boolean hasFocus) { if (rename.hasFocus()) { showEditPopupWindow(rename, cardViewClicked, switcher, cardPosition); } } }); switcher.showNext(); rename.requestFocus(); /* Forces keyboard */ }
Example #17
Source File: NetworkFragment.java From upcKeygen with GNU General Public License v2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { root = (ViewSwitcher) inflater.inflate(R.layout.fragment_network, container, false); messages = (TextView) root.findViewById(R.id.loading_text); final View autoConnect = root.findViewById(R.id.auto_connect); // Auto connect service unavailable for manual calculations if (wifiNetwork.getScanResult() == null) autoConnect.setVisibility(View.GONE); else { final int level = wifiNetwork.getLevel(); } if (passwordList != null) displayResults(); return root; }
Example #18
Source File: SingleInputFormActivity.java From material-singleinputform with MIT License | 6 votes |
private void setupTitle(){ titleSwitcher.setInAnimation(getAnimation(R.anim.slide_in_to_bottom, true)); titleSwitcher.setOutAnimation(getAnimation(R.anim.slide_out_to_top, false)); titleSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_title, titleSwitcher, false); if (view != null) { view.setTextColor(titleTextColor); } return view; } }); titleSwitcher.setText(""); }
Example #19
Source File: AboutActivity.java From FakeWeather with Apache License 2.0 | 6 votes |
@Override protected void initViews(Bundle savedInstanceState) { setDisplayHomeAsUpEnabled(true); tvVersion = findViewById(R.id.tv_app_version); tvVersion.setText("v" + BuildConfig.VERSION_NAME); imageSwitcher = findViewById(R.id.imageSwitcher); imageSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView imageView = new ImageView(AboutActivity.this); imageView.setScaleType(ImageView.ScaleType.FIT_XY); return imageView; } }); imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.zoom_in)); imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.zoom_out)); }
Example #20
Source File: PinView.java From financisto with GNU General Public License v2.0 | 6 votes |
public PinView(Context context, PinListener listener, String pin, int layoutId) { this.context = context; this.listener = listener; this.confirmPin = pin == null; this.pin1 = pin; LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = layoutInflater.inflate(layoutId, null); for (int id : buttons) { v.findViewById(id).setOnClickListener(this); } result = (TextView)v.findViewById(R.id.result1); switcher = (ViewSwitcher)v.findViewById(R.id.switcher); switcher.setInAnimation(inFromRightAnimation()); switcher.setOutAnimation(outToLeftAnimation()); try { digest = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } this.vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); }
Example #21
Source File: VisualizerFragment.java From Musicoco with Apache License 2.0 | 6 votes |
private void initViews() { albumView = (ImageSwitcher) view.findViewById(R.id.play_album_is); albumView.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView imageView = new ImageView(getActivity()); imageView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); int pad = (int) getActivity().getResources().getDimension(R.dimen.play_album_padding); imageView.setPadding(pad, pad, pad, pad); return imageView; } }); DisplayMetrics metrics = Utils.getMetrics(getActivity()); //专辑图片直径 int size = metrics.widthPixels * 2 / 3; albumPictureController = new AlbumPictureController(getActivity(), albumView, size); }
Example #22
Source File: PlayBgDrawableController.java From Musicoco with Apache License 2.0 | 6 votes |
public void initViews() { flRootView = (FrameLayout) activity.findViewById(R.id.play_root); isBg = (ImageSwitcher) activity.findViewById(R.id.play_bg); isBg.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView view = new ImageView(activity); view.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); view.setScaleType(ImageView.ScaleType.CENTER_CROP); return view; } }); }
Example #23
Source File: SingleInputFormActivity.java From material-singleinputform with MIT License | 6 votes |
private void setupError(){ errorSwitcher.setInAnimation(getAnimation(android.R.anim.slide_in_left, true)); errorSwitcher.setOutAnimation(getAnimation(android.R.anim.slide_out_right, false)); errorSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_error, titleSwitcher, false); if (view != null && errorTextColor != -1) { view.setTextColor(errorTextColor); } return view; } }); errorSwitcher.setText(""); }
Example #24
Source File: LyricsViewFragment.java From QuickLyric with GNU General Public License v3.0 | 5 votes |
private void startEditTagsMode() { ImageButton editButton = getActivity().findViewById(R.id.edit_tags_btn); editButton.setImageResource(R.drawable.ic_edit_anim); ((Animatable) editButton.getDrawable()).start(); ((DrawerLayout) ((MainActivity) getActivity()).drawer).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); mRefreshLayout.setEnabled(false); getActivity().findViewById(R.id.refresh_fab).setEnabled(false); ((RefreshIcon) getActivity().findViewById(R.id.refresh_fab)).hide(); ((Toolbar) getActivity().findViewById(R.id.toolbar)).getMenu().clear(); ViewSwitcher viewSwitcher = getActivity().findViewById(R.id.switcher); EditText songTV = getActivity().findViewById(R.id.song); TextView artistTV = getActivity().findViewById(R.id.artist); EditText newLyrics = getActivity().findViewById(R.id.edit_lyrics); newLyrics.setTypeface(LyricsTextFactory.FontCache.get("light", getActivity())); newLyrics.setText(Html.fromHtml(TextUtils.isEmpty(mLyrics.getText()) ? "" : mLyrics.getText()), TextView.BufferType.EDITABLE); viewSwitcher.setVisibility(View.GONE); newLyrics.setVisibility(View.VISIBLE); songTV.setInputType(InputType.TYPE_CLASS_TEXT); artistTV.setInputType(InputType.TYPE_CLASS_TEXT); songTV.setBackgroundResource(R.drawable.abc_textfield_search_material); artistTV.setBackgroundResource(R.drawable.abc_textfield_search_material); if (songTV.requestFocus()) { InputMethodManager imm = (InputMethodManager) getActivity().getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.SHOW_IMPLICIT); } }
Example #25
Source File: EmvReadActivity.java From smartcard-reader with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_activity_emv_read); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.emv_drawer_layout); mNavDrawer = new NavDrawer(this, savedInstanceState, R.id.emv_read, drawerLayout, toolbar); ListView listView = (ListView) findViewById(R.id.msg_list); ViewSwitcher switcher = (ViewSwitcher) findViewById(R.id.switcher); mConsole = new Console(this, savedInstanceState, TEST_MODE_EMV_READ, listView, switcher); mNfcManager = new NfcManager(this, this); ApduParser.init(this); EMVTerminal.loadProperties(getResources()); // persistent "shared preferences" SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE); mEditor = ss.edit(); // persistent settings and settings listener SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); mAutoClear = prefs.getBoolean("pref_auto_clear", true); mShowMsgSeparators = prefs.getBoolean("pref_show_separators", true); String tapFeedback = prefs.getString("pref_tap_feedback", "1"); mTapFeedback = Integer.valueOf(tapFeedback); mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); }
Example #26
Source File: LyricsViewFragment.java From QuickLyric with GNU General Public License v3.0 | 5 votes |
private void showFirstStart() { stopRefreshAnimation(); LayoutInflater inflater = LayoutInflater.from(getActivity()); ViewGroup parent = (ViewGroup) ((ViewGroup) getActivity().findViewById(R.id.scrollview)).getChildAt(0); if (parent.findViewById(R.id.tracks_msg) == null) inflater.inflate(R.layout.no_tracks, parent); TypedValue typedValue = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.firstLaunchCoverDrawable, typedValue, true); int firstLaunchBGid = typedValue.resourceId; @SuppressWarnings("deprecation") BitmapDrawable bd = ((BitmapDrawable) getResources().getDrawable(firstLaunchBGid)); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); setCoverArt(bd != null ? bd.getBitmap() : null, null, true); ViewSwitcher viewSwitcher = getActivity().findViewById(R.id.switcher); if (viewSwitcher.getChildCount() > 1) viewSwitcher.removeViewAt(0); viewSwitcher.addView(new View(getActivity())); viewSwitcher.showNext(); int themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0")); if (themeNum > 0 && themeNum != 7) { TypedValue darkColorValue = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.colorPrimaryDark, darkColorValue, true); ((FadeInNetworkImageView) getActivity().findViewById(R.id.cover)) .setColorFilter(darkColorValue.data, PorterDuff.Mode.OVERLAY); } getActivity().findViewById(R.id.error_msg).setVisibility(View.INVISIBLE); ((TextView) getActivity().findViewById(R.id.artist)).setText(""); ((TextView) getActivity().findViewById(R.id.song)).setText(""); getActivity().findViewById(R.id.top_gradient).setVisibility(View.INVISIBLE); getActivity().findViewById(R.id.bottom_gradient).setVisibility(View.INVISIBLE); getActivity().findViewById(R.id.edit_tags_btn).setVisibility(View.INVISIBLE); }
Example #27
Source File: MainActivity.java From journaldev with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mTextSwitcher = (TextSwitcher) findViewById(R.id.textSwitcher); mTextSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView textView = new TextView(MainActivity.this); textView.setTextSize(18); textView.setGravity(Gravity.CENTER); return textView; } }); mTextSwitcher.setInAnimation(this, android.R.anim.fade_in); mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out); mImageSwitcher = (ImageSwitcher) findViewById(R.id.imageSwitcher); mImageSwitcher.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { ImageView imageView = new ImageView(MainActivity.this); return imageView; } }); mImageSwitcher.setInAnimation(this, android.R.anim.slide_in_left); mImageSwitcher.setOutAnimation(this, android.R.anim.slide_out_right); onSwitch(null); }
Example #28
Source File: DashboardFragment.java From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { mViewSwitcher = (ViewSwitcher) view; mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); final int spanCount = getResources().getInteger(R.integer.column_nums); mAdapter = new DashboardItemAdapter(getActivity(), getAccessFromBundle(getArguments()), spanCount, this); GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), spanCount); gridLayoutManager.setOrientation(GridLayoutManager.VERTICAL); gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return mAdapter.getSpanSize(position); } }); mRecyclerView.setLayoutManager(gridLayoutManager); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mRecyclerView.addItemDecoration(new GridDividerDecoration(getActivity() .getApplicationContext())); mRecyclerView.setAdapter(mAdapter); }
Example #29
Source File: WebFragmentTest.java From materialistic with Apache License 2.0 | 5 votes |
@Test public void testSearch() { LocalBroadcastManager.getInstance(activity) .sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN) .putExtra(WebFragment.EXTRA_FULLSCREEN, true)); activity.findViewById(R.id.button_find).performClick(); ViewSwitcher controlSwitcher = activity.findViewById(R.id.control_switcher); assertThat(controlSwitcher.getDisplayedChild()).isEqualTo(1); ShadowWebView shadowWebView = Shadow.extract(activity.findViewById(R.id.web_view)); // no query EditText editText = activity.findViewById(R.id.edittext); shadowOf(editText).getOnEditorActionListener().onEditorAction(null, 0, null); assertThat((View) activity.findViewById(R.id.button_next)).isDisabled(); // with results shadowWebView.setFindCount(1); editText.setText("abc"); shadowOf(editText).getOnEditorActionListener().onEditorAction(null, 0, null); assertThat((View) activity.findViewById(R.id.button_next)).isEnabled(); activity.findViewById(R.id.button_next).performClick(); assertThat(shadowWebView.getFindIndex()).isEqualTo(1); activity.findViewById(R.id.button_clear).performClick(); assertThat(editText).isEmpty(); assertThat(controlSwitcher.getDisplayedChild()).isEqualTo(0); // with no results shadowWebView.setFindCount(0); editText.setText("abc"); shadowOf(editText).getOnEditorActionListener().onEditorAction(null, 0, null); assertThat((View) activity.findViewById(R.id.button_next)).isDisabled(); assertThat(ShadowToast.getTextOfLatestToast()).contains(activity.getString(R.string.no_matches)); }
Example #30
Source File: JobsFragment.java From here-android-sdk-examples with Apache License 2.0 | 5 votes |
ViewHolder(View item) { jobId = (TextView) item.findViewById(R.id.job_id); jobMessage = (TextView) item.findViewById(R.id.job_message); jobTime = (TextView) item.findViewById(R.id.job_time); jobDate = (TextView) item.findViewById(R.id.job_date); jobStateSwitcher = (ViewSwitcher) item.findViewById(R.id.job_state_switcher); }