package com.yitu.pictureshare;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.yitu.pictureshare.bean.CommentBean;
import com.yitu.pictureshare.bean.SaveImgTools;
import com.yitu.pictureshare.common.AppAuthorization;
import com.yitu.pictureshare.adapter.CommentAdapter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class ShareInfoActivity extends AppCompatActivity {
private static Handler handler;
private ArrayList<CommentBean> comments;
private String username;
private String pUserId;
private String userId;
private String shareId;
private String likeNum;
private String pUserName;
private String title;
private String content;
private String intentImageUrl;
private Boolean hasLike;
private Boolean hasFocus;
private int commentSize;
private TextView textView_title;
private TextView textView_content;
private TextView textView_author;
private TextView textView_likeNum;
private TextView textView_commentNum;
private TextView textView_deleteComment;
private EditText editText_comment;
private ImageView imageView;
private ImageView imageView_like;
private ImageView imageView_save;
private Button button_focus;
private Button button_submitComment;
private ListView listView;
@SuppressLint("UseCompatLoadingForDrawables")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_share_info);
Button back_to_index = findViewById(R.id.share_info_button_to_index);
textView_author = findViewById(R.id.share_user_name);
textView_title = findViewById(R.id.share_info_title);
textView_content = findViewById(R.id.share_info_content);
textView_likeNum = findViewById(R.id.like_num);
textView_commentNum = findViewById(R.id.comment_number);
textView_deleteComment = findViewById(R.id.delete_share);
editText_comment = findViewById(R.id.edit_text_comment);
imageView = findViewById(R.id.share_info_image);
imageView_like = findViewById(R.id.image_like);
imageView_save = findViewById(R.id.image_save);
listView = findViewById(R.id.list_comment);
button_focus = findViewById(R.id.button_focus);
button_submitComment = findViewById(R.id.button_submit_comment);
Intent intent = getIntent();
shareId = intent.getStringExtra("shareId");
intentImageUrl = intent.getStringExtra("intentImageUrl");
pUserName = intent.getStringExtra("pUserName");
Context ctx = ShareInfoActivity.this;
SharedPreferences sp = ctx.getSharedPreferences("SP", Context.MODE_PRIVATE);
username = sp.getString("username",null);
userId = sp.getString("id",null);
handler = new Handler(Looper.getMainLooper());
getShareInfo();
getComments();
textView_author.setText(pUserName);
textView_title.setText(title);
textView_content.setText(content);
back_to_index.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
Glide.with(ShareInfoActivity.this)
.load(intentImageUrl) //加载地址
.asBitmap()
.placeholder(R.drawable.loading_img)//加载未完成时显示占位图
.diskCacheStrategy(DiskCacheStrategy.NONE)
.into(imageView);//显示的位置
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent1 = new Intent(ShareInfoActivity.this, ShowPictureActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent1.putExtra("imageUrl", intentImageUrl);
startActivity(intent1);
}
});
imageView_save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SaveImgTools.SaveImageToSysAlbum(ShareInfoActivity.this, imageView);
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
finish();
}
public void getShareInfo(){
String url = "http://47.107.52.7:88/member/photo/share/detail";
// String url = "http://35.241.95.124:8081/user/login";
OkHttpClient client = new OkHttpClient();
SharedPreferences sp = ShareInfoActivity.this.getSharedPreferences("SP", Context.MODE_PRIVATE);
String appId = AppAuthorization.getAppId(sp);
String appSecret = AppAuthorization.getAppSecret(sp);
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("userId",userId);
// jsonObject.put("current",current);
// jsonObject.put("size",10);
//构建请求
// RequestBody body = RequestBody.create(jsonObject.toString(), MediaType.parse("application/json;charset=utf-8"));
Request request=new Request.Builder()
.addHeader("appId",appId)
.addHeader("appSecret",appSecret)
.url(url+"?userId="+userId+"&shareId="+shareId)
.get()
.build();
//异步请求
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.d("register", "连接失败" + e.getLocalizedMessage());
finish();
Looper.prepare();
Toast.makeText(ShareInfoActivity.this, "网络连接失败", Toast.LENGTH_SHORT).show();
Looper.loop();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
// System.out.println(response.body().string());
String result_string = response.body().string();
Map result = JSON.parseObject(result_string);
Map result_data = JSON.parseObject(result.get("data").toString());
System.out.println("————————————响应信息————————————\n"+result_data.toString());
System.out.println("————————————响应结束————————————");
if (result.get("code").toString().equals("200")) {
title = result_data.get("title").toString();
content = result_data.get("content").toString();
pUserId = result_data.get("pUserId").toString();
if(result_data.get("likeNum") != null)
likeNum = result_data.get("likeNum").toString();
else
likeNum = "0";
System.out.println("+++++++++++++++++++++++++++++"+result_data.get("pUserId").toString());
System.out.println("+++++++++++++++++
没有合适的资源?快使用搜索试试~ 我知道了~
基于Android的图片共享APP(桂林电子科技大学GUETers安卓课设).zip
共125个文件
xml:62个
java:25个
png:25个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 146 浏览量
2022-11-30
12:00:43
上传
评论 2
收藏 802KB ZIP 举报
温馨提示
基于Android的图片共享APP(桂林电子科技大学GUETers安卓课设).zip
资源推荐
资源详情
资源评论
收起资源包目录
基于Android的图片共享APP(桂林电子科技大学GUETers安卓课设).zip (125个子文件)
gradlew.bat 3KB
.gitignore 225B
.gitignore 47B
.gitignore 6B
build.gradle 2KB
build.gradle 505B
settings.gradle 334B
gradlew 6KB
gradle-wrapper.jar 58KB
ShareInfoActivity.java 34KB
HomeFragment.java 13KB
MyPictureActivity.java 13KB
FocusActivity.java 13KB
LoginActivity.java 10KB
ShareActivity.java 10KB
DcimUriget.java 6KB
ProfileFragment.java 5KB
RegisterActivity.java 4KB
CommentAdapter.java 4KB
IndexActivity.java 3KB
MySharesAdapter.java 3KB
ShowPictureActivity.java 2KB
SettingActivity.java 2KB
SharesAdapter.java 2KB
SaveImgTools.java 2KB
ShareBean.java 2KB
ExampleInstrumentedTest.java 762B
AboutActivity.java 689B
VersionActivity.java 678B
CommentBean.java 425B
ExampleUnitTest.java 382B
AppAuthorization.java 372B
ProfileViewModel.java 178B
HomeViewModel.java 134B
.name 12B
head_p1.png 627KB
ic_launcher_round.png 11KB
ic_launcher-playstore.png 9KB
ic_launcher_round.png 7KB
ic_launcher_round.png 5KB
ic_launcher.png 4KB
ic_launcher_round.png 3KB
ic_launcher.png 3KB
shezhi.png 2KB
guanyu.png 2KB
ic_launcher_round.png 2KB
gz.png 2KB
ic_launcher.png 2KB
zan.png 2KB
weishoucang.png 2KB
shoucang.png 2KB
fabu.png 1KB
weidianzan.png 1KB
ic_launcher.png 1KB
yishoucang.png 1KB
banben.png 1KB
baocun.png 1024B
yidianzan.png 910B
ic_launcher.png 895B
wenti.png 604B
proguard-rules.pro 750B
gradle.properties 1KB
gradle-wrapper.properties 232B
activity_share_info.xml 15KB
fragment_profile.xml 13KB
misc.xml 10KB
activity_login.xml 7KB
activity_register.xml 6KB
ic_launcher_background.xml 6KB
activity_setting.xml 5KB
activity_share.xml 5KB
activity_version.xml 4KB
activity_about.xml 4KB
AndroidManifest.xml 3KB
fragment_home.xml 3KB
cardview_picture.xml 2KB
strings.xml 2KB
card_view_mypicture.xml 2KB
activity_my_picture.xml 2KB
activity_focus.xml 2KB
activity_index.xml 2KB
themes.xml 1KB
ic_outline_visibility_off_24.xml 1KB
root_preferences.xml 1KB
circle_image.xml 1KB
comment_item.xml 953B
activity_show_picture.xml 843B
mobile_navigation.xml 840B
themes.xml 834B
ic_outline_account_circle_24.xml 797B
gradle.xml 680B
progress_bar.xml 670B
ic_outline_visibility_24.xml 647B
ic_baseline_favorite_border_24.xml 639B
ic_launcher_foreground.xml 592B
ic_outline_lock_24.xml 569B
ic_baseline_favorite_24.xml 459B
bottom_nav_menu.xml 440B
logo_about.xml 417B
customer_selector.xml 409B
共 125 条
- 1
- 2
资源评论
- AAA肖建国电路维修2023-10-15终于找到了超赞的宝藏资源,果断冲冲冲,支持!
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6718
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功