Search in sources :

Example 1 with CaptureStrategy

use of com.zhihu.matisse.internal.entity.CaptureStrategy in project ttdj by soonphe.

the class PublishGoodsFragment method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (parent.getId() == R.id.activity_postmessage_gridview) {
        // 判断是否为最后一个
        if (position == parent.getChildCount() - 1) {
            new RxPermissions(getContext()).request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA).subscribe(granded -> {
                if (granded) {
                    Matisse.from(this).choose(MimeType.ofAll(), false).countable(true).capture(// 拍照
                    true).captureStrategy(new CaptureStrategy(true, "com.connxun.ltcx.app.fileprovider")).maxSelectable(6).addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K)).gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size)).restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED).thumbnailScale(0.85f).imageEngine(new GlideEngine()).forResult(REQUEST_CODE_CHOOSE);
                } else {
                    ToastUtils.showShort("请先授予应用相关权限");
                    mOperation.showBasicDialog(R.string.error, R.string.grant_permission, (dialog, which) -> {
                        // Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);    //飞行模式,无线网和网络设置界面
                        // 跳转位置服务界面
                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(intent);
                    });
                }
            });
        }
    }
}
Also used : CaptureStrategy(com.zhihu.matisse.internal.entity.CaptureStrategy) RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) GlideEngine(com.zhihu.matisse.engine.impl.GlideEngine) Intent(android.content.Intent) GifSizeFilter(com.connxun.ltcx.utils.GifSizeFilter)

Example 2 with CaptureStrategy

use of com.zhihu.matisse.internal.entity.CaptureStrategy in project ttdj by soonphe.

the class ApplyStoreActivity method onViewClicked.

@OnClick({ R.id.iv_image, R.id.tv_publish })
public void onViewClicked(View view) {
    switch(view.getId()) {
        case R.id.iv_image:
            new RxPermissions(getContext()).request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA).subscribe(granded -> {
                if (granded) {
                    Matisse.from(getContext()).choose(MimeType.ofAll(), false).countable(true).capture(// 拍照
                    true).captureStrategy(new CaptureStrategy(true, "com.connxun.ltcx.app.fileprovider")).maxSelectable(1).addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K)).gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size)).restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED).thumbnailScale(0.85f).imageEngine(new GlideEngine()).forResult(REQUEST_CODE_CHOOSE);
                } else {
                    ToastUtils.showShort("请先授予应用相关权限");
                    mOperation.showBasicDialog(R.string.error, R.string.grant_permission, (dialog, which) -> {
                        // Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);    //飞行模式,无线网和网络设置界面
                        // 跳转位置服务界面
                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(intent);
                    });
                }
            });
            break;
        case R.id.tv_publish:
            validator.validate();
            break;
    }
}
Also used : CaptureStrategy(com.zhihu.matisse.internal.entity.CaptureStrategy) RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) GlideEngine(com.zhihu.matisse.engine.impl.GlideEngine) Intent(android.content.Intent) GifSizeFilter(com.connxun.ltcx.utils.GifSizeFilter) OnClick(butterknife.OnClick)

Example 3 with CaptureStrategy

use of com.zhihu.matisse.internal.entity.CaptureStrategy in project ttdj by soonphe.

the class PersonCertifyActivity method initView.

