Search in sources :

Example 61 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project ExpandTextView by mugku.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    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();
        }
    });
    ExpandableTextView expTv1 = (ExpandableTextView) this.findViewById(R.id.expand_text_view);
    expTv1.setText(getString(R.string.dummy_text1));
}
Also used : ExpandableTextView(com.github.dubu.expandabletextview.ExpandableTextView) FloatingActionButton(android.support.design.widget.FloatingActionButton) ExpandableTextView(com.github.dubu.expandabletextview.ExpandableTextView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 62 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project material-design-dimens by DmitryMalkovich.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    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();
        }
    });
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 63 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project Shuttle by timusus.

the class DetailFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_detail, container, false);
    recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapter);
    if (canEdit()) {
        itemTouchHelper = new ItemTouchHelper(new ItemTouchHelperCallback((from, to) -> {
            long songViewCount = Stream.of(adapter.items).filter(adaptableItem -> adaptableItem instanceof SongView).count();
            int offset = (int) (adapter.getItemCount() - songViewCount);
            if (to >= offset) {
                adapter.moveItem(from, to);
            }
        }, (from, to) -> {
            // The 'offset' here is the number of items in the list which are not
            // SongViews. We need this to determine the actual playlist positions of the items.
            long songViewCount = Stream.of(adapter.items).filter(adaptableItem -> adaptableItem instanceof SongView).count();
            int offset = (int) (adapter.getItemCount() - songViewCount);
            from -= offset;
            to -= offset;
            try {
                MediaStore.Audio.Playlists.Members.moveItem(getActivity().getContentResolver(), playlist.id, from, to);
            } catch (IllegalArgumentException e) {
                CrashlyticsCore.getInstance().log(String.format("Failed to move playlist item from %s to %s. Adapter count: %s. Error:%s", from, to, adapter.getItemCount(), e.getMessage()));
            }
        }, null));
        itemTouchHelper.attachToRecyclerView(recyclerView);
    }
    fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    fab.setOnClickListener(this);
    lineOne = (TextView) rootView.findViewById(R.id.line_one);
    lineTwo = (TextView) rootView.findViewById(R.id.line_two);
    overflowButton = (NonScrollImageButton) rootView.findViewById(R.id.btn_overflow);
    overflowButton.setOnClickListener(this);
    if (albumArtist != null) {
        lineOne.setText(albumArtist.name);
        overflowButton.setContentDescription(getString(R.string.btn_options, albumArtist.name));
    } else if (album != null) {
        lineOne.setText(album.name);
        overflowButton.setContentDescription(getString(R.string.btn_options, album.name));
    } else if (genre != null) {
        lineOne.setText(genre.name);
        overflowButton.setVisibility(View.GONE);
    } else if (playlist != null) {
        lineOne.setText(playlist.name);
        overflowButton.setContentDescription(getString(R.string.btn_options, playlist.name));
    }
    textProtectionScrim = rootView.findViewById(R.id.textProtectionScrim);
    headerImageView = (ImageView) rootView.findViewById(R.id.background);
    String transitionName = getArguments().getString(ARG_TRANSITION_NAME);
    ViewCompat.setTransitionName(headerImageView, transitionName);
    if (transitionName != null) {
        textProtectionScrim.setVisibility(View.GONE);
        fab.setVisibility(View.GONE);
    }
    int width = ResourceUtils.getScreenSize().width + ResourceUtils.toPixels(60);
    int height = getResources().getDimensionPixelSize(R.dimen.header_view_height);
    if (albumArtist != null || album != null) {
        requestManager.load(albumArtist == null ? album : albumArtist).override(width, height).diskCacheStrategy(DiskCacheStrategy.SOURCE).priority(Priority.HIGH).placeholder(GlideUtils.getPlaceHolderDrawable(albumArtist == null ? album.name : albumArtist.name, false)).centerCrop().animate(new AlwaysCrossFade(false)).into(headerImageView);
    }
    actionMode = null;
    //Set the RecyclerView HeaderView height equal to the headerItem height
    headerView = rootView.findViewById(R.id.headerView);
    headerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            headerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            DetailFragment.this.headerItem.height = headerView.getHeight();
        }
    });
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            headerTranslation = headerView.getTranslationY() - dy;
            headerImageTranslation = headerImageView.getTranslationY() + dy / 2;
            //the header translation.
            if (headerTranslation == 0) {
                headerImageTranslation = 0;
            }
            float ratio = Math.min(1, -headerTranslation / headerView.getHeight());
            headerView.setTranslationY(headerTranslation);
            headerImageView.setTranslationY(headerImageTranslation);
            //when recreating this fragment.
            if (getActivity() != null) {
                if (((MainActivity) getActivity()).canSetAlpha()) {
                    ((MainActivity) getActivity()).setActionBarAlpha(ratio, true);
                }
            }
        }
    });
    themeUIComponents();
    headerView.setTranslationY(headerTranslation);
    headerImageView.setTranslationY(headerImageTranslation);
    return rootView;
}
Also used : ModalMultiSelectorCallback(com.bignerdranch.android.multiselector.ModalMultiSelectorCallback) R(com.simplecity.amp_library.R) Genre(com.simplecity.amp_library.model.Genre) Bundle(android.os.Bundle) SongView(com.simplecity.amp_library.ui.modelviews.SongView) CrashlyticsCore(com.crashlytics.android.core.CrashlyticsCore) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Random(java.util.Random) ItemAdapter(com.simplecity.amp_library.ui.adapters.ItemAdapter) ColorStateList(android.content.res.ColorStateList) Song(com.simplecity.amp_library.model.Song) Priority(com.bumptech.glide.Priority) RequestManager(com.bumptech.glide.RequestManager) HorizontalAlbumView(com.simplecity.amp_library.ui.modelviews.HorizontalAlbumView) MediaStore(android.provider.MediaStore) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) Schedulers(rx.schedulers.Schedulers) View(android.view.View) DetailAdapter(com.simplecity.amp_library.ui.adapters.DetailAdapter) ResourceUtils(com.simplecity.amp_library.utils.ResourceUtils) ViewCompat(android.support.v4.view.ViewCompat) Transition(android.transition.Transition) PreferenceManager(android.preference.PreferenceManager) ItemTouchHelperCallback(com.simplecity.amp_library.ui.recyclerview.ItemTouchHelperCallback) FloatingActionButton(android.support.design.widget.FloatingActionButton) SortManager(com.simplecity.amp_library.utils.SortManager) ActionMode(android.support.v7.view.ActionMode) Playlist(com.simplecity.amp_library.model.Playlist) MainActivity(com.simplecity.amp_library.ui.activities.MainActivity) ObjectAnimator(android.animation.ObjectAnimator) IntentFilter(android.content.IntentFilter) PopupMenu(android.support.v7.widget.PopupMenu) SubMenu(android.view.SubMenu) BroadcastReceiver(android.content.BroadcastReceiver) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) BaseAdaptableItem(com.simplecity.amp_library.ui.modelviews.BaseAdaptableItem) NonScrollImageButton(com.simplecity.amp_library.ui.views.NonScrollImageButton) Serializable(java.io.Serializable) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) TextView(android.widget.TextView) PermissionUtils(com.simplecity.amp_library.utils.PermissionUtils) GlideUtils(com.simplecity.amp_library.glide.utils.GlideUtils) AdaptableItem(com.simplecity.amp_library.model.AdaptableItem) Subscription(rx.Subscription) Context(android.content.Context) Album(com.simplecity.amp_library.model.Album) Stream(com.annimon.stream.Stream) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) DrawableUtils(com.simplecity.amp_library.utils.DrawableUtils) Intent(android.content.Intent) StringUtils(com.simplecity.amp_library.utils.StringUtils) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Observable(rx.Observable) ThemeUtils(com.simplecity.amp_library.utils.ThemeUtils) ColorUtils(com.simplecity.amp_library.utils.ColorUtils) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) Menu(android.view.Menu) AnimatorSet(android.animation.AnimatorSet) WeakReference(java.lang.ref.WeakReference) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) SharedElementCallback(android.support.v4.app.SharedElementCallback) AlwaysCrossFade(com.simplecity.amp_library.glide.utils.AlwaysCrossFade) ViewType(com.simplecity.amp_library.ui.modelviews.ViewType) Collectors(com.annimon.stream.Collectors) LayoutInflater(android.view.LayoutInflater) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DiscNumberView(com.simplecity.amp_library.ui.modelviews.DiscNumberView) DialogUtils(com.simplecity.amp_library.utils.DialogUtils) TimeUnit(java.util.concurrent.TimeUnit) CompositeSubscription(rx.subscriptions.CompositeSubscription) RecyclerView(android.support.v7.widget.RecyclerView) BlacklistHelper(com.simplecity.amp_library.sql.databases.BlacklistHelper) Glide(com.bumptech.glide.Glide) SharedPreferences(android.content.SharedPreferences) HorizontalRecyclerView(com.simplecity.amp_library.ui.modelviews.HorizontalRecyclerView) OvershootInterpolator(android.view.animation.OvershootInterpolator) MultiSelector(com.bignerdranch.android.multiselector.MultiSelector) ComparisonUtils(com.simplecity.amp_library.utils.ComparisonUtils) ViewTreeObserver(android.view.ViewTreeObserver) DataManager(com.simplecity.amp_library.utils.DataManager) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) Operators(com.simplecity.amp_library.utils.Operators) Collections(java.util.Collections) ContentUris(android.content.ContentUris) SongView(com.simplecity.amp_library.ui.modelviews.SongView) AlwaysCrossFade(com.simplecity.amp_library.glide.utils.AlwaysCrossFade) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ItemTouchHelperCallback(com.simplecity.amp_library.ui.recyclerview.ItemTouchHelperCallback) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) RecyclerView(android.support.v7.widget.RecyclerView) HorizontalRecyclerView(com.simplecity.amp_library.ui.modelviews.HorizontalRecyclerView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 64 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project LeMondeRssReader by MBach.

the class ArticleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initActivityTransitions();
    setContentView(R.layout.activity_article);
    appBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    articleActivityRecyclerView = (ScrollFeedbackRecyclerView) findViewById(R.id.articleActivityRecyclerView);
    articleActivityRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    setSupportActionBar(toolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fabProgressCircle = (FABProgressCircle) findViewById(R.id.fabProgressCircle);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            fabProgressCircle.show();
            List<Model> comments = loadMoreComments();
            fabProgressCircle.hide();
            if (comments.isEmpty()) {
                Snackbar.make(findViewById(R.id.coordinatorArticle), "Pas de nouveau commentaire", Snackbar.LENGTH_LONG).show();
            } else {
                ArticleAdapter adapter = (ArticleAdapter) articleActivityRecyclerView.getAdapter();
                adapter.insertItems(comments);
            }
        }
    });
    //ViewCompat.setTransitionName(appBarLayout, Constants.EXTRA_RSS_IMAGE);
    //supportPostponeEnterTransition();
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
        collapsingToolbar.setTitle(extras.getString(Constants.EXTRA_NEWS_CATEGORY));
        final ImageView imageView = (ImageView) findViewById(R.id.imageArticle);
        Picasso.with(getBaseContext()).load(extras.getString(Constants.EXTRA_RSS_IMAGE)).into(imageView);
        try {
            Document doc = Jsoup.connect(extras.getString(Constants.EXTRA_RSS_LINK)).get();
            if (doc.getElementById("teaser_article") != null) {
                TextView paidArticle = (TextView) findViewById(R.id.paidArticle);
                paidArticle.setVisibility(View.VISIBLE);
            }
            Elements articles = doc.getElementsByTag("article");
            List<Model> items = null;
            if (!articles.isEmpty()) {
                Elements category = doc.select("div.tt_rubrique_ombrelle");
                if (atLeastOneChild(category)) {
                    getSupportActionBar().setTitle(category.text());
                }
                items = extractStandardArticle(articles);
                items.addAll(loadAndExtractCommentPreview(doc.getElementById("liste_reactions")));
            } else if (doc.getElementById("content") != null) {
                items = extractBlogArticle(doc);
            }
            if (items != null && !items.isEmpty()) {
                articleActivityRecyclerView.setAdapter(new ArticleAdapter(items));
            }
        } catch (IOException e) {
            Log.d(TAG, e.getMessage());
        }
    }
}
Also used : Bundle(android.os.Bundle) IOException(java.io.IOException) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) FloatingActionButton(android.support.design.widget.FloatingActionButton) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) ArrayList(java.util.ArrayList) List(java.util.List) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 65 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project LeMondeRssReader by MBach.

