Search in sources :

Example 56 with AppCompatActivity

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

the class LibraryController method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_library, container, false);
    unbinder = ButterKnife.bind(this, rootView);
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
    setupViewPager();
    Aesthetic.get(getContext()).colorPrimary().take(1).subscribe(color -> ViewBackgroundAction.create(appBarLayout).accept(color), onErrorLogAndRethrow());
    compositeDisposable.add(Aesthetic.get(getContext()).colorPrimary().compose(distinctToMainThread()).subscribe(color -> ViewBackgroundAction.create(appBarLayout).accept(color), onErrorLogAndRethrow()));
    return rootView;
}
Also used : R(com.simplecity.amp_library.R) Genre(com.simplecity.amp_library.model.Genre) BaseDetailFragment(com.simplecity.amp_library.ui.detail.BaseDetailFragment) Bundle(android.os.Bundle) Rx.onErrorLogAndRethrow(com.afollestad.aesthetic.Rx.onErrorLogAndRethrow) CategoryItem(com.simplecity.amp_library.model.CategoryItem) PagerAdapter(com.simplecity.amp_library.ui.adapters.PagerAdapter) BindView(butterknife.BindView) Aesthetic(com.afollestad.aesthetic.Aesthetic) ToolbarListener(com.simplecity.amp_library.ui.activities.ToolbarListener) View(android.view.View) ViewCompat(android.support.v4.view.ViewCompat) Transition(android.transition.Transition) PreferenceManager(android.preference.PreferenceManager) Unbinder(butterknife.Unbinder) Playlist(com.simplecity.amp_library.model.Playlist) IntentFilter(android.content.IntentFilter) FragmentInfo(test.com.androidnavigation.fragment.FragmentInfo) RxBroadcast(com.cantrowitz.rxbroadcast.RxBroadcast) GenreDetailFragment(com.simplecity.amp_library.ui.detail.GenreDetailFragment) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) SettingsManager(com.simplecity.amp_library.utils.SettingsManager) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) ContextualToolbarHost(com.simplecity.amp_library.ui.views.ContextualToolbarHost) Nullable(android.support.annotation.Nullable) ArtistDetailFragment(com.simplecity.amp_library.ui.detail.ArtistDetailFragment) AppBarLayout(android.support.design.widget.AppBarLayout) Album(com.simplecity.amp_library.model.Album) Stream(com.annimon.stream.Stream) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) ButterKnife(butterknife.ButterKnife) AlbumDetailFragment(com.simplecity.amp_library.ui.detail.AlbumDetailFragment) ViewPager(android.support.v4.view.ViewPager) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) TabLayout(android.support.design.widget.TabLayout) Inject(javax.inject.Inject) MultiSheetEventRelay(com.simplecity.amp_library.ui.views.multisheet.MultiSheetEventRelay) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) ViewBackgroundAction(com.afollestad.aesthetic.ViewBackgroundAction) Rx.distinctToMainThread(com.afollestad.aesthetic.Rx.distinctToMainThread) MultiSheetView(com.simplecity.multisheetview.ui.view.MultiSheetView) LayoutInflater(android.view.LayoutInflater) NavigationEventRelay(com.simplecity.amp_library.ui.drawer.NavigationEventRelay) DialogUtils(com.simplecity.amp_library.utils.DialogUtils) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) SearchFragment(com.simplecity.amp_library.search.SearchFragment) SharedPreferences(android.content.SharedPreferences) Toolbar(android.support.v7.widget.Toolbar) Pair(android.support.v4.util.Pair) TransitionInflater(android.transition.TransitionInflater) PlaylistDetailFragment(com.simplecity.amp_library.ui.detail.PlaylistDetailFragment) AlbumArtist(com.simplecity.amp_library.model.AlbumArtist) AppCompatActivity(android.support.v7.app.AppCompatActivity) BindView(butterknife.BindView) View(android.view.View) MultiSheetView(com.simplecity.multisheetview.ui.view.MultiSheetView) Nullable(android.support.annotation.Nullable)

Example 57 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project MadMax by deviz92.

the class BarDetailFragment method initCollapsingToolbar.

/* */
/**
 * This interface must be implemented by activities that contain this
 * fragment to allow an interaction in this fragment to be communicated
 * to the activity and potentially other fragments contained in that
 * activity.
 * <p>
 * See the Android Training lesson <a href=
 * "http://developer.android.com/training/basics/fragments/communicating.html"
 * >Communicating with Other Fragments</a> for more information.
 */
/*
    public interface OnFragmentInteractionListener {
        // TODO: Update argument type and name
        void onFragmentInteraction(Uri uri);
    }*/
