首页 > 其他分享 >TransformMine图片表格化安卓APP

TransformMine图片表格化安卓APP

时间:2023-05-28 21:55:05浏览次数:47  
标签:APP Bitmap 化安卓 Intent TransformMine import android com void

TransformMine图片表格化安卓APP

展示:

 

部分代码:

<?xml version="1.0" encoding="utf-8"?>

<com.scwang.smart.refresh.layout.SmartRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    style="@style/PullDownStyle"
    android:background="?attr/xui_config_color_background">

    <androidx.core.widget.NestedScrollView style="@style/ScrollViewStyle">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingTop="50dp">

            <com.xuexiang.xui.widget.imageview.crop.CropImageView
                android:id="@+id/crop_image_view"
                android:layout_width="match_parent"
                android:layout_height="400dp"
                app:civ_imageResource="@null" />


            <com.xuexiang.xui.widget.textview.supertextview.SuperButton
                android:id="@+id/btn_upload"
                style="@style/SuperButton.Primary.Login"
                android:layout_marginTop="16dp"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="上传照片"
                android:textSize="26sp"/>
        </LinearLayout>
    </androidx.core.widget.NestedScrollView>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
package com.transform.transformMine.fragment.other;

import static android.app.Activity.RESULT_OK;
import static com.xuexiang.xui.XUI.getContext;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.MediaStore;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.transform.transformMine.R;
import com.transform.transformMine.core.BaseFragment;
import com.transform.transformMine.databinding.FragmentTransBinding;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xui.widget.imageview.crop.CropImageView;

import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;

@Page(anim = CoreAnim.none)
public class TransFragment extends BaseFragment<FragmentTransBinding> implements View.OnClickListener {

    CropImageView cropImageView ;
    public static final int REQUEST_CODE_PICK_IMAGE = 1;

    @NonNull
    @Override
    protected FragmentTransBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
        return FragmentTransBinding.inflate(inflater, container, attachToRoot);
    }

    @Override
    protected void initViews() {
        cropImageView = findViewById(R.id.crop_image_view);
    }

    @Override
    protected void initListeners() {
        binding.btnUpload.setOnClickListener(this);
    }

    @SuppressLint("IntentReset")
    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.btn_upload){


            Intent intent = new Intent(Intent.ACTION_PICK, null);
            intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");

            startActivityForResult(intent, REQUEST_CODE_PICK_IMAGE);
        }
    }
    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case REQUEST_CODE_PICK_IMAGE:
                if (resultCode == RESULT_OK) {       //
                    if (data != null) {
                        // 得到图片的全路径
                        Uri uri = data.getData();
                        Bitmap bitmap1 = null;
                        try {
                            Bitmap bitmap = BitmapFactory.decodeStream(getContext().getContentResolver().openInputStream(uri));
                            bitmap1 = compressByJpeg(bitmap,50);
                        } catch (FileNotFoundException e) {
                            e.printStackTrace();
                        }
                        cropImageView.setImageBitmap(bitmap1);
                        String imagePath = uri.getPath();
                        // 调用目标方法进行处理
                        processImage(imagePath);
                    }
                }
                break;
        }
    }
    //压缩图片的代码,quality是压缩的百分比,填1-100代表1%到100%
    private Bitmap compressByJpeg(Bitmap bitmap, int quality) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
        byte[] byteArray = outputStream.toByteArray();
        return BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
    }
    // 目标方法,处理选择的图片
    private void processImage(String imagePath) {

    }
}

 

标签:APP,Bitmap,化安卓,Intent,TransformMine,import,android,com,void
From: https://www.cnblogs.com/rsy-bxf150/p/17438952.html

相关文章

  • Java学习:使用MyBatis Plus的分页插件和QueryWrapper结合自定义mapper xml实现多表关联
     Vo:/***用来返回给前端展示列表的数据实体*/@DatapublicclassCourseVoimplementsSerializable{privatestaticfinallongserialVersionUID=1L;privateStringid;privateStringtitle;privateStringsubjectParentTitle;private......
  • Appium自动化(14):Appium常用操作之app操作
    APP操作方法:appium支持对手机上的app进行管理和操作,有如下方法:1、install_app(self,app_path,**options):安装app,app_path为安装包路径2、remove_app(self,app_id,**options):卸载app,app_id为app包名3、is_app_installed(self,bundle_id):检查app是否有安装bundle_id为app包名......
  • Appium自动化(15):Appium常用操作之混合应用webview页面操作--待补充!
    上下文操作:在appium中,对于混合应用,需要进行WebView页面和原生应用的切换 常用的方法如下:1、context(self)/current_context(self):返回当前会话的当前上下文,context可以理解为可进入的窗口。对于原生应用,可用的context和默认context均为“NATIVE_APP”,对于webvi......
  • Mybatis-plus中自定义的sql语句调用QueryWrapper实现查询
     一、引言MP自带的条件构造器虽然很强大,有时候也避免不了写稍微复杂一点业务的sql,那么今天说说MP怎么自定义sql语句吧。 二、具体实现使用注解实现:在我们Mapper接口中定义自定义方法即可。/***@Date:2019/6/1014:40*@Description</span>:User对象持久层*/p......
  • Appium自动化(16):Appium常用操作之H5页面操作 --待补充!
    手机chrome浏览器操作:手机端chrome浏览器一般用于打开H5手机版网站,它的操作方式与PC端的浏览器操作(即selenium对浏览器的操作)是一模一样的,由于切换后的WebView页面也属于网页下述的方法中部分支持在webview页面中使用:1、get(self,url):打开网站,url参数为url地址,必须包含http/h......
  • Appium自动化(17):Appium常用操作之等待操作
    等待机制:为了保证脚本的稳定性,有时候需要引入等待时间,等待页面加载元素后再进行操作,主要有三种等待时间设置方式。 方式一:sleep():固定等待时间设置,python的time包里提供了休眠方法sleep,导入包后就能使用;sleep()方法以秒为单位,如果超时设置小于1秒,可以使用小数写法:time.sleep(......
  • Appium自动化(18):使用appium后安卓手机无法调出键盘解决方法
    问题:用appium进行真机调试后,使用手机的app进行输入时无法调出键盘。原因:appium调试时,将手机输入法设置成了UnicodeIME注:按键详细操作参考:转载至作者:oscarforever  地址:https://www.cnblogs.com/oscarforever/p/10721774.html解决方法:方法一,手机设置里修改输入法:不同的手机型号......
  • 应用启动时加载application.properties配置文件
    配置aliyun.sms.regionId=defaultaliyun.sms.accessKeyId=LTAIxxxaliyun.sms.secret=PAxxxx importorg.springframework.beans.factory.InitializingBean;importorg.springframework.beans.factory.annotation.Value;importorg.springframework.stereotype.Compone......
  • RN从0到1系统精讲与小红书APP实战(2023版)
    RN从0到1系统精讲与小红书APP实战(2023版)download:3wzxit666comRN从0到1系统精讲Part2:组件和API在上一篇文章中,我们介绍了如何搭建ReactNative开发环境并创建新项目。本文将介绍ReactNative的组件和API。组件ReactNative提供了许多可重用的UI组件,如View、Text、Image等。这......
  • Appium自动化(13):Appium常用操作之TouchAction操作
    TouchAction操作Appium的辅助类,主要针对手势操作,比如滑动、长按、拖动等。其原理是将一系列的动作放在一个链条中,然后将该链条传递给服务器。服务器接受到该链条后,解析各个动作,逐个执行。TouchAction类支持的动作很多;常用操作如下:1、press(self,el=None,x=None,y=None): 按......