Search in sources :

Example 31 with ActionBar

use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.

the class LegacyEditorFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_edit_post_content, container, false);
    mFormatBar = (LinearLayout) rootView.findViewById(R.id.format_bar);
    mTitleEditText = (EditText) rootView.findViewById(R.id.post_title);
    mTitleEditText.setText(mTitle);
    mTitleEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            // Go to full screen editor when 'next' button is tapped on soft keyboard
            ActionBar actionBar = getActionBar();
            if (actionId == EditorInfo.IME_ACTION_NEXT && actionBar != null && actionBar.isShowing()) {
                setContentEditingModeVisible(true);
            }
            return false;
        }
    });
    mContentEditText = (WPEditText) rootView.findViewById(R.id.post_content);
    mContentEditText.setText(mContent);
    mPostContentLinearLayout = (LinearLayout) rootView.findViewById(R.id.post_content_wrapper);
    mPostSettingsLinearLayout = (LinearLayout) rootView.findViewById(R.id.post_settings_wrapper);
    Button postSettingsButton = (Button) rootView.findViewById(R.id.post_settings_button);
    postSettingsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mEditorFragmentListener.onSettingsClicked();
        }
    });
    mBoldToggleButton = (ToggleButton) rootView.findViewById(R.id.bold);
    mEmToggleButton = (ToggleButton) rootView.findViewById(R.id.em);
    mBquoteToggleButton = (ToggleButton) rootView.findViewById(R.id.bquote);
    mUnderlineToggleButton = (ToggleButton) rootView.findViewById(R.id.underline);
    mStrikeToggleButton = (ToggleButton) rootView.findViewById(R.id.strike);
    mAddPictureButton = (Button) rootView.findViewById(R.id.addPictureButton);
    Button linkButton = (Button) rootView.findViewById(R.id.link);
    Button moreButton = (Button) rootView.findViewById(R.id.more);
    registerForContextMenu(mAddPictureButton);
    mContentEditText = (WPEditText) rootView.findViewById(R.id.post_content);
    mContentEditText.setOnSelectionChangedListener(this);
    mContentEditText.setOnTouchListener(this);
    mContentEditText.addTextChangedListener(this);
    mContentEditText.setOnEditTextImeBackListener(new WPEditText.EditTextImeBackListener() {

        @Override
        public void onImeBack(WPEditText ctrl, String text) {
            // Go back to regular editor if IME keyboard is dismissed
            // Bottom comparison is there to ensure that the keyboard is actually showing
            ActionBar actionBar = getActionBar();
            if (mRootView.getBottom() < mFullViewBottom && actionBar != null && !actionBar.isShowing()) {
                setContentEditingModeVisible(false);
            }
        }
    });
    mAddPictureButton.setOnClickListener(mFormatBarButtonClickListener);
    mBoldToggleButton.setOnClickListener(mFormatBarButtonClickListener);
    linkButton.setOnClickListener(mFormatBarButtonClickListener);
    mEmToggleButton.setOnClickListener(mFormatBarButtonClickListener);
    mUnderlineToggleButton.setOnClickListener(mFormatBarButtonClickListener);
    mStrikeToggleButton.setOnClickListener(mFormatBarButtonClickListener);
    mBquoteToggleButton.setOnClickListener(mFormatBarButtonClickListener);
    moreButton.setOnClickListener(mFormatBarButtonClickListener);
    mEditorFragmentListener.onEditorFragmentInitialized();
    if (savedInstanceState != null) {
        Parcelable[] spans = savedInstanceState.getParcelableArray(KEY_IMAGE_SPANS);
        mContent = savedInstanceState.getString(KEY_CONTENT, "");
        mContentEditText.setText(mContent);
        mContentEditText.setSelection(savedInstanceState.getInt(KEY_START, 0), savedInstanceState.getInt(KEY_END, 0));
        if (spans != null && spans.length > 0) {
            for (Parcelable s : spans) {
                WPImageSpan editSpan = (WPImageSpan) s;
                addMediaFile(editSpan.getMediaFile(), editSpan.getMediaFile().getFilePath(), mImageLoader, editSpan.getStartPosition(), editSpan.getEndPosition());
            }
        }
    }
    return rootView;
}
Also used : ViewGroup(android.view.ViewGroup) Parcelable(android.os.Parcelable) WPImageSpan(org.wordpress.android.util.helpers.WPImageSpan) View(android.view.View) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) Button(android.widget.Button) ToggleButton(android.widget.ToggleButton) CompoundButton(android.widget.CompoundButton) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) WPEditText(org.wordpress.android.util.widgets.WPEditText)

Example 32 with ActionBar

use of android.support.v7.app.ActionBar in project WordPress-Android by wordpress-mobile.

the class LegacyEditorFragment method setContentEditingModeVisible.