// Initializing collapsing toolbar: it will show and hide the toolbar title on scroll
private void initCollapsingToolbar() {
    Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
    ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) ((AppCompatActivity) getActivity()).findViewById(R.id.collapsingToolbar);
    collapsingToolbar.setTitle(" ");
    AppBarLayout appBarLayout = (AppBarLayout) ((AppCompatActivity) getActivity()).findViewById(R.id.app_bar);
    appBarLayout.setExpanded(true);
    // hiding & showing the title when toolbar expanded & collapsed
    appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {

        boolean isShow = false;

        int scrollRange = -1;

        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (scrollRange == -1) {
                scrollRange = appBarLayout.getTotalScrollRange();
            }
            if (scrollRange + verticalOffset == 0) {
                collapsingToolbar.setTitle(nameTextView.getText());
                isShow = true;
            } else if (isShow) {
                collapsingToolbar.setTitle(" ");
                isShow = false;
            }
        }
    });
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) AppBarLayout(android.support.design.widget.AppBarLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 58 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project WilliamChart by diogobernardino.

the class ChartsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.charts, container, false);
    ((AppCompatActivity) getActivity()).setSupportActionBar((Toolbar) layout.findViewById(R.id.toolbar));
    ((TextView) layout.findViewById(R.id.title)).setTypeface(Typeface.createFromAsset(getContext().getAssets(), "Ponsi-Regular.otf"));
    RecyclerView mRecyclerView = (RecyclerView) layout.findViewById(R.id.recycler_view);
    GridLayoutManager mLayoutManager = new GridLayoutManager(getContext(), FULL_SPAN);
    mLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            switch(mAdapter.getItemViewType(position)) {
                case 0:
                    return FULL_SPAN;
                case 1:
                    return MULTI_SPAN;
                case 2:
                    return SINGLE_SPAN;
                case 3:
                    return FULL_SPAN;
                case 4:
                    return FULL_SPAN;
                case 5:
                    return SINGLE_SPAN;
                case 6:
                    return MULTI_SPAN;
                case 7:
                    return FULL_SPAN;
                case 8:
                    return FULL_SPAN;
                default:
                    return SINGLE_SPAN;
            }
        }
    });
    mAdapter = new ChartAdapter(getContext());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(mAdapter);
    return layout;
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) AppCompatActivity(android.support.v7.app.AppCompatActivity) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 59 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project T-MVP by north2016.

the class SysPermissionAspect method aroundJoinPoint.

@Around("execution(@com.app.annotation.aspect.Permission * *(..)) && @annotation(permission)")
public void aroundJoinPoint(ProceedingJoinPoint joinPoint, Permission permission) throws Throwable {
    AppCompatActivity ac = (AppCompatActivity) App.getAppContext().getCurActivity();
    new AlertDialog.Builder(ac).setTitle("提示").setMessage("为了应用可以正常使用,请您点击确认申请权限。").setNegativeButton("取消", null).setPositiveButton("允许", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            MPermissionUtils.requestPermissionsResult(ac, 1, permission.value(), new MPermissionUtils.OnPermissionListener() {

                @Override
                public void onPermissionGranted() {
                    try {
                        // 获得权限,执行原方法
                        joinPoint.proceed();
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                }

                @Override
                public void onPermissionDenied() {
                    MPermissionUtils.showTipsDialog(ac);
                }
            });
        }
    }).create().show();
}
Also used : DialogInterface(android.content.DialogInterface) AppCompatActivity(android.support.v7.app.AppCompatActivity) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) Around(org.aspectj.lang.annotation.Around)

Example 60 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project WeexErosFramework by bmfe.

the class BaseCommonUtil method getSmartBarHeight.

public static int getSmartBarHeight(AppCompatActivity activity) {
    ActionBar actionbar = activity.getSupportActionBar();
    if (actionbar != null)
        try {
            Class c = Class.forName("com.android.internal.R$dimen");
            Object obj = c.newInstance();
            Field field = c.getField("mz_action_button_min_height");
            int height = Integer.parseInt(field.get(obj).toString());
            return activity.getResources().getDimensionPixelSize(height);
        } catch (Exception e) {
            e.printStackTrace();
            actionbar.getHeight();
        }
    return 0;
}
Also used : Field(java.lang.reflect.Field) ActionBar(android.support.v7.app.ActionBar)

Aggregations

AppCompatActivity (android.support.v7.app.AppCompatActivity)99 View (android.view.View)43 ActionBar (android.support.v7.app.ActionBar)36 TextView (android.widget.TextView)28 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)17 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 Toolbar (android.support.v7.widget.Toolbar)14 BindView (butterknife.BindView)11 Fragment (android.support.v4.app.Fragment)8 PopupMenu (android.support.v7.widget.PopupMenu)8 Transition (android.transition.Transition)7 MenuItem (android.view.MenuItem)7 Intent (android.content.Intent)6 FragmentTransaction (android.support.v4.app.FragmentTransaction)6 TargetApi (android.annotation.TargetApi)5 Activity (android.app.Activity)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 Bundle (android.os.Bundle)4 FragmentManager (android.support.v4.app.FragmentManager)4