Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
王宇洋 | 273dd505fa | 3 years ago |
王宇洋 | 7c79a7d164 | 3 years ago |
王宇洋 | 363151ac33 | 3 years ago |
王宇洋 | 7030273505 | 3 years ago |
王宇洋 | c147d5c9f0 | 3 years ago |
王宇洋 | c73799e88e | 3 years ago |
@ -0,0 +1,39 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "675677589197",
|
||||
"project_id": "android-colorize",
|
||||
"storage_bucket": "android-colorize.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:675677589197:android:6a326992f3f1a26ad3e384",
|
||||
"android_client_info": {
|
||||
"package_name": "com.echo.colorize"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "675677589197-h68j30ga4sgb7q7ml4838vgs47gic5dg.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyBP2PgEHuz8TLE0LikRV5I19piagGG4CQg"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "675677589197-h68j30ga4sgb7q7ml4838vgs47gic5dg.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.echo.colorizeit.Interfaces;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/10-19:38
|
||||
* @Project: My Application
|
||||
* @Package: com.echo.colorizeit.Interfaces
|
||||
* @Description:
|
||||
**/
|
||||
public interface ImageRequestListener {
|
||||
void success(Bitmap image);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.echo.colorizeit.ui.a_add_newpost_activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.echo.colorizeit.ui.BaseActivity;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/10-19:15
|
||||
* @Project: My Application
|
||||
* @Package: com.echo.colorizeit.ui.a_add_newpost_activity
|
||||
* @Description:
|
||||
**/
|
||||
public class AddNewPostActivity extends BaseActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package com.echo.colorizeit.ui.a_comments_details;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.myapplication.databinding.CommunityDetailItemBinding;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import cn.leancloud.LCFile;
|
||||
import cn.leancloud.LCObject;
|
||||
import cn.leancloud.LCQuery;
|
||||
import cn.leancloud.gson.GsonObject;
|
||||
import cn.leancloud.json.JSONObject;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/13-14:34
|
||||
* @Project: My Application
|
||||
* @Package: com.echo.colorizeit.ui.a_comments_details
|
||||
* @Description:
|
||||
**/
|
||||
public class CommentItemAdapter extends RecyclerView.Adapter {
|
||||
private CommentsActivity context;
|
||||
private JSONObject comments = new GsonObject();
|
||||
|
||||
public CommentItemAdapter(CommentsActivity context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void update_comments(JSONObject posts) {
|
||||
this.comments = new GsonObject(posts);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
CommunityDetailItemBinding binding;
|
||||
binding = CommunityDetailItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
CommentsViewHolder holder = new CommentsViewHolder(binding.getRoot());
|
||||
holder.binding = binding;
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
CommentsViewHolder holder1 = (CommentsViewHolder) holder;
|
||||
JSONObject object = comments.getJSONObject(String.valueOf(position));
|
||||
holder1.binding.commentCommentText.setText(object.getString("text"));
|
||||
holder1.binding.commentPostDate.setText(object.getString("time"));
|
||||
holder1.binding.commentUsername.setText(object.getString("username") != null ? object.getString("username").toString() : "");
|
||||
holder1.binding.commentsUserIcon.setClipToOutline(true);
|
||||
JSONObject user = object.getJSONObject("User");
|
||||
if (user != null) {
|
||||
System.out.println(user);
|
||||
JSONObject user_icon = user.getJSONObject("serverData");
|
||||
user_icon = user_icon.getJSONObject("user_icon");
|
||||
JSONObject user_avatar = user_icon.getJSONObject("serverData");
|
||||
LCQuery<LCObject> query2 = new LCQuery<>("_File");
|
||||
query2.getInBackground(user_avatar.getString("objectId")).subscribe(new Observer<LCObject>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull LCObject lcObject) {
|
||||
LCFile tmp = (LCFile) lcObject;
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(400 * position);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(tmp.getUrl());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = url.openStream();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (is != null) {
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||
context.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder1.binding.commentsUserIcon.setImageBitmap(bitmap);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return comments.size();
|
||||
}
|
||||
|
||||
private static class CommentsViewHolder extends RecyclerView.ViewHolder {
|
||||
public CommunityDetailItemBinding binding;
|
||||
|
||||
public CommentsViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.echo.colorizeit.ui.a_comments_details;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.echo.colorizeit.ImageUtil.PhotoLib;
|
||||
import com.echo.colorizeit.ui.BaseActivity;
|
||||
import com.example.myapplication.databinding.CommunityDetailBinding;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.leancloud.LCObject;
|
||||
import cn.leancloud.LCQuery;
|
||||
import cn.leancloud.LCUser;
|
||||
import cn.leancloud.gson.GsonObject;
|
||||
import cn.leancloud.json.JSONObject;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/13-14:32
|
||||
* @Project: My Application
|
||||
* @Package: com.echo.colorizeit.ui.a_comments_details
|
||||
* @Description:
|
||||
**/
|
||||
public class CommentsActivity extends BaseActivity {
|
||||
private CommunityDetailBinding binding;
|
||||
private CommentsViewModel model;
|
||||
private CommentItemAdapter adapter = new CommentItemAdapter(this);
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = CommunityDetailBinding.inflate(getLayoutInflater());
|
||||
model = new ViewModelProvider(this).get(CommentsViewModel.class);
|
||||
setContentView(binding.getRoot());
|
||||
Intent intent = getIntent();
|
||||
String image_path = intent.getStringExtra("image_path");
|
||||
String image_object_id = intent.getStringExtra("object_id");
|
||||
LCQuery<LCObject> query = new LCQuery<>("Posts");
|
||||
query.getInBackground(image_object_id).subscribe(new Observer<LCObject>() {
|
||||
public void onSubscribe(Disposable disposable) {}
|
||||
public void onNext(LCObject post) {
|
||||
JSONObject comments = post.getJSONObject("comments");
|
||||
adapter.update_comments(comments);
|
||||
binding.sendCommentButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
System.out.println("sendCommentButton");
|
||||
String text = binding.commentTextField.getText().toString();
|
||||
JSONObject comment_object = new GsonObject();
|
||||
comment_object.put("userid", LCUser.currentUser().getObjectId());
|
||||
comment_object.put("username", LCUser.currentUser().getUsername());
|
||||
comment_object.put("text", text);
|
||||
comment_object.put("User", LCUser.currentUser());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
comment_object.put("time", LocalTime.now().toString());
|
||||
}
|
||||
comments.put(String.valueOf(comments.size()),comment_object);
|
||||
post.put("comments",comments);
|
||||
post.saveInBackground().subscribe(new Observer<LCObject>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull LCObject o) {
|
||||
adapter.update_comments(comments);
|
||||
System.out.println("Save finished.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
public void onError(Throwable throwable) {}
|
||||
public void onComplete() {}
|
||||
});
|
||||
Bitmap image = BitmapFactory.decodeFile(image_path);
|
||||
binding.imageView3.setImageBitmap(image);
|
||||
binding.recyclerView.setAdapter(adapter);
|
||||
binding.imageView3.setClipToOutline(true);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.echo.colorizeit.ui.a_comments_details;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/13-14:32
|
||||
* @Project: My Application
|
||||
* @Package: com.echo.colorizeit.ui.a_comments_details
|
||||
* @Description:
|
||||
**/
|
||||
public class CommentsViewModel extends ViewModel {
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.echo.colorizeit.ui.f_community_view;
|
||||
|
||||
import androidx.lifecycle.MediatorLiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.leancloud.LCObject;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/10-18:16
|
||||
* @Project: My Application
|
||||
* @Package: com.echo.colorizeit.ui.f_community_view
|
||||
* @Description:
|
||||
**/
|
||||
public class CommunityViewModel extends ViewModel {
|
||||
// private ArrayList<LCObject> posts = new ArrayList<>();
|
||||
}
|
@ -0,0 +1,326 @@
|
||||
package com.echo.colorizeit.ui.f_community_view;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
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 androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.echo.colorizeit.ImageUtil.PhotoLib;
|
||||
import com.echo.colorizeit.Util;
|
||||
import com.echo.colorizeit.ui.a_comments_details.CommentsActivity;
|
||||
import com.example.myapplication.databinding.CommunityItemBinding;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.leancloud.LCFile;
|
||||
import cn.leancloud.LCObject;
|
||||
import cn.leancloud.LCQuery;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @Author: WangYuyang
|
||||
* @Date: 2021/11/10-18:16
|
||||
* @Project: My Application
|
||||
* @Package: com.echo.colorizeit.ui.f_community_view
|
||||
* @Description:
|
||||
**/
|
||||
public class PostAdapter extends RecyclerView.Adapter {
|
||||
private CommunityFragment context;
|
||||
private ArrayList<LCObject> posts = new ArrayList<>();
|
||||
|
||||
public PostAdapter(CommunityFragment context) {
|
||||
this.context = context;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void update_posts(List<LCObject> posts) {
|
||||
this.posts = new ArrayList<>(posts);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
CommunityItemBinding binding;
|
||||
binding = CommunityItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
PostViewHolder holder = new PostViewHolder(binding.getRoot());
|
||||
holder.binding = binding;
|
||||
return holder;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
PostViewHolder holder1 = (PostViewHolder) holder;
|
||||
LCObject object = posts.get(position);
|
||||
holder1.binding.postedBy.setText(object.get("Username") != null ? object.get("Username").toString() : "");
|
||||
holder1.binding.thumbUpCount.setText(object.get("thumb_up_count").toString());
|
||||
holder1.binding.shareCount.setText(object.get("share_count").toString());
|
||||
holder1.binding.downloadCount.setText(object.get("download_count").toString());
|
||||
holder1.binding.postedTime.setText(object.getCreatedAt().toLocaleString());
|
||||
holder1.binding.userIcon.setClipToOutline(true);
|
||||
|
||||
LCObject file_id = (LCObject) object.get("Image");
|
||||
LCQuery<LCObject> query = new LCQuery<>("_File");
|
||||
query.getInBackground(file_id.getObjectId()).subscribe(new Observer<LCObject>() {
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
}
|
||||
|
||||
public void onNext(LCObject file) {
|
||||
LCFile tmp = (LCFile) file;
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(400 * position);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(tmp.getUrl());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = url.openStream();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (is != null) {
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||
context.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder1.binding.rcImageView2.setImageBitmap(bitmap);
|
||||
holder1.binding.rcImageView2.setVisibility(View.VISIBLE);
|
||||
holder1.binding.imageLoadingViewAnim.setVisibility(View.GONE);
|
||||
holder1.binding.rcImageView2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(holder.itemView.getContext(), CommentsActivity.class);
|
||||
String image_path = PhotoLib.saveImageTmp(holder.itemView.getContext(),bitmap);
|
||||
intent.putExtra("image_path", image_path);
|
||||
intent.putExtra("object_id", object.getObjectId());
|
||||
holder.itemView.getContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
holder1.binding.thumbUpButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
object.put("thumb_up_count", ((int) object.get("thumb_up_count")) + 1);
|
||||
holder1.binding.thumbUpCount.setText(String.valueOf((int) object.get("thumb_up_count")));
|
||||
object.saveInBackground().subscribe(new Observer<LCObject>() {
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
}
|
||||
|
||||
public void onNext(LCObject savedTodo) {
|
||||
System.out.println("保存成功");
|
||||
}
|
||||
|
||||
public void onError(Throwable throwable) {
|
||||
System.out.println("保存失败!");
|
||||
}
|
||||
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
;
|
||||
}
|
||||
});
|
||||
holder1.binding.gallerySaveButton2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
object.put("download_count", ((int) object.get("download_count")) + 1);
|
||||
holder1.binding.downloadCount.setText(String.valueOf(((int) object.get("download_count"))));
|
||||
object.saveInBackground().subscribe(new Observer<LCObject>() {
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
}
|
||||
|
||||
public void onNext(LCObject savedTodo) {
|
||||
System.out.println("保存成功");
|
||||
}
|
||||
|
||||
public void onError(Throwable throwable) {
|
||||
System.out.println("保存失败!");
|
||||
}
|
||||
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
;
|
||||
Bitmap tmp = bitmap;
|
||||
String data = MediaStore.Images.Media.insertImage(holder.itemView.getContext().getContentResolver(), tmp, String.valueOf(System.currentTimeMillis()), ":)");
|
||||
final AlertDialog.Builder alterDialog = new AlertDialog.Builder(holder.itemView.getContext());
|
||||
alterDialog.setTitle("Image saved successfully.");//文字
|
||||
alterDialog.setMessage("You can view it in your gallery.");//提示消息
|
||||
alterDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(android.content.Intent.ACTION_VIEW);
|
||||
intent.setType("image/*");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
holder.itemView.getContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
alterDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
});
|
||||
alterDialog.show();
|
||||
|
||||
}
|
||||
});
|
||||
holder1.binding.galleryShareButton2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
object.put("share_count", ((int) object.get("share_count")) + 1);
|
||||
holder1.binding.shareCount.setText(String.valueOf(((int) object.get("share_count"))));
|
||||
object.saveInBackground().subscribe(new Observer<LCObject>() {
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
}
|
||||
|
||||
public void onNext(LCObject savedTodo) {
|
||||
System.out.println("保存成功");
|
||||
}
|
||||
|
||||
public void onError(Throwable throwable) {
|
||||
System.out.println("保存失败!");
|
||||
}
|
||||
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
;
|
||||
Bitmap tmp = bitmap;
|
||||
String data = MediaStore.Images.Media.insertImage(holder.itemView.getContext().getContentResolver(), tmp, String.valueOf(System.currentTimeMillis()), ":)");
|
||||
while (data == null) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Uri ColorizedImageUri = Uri.parse(data);
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
intent.setType("image/*");
|
||||
intent.putExtra(Intent.EXTRA_STREAM, ColorizedImageUri);
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, "Share");//添加分享内容标题
|
||||
intent = Intent.createChooser(intent, "Share");
|
||||
holder.itemView.getContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void onError(Throwable throwable) {
|
||||
}
|
||||
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
|
||||
LCObject user = (LCObject) object.get("User");
|
||||
System.out.println(user);
|
||||
LCObject user_avatar = (LCObject) user.get("user_icon");
|
||||
LCQuery<LCObject> query2 = new LCQuery<>("_File");
|
||||
query2.getInBackground(user_avatar.getObjectId()).subscribe(new Observer<LCObject>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull LCObject lcObject) {
|
||||
LCFile tmp = (LCFile) lcObject;
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(300 * position);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(tmp.getUrl());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = url.openStream();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (is != null) {
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||
context.getActivity().runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
holder1.binding.userIcon.setImageBitmap(bitmap);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return posts.size();
|
||||
}
|
||||
|
||||
private static class PostViewHolder extends RecyclerView.ViewHolder {
|
||||
public CommunityItemBinding binding;
|
||||
|
||||
public PostViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<vector android:alpha="0.8" android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal" android:viewportHeight="24"
|
||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM17,13l-5,5 -5,-5h3V9h4v4h3z"/>
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector android:alpha="0.8" android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal" android:viewportHeight="24"
|
||||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M1,21h4L5,9L1,9v12zM23,10c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.59,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-2z"/>
|
||||
</vector>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
@ -0,0 +1,18 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView8"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:fontFamily="@font/aclonica"
|
||||
android:text="Add a new post"
|
||||
android:textSize="34sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView 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">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/round"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView3"
|
||||
tools:itemCount="2"
|
||||
tools:listitem="@layout/community_detail_item" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/comment_text_field"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:ems="10"
|
||||
android:hint="Give a comment here ~"
|
||||
android:inputType="textPersonName"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/send_comment_button"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/recyclerView" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/send_comment_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="send"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/comment_text_field"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/comment_text_field" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</ScrollView>
|
@ -0,0 +1,51 @@
|
||||
<?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="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/comments_user_icon"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/round"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_username"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="w1109790800@gmail.com"
|
||||
app:layout_constraintStart_toEndOf="@+id/comments_user_icon"
|
||||
app:layout_constraintTop_toTopOf="@+id/comments_user_icon" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_post_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="2021-01-21"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/comments_user_icon"
|
||||
app:layout_constraintStart_toStartOf="@+id/comment_username"
|
||||
app:layout_constraintTop_toBottomOf="@+id/comment_username" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_comment_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="dfdddddddddddddddddddddddddddd"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/comments_user_icon"
|
||||
app:layout_constraintTop_toBottomOf="@+id/comments_user_icon" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,146 @@
|
||||
<?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="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@drawable/gallery_background">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/posted_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2021-9-21"
|
||||
android:textSize="10sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/posted_by"
|
||||
app:layout_constraintTop_toBottomOf="@+id/posted_by" />
|
||||
|
||||
<com.airbnb.lottie.LottieAnimationView
|
||||
android:id="@+id/image_loading_view_anim"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:padding="10dp"
|
||||
android:scaleType="fitXY"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/rc_image_view2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/rc_image_view2"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:lottie_autoPlay="true"
|
||||
app:lottie_loop="true"
|
||||
app:lottie_rawRes="@raw/image_loading2" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/rc_image_view2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:adjustViewBounds="true"
|
||||
|
||||
android:padding="10dp"
|
||||
android:scaleType="fitXY"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/original" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/posted_by"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:text="w1109790800@gamil.com"
|
||||
android:textSize="10sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/user_icon"
|
||||
app:layout_constraintTop_toBottomOf="@+id/rc_image_view2" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gallery_save_button2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:padding="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/gallery_share_button2"
|
||||
app:layout_constraintEnd_toStartOf="@+id/gallery_share_button2"
|
||||
app:layout_constraintTop_toTopOf="@+id/gallery_share_button2"
|
||||
app:srcCompat="@drawable/ic_baseline_save_alt_24" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gallery_share_button2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:padding="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/posted_time"
|
||||
app:srcCompat="@drawable/ic_baseline_share_24" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/thumb_up_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:padding="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/gallery_save_button2"
|
||||
app:layout_constraintEnd_toStartOf="@+id/gallery_save_button2"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/gallery_save_button2"
|
||||
app:srcCompat="@drawable/ic_baseline_thumb_up_24" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/thumb_up_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:text="10"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/thumb_up_button"
|
||||
app:layout_constraintStart_toStartOf="@+id/thumb_up_button"
|
||||
app:layout_constraintTop_toBottomOf="@+id/thumb_up_button" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/download_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:text="300"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/gallery_save_button2"
|
||||
app:layout_constraintStart_toStartOf="@+id/gallery_save_button2"
|
||||
app:layout_constraintTop_toBottomOf="@+id/gallery_save_button2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/share_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center"
|
||||
android:text="100"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/gallery_share_button2"
|
||||
app:layout_constraintStart_toStartOf="@+id/gallery_share_button2"
|
||||
app:layout_constraintTop_toBottomOf="@+id/gallery_share_button2" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/user_icon"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:background="@drawable/round"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/posted_time"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/posted_by"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,44 @@
|
||||
<?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">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView9"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:fontFamily="@font/aclonica"
|
||||
android:text="Community"
|
||||
android:textSize="34sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rcGallery"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:paddingBottom="45dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView9"
|
||||
app:spanCount="2"
|
||||
tools:ignore="SpeakableTextPresentCheck"
|
||||
tools:listitem="@layout/community_item" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/add_new_post_button"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/textView9"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/textView9"
|
||||
app:layout_constraintTop_toTopOf="@+id/textView9"
|
||||
app:srcCompat="@android:drawable/ic_menu_add" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,25 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
maven{ url 'https://maven.aliyun.com/repository/central' }
|
||||
maven{ url 'https://maven.aliyun.com/repository/public' }
|
||||
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url "https://www.jitpack.io" }
|
||||
maven { url "https://jcenter.bintray.com" }
|
||||
maven { url 'https://artifactory.mxtracks.info/artifactory/gradle-dev-local/' }
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.0.3'
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
Loading…
Reference in New Issue