@Override
public void initView(View view) {
    presenter.attachView(this);
    // 初始化底部recycleView
    certifyAdapter = new CertifyAdapter(R.layout.item_center_rv);
    // recycleView布局加载(LinearLayoutManager)
    rvList.setLayoutManager(new GridLayoutManager(getContext(), 4));
    // 添加分割线
    rvList.addItemDecoration(new SpaceDecoration(20));
    // rvList.addItemDecoration(new DividerDecoration(R.color.divider_recycle,1));
    // rvList.addItemDecoration(new RecycleViewDivider(getContext(), LinearLayoutManager.HORIZONTAL));
    rvList.setAdapter(certifyAdapter);
    // 解决NestedScrollView和RecycleView滑动冲突
    rvList.setNestedScrollingEnabled(false);
    certifyAdapter.setFooterView(LayoutInflater.from(this).inflate(R.layout.item_center_rv_footer, null));
    certifyAdapter.setFooterViewAsFlow(true);
    certifyAdapter.getFooterLayout().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new RxPermissions(getContext()).request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA).subscribe(granded -> {
                if (granded) {
                    Matisse.from(getContext()).choose(MimeType.ofAll(), false).countable(true).capture(// 拍照
                    true).captureStrategy(new CaptureStrategy(true, "com.connxun.ltcx.app.fileprovider")).maxSelectable(2 - certifyAdapter.getData().size()).addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K)).gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size)).restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED).thumbnailScale(0.85f).imageEngine(new GlideEngine()).forResult(REQUEST_CODE_CHOOSE);
                } else {
                    ToastUtils.showShort("请先授予应用相关权限");
                    mOperation.showBasicDialog(R.string.error, R.string.grant_permission, (dialog, which) -> {
                        // Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);    //飞行模式,无线网和网络设置界面
                        // 跳转位置服务界面
                        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                        startActivity(intent);
                    });
                }
            });
        }
    });
}
Also used : Context(android.content.Context) PUser(com.connxun.ltcx.entity.PUser) GridLayoutManager(android.support.v7.widget.GridLayoutManager) Bundle(android.os.Bundle) Filter(com.zhihu.matisse.filter.Filter) CacheUtils(com.blankj.utilcode.util.CacheUtils) PCertify(com.connxun.ltcx.entity.PCertify) CertifyAdapter(com.connxun.ltcx.ui.adapter.center.CertifyAdapter) RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) Matisse(com.zhihu.matisse.Matisse) Intent(android.content.Intent) GifSizeFilter(com.connxun.ltcx.utils.GifSizeFilter) Validator(com.mobsandgeeks.saripaar.Validator) ValidationError(com.mobsandgeeks.saripaar.ValidationError) Headers(okhttp3.Headers) LogUtils(com.blankj.utilcode.util.LogUtils) OnClick(butterknife.OnClick) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) RequestBody(okhttp3.RequestBody) Inject(javax.inject.Inject) Manifest(android.Manifest) CaptureStrategy(com.zhihu.matisse.internal.entity.CaptureStrategy) MimeType(com.zhihu.matisse.MimeType) ActivityInfo(android.content.pm.ActivityInfo) View(android.view.View) Button(android.widget.Button) Settings(android.provider.Settings) MediaType(okhttp3.MediaType) ToastUtils(com.blankj.utilcode.util.ToastUtils) GlideEngine(com.zhihu.matisse.engine.impl.GlideEngine) LayoutInflater(android.view.LayoutInflater) USER_ID(com.connxun.ltcx.constants.Constants.USER_ID) OnCompressListener(top.zibin.luban.OnCompressListener) R(com.connxun.ltcx.R) File(java.io.File) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) SpaceDecoration(com.jude.easyrecyclerview.decoration.SpaceDecoration) MultipartBody(okhttp3.MultipartBody) BaseSwipeBackActivity(com.connxun.ltcx.ui.mvp.BaseSwipeBackActivity) Constants(com.connxun.ltcx.constants.Constants) NotEmpty(com.mobsandgeeks.saripaar.annotation.NotEmpty) Luban(top.zibin.luban.Luban) DIRECTORY_PICTURES(android.os.Environment.DIRECTORY_PICTURES) USER(com.connxun.ltcx.constants.Constants.USER) EditText(android.widget.EditText) CaptureStrategy(com.zhihu.matisse.internal.entity.CaptureStrategy) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) GlideEngine(com.zhihu.matisse.engine.impl.GlideEngine) CertifyAdapter(com.connxun.ltcx.ui.adapter.center.CertifyAdapter) SpaceDecoration(com.jude.easyrecyclerview.decoration.SpaceDecoration) Intent(android.content.Intent) GifSizeFilter(com.connxun.ltcx.utils.GifSizeFilter) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

Intent (android.content.Intent)3 GifSizeFilter (com.connxun.ltcx.utils.GifSizeFilter)3 RxPermissions (com.tbruyelle.rxpermissions2.RxPermissions)3 GlideEngine (com.zhihu.matisse.engine.impl.GlideEngine)3 CaptureStrategy (com.zhihu.matisse.internal.entity.CaptureStrategy)3 OnClick (butterknife.OnClick)2 Manifest (android.Manifest)1 Context (android.content.Context)1 ActivityInfo (android.content.pm.ActivityInfo)1 Bundle (android.os.Bundle)1 DIRECTORY_PICTURES (android.os.Environment.DIRECTORY_PICTURES)1 Settings (android.provider.Settings)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 BindView (butterknife.BindView)1 CacheUtils (com.blankj.utilcode.util.CacheUtils)1