Search in sources :

Example 21 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTabFragmentParentFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_viewpagertabfragment_parent, container, false);
    AppCompatActivity parentActivity = (AppCompatActivity) getActivity();
    mPagerAdapter = new NavigationAdapter(getChildFragmentManager());
    mPager = (ViewPager) view.findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(mPager);
    ViewConfiguration vc = ViewConfiguration.get(parentActivity);
    mSlop = vc.getScaledTouchSlop();
    mInterceptionLayout = (TouchInterceptionFrameLayout) view.findViewById(R.id.container);
    mInterceptionLayout.setScrollInterceptionListener(mInterceptionListener);
    return view;
}
Also used : ViewConfiguration(android.view.ViewConfiguration) AppCompatActivity(android.support.v7.app.AppCompatActivity) SlidingTabLayout(com.google.samples.apps.iosched.ui.widget.SlidingTabLayout) View(android.view.View)

Example 22 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project material-components-android by material-components.

the class AppBarLayoutBaseTest method configureContent.

@CallSuper
protected void configureContent(@LayoutRes final int layoutResId, @StringRes final int titleResId) throws Throwable {
    onView(withId(R.id.coordinator_stub)).perform(inflateViewStub(layoutResId));
    mAppBar = (AppBarLayout) mCoordinatorLayout.findViewById(R.id.app_bar);
    mCollapsingToolbar = (CollapsingToolbarLayout) mAppBar.findViewById(R.id.collapsing_app_bar);
    mToolbar = (Toolbar) mAppBar.findViewById(R.id.toolbar);
    final AppCompatActivity activity = activityTestRule.getActivity();
    activityTestRule.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            activity.setSupportActionBar(mToolbar);
        }
    });
    final CharSequence activityTitle = activity.getString(titleResId);
    activityTestRule.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            activity.setTitle(activityTitle);
        }
    });
    getInstrumentation().waitForIdleSync();
    if (mCollapsingToolbar != null) {
        onView(withId(R.id.collapsing_app_bar)).perform(setTitle(activityTitle)).perform(setContentScrimColor(Color.MAGENTA));
    }
    TextView dialog = (TextView) mCoordinatorLayout.findViewById(R.id.textview_dialogue);
    if (dialog != null) {
        onView(withId(R.id.textview_dialogue)).perform(setText(TextUtils.concat(Shakespeare.DIALOGUE)));
    }
    mDefaultElevationValue = mAppBar.getResources().getDimension(R.dimen.design_appbar_elevation);
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) TextView(android.widget.TextView) CallSuper(android.support.annotation.CallSuper)

Example 23 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.

the class ThemeUtils method themeActionBar.

@SuppressLint("NewApi")
public static Drawable themeActionBar(AppCompatActivity activity) {
    if (activity == null) {
        return null;
    }
    if (ShuttleUtils.hasLollipop()) {
        Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.ic_launcher);
        if (bitmap != null) {
            ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(null, bitmap, ColorUtils.getPrimaryColor());
            activity.setTaskDescription(td);
            bitmap.recycle();
        }
    }
    if (ThemeUtils.getInstance().themeType == ThemeType.TYPE_LIGHT || ThemeUtils.getInstance().themeType == ThemeType.TYPE_DARK) {
        activity.getSupportActionBar().setBackgroundDrawable(DrawableUtils.getColoredDrawable(activity, CompatUtils.getDrawableCompat(activity, R.drawable.ab_transparent)));
    }
    if (activity instanceof MainActivity || isActionBarSolid(activity)) {
        ActionBar actionBar = activity.getSupportActionBar();
        Drawable actionBarDrawable = DrawableUtils.getColoredDrawable(activity, CompatUtils.getDrawableCompat(activity, R.drawable.action_bar_bg));
        actionBar.setBackgroundDrawable(actionBarDrawable);
        return actionBarDrawable;
    }
    return null;
}
Also used : Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) FilterableStateListDrawable(com.simplecity.amp_library.ui.views.FilterableStateListDrawable) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) MainActivity(com.simplecity.amp_library.ui.activities.MainActivity) ActivityManager(android.app.ActivityManager) ActionBar(android.support.v7.app.ActionBar) SuppressLint(android.annotation.SuppressLint)

Example 24 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.

the class AlbumArtistFragment method onOverflowClick.

@Override
public void onOverflowClick(View v, int position, AlbumArtist albumArtist) {
    PopupMenu menu = new PopupMenu(AlbumArtistFragment.this.getActivity(), v);
    MenuUtils.addAlbumArtistMenuOptions(getActivity(), menu);
    MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, albumArtist);
    menu.show();
}
Also used : PopupMenu(android.support.v7.widget.PopupMenu)

Example 25 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Shuttle by timusus.

the class DetailFragment method onOverflowClick.

@Override
public void onOverflowClick(View v, final int position, final Song song) {
    PopupMenu menu = new PopupMenu(getActivity(), v);
    MenuUtils.addSongMenuOptions(getActivity(), menu);
    if (playlist != null && playlist.canEdit) {
        menu.getMenu().add(SONG_FRAGMENT_GROUP_ID, REMOVE, 10, R.string.remove_from_playlist);
    }
    MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, song, item -> {
        switch(item.getItemId()) {
            case BLACKLIST:
                adapter.removeItem(position);
                BlacklistHelper.addToBlacklist(song);
                return true;
            case REMOVE:
                if (playlist != null) {
                    adapter.removeItem(position);
                    Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlist.id);
                    getActivity().getContentResolver().delete(ContentUris.withAppendedId(uri, song.playlistSongId), null, null);
                }
        }
        return false;
    });
    menu.show();
}
Also used : Uri(android.net.Uri) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

AppCompatActivity (android.support.v7.app.AppCompatActivity)85 View (android.view.View)36 ActionBar (android.support.v7.app.ActionBar)32 TextView (android.widget.TextView)22 RecyclerView (android.support.v7.widget.RecyclerView)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 ImageView (android.widget.ImageView)16 Toolbar (android.support.v7.widget.Toolbar)12 Fragment (android.support.v4.app.Fragment)8 PopupMenu (android.support.v7.widget.PopupMenu)8 Intent (android.content.Intent)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 Transition (android.transition.Transition)6 MenuItem (android.view.MenuItem)6 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 FragmentManager (android.support.v4.app.FragmentManager)4 PopupMenu (android.widget.PopupMenu)4 BindView (butterknife.BindView)4