public void setContentEditingModeVisible(boolean isVisible) {
    if (!isAdded()) {
        return;
    }
    ActionBar actionBar = getActionBar();
    if (isVisible) {
        Animation fadeAnimation = new AlphaAnimation(1, 0);
        fadeAnimation.setDuration(CONTENT_ANIMATION_DURATION);
        fadeAnimation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
                mTitleEditText.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mPostSettingsLinearLayout.setVisibility(View.GONE);
                mFormatBar.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mPostContentLinearLayout.startAnimation(fadeAnimation);
        if (actionBar != null) {
            actionBar.hide();
        }
    } else {
        mTitleEditText.setVisibility(View.VISIBLE);
        mFormatBar.setVisibility(View.GONE);
        Animation fadeAnimation = new AlphaAnimation(0, 1);
        fadeAnimation.setDuration(CONTENT_ANIMATION_DURATION);
        fadeAnimation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mPostSettingsLinearLayout.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mPostContentLinearLayout.startAnimation(fadeAnimation);
        getActivity().invalidateOptionsMenu();
        if (actionBar != null) {
            actionBar.show();
        }
    }
}
Also used : Animation(android.view.animation.Animation) AlphaAnimation(android.view.animation.AlphaAnimation) ActionBar(android.support.v7.app.ActionBar) AlphaAnimation(android.view.animation.AlphaAnimation)

Example 33 with ActionBar

use of android.support.v7.app.ActionBar in project Hummingbird-for-Android by xiprox.

the class NavigationDrawerFragment method setUp.

public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;
    mDrawerLayout.setDrawerShadow(R.drawable.navigation_drawer_shadow, GravityCompat.START);
    mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.apptheme_primary_dark));
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), mDrawerLayout, ((MainActivity) getActivity()).getToolbar(), R.string.navigation_drawer_open, R.string.navigation_drawer_close) {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }
            getActivity().invalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }
            if (!mUserLearnedDrawer) {
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }
            getActivity().invalidateOptionsMenu();
        }
    };
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        mDrawerLayout.openDrawer(mFragmentContainerView);
    }
    mDrawerLayout.post(new Runnable() {

        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });
    mDrawerLayout.setDrawerListener(mDrawerToggle);
}
Also used : SharedPreferences(android.content.SharedPreferences) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ActionBar(android.support.v7.app.ActionBar)

Example 34 with ActionBar

use of android.support.v7.app.ActionBar in project SwipeRecyclerView by yanzhenjie.

the class MenuCardActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    mContext = this;
    List<String> dataList = new ArrayList<>();
    for (int i = 0; i < 30; i++) {
        dataList.add("我是第" + i + "个菜单");
    }
    mMenuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
    // 布局管理器。
    mMenuRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mMenuRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            outRect.set(10, 10, 10, 10);
        }
    });
    MenuCardAdapter menuCardAdapter = new MenuCardAdapter(dataList);
    menuCardAdapter.setOnItemClickListener(onItemClickListener);
    mMenuRecyclerView.setAdapter(menuCardAdapter);
}
Also used : Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) SwipeMenuRecyclerView(com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeMenuRecyclerView(com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar) MenuCardAdapter(com.yanzhenjie.swiperecyclerview.adapter.MenuCardAdapter)

Example 35 with ActionBar

use of android.support.v7.app.ActionBar in project SwipeRecyclerView by yanzhenjie.

the class MenuDefineActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mContext = this;
    setContentView(R.layout.activity_define);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    mSwipeSwitch = (SwipeSwitch) findViewById(R.id.swipe_layout);
    TextView btnLeft = (TextView) findViewById(R.id.left_view);
    TextView btnRight = (TextView) findViewById(R.id.right_view);
    btnLeft.setOnClickListener(xOnClickListener);
    btnRight.setOnClickListener(xOnClickListener);
}
Also used : TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ActionBar (android.support.v7.app.ActionBar)443 View (android.view.View)130 Toolbar (android.support.v7.widget.Toolbar)108 TextView (android.widget.TextView)78 AppCompatActivity (android.support.v7.app.AppCompatActivity)36 ImageView (android.widget.ImageView)34 Intent (android.content.Intent)31 RecyclerView (android.support.v7.widget.RecyclerView)29 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)23 AdapterView (android.widget.AdapterView)21 Bundle (android.os.Bundle)19 BindView (butterknife.BindView)19 ViewPager (android.support.v4.view.ViewPager)18 Fragment (android.support.v4.app.Fragment)17 ArrayList (java.util.ArrayList)16 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)15 ListView (android.widget.ListView)14 SuppressLint (android.annotation.SuppressLint)13 FragmentManager (android.app.FragmentManager)12 NavigationView (android.support.design.widget.NavigationView)12