Search in sources :

Example 41 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Douya by DreaminginCodeZH.

the class BroadcastFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    CustomTabsHelperFragment.attachTo(this);
    mBroadcastAndCommentListResource = BroadcastAndCommentListResource.attachTo(mBroadcastId, mBroadcast, this);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setTitle(getTitle());
    activity.setSupportActionBar(mToolbar);
    mContainerLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ActivityCompat.finishAfterTransition(getActivity());
        }
    });
    ViewCompat.setTransitionName(mSharedView, Broadcast.makeTransitionName(mBroadcastId));
    // This magically gives better visual effect when the broadcast is partially visible. Using
    // setEnterSharedElementCallback() disables this hack when no transition is used to start
    // this Activity.
    ActivityCompat.setEnterSharedElementCallback(activity, new SharedElementCallback() {

        @Override
        public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
            mBroadcastCommentList.scrollToPosition(0);
        }
    });
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            mBroadcastAndCommentListResource.loadBroadcast();
            mBroadcastAndCommentListResource.loadCommentList(false);
        }
    });
    mBroadcastCommentList.setHasFixedSize(true);
    mBroadcastCommentList.setItemAnimator(new NoChangeAnimationItemAnimator());
    mBroadcastCommentList.setLayoutManager(new LinearLayoutManager(activity));
    mBroadcastAdapter = new SingleBroadcastAdapter(null, this);
    setBroadcast(mBroadcastAndCommentListResource.getBroadcast());
    mCommentAdapter = new CommentAdapter(mBroadcastAndCommentListResource.getCommentList(), new ClickableSimpleAdapter.OnItemClickListener<Comment, CommentAdapter.ViewHolder>() {

        @Override
        public void onItemClick(RecyclerView parent, Comment item, CommentAdapter.ViewHolder holder) {
            onShowCommentAction(item);
        }
    });
    mAdapter = new LoadMoreAdapter(R.layout.load_more_item, mBroadcastAdapter, mCommentAdapter);
    mBroadcastCommentList.setAdapter(mAdapter);
    mBroadcastCommentList.addOnScrollListener(new OnVerticalScrollListener() {

        public void onScrolledToBottom() {
            mBroadcastAndCommentListResource.loadCommentList(true);
        }
    });
    CheatSheetUtils.setup(mSendButton);
    mSendButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            onSendComment();
        }
    });
    updateSendCommentStatus();
    if (savedInstanceState == null) {
        if (mShowSendComment) {
            TransitionUtils.postAfterTransition(this, new Runnable() {

                @Override
                public void run() {
                    onShowSendComment();
                }
            });
        }
    }
    TransitionUtils.setEnterReturnExplode(this);
    TransitionUtils.setupTransitionOnActivityCreated(this);
}
Also used : Comment(me.zhanghai.android.douya.network.api.info.apiv2.Comment) AppCompatActivity(android.support.v7.app.AppCompatActivity) OnVerticalScrollListener(me.zhanghai.android.douya.ui.OnVerticalScrollListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView) SharedElementCallback(android.support.v4.app.SharedElementCallback) LoadMoreAdapter(me.zhanghai.android.douya.ui.LoadMoreAdapter) NoChangeAnimationItemAnimator(me.zhanghai.android.douya.ui.NoChangeAnimationItemAnimator)

Example 42 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Douya by DreaminginCodeZH.

the class FollowshipListActivityFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mToolbar);
    TransitionUtils.setupTransitionOnActivityCreated(this);
    if (savedInstanceState == null) {
        FragmentUtils.add(onCreateListFragment(), this, R.id.followship_list_fragment);
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity)

Example 43 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project GSYVideoPlayer by CarGuo.

the class CommonUtil method hideSupportActionBar.

public static void hideSupportActionBar(Context context, boolean actionBar, boolean statusBar) {
    if (actionBar) {
        AppCompatActivity appCompatActivity = CommonUtil.getAppCompActivity(context);
        if (appCompatActivity != null) {
            ActionBar ab = appCompatActivity.getSupportActionBar();
            if (ab != null) {
                ab.setShowHideAnimationEnabled(false);
                ab.hide();
            }
        }
    }
    if (statusBar) {
        if (context instanceof FragmentActivity) {
            FragmentActivity fragmentActivity = (FragmentActivity) context;
            fragmentActivity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } else {
            CommonUtil.getAppCompActivity(context).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
    }
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) AppCompatActivity(android.support.v7.app.AppCompatActivity) ActionBar(android.support.v7.app.ActionBar)

Example 44 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project GSYVideoPlayer by CarGuo.

the class CommonUtil method showSupportActionBar.

public static void showSupportActionBar(Context context, boolean actionBar, boolean statusBar) {
    if (actionBar) {
        AppCompatActivity appCompatActivity = CommonUtil.getAppCompActivity(context);
        if (appCompatActivity != null) {
            ActionBar ab = appCompatActivity.getSupportActionBar();
            if (ab != null) {
                ab.setShowHideAnimationEnabled(false);
                ab.show();
            }
        }
    }
    if (statusBar) {
        if (context instanceof FragmentActivity) {
            FragmentActivity fragmentActivity = (FragmentActivity) context;
            fragmentActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } else {
            CommonUtil.getAppCompActivity(context).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
    }
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) AppCompatActivity(android.support.v7.app.AppCompatActivity) ActionBar(android.support.v7.app.ActionBar)

Example 45 with AppCompatActivity

use of android.support.v7.app.AppCompatActivity in project Douya by DreaminginCodeZH.

the class ProfileFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    CustomTabsHelperFragment.attachTo(this);
    mProfileResource = ProfileResource.attachTo(mUserIdOrUid, mSimpleUser, mUser, this);
    mScrollLayout.setListener(new ProfileLayout.Listener() {

        @Override
        public void onEnterAnimationEnd() {
        }

        @Override
        public void onExitAnimationEnd() {
            getActivity().finish();
        }
    });
    if (savedInstanceState == null) {
        mScrollLayout.enter();
    }
    mDismissView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            exit();
        }
    });
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mToolbar);
    activity.getSupportActionBar().setTitle(null);
    if (mProfileResource.hasUser()) {
        mHeaderLayout.bindUser(mProfileResource.getUser());
    } else if (mProfileResource.hasSimpleUser()) {
        mHeaderLayout.bindSimpleUser(mProfileResource.getSimpleUser());
    }
    mHeaderLayout.setListener(this);
    if (ViewUtils.hasSw600Dp(activity)) {
        mContentList.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
    } else {
        mContentList.setLayoutManager(new LinearLayoutManager(activity));
    }
    mProfileAdapter = new ProfileAdapter(this);
    mContentList.setAdapter(mProfileAdapter);
    if (mProfileResource.isLoaded()) {
        mProfileResource.notifyChangedIfLoaded();
    } else {
        mContentStateLayout.setLoading();
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

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