Day11.01作业
布局两个接口两个JavaBean
Okhttp封装适配器MainMain2Main3
布局
<?xml version
="1.0" encoding
="utf-8"?>
<LinearLayout 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"
android
:orientation
="vertical"
tools
:context
=".MainActivity">
<EditText
android
:id
="@+id/name"
android
:hint
="用户名"
android
:layout_width
="match_parent"
android
:layout_height
="wrap_content" />
<EditText
android
:id
="@+id/pwd"
android
:hint
="密码"
android
:layout_width
="match_parent"
android
:layout_height
="wrap_content" />
<Button
android
:id
="@+id/login"
android
:text
="登录"
android
:layout_width
="wrap_content"
android
:layout_height
="wrap_content" />
<Button
android
:id
="@+id/register"
android
:text
="注册"
android
:layout_width
="wrap_content"
android
:layout_height
="wrap_content" />
</LinearLayout
>
<?xml version
="1.0" encoding
="utf-8"?>
<LinearLayout 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"
android
:orientation
="vertical"
tools
:context
=".Main2Activity">
<EditText
android
:id
="@+id/name"
android
:hint
="用户名"
android
:layout_width
="match_parent"
android
:layout_height
="wrap_content" />
<EditText
android
:id
="@+id/pwd"
android
:hint
="密码"
android
:layout_width
="match_parent"
android
:layout_height
="wrap_content" />
<Button
android
:id
="@+id/register"
android
:text
="注册"
android
:layout_width
="wrap_content"
android
:layout_height
="wrap_content" />
</LinearLayout
>
<?xml version
="1.0" encoding
="utf-8"?>
<LinearLayout 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
=".Main3Activity">
<ListView
android
:id
="@+id/lv"
android
:layout_width
="match_parent"
android
:layout_height
="match_parent"></ListView
>
</LinearLayout
>
<?xml version
="1.0" encoding
="utf-8"?>
<LinearLayout
xmlns
:android
="http://schemas.android.com/apk/res/android" android
:layout_width
="match_parent"
android
:layout_height
="match_parent">
<TextView
android
:id
="@+id/tv"
android
:text
="这是标题"
android
:textSize
="20sp"
android
:layout_width
="wrap_content"
android
:layout_height
="wrap_content" />
</LinearLayout
>
两个接口
package com
.example
.day1001homework
.listener
;
public interface MyListener {
void onOk(String ok
);
void onError(String message
);
}
package com
.example
.day1001homework
.listener
;
public interface MyProgressListener {
void setProgress(int s
);
void finish();
void onError(String s
);
}
两个JavaBean
package com
.example
.day1001homework
;
import java
.util
.List
;
public class Douyin {
private int code
;
private String msg
;
private List
<DataBean> data
;
public int getCode() {
return code
;
}
public void setCode(int code
) {
this.code
= code
;
}
public String
getMsg() {
return msg
;
}
public void setMsg(String msg
) {
this.msg
= msg
;
}
public List
<DataBean> getData() {
return data
;
}
public void setData(List
<DataBean> data
) {
this.data
= data
;
}
public static class DataBean {
private String type
;
private String text
;
private String user_id
;
private String name
;
private String screen_name
;
private String profile_image
;
private String created_at
;
private Object create_time
;
private String passtime
;
private String love
;
private String hate
;
private String comment
;
private String repost
;
private String bookmark
;
private String bimageuri
;
private Object voiceuri
;
private Object voicetime
;
private Object voicelength
;
private String status
;
private String theme_id
;
private String theme_name
;
private String theme_type
;
private String videouri
;
private int videotime
;
private String original_pid
;
private int cache_version
;
private Object playcount
;
private Object playfcount
;
private String cai
;
private Object weixin_url
;
private String image1
;
private String image2
;
private boolean is_gif
;
private String image0
;
private Object image_small
;
private String cdn_img
;
private String width
;
private String height
;
private String tag
;
private int t
;
private String ding
;
private String favourite
;
private Object top_cmt
;
private Object themes
;
public String
getType() {
return type
;
}
public void setType(String type
) {
this.type
= type
;
}
public String
getText() {
return text
;
}
public void setText(String text
) {
this.text
= text
;
}
public String
getUser_id() {
return user_id
;
}
public void setUser_id(String user_id
) {
this.user_id
= user_id
;
}
public String
getName() {
return name
;
}
public void setName(String name
) {
this.name
= name
;
}
public String
getScreen_name() {
return screen_name
;
}
public void setScreen_name(String screen_name
) {
this.screen_name
= screen_name
;
}
public String
getProfile_image() {
return profile_image
;
}
public void setProfile_image(String profile_image
) {
this.profile_image
= profile_image
;
}
public String
getCreated_at() {
return created_at
;
}
public void setCreated_at(String created_at
) {
this.created_at
= created_at
;
}
public Object
getCreate_time() {
return create_time
;
}
public void setCreate_time(Object create_time
) {
this.create_time
= create_time
;
}
public String
getPasstime() {
return passtime
;
}
public void setPasstime(String passtime
) {
this.passtime
= passtime
;
}
public String
getLove() {
return love
;
}
public void setLove(String love
) {
this.love
= love
;
}
public String
getHate() {
return hate
;
}
public void setHate(String hate
) {
this.hate
= hate
;
}
public String
getComment() {
return comment
;
}
public void setComment(String comment
) {
this.comment
= comment
;
}
public String
getRepost() {
return repost
;
}
public void setRepost(String repost
) {
this.repost
= repost
;
}
public String
getBookmark() {
return bookmark
;
}
public void setBookmark(String bookmark
) {
this.bookmark
= bookmark
;
}
public String
getBimageuri() {
return bimageuri
;
}
public void setBimageuri(String bimageuri
) {
this.bimageuri
= bimageuri
;
}
public Object
getVoiceuri() {
return voiceuri
;
}
public void setVoiceuri(Object voiceuri
) {
this.voiceuri
= voiceuri
;
}
public Object
getVoicetime() {
return voicetime
;
}
public void setVoicetime(Object voicetime
) {
this.voicetime
= voicetime
;
}
public Object
getVoicelength() {
return voicelength
;
}
public void setVoicelength(Object voicelength
) {
this.voicelength
= voicelength
;
}
public String
getStatus() {
return status
;
}
public void setStatus(String status
) {
this.status
= status
;
}
public String
getTheme_id() {
return theme_id
;
}
public void setTheme_id(String theme_id
) {
this.theme_id
= theme_id
;
}
public String
getTheme_name() {
return theme_name
;
}
public void setTheme_name(String theme_name
) {
this.theme_name
= theme_name
;
}
public String
getTheme_type() {
return theme_type
;
}
public void setTheme_type(String theme_type
) {
this.theme_type
= theme_type
;
}
public String
getVideouri() {
return videouri
;
}
public void setVideouri(String videouri
) {
this.videouri
= videouri
;
}
public int getVideotime() {
return videotime
;
}
public void setVideotime(int videotime
) {
this.videotime
= videotime
;
}
public String
getOriginal_pid() {
return original_pid
;
}
public void setOriginal_pid(String original_pid
) {
this.original_pid
= original_pid
;
}
public int getCache_version() {
return cache_version
;
}
public void setCache_version(int cache_version
) {
this.cache_version
= cache_version
;
}
public Object
getPlaycount() {
return playcount
;
}
public void setPlaycount(Object playcount
) {
this.playcount
= playcount
;
}
public Object
getPlayfcount() {
return playfcount
;
}
public void setPlayfcount(Object playfcount
) {
this.playfcount
= playfcount
;
}
public String
getCai() {
return cai
;
}
public void setCai(String cai
) {
this.cai
= cai
;
}
public Object
getWeixin_url() {
return weixin_url
;
}
public void setWeixin_url(Object weixin_url
) {
this.weixin_url
= weixin_url
;
}
public String
getImage1() {
return image1
;
}
public void setImage1(String image1
) {
this.image1
= image1
;
}
public String
getImage2() {
return image2
;
}
public void setImage2(String image2
) {
this.image2
= image2
;
}
public boolean isIs_gif() {
return is_gif
;
}
public void setIs_gif(boolean is_gif
) {
this.is_gif
= is_gif
;
}
public String
getImage0() {
return image0
;
}
public void setImage0(String image0
) {
this.image0
= image0
;
}
public Object
getImage_small() {
return image_small
;
}
public void setImage_small(Object image_small
) {
this.image_small
= image_small
;
}
public String
getCdn_img() {
return cdn_img
;
}
public void setCdn_img(String cdn_img
) {
this.cdn_img
= cdn_img
;
}
public String
getWidth() {
return width
;
}
public void setWidth(String width
) {
this.width
= width
;
}
public String
getHeight() {
return height
;
}
public void setHeight(String height
) {
this.height
= height
;
}
public String
getTag() {
return tag
;
}
public void setTag(String tag
) {
this.tag
= tag
;
}
public int getT() {
return t
;
}
public void setT(int t
) {
this.t
= t
;
}
public String
getDing() {
return ding
;
}
public void setDing(String ding
) {
this.ding
= ding
;
}
public String
getFavourite() {
return favourite
;
}
public void setFavourite(String favourite
) {
this.favourite
= favourite
;
}
public Object
getTop_cmt() {
return top_cmt
;
}
public void setTop_cmt(Object top_cmt
) {
this.top_cmt
= top_cmt
;
}
public Object
getThemes() {
return themes
;
}
public void setThemes(Object themes
) {
this.themes
= themes
;
}
}
}
package com
.example
.day1001homework
;
public class JavaBean {
private int code
;
private String msg
;
private DataBean data
;
public int getCode() {
return code
;
}
public void setCode(int code
) {
this.code
= code
;
}
public String
getMsg() {
return msg
;
}
public void setMsg(String msg
) {
this.msg
= msg
;
}
public DataBean
getData() {
return data
;
}
public void setData(DataBean data
) {
this.data
= data
;
}
public static class DataBean {
private String appId
;
private String appkey
;
public String
getAppId() {
return appId
;
}
public void setAppId(String appId
) {
this.appId
= appId
;
}
public String
getAppkey() {
return appkey
;
}
public void setAppkey(String appkey
) {
this.appkey
= appkey
;
}
}
}
Okhttp封装
package com
.example
.day1001homework
;
import android
.os
.Handler
;
import com
.example
.day1001homework
.listener
.MyListener
;
import com
.example
.day1001homework
.listener
.MyProgressListener
;
import java
.io
.File
;
import java
.io
.FileOutputStream
;
import java
.io
.IOException
;
import java
.io
.InputStream
;
import java
.util
.HashMap
;
import java
.util
.Map
;
import java
.util
.Set
;
import java
.util
.concurrent
.TimeUnit
;
import okhttp3
.Call
;
import okhttp3
.Callback
;
import okhttp3
.FormBody
;
import okhttp3
.MediaType
;
import okhttp3
.MultipartBody
;
import okhttp3
.OkHttpClient
;
import okhttp3
.Request
;
import okhttp3
.RequestBody
;
import okhttp3
.Response
;
public class MyHttpUtils {
private static OkHttpClient client
;
private static Handler handler
= new Handler();
private MyHttpUtils() {
client
= new OkHttpClient.Builder()
.connectTimeout(20, TimeUnit
.SECONDS
)
.connectTimeout(20,TimeUnit
.SECONDS
)
.build();
}
private static MyHttpUtils myHttpUtils
= null
;
public static MyHttpUtils
getInstance(){
if (myHttpUtils
== null
){
synchronized (Object
.class){
if (myHttpUtils
== null
){
myHttpUtils
= new MyHttpUtils();
}
}
}
return myHttpUtils
;
}
public static void doget(String url
, final MyListener myListener
){
Request request
= new Request.Builder()
.get()
.url(url
)
.build();
client
.newCall(request
).enqueue(new Callback() {
@Override
public void onFailure(Call call
, IOException e
) {
final String message
= e
.getMessage();
handler
.post(new Runnable() {
@Override
public void run() {
myListener
.onError(message
);
}
});
}
@Override
public void onResponse(Call call
, Response response
) throws IOException
{
final String string
= response
.body().string();
handler
.post(new Runnable() {
@Override
public void run() {
myListener
.onOk(string
);
}
});
}
});
}
public static void onpost(String url
, HashMap
<String,String> map
, final MyListener myListener
){
FormBody
.Builder builder
= new FormBody.Builder();
Set
<Map
.Entry
<String, String>> entries
= map
.entrySet();
for (Map
.Entry
<String, String> entry
: entries
) {
builder
.add(entry
.getKey(),entry
.getValue());
}
Request request
= new Request.Builder()
.url(url
)
.post(builder
.build())
.build();
client
.newCall(request
).enqueue(new Callback() {
@Override
public void onFailure(Call call
, IOException e
) {
final String message
= e
.getMessage();
handler
.post(new Runnable() {
@Override
public void run() {
myListener
.onError(message
);
}
});
}
@Override
public void onResponse(Call call
, Response response
) throws IOException
{
final String string
= response
.body().string();
handler
.post(new Runnable() {
@Override
public void run() {
myListener
.onOk(string
);
}
});
}
});
}
public static void upload(String url
, final String path
,String servername
,String type
, final MyListener myListener
){
RequestBody requestBody
= RequestBody
.create(MediaType
.parse(type
), new File(path
));
MultipartBody build
= new MultipartBody.Builder()
.addFormDataPart("file",servername
,requestBody
)
.setType(MultipartBody
.FORM
)
.build();
Request request
= new Request.Builder()
.url(url
)
.post(build
)
.build();
client
.newCall(request
).enqueue(new Callback() {
@Override
public void onFailure(Call call
, IOException e
) {
final String message
= e
.getMessage();
handler
.post(new Runnable() {
@Override
public void run() {
myListener
.onError(message
);
}
});
}
@Override
public void onResponse(Call call
, Response response
) throws IOException
{
handler
.post(new Runnable() {
@Override
public void run() {
myListener
.onOk("上传成功");
}
});
}
});
}
public static void dowmload(String url
, final String path
, final MyProgressListener myProgressListener
){
Request request
= new Request.Builder()
.get()
.url(url
)
.build();
client
.newCall(request
).enqueue(new Callback() {
@Override
public void onFailure(Call call
, IOException e
) {
final String message
= e
.getMessage();
handler
.post(new Runnable() {
@Override
public void run() {
myProgressListener
.onError(message
);
}
});
}
@Override
public void onResponse(Call call
, Response response
) throws IOException
{
long length
= response
.body().contentLength();
InputStream inputStream
= response
.body().byteStream();
FileOutputStream fileOutputStream
= new FileOutputStream(path
);
int len
= 0;
int count
= 0;
byte[] bytes
= new byte[1024];
while ((len
= inputStream
.read(bytes
))!=-1){
fileOutputStream
.write(bytes
,0,len
);
count
+= len
;
final int progress
= (int) (count
*100/length
);
handler
.post(new Runnable() {
@Override
public void run() {
myProgressListener
.setProgress(progress
);
}
});
}
handler
.post(new Runnable() {
@Override
public void run() {
myProgressListener
.finish();
}
});
}
});
}
}
适配器
package com
.example
.day1001homework
;
import android
.content
.Context
;
import android
.view
.LayoutInflater
;
import android
.view
.View
;
import android
.view
.ViewGroup
;
import android
.widget
.BaseAdapter
;
import android
.widget
.TextView
;
import java
.util
.List
;
public class MyAdapter extends BaseAdapter {
private List
<Douyin.DataBean> list
;
private Context context
;
private LayoutInflater layoutInflater
;
public MyAdapter(List
<Douyin.DataBean> list
, Context context
) {
this.list
= list
;
this.context
= context
;
layoutInflater
= LayoutInflater
.from(context
);
}
@Override
public int getCount() {
return list
.size();
}
@Override
public Object
getItem(int position
) {
return list
.get(position
);
}
@Override
public long getItemId(int position
) {
return position
;
}
@Override
public View
getView(int position
, View convertView
, ViewGroup parent
) {
ViewHolder holder
= null
;
if (convertView
== null
){
holder
= new ViewHolder();
convertView
= layoutInflater
.inflate(R
.layout
.layout_item
,null
);
holder
.tv
= convertView
.findViewById(R
.id
.tv
);
convertView
.setTag(holder
);
}else {
holder
= (ViewHolder
) convertView
.getTag();
}
holder
.tv
.setText(list
.get(position
).getText());
return convertView
;
}
class ViewHolder{
TextView tv
;
}
}
Main
package com
.example
.day1001homework
;
import android
.Manifest
;
import android
.content
.Intent
;
import android
.support
.v7
.app
.AppCompatActivity
;
import android
.os
.Bundle
;
import android
.view
.View
;
import android
.widget
.Button
;
import android
.widget
.EditText
;
import android
.widget
.Toast
;
import com
.example
.day1001homework
.listener
.MyListener
;
import com
.google
.gson
.Gson
;
import java
.util
.HashMap
;
public class MainActivity extends AppCompatActivity {
private EditText name
;
private EditText pwd
;
private Button login
;
private Button register
;
private String get_url
= "https://www.apiopen.top/createUserKey?appId=com.github.wlsj&passwd=123456";
private String post_url
="https://www.apiopen.top/login";
private String appkey
;
@Override
protected void onCreate(Bundle savedInstanceState
) {
super.onCreate(savedInstanceState
);
setContentView(R
.layout
.activity_main
);
name
= (EditText
) findViewById(R
.id
.name
);
pwd
= (EditText
) findViewById(R
.id
.pwd
);
login
= (Button
) findViewById(R
.id
.login
);
register
= (Button
) findViewById(R
.id
.register
);
requestPermissions(new String[]{Manifest
.permission
.WRITE_EXTERNAL_STORAGE
,Manifest
.permission
.READ_EXTERNAL_STORAGE
},100);
register
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v
) {
Intent intent
= new Intent(MainActivity
.this, Main2Activity
.class);
startActivity(intent
);
}
});
MyHttpUtils
.getInstance().doget(get_url
, new MyListener() {
@Override
public void onOk(String ok
) {
JavaBean javaBean
= new Gson().fromJson(ok
, JavaBean
.class);
JavaBean
.DataBean data
= javaBean
.getData();
appkey
= data
.getAppkey();
}
@Override
public void onError(String message
) {
}
});
https
://www
.apiopen
.top
/login
?key
=00d91e8e0cca2b76f515926a36db68f5
&phone
=13594347817&passwd
=123456
login
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v
) {
String s
= name
.getText().toString();
String s1
= pwd
.getText().toString();
HashMap
<String, String> map
= new HashMap<>();
map
.put("key",appkey
);
map
.put("phone",s
);
map
.put("passwd",s1
);
MyHttpUtils
.getInstance().onpost(post_url
, map
, new MyListener() {
@Override
public void onOk(String ok
) {
finish();
Intent intent
= new Intent(MainActivity
.this, Main3Activity
.class);
startActivity(intent
);
Toast
.makeText(MainActivity
.this, "登录成功", Toast
.LENGTH_SHORT
).show();
}
@Override
public void onError(String message
) {
}
});
}
});
}
}
Main2
package com
.example
.day1001homework
;
import android
.support
.v7
.app
.AppCompatActivity
;
import android
.os
.Bundle
;
import android
.view
.View
;
import android
.widget
.Button
;
import android
.widget
.EditText
;
import android
.widget
.Toast
;
import com
.example
.day1001homework
.listener
.MyListener
;
import com
.google
.gson
.Gson
;
import java
.util
.HashMap
;
public class Main2Activity extends AppCompatActivity {
private EditText name
;
private EditText pwd
;
private Button register
;
private String appkey
;
private String get_url
= "https://www.apiopen.top/createUserKey?appId=com.github.wlsj&passwd=123456";
private String post_url
="https://www.apiopen.top/createUser";
@Override
protected void onCreate(Bundle savedInstanceState
) {
super.onCreate(savedInstanceState
);
setContentView(R
.layout
.activity_main2
);
name
= (EditText
) findViewById(R
.id
.name
);
pwd
= (EditText
) findViewById(R
.id
.pwd
);
register
= (Button
) findViewById(R
.id
.register
);
MyHttpUtils
.getInstance().doget(get_url
, new MyListener() {
@Override
public void onOk(String ok
) {
JavaBean javaBean
= new Gson().fromJson(ok
, JavaBean
.class);
JavaBean
.DataBean data
= javaBean
.getData();
appkey
= data
.getAppkey();
Toast
.makeText(Main2Activity
.this, ""+appkey
, Toast
.LENGTH_SHORT
).show();
}
@Override
public void onError(String message
) {
}
});
register
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v
) {
String s
= name
.getText().toString();
String s1
= pwd
.getText().toString();
HashMap
<String, String> map
= new HashMap<>();
map
.put("key",appkey
);
map
.put("phone",s
);
map
.put("passwd",s1
);
MyHttpUtils
.getInstance().onpost(post_url
, map
, new MyListener() {
@Override
public void onOk(String ok
) {
finish();
Toast
.makeText(Main2Activity
.this, "注册成功", Toast
.LENGTH_SHORT
).show();
}
@Override
public void onError(String message
) {
Toast
.makeText(Main2Activity
.this, "注册失败", Toast
.LENGTH_SHORT
).show();
}
});
}
});
}
}
Main3
package com
.example
.day1001homework
;
import android
.support
.v7
.app
.AppCompatActivity
;
import android
.os
.Bundle
;
import android
.view
.View
;
import android
.widget
.AdapterView
;
import android
.widget
.ListView
;
import android
.widget
.Toast
;
import com
.example
.day1001homework
.listener
.MyListener
;
import com
.example
.day1001homework
.listener
.MyProgressListener
;
import com
.google
.gson
.Gson
;
import java
.io
.File
;
import java
.util
.ArrayList
;
import java
.util
.List
;
public class Main3Activity extends AppCompatActivity {
private List
<Douyin.DataBean> list
= new ArrayList<>();
private String get_url
="https://www.apiopen.top/satinApi?type=1&page=2";
private String upload_url
="http://169.254.66.222/hfs/";
private MyAdapter myAdapter
;
private ListView lv
;
@Override
protected void onCreate(Bundle savedInstanceState
) {
super.onCreate(savedInstanceState
);
setContentView(R
.layout
.activity_main3
);
lv
= (ListView
) findViewById(R
.id
.lv
);
MyHttpUtils
.getInstance().doget(get_url
, new MyListener() {
@Override
public void onOk(String ok
) {
Douyin douyin
= new Gson().fromJson(ok
, Douyin
.class);
List
<Douyin.DataBean> data
= douyin
.getData();
list
.addAll(data
);
myAdapter
= new MyAdapter(list
,Main3Activity
.this);
lv
.setAdapter(myAdapter
);
}
@Override
public void onError(String message
) {
Toast
.makeText(Main3Activity
.this, "请求失败", Toast
.LENGTH_SHORT
).show();
}
});
lv
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView
<?> parent
, View view
, int position
, long id
) {
String videouri
= list
.get(position
).getVideouri();
if (!videouri
.equals("")){
MyHttpUtils
.getInstance().dowmload(videouri
, "/storage/emulated/0/Movies/DouMusic"+position
+".mp4", new MyProgressListener() {
@Override
public void setProgress(int s
) {
}
@Override
public void finish() {
Toast
.makeText(Main3Activity
.this, "下载成功", Toast
.LENGTH_SHORT
).show();
}
@Override
public void onError(String s
) {
Toast
.makeText(Main3Activity
.this, "没有请求到数据", Toast
.LENGTH_SHORT
).show();
}
});
}else {
Toast
.makeText(Main3Activity
.this, "没有地址", Toast
.LENGTH_SHORT
).show();
}
}
});
lv
.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView
<?> parent
, View view
, int position
, long id
) {
String upload_path
="/storage/emulated/0/Movies/DouMusic" + position
+ ".mp4";
File file
= new File("/storage/emulated/0/Movies/DouMusic" + position
+ ".mp4");
if (file
.exists()){
MyHttpUtils
.getInstance().upload(upload_url
, upload_path
, "DouMusic" + position
+".mp4", "media/mp4", new MyListener() {
@Override
public void onOk(String ok
) {
Toast
.makeText(Main3Activity
.this, "上传成功", Toast
.LENGTH_SHORT
).show();
}
@Override
public void onError(String message
) {
Toast
.makeText(Main3Activity
.this, "上传失败", Toast
.LENGTH_SHORT
).show();
}
});
}else{
Toast
.makeText(Main3Activity
.this, "不存在", Toast
.LENGTH_SHORT
).show();
}
return true;
}
});
}
}