Search in sources :

Example 21 with ActionBar

use of androidx.appcompat.app.ActionBar in project Conversations by siacs.

the class ShortcutActivity method onStart.

@Override
protected void onStart() {
    super.onStart();
    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        bar.setTitle(R.string.create_shortcut);
    }
}
Also used : ActionBar(androidx.appcompat.app.ActionBar)

Example 22 with ActionBar

use of androidx.appcompat.app.ActionBar in project Android-Image-Cropper by ArthurHub.

the class CropImageActivity method onCreate.

@Override
@SuppressLint("NewApi")
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.crop_image_activity);
    mCropImageView = findViewById(R.id.cropImageView);
    Bundle bundle = getIntent().getBundleExtra(CropImage.CROP_IMAGE_EXTRA_BUNDLE);
    mCropImageUri = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_SOURCE);
    mOptions = bundle.getParcelable(CropImage.CROP_IMAGE_EXTRA_OPTIONS);
    if (savedInstanceState == null) {
        if (mCropImageUri == null || mCropImageUri.equals(Uri.EMPTY)) {
            if (CropImage.isExplicitCameraPermissionRequired(this)) {
                // request permissions and handle the result in onRequestPermissionsResult()
                requestPermissions(new String[] { Manifest.permission.CAMERA }, CropImage.CAMERA_CAPTURE_PERMISSIONS_REQUEST_CODE);
            } else {
                CropImage.startPickImageActivity(this);
            }
        } else if (CropImage.isReadExternalStoragePermissionsRequired(this, mCropImageUri)) {
            // request permissions and handle the result in onRequestPermissionsResult()
            requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
        } else {
            // no permissions required or already grunted, can start crop image activity
            mCropImageView.setImageUriAsync(mCropImageUri);
        }
    }
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        CharSequence title = mOptions != null && mOptions.activityTitle != null && mOptions.activityTitle.length() > 0 ? mOptions.activityTitle : getResources().getString(R.string.crop_image_activity_title);
        actionBar.setTitle(title);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
}
Also used : Bundle(android.os.Bundle) ActionBar(androidx.appcompat.app.ActionBar) SuppressLint(android.annotation.SuppressLint)

Example 23 with ActionBar

use of androidx.appcompat.app.ActionBar in project SwipeRecyclerView by yanzhenjie.

the class GridActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scroll);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    mRecyclerView = findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    mRecyclerView.addItemDecoration(new BorderItemDecoration(ContextCompat.getColor(this, R.color.divider_color)));
    mRecyclerView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View itemView, int position) {
            // 根据原position判断该item是否是parent item
            if (mAdapter.isParentItem(position)) {
                // 换取parent position
                int parentPosition = mAdapter.parentItemPosition(position);
                // 判断parent是否打开了二级菜单
                if (mAdapter.isExpanded(parentPosition)) {
                    mDataList.get(parentPosition).setExpanded(false);
                    mAdapter.notifyParentChanged(parentPosition);
                    // 关闭该parent下的二级菜单
                    mAdapter.collapseParent(parentPosition);
                } else {
                    mDataList.get(parentPosition).setExpanded(true);
                    mAdapter.notifyParentChanged(parentPosition);
                    // 打开该parent下的二级菜单
                    mAdapter.expandParent(parentPosition);
                }
            } else {
                // 换取parent position
                int parentPosition = mAdapter.parentItemPosition(position);
                // 换取child position
                int childPosition = mAdapter.childItemPosition(position);
                String message = String.format("我是%1$d爸爸的%2$d儿子", parentPosition, childPosition);
                Toast.makeText(GridActivity.this, message, Toast.LENGTH_LONG).show();
            }
        }
    });
    mAdapter = new ExpandedAdapter(this);
    mRecyclerView.setAdapter(mAdapter);
    refresh();
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) OnItemClickListener(com.yanzhenjie.recyclerview.OnItemClickListener) ExpandedAdapter(com.yanzhenjie.recyclerview.sample.adapter.ExpandedAdapter) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) View(android.view.View) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar) BorderItemDecoration(com.yanzhenjie.recyclerview.widget.BorderItemDecoration)

Example 24 with ActionBar

use of androidx.appcompat.app.ActionBar in project SwipeRecyclerView by yanzhenjie.

the class StaggeredActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scroll);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    mRecyclerView = findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(this, R.color.divider_color)));
    mRecyclerView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View itemView, int position) {
            // 根据原position判断该item是否是parent item
            if (mAdapter.isParentItem(position)) {
                // 换取parent position
                int parentPosition = mAdapter.parentItemPosition(position);
                // 判断parent是否打开了二级菜单
                if (mAdapter.isExpanded(parentPosition)) {
                    mDataList.get(parentPosition).setExpanded(false);
                    mAdapter.notifyParentChanged(parentPosition);
                    // 关闭该parent下的二级菜单
                    mAdapter.collapseParent(parentPosition);
                } else {
                    mDataList.get(parentPosition).setExpanded(true);
                    mAdapter.notifyParentChanged(parentPosition);
                    // 打开该parent下的二级菜单
                    mAdapter.expandParent(parentPosition);
                }
            } else {
                // 换取parent position
                int parentPosition = mAdapter.parentItemPosition(position);
                // 换取child position
                int childPosition = mAdapter.childItemPosition(position);
                String message = String.format("我是%1$d爸爸的%2$d儿子", parentPosition, childPosition);
                Toast.makeText(StaggeredActivity.this, message, Toast.LENGTH_LONG).show();
            }
        }
    });
    mAdapter = new ExpandedAdapter(this);
    mRecyclerView.setAdapter(mAdapter);
    refresh();
}
Also used : DefaultItemDecoration(com.yanzhenjie.recyclerview.widget.DefaultItemDecoration) OnItemClickListener(com.yanzhenjie.recyclerview.OnItemClickListener) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) ExpandedAdapter(com.yanzhenjie.recyclerview.sample.adapter.ExpandedAdapter) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) View(android.view.View) ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar)

Example 25 with ActionBar

use of androidx.appcompat.app.ActionBar in project SwipeRecyclerView by yanzhenjie.

the class LayoutActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group_layout);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    assert actionBar != null;
    actionBar.setDisplayHomeAsUpEnabled(true);
    initTabLayout();
/*
         * 注意:
         * 1. 要给需要sticky的View设置tab属性:android:tag="sticky";
         * 2. 也可以Java动态设置:view.setTag("sticky");
         * 3. 如果这个sticky的View是可点击的,那么tag为:android:tag="sticky-nonconstant"或者view.setTag("sticky-nonconstant");
         */
}
Also used : ActionBar(androidx.appcompat.app.ActionBar) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

ActionBar (androidx.appcompat.app.ActionBar)139 View (android.view.View)30 Toolbar (androidx.appcompat.widget.Toolbar)29 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)26 TextView (android.widget.TextView)18 Intent (android.content.Intent)11 Bundle (android.os.Bundle)11 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7 AdapterView (android.widget.AdapterView)7 ImageView (android.widget.ImageView)7 Uri (android.net.Uri)6 DefaultItemDecoration (com.yanzhenjie.recyclerview.widget.DefaultItemDecoration)6 SharedPreferences (android.content.SharedPreferences)5 ListView (android.widget.ListView)5 Spinner (android.widget.Spinner)5 Typeface (com.mta.tehreer.graphics.Typeface)5 File (java.io.File)5 MenuItem (android.view.MenuItem)4 Button (android.widget.Button)4