Compare commits
4 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
e017c5712d | 3 years ago |
|
|
ed24552663 | 3 years ago |
|
|
b2d354400a | 3 years ago |
|
|
adf5d1bddb | 3 years ago |
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android API 33, extension level 3 Platform" project-jdk-type="Android SDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.example.Fruits;
|
package com.example.ceshi;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.transfer;
|
package com.baidu.ai.aip;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.baidu.ai.aip;
|
||||||
|
|
||||||
|
import com.baidu.ai.aip.ImgCombination;
|
||||||
|
import com.example.ceshi.four;
|
||||||
|
|
||||||
|
public class ToIngredient{
|
||||||
|
public static String name_odds="AAAAAAAAAAAA";
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ImgCombination img=new ImgCombination();
|
||||||
|
String str = img.imgCombination();
|
||||||
|
String name=str.substring(str.indexOf("name")+7,str.indexOf("\"}"));
|
||||||
|
String odds=str.substring(str.indexOf("score")+7,str.indexOf(","));
|
||||||
|
name_odds="aaaa";//"有"+odds.substring(0,4)+"的概率是"+name;
|
||||||
|
System.out.println("有"+odds.substring(0,4)+"的概率是"+name);
|
||||||
|
}
|
||||||
|
public String x(){
|
||||||
|
name_odds="bbbb";
|
||||||
|
return name_odds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.example.ceshi;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
public class collection extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.collview);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,118 @@
|
|||||||
|
package com.example.ceshi;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
|
import com.baidu.ai.aip.ImgCombination;
|
||||||
|
import com.baidu.ai.aip.ToIngredient;
|
||||||
|
import com.baidu.ai.aip.Ingredient;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class four extends AppCompatActivity {
|
||||||
|
final int TAKE_PHOTO=1;
|
||||||
|
ImageView iv_photo;
|
||||||
|
Uri imageUri;
|
||||||
|
TextView t1;
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState){
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.fourview);
|
||||||
|
|
||||||
|
Button btn_1=findViewById(R.id.btn_takephoto);
|
||||||
|
iv_photo=findViewById(R.id.img_photo);
|
||||||
|
t1=findViewById(R.id.textView11);
|
||||||
|
|
||||||
|
|
||||||
|
//ToIngredient ii= new ToIngredient();
|
||||||
|
|
||||||
|
ImgCombination img=new ImgCombination();
|
||||||
|
//String str11 = img.imgCombination();
|
||||||
|
Ingredient a=new Ingredient();
|
||||||
|
// "{\"result_num\":5,\"result\":[{\"score\":0.6307158,\"name\":\"砀山酥梨\"},{\"score\":0.19453917,\"name\":\"砀山梨\"},{\"score\":0.06309598,\"name\":\"北丰梨\"},{\"score\":0.062131744,\"name\":\"雪梨\"},{\"score\":0.0255048,\"name\":\"梨\"}],\"log_id\":1582269295467236738}\n";
|
||||||
|
//t1.setText("A"+str11+"B");
|
||||||
|
t1.setText("###"+Ingredient.ingredient());
|
||||||
|
|
||||||
|
|
||||||
|
btn_1.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
File output=new File(getExternalCacheDir(),"output_image.jpg");
|
||||||
|
try {
|
||||||
|
if (output.exists()){
|
||||||
|
output.delete();
|
||||||
|
}
|
||||||
|
output.createNewFile();
|
||||||
|
}catch (IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT>=24){
|
||||||
|
//图片的保存路径
|
||||||
|
imageUri= FileProvider.getUriForFile(four.this,"com.example.takephoto.fileprovider",output);
|
||||||
|
}
|
||||||
|
else { imageUri=Uri.fromFile(output);}
|
||||||
|
//跳转界面到系统自带的拍照界面
|
||||||
|
Intent intent=new Intent("android.media.action.IMAGE_CAPTURE");
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT,imageUri);
|
||||||
|
startActivityForResult(intent,TAKE_PHOTO);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// String str = ImgCombination.imgCombination();
|
||||||
|
// String name=str.substring(str.indexOf("name")+7,str.indexOf("\"}"));
|
||||||
|
// String odds=str.substring(str.indexOf("score")+7,str.indexOf(","));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
|
||||||
|
protected void onActivityResult(int requestCode,int resultCode,Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
switch (requestCode){
|
||||||
|
case TAKE_PHOTO:
|
||||||
|
if (resultCode==RESULT_OK){
|
||||||
|
// 使用try让程序运行在内报错
|
||||||
|
try {
|
||||||
|
//将图片保存
|
||||||
|
Bitmap bitmap= BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri));
|
||||||
|
iv_photo.setImageBitmap(bitmap);
|
||||||
|
|
||||||
|
|
||||||
|
//ToIngredient to_in=new ToIngredient();
|
||||||
|
|
||||||
|
ImgCombination img1=new ImgCombination();
|
||||||
|
String str1 =img1.imgCombination();
|
||||||
|
//// ToIngredient ii= new ToIngredient();
|
||||||
|
// String aa=ii.x();
|
||||||
|
//String name=str.substring(str.indexOf("name")+7,str.indexOf("\"}"));
|
||||||
|
//TextView t1=()findViewById(R.id.textView11);
|
||||||
|
//t1.setText(str1);
|
||||||
|
}catch (FileNotFoundException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
package com.example.ceshi;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;d
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class get extends Activity {
|
||||||
|
// textview
|
||||||
|
private TextView mTextView;
|
||||||
|
// handler线程
|
||||||
|
private Handler mHandler = new Handler() {
|
||||||
|
public void handleMessage(android.os.Message msg) {
|
||||||
|
mTextView.setText((String) msg.obj);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.get);
|
||||||
|
// 绑定id
|
||||||
|
mTextView = (TextView) findViewById(R.id.a);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 联网
|
||||||
|
private void getHttp() {
|
||||||
|
InputStream stream = null;
|
||||||
|
InputStreamReader re = null;
|
||||||
|
BufferedReader reader = null;
|
||||||
|
try {
|
||||||
|
// 找水源
|
||||||
|
URL url = new URL("http://www.taobao.com");
|
||||||
|
// 建立总闸
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
// 建立水道
|
||||||
|
stream = conn.getInputStream();
|
||||||
|
// 捕鱼
|
||||||
|
// 小渔网
|
||||||
|
re = new InputStreamReader(stream);
|
||||||
|
// 大渔网
|
||||||
|
reader = new BufferedReader(re);
|
||||||
|
|
||||||
|
// 捞鱼
|
||||||
|
// 大水桶
|
||||||
|
String len = "";
|
||||||
|
// 小水桶
|
||||||
|
String temp = "";
|
||||||
|
while ((temp = reader.readLine()) != null) {
|
||||||
|
len += temp;
|
||||||
|
}
|
||||||
|
// 更新UI
|
||||||
|
Message sg = new Message();
|
||||||
|
sg.obj = len;
|
||||||
|
mHandler.sendMessage(sg);
|
||||||
|
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// 晒网,关闭资源
|
||||||
|
try {
|
||||||
|
if (reader != null) {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
if (re != null) {
|
||||||
|
re.close();
|
||||||
|
}
|
||||||
|
if (stream != null) {
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e2) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按钮监听
|
||||||
|
public void aaa(View v) {
|
||||||
|
//新建一个线程
|
||||||
|
new Thread() {
|
||||||
|
public void run() {
|
||||||
|
getHttp();
|
||||||
|
};
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 649 B |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/web_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:layout_editor_absoluteX="61dp"
|
||||||
|
tools:layout_editor_absoluteY="86dp">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button8"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_x="307dp"
|
||||||
|
android:layout_y="666dp"
|
||||||
|
android:background="@android:color/holo_orange_light"
|
||||||
|
android:text="收藏" />
|
||||||
|
</WebView>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".first">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/five"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="我的收藏"
|
||||||
|
android:textSize="25dp"
|
||||||
|
android:textColor="#663399"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.497"
|
||||||
|
app:layout_constraintVertical_bias="0.499"/>
|
||||||
|
<SearchView
|
||||||
|
android:layout_width="407dp"
|
||||||
|
android:layout_height="100dp" tools:layout_editor_absoluteY="1dp" tools:layout_editor_absoluteX="1dp"
|
||||||
|
tools:ignore="MissingConstraints"/>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/a12"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="获取"
|
||||||
|
android:onClick="aaa"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_below="@id/a12"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/a"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="获取网址内容" />
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 982 B After Width: | Height: | Size: 982 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
@ -1,4 +1,4 @@
|
|||||||
package com.example.Fruits;
|
package com.example.ceshi;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 236 KiB |
|
Before Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 27 KiB |