the class ScrollFeedbackRecyclerView method onScrolled.

@Override
public void onScrolled(int dx, int dy) {
    LinearLayoutManager layout = (LinearLayoutManager) getLayoutManager();
    if (layout.findFirstCompletelyVisibleItemPosition() == 0) {
        if (callbacks != null && callbacks.get().isAppBarCollapsed()) {
            callbacks.get().setExpanded(true);
        }
    }
    if (layout.findLastCompletelyVisibleItemPosition() == getLayoutManager().getItemCount() - 1) {
        fab.show(new FloatingActionButton.OnVisibilityChangedListener() {

            @Override
            public void onShown(FloatingActionButton fab) {
                super.onShown(fab);
                fabProgressCircle.setVisibility(VISIBLE);
            }
        });
    } else {
        fab.hide(new FloatingActionButton.OnVisibilityChangedListener() {

            @Override
            public void onHidden(FloatingActionButton fab) {
                super.onShown(fab);
                fabProgressCircle.setVisibility(INVISIBLE);
            }
        });
    }
    super.onScrolled(dx, dy);
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

FloatingActionButton (android.support.design.widget.FloatingActionButton)79 View (android.view.View)56 Toolbar (android.support.v7.widget.Toolbar)29 TextView (android.widget.TextView)18 ImageView (android.widget.ImageView)15 Intent (android.content.Intent)12 RecyclerView (android.support.v7.widget.RecyclerView)11 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 ColorStateList (android.content.res.ColorStateList)8 Bundle (android.os.Bundle)8 NavigationView (android.support.design.widget.NavigationView)8 TabLayout (android.support.design.widget.TabLayout)8 ViewPager (android.support.v4.view.ViewPager)8 ActionBar (android.support.v7.app.ActionBar)7 UiController (android.support.test.espresso.UiController)6 ViewAction (android.support.test.espresso.ViewAction)6 AdapterView (android.widget.AdapterView)6 DrawerLayout (android.support.v4.widget.DrawerLayout)4 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)4 MenuItem (android.view.MenuItem)4