├── .gitignore
├── .idea
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── bmob
│ │ └── yellowdoing
│ │ └── com
│ │ └── bmobcommunity
│ │ ├── LoginActivity.java
│ │ ├── MainActivity.java
│ │ ├── MyComment.java
│ │ ├── MyCommunity.java
│ │ ├── User.java
│ │ └── UserInfoActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_post.png
│ ├── drawable-mdpi
│ └── ic_post.png
│ ├── drawable-xhdpi
│ └── ic_post.png
│ ├── drawable-xxhdpi
│ └── ic_post.png
│ ├── layout
│ ├── activity_login.xml
│ ├── activity_main.xml
│ ├── activity_user_info.xml
│ ├── content_main.xml
│ └── dialog_register.xml
│ ├── menu
│ └── menu_main.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── communityUI
├── build.gradle
├── gradlew
├── gradlew.bat
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── hg
│ │ └── yellowdoing
│ │ └── communityui
│ │ ├── ChildReplyAdapter.java
│ │ ├── ChildReplyAdapter2.java
│ │ ├── CircleImageView.java
│ │ ├── Comment.java
│ │ ├── CommentAdapter.java
│ │ ├── CommentDetailActivity.java
│ │ ├── Community.java
│ │ ├── CommunityAdapter.java
│ │ ├── CommunityDetialActivity.java
│ │ ├── CommunityFragment.java
│ │ ├── CommunityInterface.java
│ │ ├── ImageAdapter.java
│ │ ├── ImageSelectAdapter.java
│ │ ├── MyListView.java
│ │ └── PostActivity.java
│ └── res
│ ├── drawable-hdpi
│ ├── ic_add_picture.png
│ ├── ic_back.png
│ ├── ic_reply.png
│ ├── ic_zan.png
│ └── ic_zan_hover.png
│ ├── drawable-mdpi
│ ├── edit_style.xml
│ ├── edit_text_cursor.xml
│ ├── ic_add_picture.png
│ ├── ic_back.png
│ ├── ic_reply.png
│ ├── ic_zan.png
│ ├── ic_zan_hover.png
│ └── text_item_reply.xml
│ ├── drawable-xhdpi
│ ├── ic_add_picture.png
│ ├── ic_back.png
│ ├── ic_reply.png
│ ├── ic_zan.png
│ └── ic_zan_hover.png
│ ├── drawable-xxhdpi
│ ├── hospital_bitmap.png
│ ├── ic_add_picture.png
│ ├── ic_back.png
│ ├── ic_reply.png
│ ├── ic_zan.png
│ └── ic_zan_hover.png
│ ├── drawable
│ ├── zan_style.xml
│ └── zan_style_2.xml
│ ├── layout
│ ├── activity_comment_detail.xml
│ ├── activity_community_detail.xml
│ ├── activity_post.xml
│ ├── fragment_communicty.xml
│ ├── list_item_child_reply.xml
│ ├── list_item_child_reply_2.xml
│ ├── list_item_community.xml
│ ├── list_item_image.xml
│ ├── list_item_more.xml
│ ├── list_item_reply.xml
│ └── reply_layout.xml
│ └── values
│ └── values.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 | .idea/vcs.xml
11 | app/libs/
12 | app/src/main/res/drawable/
13 | communityUI/libs/
14 | communityUI/src/androidTest/
15 |
16 | communityUI/src/test/
17 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## communityUI
2 | 一个可快速集成的朋友圈界面,支持评论、子评论、点赞、回复人数。
3 |
4 |  
5 |
6 | > 建议有一个自己的后台数据库,可直接集成,示例代码用的是作者自己的简单后台
7 |
8 | #### 集成步骤
9 | 1 . 继承CommunityInterface接口,添加fragment
10 |
11 | ```
12 | //朋友圈列表是一个fragment,需要事务添加
13 | public class MainActivity extends AppCompatActivity implements CommunityInterface {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 |
20 | getSupportFragmentManager().beginTransaction()
21 | .add(R.id.container, new CommunityFragment().setCommunityInterface(this))
22 | .commit();
23 | }
24 | ```
25 | 2 . 实现接口的六个方法,进行数据转换
26 |
27 | void loadCommunityList(CommunitySubsriber subsriber,int page);
28 |
29 | void comment(CommentSubsriber2 subsriber,String communityId,String parentId,String commentId,String content);
30 |
31 | void loadComments(CommentSubsriber subsriber,String communityId,int page);
32 |
33 | void like(Subsriber subsriber,String communityId);
34 |
35 | void unLike(Subsriber subsriber,String communityId);
36 |
37 | void post(Subsriber subsriber,ArrayList imagePaths,String content);
38 |
39 | 3 . 在Mainifest.xml文件添加activity声明
40 |
41 |
42 | ```
43 |
44 |
46 |
48 |
49 |
50 |
51 | ```
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "26.0.2"
6 | defaultConfig {
7 | applicationId "bmob.yellowdoing.com.bmobcommunity"
8 | minSdkVersion 15
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile project(':communityUI')
25 | compile 'com.android.support:design:26.+'
26 | compile 'com.droi.sdk:Core:+'
27 | compile 'com.squareup.okhttp3:okhttp:3.8.1'
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/ganhuang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
34 |
35 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/bmob/yellowdoing/com/bmobcommunity/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package bmob.yellowdoing.com.bmobcommunity;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.DialogInterface;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.util.Log;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.EditText;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 | import com.droi.sdk.DroiError;
16 | import com.droi.sdk.core.DroiPermission;
17 | import com.droi.sdk.core.DroiUser;
18 |
19 | public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
20 |
21 | private EditText mEtUsername, mEtPassword;
22 | private TextView mTvRegister;
23 | private Button mBtLogin;
24 |
25 | @Override
26 | protected void onCreate(@Nullable Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_login);
29 |
30 | mEtUsername = (EditText) findViewById(R.id.et_username);
31 | mEtPassword = (EditText) findViewById(R.id.et_password);
32 | mTvRegister = (TextView) findViewById(R.id.tv_regitser);
33 | mBtLogin = (Button) findViewById(R.id.bt_login);
34 |
35 | mBtLogin.setOnClickListener(this);
36 | mTvRegister.setOnClickListener(this);
37 | }
38 |
39 | @Override
40 | public void onClick(View v) {
41 | switch (v.getId()) {
42 | case R.id.bt_login: //登陆
43 | login();
44 | break;
45 | case R.id.tv_regitser: //注册
46 | register();
47 | break;
48 | }
49 | }
50 |
51 | private void login() {
52 | DroiError error = new DroiError();
53 | User user = DroiUser.login(mEtUsername.getText().toString(), mEtPassword.getText().toString(), User.class, error);
54 | if (error.isOk() && user != null && user.isAuthorized()) {
55 | Toast.makeText(LoginActivity.this, "登陆成功", Toast.LENGTH_SHORT).show();
56 | getSharedPreferences("user",MODE_PRIVATE).edit().putBoolean("isLogin",true).apply();
57 | finish();
58 | }else
59 | Toast.makeText(LoginActivity.this, error.getAppendedMessage(), Toast.LENGTH_SHORT).show();
60 |
61 | }
62 |
63 | private void register() {
64 | View view = LayoutInflater.from(this).inflate(R.layout.dialog_register, null);
65 | final EditText username = (EditText) view.findViewById(R.id.et_username);
66 | final EditText password = (EditText) view.findViewById(R.id.et_password);
67 |
68 | new AlertDialog.Builder(this)
69 | .setView(view)
70 | .setNegativeButton("注册", new DialogInterface.OnClickListener() {
71 | @Override
72 | public void onClick(DialogInterface dialog, int which) {
73 | User user = new User();
74 | user.setUserId(username.getText().toString());
75 | user.setPassword(password.getText().toString());
76 | DroiPermission permission = new DroiPermission();
77 | permission.setPublicReadPermission(true);
78 | user.setPermission(permission);
79 | DroiError result = user.signUp();
80 | if (result.isOk()) {
81 | Toast.makeText(LoginActivity.this, "注册成功", Toast.LENGTH_SHORT).show();
82 | getSharedPreferences("user",MODE_PRIVATE).edit().putBoolean("isLogin",true).apply();
83 | finish();
84 | }else Log.d("aaaa", "login: " + result.toString());
85 | }
86 | })
87 | .setPositiveButton("取消", new DialogInterface.OnClickListener() {
88 | @Override
89 | public void onClick(DialogInterface dialog, int which) {
90 |
91 | }
92 | }).show();
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/bmob/yellowdoing/com/bmobcommunity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package bmob.yellowdoing.com.bmobcommunity;
2 |
3 | import android.Manifest;
4 | import android.content.Intent;
5 | import android.content.pm.PackageManager;
6 | import android.os.Bundle;
7 | import android.support.design.widget.FloatingActionButton;
8 | import android.support.v4.app.ActivityCompat;
9 | import android.support.v4.content.ContextCompat;
10 | import android.support.v7.app.AppCompatActivity;
11 | import android.support.v7.widget.Toolbar;
12 | import android.util.Log;
13 | import android.view.View;
14 | import android.view.Menu;
15 | import android.view.MenuItem;
16 | import android.widget.Toast;
17 |
18 | import com.droi.sdk.DroiCallback;
19 | import com.droi.sdk.DroiError;
20 | import com.droi.sdk.core.Core;
21 | import com.droi.sdk.core.DroiCondition;
22 | import com.droi.sdk.core.DroiFile;
23 | import com.droi.sdk.core.DroiObject;
24 | import com.droi.sdk.core.DroiPermission;
25 | import com.droi.sdk.core.DroiQuery;
26 | import com.droi.sdk.core.DroiUser;
27 |
28 | import org.json.JSONException;
29 | import org.json.JSONObject;
30 |
31 | import java.io.IOException;
32 | import java.text.SimpleDateFormat;
33 | import java.util.ArrayList;
34 | import java.util.Date;
35 | import java.util.List;
36 |
37 | import hg.yellowdoing.communityui.ChildReplyAdapter2;
38 | import hg.yellowdoing.communityui.Comment;
39 | import hg.yellowdoing.communityui.Community;
40 | import hg.yellowdoing.communityui.CommunityFragment;
41 | import hg.yellowdoing.communityui.CommunityInterface;
42 | import hg.yellowdoing.communityui.PostActivity;
43 | import okhttp3.Call;
44 | import okhttp3.Callback;
45 | import okhttp3.MediaType;
46 | import okhttp3.OkHttpClient;
47 | import okhttp3.Request;
48 | import okhttp3.RequestBody;
49 | import okhttp3.Response;
50 | import okio.BufferedSink;
51 |
52 |
53 | public class MainActivity extends AppCompatActivity implements CommunityInterface {
54 |
55 | @Override
56 | protected void onCreate(Bundle savedInstanceState) {
57 | super.onCreate(savedInstanceState);
58 | setContentView(R.layout.activity_main);
59 |
60 | //初始化Droibaas SDK
61 | DroiObject.registerCustomClass(User.class);
62 | DroiObject.registerCustomClass(MyCommunity.class);
63 | DroiObject.registerCustomClass(MyComment.class);
64 | Core.initialize(this);
65 |
66 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
67 | setSupportActionBar(toolbar);
68 |
69 | getSupportFragmentManager().beginTransaction()
70 | .add(R.id.container, new CommunityFragment().setCommunityInterface(this))
71 | .commit();
72 |
73 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
74 | fab.setOnClickListener(new View.OnClickListener() {
75 | @Override
76 | public void onClick(View view) {
77 | if (getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
78 | User user = DroiUser.getCurrentUser(User.class);
79 | if (user.getAvatar() == null || user.getNickName() == null)
80 | startActivity(new Intent(MainActivity.this, UserInfoActivity.class));
81 | else
82 | startActivity(new Intent(MainActivity.this, PostActivity.class));
83 | } else
84 | startActivity(new Intent(MainActivity.this, LoginActivity.class));
85 | }
86 | });
87 | }
88 |
89 | @Override
90 | public boolean onCreateOptionsMenu(Menu menu) {
91 | getMenuInflater().inflate(R.menu.menu_main, menu);
92 | return true;
93 | }
94 |
95 | @Override
96 | public boolean onOptionsItemSelected(MenuItem item) {
97 | int id = item.getItemId();
98 | if (id == R.id.action_settings) {
99 | DroiUser.getCurrentUser().logout();
100 | getSharedPreferences("user", MODE_PRIVATE).edit().putBoolean("isLogin", false).apply();
101 | startActivity(new Intent(this, LoginActivity.class));
102 | return true;
103 | } else if (id == R.id.user_info) {
104 | if (DroiUser.getCurrentUser(User.class) != null)
105 | startActivity(new Intent(this, UserInfoActivity.class));
106 | else
107 | startActivity(new Intent(this, LoginActivity.class));
108 | }
109 | return super.onOptionsItemSelected(item);
110 | }
111 |
112 |
113 | @Override
114 | public void loadCommunityList(CommunitySubsriber subsriber, int page) {
115 | DroiQuery query = DroiQuery.Builder.newBuilder()
116 | .query(MyCommunity.class)
117 | .limit(20)
118 | .offset((page - 1) * 20)
119 | .orderBy("_CreationTime", false)
120 | .build();
121 | DroiError error = new DroiError();
122 | List result = query.runQuery(error);
123 | List communities = new ArrayList<>();
124 | if (error.isOk()) {
125 | for (int i = 0; i < result.size(); i++) {
126 | MyCommunity myCommunity = result.get(i);
127 | communities.add(new Community()
128 | .setId(myCommunity.getObjectId())
129 | .setContent(myCommunity.getContent())
130 | .setReplyNum(myCommunity.getReplyNum())
131 | .setLike(DroiUser.getCurrentUser(User.class) != null && myCommunity.getLikePersons().contains(DroiUser.getCurrentUser(User.class).getObjectId()))
132 | .setImagePaths(myCommunity.getImagePaths())
133 | .setLikeNum(myCommunity.getLikePersons().size())
134 | .setNickName(myCommunity.getAuthor().getNickName())
135 | .setCreateTime(dateCompare(myCommunity.getCreationTime().getTime()))
136 | .setAvatar(myCommunity.getAuthor().getAvatar().getUri().toString().replaceAll("\\\\", "")));
137 | }
138 | subsriber.onComplete(communities);
139 | }
140 | }
141 |
142 |
143 | @Override
144 | public void comment(CommentSubsriber2 subsriber, String communityId, String parentId, String commentId, String content) {
145 |
146 |
147 | if (!getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
148 | startActivity(new Intent(this, LoginActivity.class));
149 | return;
150 | }else {
151 | if (DroiUser.getCurrentUser(User.class).getAvatar() == null || DroiUser.getCurrentUser(User.class).getNickName() == null){
152 | startActivity(new Intent(this, UserInfoActivity.class));
153 | return;
154 | }
155 | }
156 | MyComment comment = new MyComment();
157 | DroiPermission droiPermission = new DroiPermission();
158 | droiPermission.setPublicReadPermission(true);
159 | comment.setPermission(droiPermission);
160 | comment.setContent(content);
161 | comment.setCommunityId(communityId);
162 | comment.setCommentId(commentId);
163 | comment.setParentId(parentId);
164 | comment.setAuthor(DroiUser.getCurrentUser(User.class));
165 | DroiError error = comment.save();
166 | if (error.isOk()) {
167 | Comment c = new Comment();
168 | c.setContent(content);
169 | c.setCommunityId(communityId);
170 | c.setCommentId(commentId);
171 | c.setParentId(parentId);
172 | c.setId(comment.getObjectId());
173 | c.setNickName(DroiUser.getCurrentUser(User.class).getNickName());
174 | c.setAvatar(DroiUser.getCurrentUser(User.class).getAvatar().getUri().toString().replaceAll("\\\\",""));
175 | subsriber.onComplete(c);
176 | likeOrUnlike(new Subsriber() {
177 | @Override
178 | public void onComplete() {
179 |
180 | }
181 | }, communityId, "replyNum", "Increment");
182 | } else Toast.makeText(this, "回复失败", Toast.LENGTH_SHORT).show();
183 | }
184 |
185 | @Override
186 | public void loadComments(CommentSubsriber subsriber, String communityId, int page) {
187 | DroiCondition cond = DroiCondition.cond("communityId", DroiCondition.Type.EQ, communityId);
188 |
189 | DroiQuery query = DroiQuery.Builder.newBuilder()
190 | .where(cond)
191 | .query(MyComment.class)
192 | .build();
193 | DroiError error = new DroiError();
194 | List myComments = query.runQuery(error);
195 | if (error.isOk()) {
196 | List comments = new ArrayList<>();
197 | for (int i = 0; i < myComments.size(); i++) {
198 | Comment comment1 = new Comment();
199 | comment1.setAvatar(myComments.get(i).getAuthor().getAvatar().getUri().toString().replaceAll("\\\\", ""));
200 | comment1.setContent(myComments.get(i).getContent());
201 | comment1.setId(myComments.get(i).getObjectId());
202 | comment1.setNickName(myComments.get(i).getAuthor().getNickName());
203 | comment1.setParentId(myComments.get(i).getParentId());
204 | comment1.setCommentId(myComments.get(i).getCommentId());
205 | comment1.setCreateTime(myComments.get(i).getCreationTime().getTime());
206 | comments.add(comment1);
207 | }
208 | subsriber.onComplete(comments);
209 | } else Toast.makeText(this, "回复失败", Toast.LENGTH_SHORT).show();
210 | }
211 |
212 | @Override
213 | public void like(Subsriber subsriber, final String communityId) {
214 | likeOrUnlike(subsriber, communityId, "likePersons", "Add");
215 |
216 | }
217 |
218 | @Override
219 | public void unLike(Subsriber subsriber, final String communityId) {
220 | likeOrUnlike(subsriber, communityId, "likePersons", "Remove");
221 | }
222 |
223 | private void likeOrUnlike(final Subsriber subsriber, final String communityId, final String name, final String action) {
224 | new Thread(new Runnable() {
225 | @Override
226 | public void run() {
227 | OkHttpClient okHttpClient = new OkHttpClient();
228 |
229 | RequestBody body = new RequestBody() {
230 | @Override
231 | public MediaType contentType() {
232 | return MediaType.parse("application/json");
233 | }
234 |
235 | @Override
236 | public void writeTo(BufferedSink sink) throws IOException {
237 | if (name.equals("likePersons"))
238 | sink.write(("{\"" + name + "\" :{\"__op\":\"" + action + "\",\"objects\":[\"" + DroiUser.getCurrentUser(User.class).getObjectId() + "\"]}}").getBytes());
239 | else
240 | sink.write(("{\"" + name + "\" :{\"__op\":\"" + action + "\",\"amount\":1}}").getBytes());
241 | }
242 | };
243 | Request request = new Request.Builder()
244 | .url("https://api.droibaas.com/rest/objects/v2/Community/" + communityId)
245 | .addHeader("X-Droi-AppID", "3gltmbzhTh3BSQhS1kQMSa-QyLaEmjTPlQD0QtoM")
246 | .addHeader("X-Droi-Api-Key", "hCjT6NULJXTcJV4cbOcZkocGCoQEHpzdEHGzu4WwBrOiY3anhVm7ZKqMsjTRDzWD")
247 | .addHeader("Content-Type", "application/json").patch(body).build();
248 |
249 | okHttpClient.newCall(request).enqueue(new Callback() {
250 | @Override
251 | public void onFailure(Call call, final IOException e) {
252 | runOnUiThread(new Runnable() {
253 | @Override
254 | public void run() {
255 | Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
256 | }
257 | });
258 | }
259 |
260 | @Override
261 | public void onResponse(Call call, final Response response) throws IOException {
262 | final String resp = response.body().string();
263 | runOnUiThread(new Runnable() {
264 | @Override
265 | public void run() {
266 | try {
267 | JSONObject jsonObject = new JSONObject(resp);
268 | if (jsonObject.getInt("Code") == 0) subsriber.onComplete();
269 | else
270 | Toast.makeText(MainActivity.this, jsonObject.getString("Message"), Toast.LENGTH_SHORT).show();
271 | } catch (JSONException e) {
272 | e.printStackTrace();
273 | }
274 | }
275 | });
276 | }
277 | });
278 | }
279 | }).start();
280 | }
281 |
282 | @Override
283 | public void post(final Subsriber subsriber, final ArrayList imagePaths, String content) {
284 | final MyCommunity myCommunity = new MyCommunity();
285 | DroiPermission permission = new DroiPermission();
286 | permission.setPublicReadPermission(true);
287 | permission.setPublicWritePermission(true);
288 | myCommunity.setPermission(permission);
289 | myCommunity.setContent(content);
290 | myCommunity.setAuthor(User.getCurrentUser(User.class));
291 | myCommunity.setReplyNum(0);
292 | myCommunity.setLikePersons(new ArrayList());
293 | final ArrayList list = new ArrayList<>();
294 | if (imagePaths.size() == 0)
295 | saveCommunity(subsriber, myCommunity);
296 | else
297 | for (int i = 0; i < imagePaths.size(); i++) {
298 | final DroiFile file = new DroiFile(UserInfoActivity.Bitmap2Bytes(UserInfoActivity.decodeSampledBitmapFromPath(imagePaths.get(i), 120, 120)));
299 | file.saveInBackground(new DroiCallback() {
300 | @Override
301 | public void result(Boolean aBoolean, DroiError droiError) {
302 | if (aBoolean) {
303 | list.add(file.getUri().toString().replaceAll("\\\\", ""));
304 | if (list.size() == imagePaths.size()) {
305 | myCommunity.setImagePaths(list);
306 | saveCommunity(subsriber, myCommunity);
307 | }
308 | } else
309 | Toast.makeText(MainActivity.this, droiError.getTicket(), Toast.LENGTH_SHORT).show();
310 | }
311 | });
312 | }
313 | }
314 |
315 | private void saveCommunity(final Subsriber subsriber, MyCommunity myCommunity) {
316 | DroiError error = myCommunity.save();
317 | if (error.isOk()) {
318 | subsriber.onComplete();
319 | Toast.makeText(MainActivity.this, "发帖成功", Toast.LENGTH_SHORT).show();
320 | } else
321 | Toast.makeText(MainActivity.this, error.getAppendedMessage(), Toast.LENGTH_SHORT).show();
322 |
323 | }
324 |
325 | private String dateCompare(long createTime) {
326 | Date now = new Date();
327 | long day = (now.getTime() - createTime) / (86400000);
328 | if (day == 0) {
329 | long time = (now.getTime() - createTime) / 1000;
330 | if (time < 60)
331 | return "刚刚";
332 | if (60 <= time && time < 3600)
333 | return (time / 60) + "分钟前";
334 | else
335 | return (time / 3600) + "小时前";
336 | } else if (day == 1)
337 | return "昨天";
338 | else if (day > 1 && day < 31)
339 | return day + "天前";
340 | else if (day >= 31 && day < 365)
341 | return (day / 30) + "个月前";
342 | else
343 | return (day / 365) + "年前";
344 | }
345 | }
346 |
--------------------------------------------------------------------------------
/app/src/main/java/bmob/yellowdoing/com/bmobcommunity/MyComment.java:
--------------------------------------------------------------------------------
1 | package bmob.yellowdoing.com.bmobcommunity;
2 |
3 | import com.droi.sdk.core.DroiExpose;
4 | import com.droi.sdk.core.DroiObject;
5 | import com.droi.sdk.core.DroiObjectName;
6 | import com.droi.sdk.core.DroiReference;
7 |
8 | /**
9 | * Created by YellowDoing on 2017/11/21.
10 | */
11 | @DroiObjectName("Comment")
12 | public class MyComment extends DroiObject {
13 | @DroiReference
14 | private User author;
15 | @DroiExpose
16 | private String content;
17 | @DroiExpose
18 | private String commentId;
19 | @DroiExpose
20 | private String communityId;
21 | @DroiExpose
22 | private String parentId;
23 |
24 |
25 | public String getParentId() {
26 | return parentId;
27 | }
28 |
29 | public void setParentId(String parentId) {
30 | this.parentId = parentId;
31 | }
32 |
33 | public User getAuthor() {
34 | return author;
35 | }
36 |
37 | public void setAuthor(User author) {
38 | this.author = author;
39 | }
40 |
41 | public String getContent() {
42 | return content;
43 | }
44 |
45 | public void setContent(String content) {
46 | this.content = content;
47 | }
48 |
49 | public String getCommentId() {
50 | return commentId;
51 | }
52 |
53 | public void setCommentId(String commentId) {
54 | this.commentId = commentId;
55 | }
56 |
57 | public String getCommunityId() {
58 | return communityId;
59 | }
60 |
61 | public void setCommunityId(String communityId) {
62 | this.communityId = communityId;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/bmob/yellowdoing/com/bmobcommunity/MyCommunity.java:
--------------------------------------------------------------------------------
1 | package bmob.yellowdoing.com.bmobcommunity;
2 |
3 | import com.droi.sdk.core.DroiExpose;
4 | import com.droi.sdk.core.DroiObject;
5 | import com.droi.sdk.core.DroiObjectName;
6 | import com.droi.sdk.core.DroiReference;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | /**
12 | * Created by YellowDoing on 2017/11/18.
13 | *
14 | */
15 |
16 | @DroiObjectName("Community")
17 | public class MyCommunity extends DroiObject {
18 |
19 | @DroiExpose
20 | private ArrayList imagePaths;
21 | @DroiExpose
22 | private String content;
23 | @DroiReference
24 | private User author;
25 | @DroiExpose
26 | private String nickName;
27 | @DroiExpose
28 | private int replyNum;
29 | @DroiExpose
30 | private List likePersons;
31 |
32 |
33 | public List getLikePersons() {
34 | return likePersons;
35 | }
36 |
37 | public void setLikePersons(List likePersons) {
38 | this.likePersons = likePersons;
39 | }
40 |
41 | public String getNickName() {
42 | return nickName;
43 | }
44 |
45 | public void setNickName(String nickName) {
46 | this.nickName = nickName;
47 | }
48 |
49 | public int getReplyNum() {
50 | return replyNum;
51 | }
52 |
53 | public void setReplyNum(int replyNum) {
54 | this.replyNum = replyNum;
55 | }
56 |
57 | public ArrayList getImagePaths() {
58 | return imagePaths;
59 | }
60 |
61 | public void setImagePaths(ArrayList imagePaths) {
62 | this.imagePaths = imagePaths;
63 | }
64 |
65 | public String getContent() {
66 | return content;
67 | }
68 |
69 | public void setContent(String content) {
70 | this.content = content;
71 | }
72 |
73 | public User getAuthor() {
74 | return author;
75 | }
76 |
77 | public void setAuthor(User author) {
78 | this.author = author;
79 | }
80 |
81 | @Override
82 | public String toString() {
83 | return "MyCommunity{" +
84 | "imagePaths=" + imagePaths +
85 | ", content='" + content + '\'' +
86 | ", author=" + author +
87 | ", nickName='" + nickName + '\'' +
88 | ", replyNum=" + replyNum +
89 | ", likePersons=" + likePersons +
90 | '}';
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/java/bmob/yellowdoing/com/bmobcommunity/User.java:
--------------------------------------------------------------------------------
1 | package bmob.yellowdoing.com.bmobcommunity;
2 | import com.droi.sdk.core.DroiExpose;
3 | import com.droi.sdk.core.DroiFile;
4 | import com.droi.sdk.core.DroiUser;
5 |
6 | /**
7 | * Created by YellowDoing on 2017/11/18.
8 | */
9 |
10 | public class User extends DroiUser {
11 |
12 | @DroiExpose
13 | private DroiFile avatar;
14 | @DroiExpose
15 | private String nickName;
16 |
17 | public DroiFile getAvatar() {
18 | return avatar;
19 | }
20 |
21 | public void setAvatar(DroiFile avatar) {
22 | this.avatar = avatar;
23 | }
24 |
25 | public String getNickName() {
26 | return nickName;
27 | }
28 |
29 | public void setNickName(String nickName) {
30 | this.nickName = nickName;
31 | }
32 |
33 | @Override
34 | public String toString() {
35 | return "User{" +
36 | "avatar=" + avatar +
37 | ", nickName='" + nickName + '\'' +
38 | "id=" + getObjectId()+
39 | '}';
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/bmob/yellowdoing/com/bmobcommunity/UserInfoActivity.java:
--------------------------------------------------------------------------------
1 | package bmob.yellowdoing.com.bmobcommunity;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.os.Bundle;
7 | import android.support.annotation.Nullable;
8 | import android.support.v7.app.AlertDialog;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.widget.EditText;
13 | import android.widget.ImageView;
14 | import android.widget.ProgressBar;
15 | import android.widget.Toast;
16 | import com.bumptech.glide.Glide;
17 | import com.droi.sdk.DroiCallback;
18 | import com.droi.sdk.DroiError;
19 | import com.droi.sdk.DroiProgressCallback;
20 | import com.droi.sdk.core.DroiFile;
21 | import com.droi.sdk.core.DroiPermission;
22 | import com.droi.sdk.core.DroiUser;
23 |
24 | import java.io.ByteArrayOutputStream;
25 |
26 |
27 | import me.iwf.photopicker.PhotoPicker;
28 |
29 | /**
30 | * Created by YellowDoing on 2017/11/8.
31 | *
32 | */
33 |
34 | public class UserInfoActivity extends AppCompatActivity implements View.OnClickListener {
35 |
36 |
37 | private ImageView ivAvatar;
38 | private EditText etNickName;
39 | private DroiFile mFile;
40 | private AlertDialog.Builder mBuilder;
41 |
42 | @Override
43 | protected void onCreate(@Nullable Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | setContentView(R.layout.activity_user_info);
46 |
47 | ivAvatar = (ImageView) findViewById(R.id.iv_avatar);
48 | etNickName = (EditText) findViewById(R.id.et_nickname);
49 | ivAvatar.setOnClickListener(this);
50 | etNickName.setOnClickListener(this);
51 | findViewById(R.id.save).setOnClickListener(this);
52 |
53 | User user = DroiUser.getCurrentUser(User.class);
54 | if (user.getNickName() != null)
55 | etNickName.setText(user.getNickName());
56 | if (user.getAvatar() != null)
57 | Glide.with(this).load(user.getAvatar()).centerCrop().into(ivAvatar);
58 |
59 | mBuilder = new AlertDialog.Builder(this).setView(new ProgressBar(this));
60 | }
61 |
62 | @Override
63 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
64 | super.onActivityResult(requestCode, resultCode, data);
65 | if (resultCode == RESULT_OK) {
66 | switch (requestCode) {
67 | case PhotoPicker.REQUEST_CODE: //选择图片返回
68 | String path = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS).get(0);
69 | mFile = new DroiFile(Bitmap2Bytes(decodeSampledBitmapFromPath(path, 80, 80)));
70 | Glide.with(this).load(path).centerCrop().into(ivAvatar);
71 | break;
72 | }
73 | }
74 | }
75 |
76 |
77 | private void saveUser(AlertDialog dialog) {
78 | User user = DroiUser.getCurrentUser(User.class);
79 | if (mFile != null)
80 | user.setAvatar(mFile);
81 |
82 | user.setNickName(etNickName.getText().toString());
83 | DroiError error = user.save();
84 | if (error.isOk()) {
85 | Toast.makeText(UserInfoActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
86 | finish();
87 | } else
88 | Toast.makeText(UserInfoActivity.this, error.getAppendedMessage(), Toast.LENGTH_SHORT).show();
89 | dialog.cancel();
90 | }
91 |
92 | private void uploadAvatar() {
93 | final AlertDialog dialog = mBuilder.show();
94 |
95 | if (mFile != null) {
96 | DroiPermission permission = new DroiPermission();
97 | permission.setPublicReadPermission(true);
98 | mFile.setPermission(permission);
99 | mFile.saveInBackground(new DroiCallback() {
100 | @Override
101 | public void result(Boolean aBoolean, DroiError droiError) {
102 | if (aBoolean)
103 | saveUser(dialog);
104 | else
105 | Toast.makeText(UserInfoActivity.this, droiError.getAppendedMessage(), Toast.LENGTH_SHORT).show();
106 | }
107 | }, new DroiProgressCallback() {
108 | @Override
109 | public void progress(Object o, long l, long l1) {
110 | Log.d("aaaa", "上传了: " + (int)((l*100)/l1) + "%");
111 | }
112 | });
113 | } else
114 | saveUser(dialog);
115 | }
116 |
117 | @Override
118 | public void onClick(View v) {
119 | switch (v.getId()) {
120 | case R.id.iv_avatar:
121 | PhotoPicker.builder()
122 | .setPreviewEnabled(true)
123 | .setShowGif(false)
124 | .setPhotoCount(1)
125 | .setShowCamera(false)
126 | .setGridColumnCount(3)
127 | .start(this, PhotoPicker.REQUEST_CODE);
128 | break;
129 | case R.id.save:
130 | uploadAvatar();
131 | break;
132 | }
133 | }
134 |
135 | private static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
136 | // Raw height and width of image
137 | final int height = options.outHeight;
138 | final int width = options.outWidth;
139 | int inSampleSize = 1;
140 |
141 | if (height > reqHeight || width > reqWidth) {
142 |
143 | final int halfHeight = height / 2;
144 | final int halfWidth = width / 2;
145 |
146 | // Calculate the largest inSampleSize value that is a power of 2 and keeps both
147 | // height and width larger than the requested height and width.
148 | while ((halfHeight / inSampleSize) > reqHeight && (halfWidth / inSampleSize) > reqWidth) {
149 | inSampleSize *= 2;
150 | }
151 | }
152 |
153 | return inSampleSize;
154 | }
155 |
156 | public static Bitmap decodeSampledBitmapFromPath(String path, int reqWidth, int reqHeight) {
157 | // First decode with inJustDecodeBounds=true to check dimensions
158 | final BitmapFactory.Options options = new BitmapFactory.Options();
159 | options.inJustDecodeBounds = true;
160 | BitmapFactory.decodeFile(path, options);
161 |
162 | // Calculate inSampleSize
163 | options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
164 |
165 | // Decode bitmap with inSampleSize set
166 | options.inJustDecodeBounds = false;
167 | return BitmapFactory.decodeFile(path, options);
168 | }
169 |
170 | public static byte[] Bitmap2Bytes(Bitmap bm) {
171 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
172 | bm.compress(Bitmap.CompressFormat.PNG, 95, baos);
173 | return baos.toByteArray();
174 | }
175 |
176 | }
177 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_post.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/drawable-hdpi/ic_post.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_post.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/drawable-mdpi/ic_post.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_post.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/drawable-xhdpi/ic_post.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_post.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/drawable-xxhdpi/ic_post.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
21 |
22 |
29 |
30 |
31 |
32 |
36 |
37 |
45 |
46 |
54 |
55 |
56 |
57 |
63 |
64 |
72 |
73 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_user_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
25 |
26 |
32 |
33 |
34 |
35 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_register.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #000000
7 | #2894ff
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CommunityUI
3 | 注销/登陆
4 | 账号
5 | 密码
6 | 请输入账号
7 | 请输入密码
8 | 登陆
9 | 注册账号
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | maven {
7 | url "https://github.com/DroiBaaS/DroiBaaS-SDK-Android/raw/master/"
8 | }
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.0.1'
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | maven {
21 | url "https://github.com/DroiBaaS/DroiBaaS-SDK-Android/raw/master/"
22 | }
23 |
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/communityUI/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "26.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 |
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 |
26 | compile 'com.android.support:appcompat-v7:26.+'
27 | //上下拉刷新
28 | compile 'com.android.support:recyclerview-v7:26.+'
29 | compile 'com.github.bumptech.glide:glide:3.8.0'
30 | compile 'me.iwf.photopicker:PhotoPicker:0.9.5@aar'
31 | compile 'com.ufreedom.uikit:FloatingTextLibrary:0.2.0'
32 | }
33 |
--------------------------------------------------------------------------------
/communityUI/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/communityUI/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/communityUI/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/ganhuang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/communityUI/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/ChildReplyAdapter.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.BaseAdapter;
9 | import android.widget.TextView;
10 |
11 | import java.io.Serializable;
12 | import java.util.List;
13 |
14 | /**
15 | * Created by YellowDoing on 2017/11/22.
16 | */
17 |
18 | public class ChildReplyAdapter extends BaseAdapter {
19 |
20 | private List mCommentList;
21 | private CommunityDetialActivity mContext;
22 | private LayoutInflater mInflater;
23 | private Comment mComment;
24 |
25 | public ChildReplyAdapter(Comment comment, CommunityDetialActivity context) {
26 | mComment = comment;
27 | mCommentList = comment.getChildComments();
28 | mContext = context;
29 | mInflater = LayoutInflater.from(mContext);
30 | }
31 |
32 | @Override
33 | public int getCount() {
34 | return mCommentList.size() < 5 ? mCommentList.size() : 5;
35 | }
36 |
37 | @Override
38 | public Comment getItem(int position) {
39 | return mCommentList.get(position);
40 | }
41 |
42 | @Override
43 | public long getItemId(int position) {
44 | return 0;
45 | }
46 |
47 | @Override
48 | public View getView(int position, View convertView, ViewGroup parent) {
49 | View view;
50 |
51 | if (position < 4) {
52 | view = mInflater.inflate(R.layout.list_item_child_reply, null);
53 |
54 | final Comment comment = mCommentList.get(position);
55 |
56 | TextView tv_author_name = (TextView) view.findViewById(R.id.tv_author_name);
57 | TextView tv_reply = (TextView) view.findViewById(R.id.tv_reply);
58 | TextView tv_beReplied = (TextView) view.findViewById(R.id.tv_beReplied);
59 | TextView tv_content = (TextView) view.findViewById(R.id.tv_content);
60 |
61 | tv_content.setText(comment.getContent());
62 |
63 | if (comment.getTheOtherNickName() != null) {
64 | tv_reply.setVisibility(View.VISIBLE);
65 | tv_beReplied.setText(comment.getTheOtherNickName() + ":");
66 | tv_author_name.setText(comment.getNickName());
67 | } else {
68 | tv_reply.setVisibility(View.GONE);
69 | tv_author_name.setText(comment.getNickName() + ":");
70 | }
71 | } else {
72 | view = mInflater.inflate(R.layout.list_item_more, null);
73 | TextView more = view.findViewById(R.id.tv_more);
74 | more.setText("还有" + (mCommentList.size() - position) + "条回复>>");
75 | more.setOnClickListener(new View.OnClickListener() {
76 | @Override
77 | public void onClick(View v) {
78 | mContext.startActivityForResult(new Intent(mContext,CommentDetailActivity.class)
79 | .putExtra("comment",mComment),CommunityDetialActivity.REQUEST_CODE_REPLY);
80 | }
81 | });
82 | }
83 | return view;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/ChildReplyAdapter2.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.content.Intent;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.TextView;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * Created by YellowDoing on 2017/11/27.
14 | */
15 |
16 | public class ChildReplyAdapter2 extends BaseAdapter {
17 |
18 | private List mCommentList;
19 | private CommentDetailActivity mContext;
20 | private LayoutInflater mInflater;
21 | private Comment mComment;
22 |
23 | public ChildReplyAdapter2(Comment comment, CommentDetailActivity context) {
24 | mComment = comment;
25 | mCommentList = comment.getChildComments();
26 | mContext = context;
27 | mInflater = LayoutInflater.from(mContext);
28 | }
29 |
30 | public void add(Comment comment){
31 | mCommentList.add(comment);
32 | notifyDataSetChanged();
33 | }
34 |
35 | @Override
36 | public int getCount() {
37 | return mCommentList.size();
38 | }
39 |
40 | @Override
41 | public Comment getItem(int position) {
42 | return mCommentList.get(position);
43 | }
44 |
45 | @Override
46 | public long getItemId(int position) {
47 | return 0;
48 | }
49 |
50 | @Override
51 | public View getView(int position, View convertView, ViewGroup parent) {
52 | View view = mInflater.inflate(R.layout.list_item_child_reply_2, null);
53 |
54 | final Comment comment = mCommentList.get(position);
55 |
56 | TextView tv_author_name = (TextView) view.findViewById(R.id.tv_author_name);
57 | TextView tv_reply = (TextView) view.findViewById(R.id.tv_reply);
58 | TextView tv_beReplied = (TextView) view.findViewById(R.id.tv_beReplied);
59 | TextView tv_content = (TextView) view.findViewById(R.id.tv_content);
60 |
61 | tv_content.setText(comment.getContent());
62 |
63 | if (comment.getTheOtherNickName() != null) {
64 | tv_reply.setVisibility(View.VISIBLE);
65 | tv_beReplied.setText(comment.getTheOtherNickName() + ":");
66 | tv_author_name.setText(comment.getNickName());
67 | } else {
68 | tv_reply.setVisibility(View.GONE);
69 | tv_author_name.setText(comment.getNickName() + ":");
70 | }
71 |
72 | return view;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/CircleImageView.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.*;
6 | import android.graphics.drawable.BitmapDrawable;
7 | import android.graphics.drawable.ColorDrawable;
8 | import android.graphics.drawable.Drawable;
9 | import android.net.Uri;
10 | import android.support.annotation.ColorInt;
11 | import android.support.annotation.ColorRes;
12 | import android.support.annotation.DrawableRes;
13 | import android.support.v7.widget.AppCompatImageView;
14 | import android.util.AttributeSet;
15 |
16 |
17 |
18 | public class CircleImageView extends AppCompatImageView {
19 |
20 | private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP;
21 |
22 | private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
23 | private static final int COLORDRAWABLE_DIMENSION = 2;
24 |
25 | private static final int DEFAULT_BORDER_WIDTH = 0;
26 | private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
27 | private static final int DEFAULT_FILL_COLOR = Color.TRANSPARENT;
28 | private static final boolean DEFAULT_BORDER_OVERLAY = false;
29 |
30 | private final RectF mDrawableRect = new RectF();
31 | private final RectF mBorderRect = new RectF();
32 |
33 | private final Matrix mShaderMatrix = new Matrix();
34 | private final Paint mBitmapPaint = new Paint();
35 | private final Paint mBorderPaint = new Paint();
36 | private final Paint mFillPaint = new Paint();
37 |
38 | private int mBorderColor = DEFAULT_BORDER_COLOR;
39 | private int mBorderWidth = DEFAULT_BORDER_WIDTH;
40 | private int mFillColor = DEFAULT_FILL_COLOR;
41 |
42 | private Bitmap mBitmap;
43 | private BitmapShader mBitmapShader;
44 | private int mBitmapWidth;
45 | private int mBitmapHeight;
46 |
47 | private float mDrawableRadius;
48 | private float mBorderRadius;
49 |
50 | private ColorFilter mColorFilter;
51 |
52 | private boolean mReady;
53 | private boolean mSetupPending;
54 | private boolean mBorderOverlay;
55 | private boolean mDisableCircularTransformation;
56 |
57 | public CircleImageView(Context context) {
58 | super(context);
59 |
60 | init();
61 | }
62 |
63 | public CircleImageView(Context context, AttributeSet attrs) {
64 | this(context, attrs, 0);
65 | }
66 |
67 | public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
68 | super(context, attrs, defStyle);
69 |
70 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);
71 |
72 | mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_civ_border_width, DEFAULT_BORDER_WIDTH);
73 | mBorderColor = a.getColor(R.styleable.CircleImageView_civ_border_color, DEFAULT_BORDER_COLOR);
74 | mBorderOverlay = a.getBoolean(R.styleable.CircleImageView_civ_border_overlay, DEFAULT_BORDER_OVERLAY);
75 | mFillColor = a.getColor(R.styleable.CircleImageView_civ_fill_color, DEFAULT_FILL_COLOR);
76 |
77 | a.recycle();
78 |
79 | init();
80 | }
81 |
82 | private void init() {
83 | super.setScaleType(SCALE_TYPE);
84 | mReady = true;
85 |
86 | if (mSetupPending) {
87 | setup();
88 | mSetupPending = false;
89 | }
90 | }
91 |
92 | @Override
93 | public ScaleType getScaleType() {
94 | return SCALE_TYPE;
95 | }
96 |
97 | @Override
98 | public void setScaleType(ScaleType scaleType) {
99 | if (scaleType != SCALE_TYPE) {
100 | throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType));
101 | }
102 | }
103 |
104 | @Override
105 | public void setAdjustViewBounds(boolean adjustViewBounds) {
106 | if (adjustViewBounds) {
107 | throw new IllegalArgumentException("adjustViewBounds not supported.");
108 | }
109 | }
110 |
111 | @Override
112 | protected void onDraw(Canvas canvas) {
113 | if (mDisableCircularTransformation) {
114 | super.onDraw(canvas);
115 | return;
116 | }
117 |
118 | if (mBitmap == null) {
119 | return;
120 | }
121 |
122 | if (mFillColor != Color.TRANSPARENT) {
123 | canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mFillPaint);
124 | }
125 | canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mBitmapPaint);
126 | if (mBorderWidth > 0) {
127 | canvas.drawCircle(mBorderRect.centerX(), mBorderRect.centerY(), mBorderRadius, mBorderPaint);
128 | }
129 | }
130 |
131 | @Override
132 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
133 | super.onSizeChanged(w, h, oldw, oldh);
134 | setup();
135 | }
136 |
137 | @Override
138 | public void setPadding(int left, int top, int right, int bottom) {
139 | super.setPadding(left, top, right, bottom);
140 | setup();
141 | }
142 |
143 | @Override
144 | public void setPaddingRelative(int start, int top, int end, int bottom) {
145 | super.setPaddingRelative(start, top, end, bottom);
146 | setup();
147 | }
148 |
149 | public int getBorderColor() {
150 | return mBorderColor;
151 | }
152 |
153 | public void setBorderColor(@ColorInt int borderColor) {
154 | if (borderColor == mBorderColor) {
155 | return;
156 | }
157 |
158 | mBorderColor = borderColor;
159 | mBorderPaint.setColor(mBorderColor);
160 | invalidate();
161 | }
162 |
163 | /**
164 | * @deprecated Use {@link #setBorderColor(int)} instead
165 | */
166 | @Deprecated
167 | public void setBorderColorResource(@ColorRes int borderColorRes) {
168 | setBorderColor(getContext().getResources().getColor(borderColorRes));
169 | }
170 |
171 | /**
172 | * Return the color drawn behind the circle-shaped drawable.
173 | *
174 | * @return The color drawn behind the drawable
175 | *
176 | * @deprecated Fill color support is going to be removed in the future
177 | */
178 | @Deprecated
179 | public int getFillColor() {
180 | return mFillColor;
181 | }
182 |
183 | /**
184 | * Set a color to be drawn behind the circle-shaped drawable. Note that
185 | * this has no effect if the drawable is opaque or no drawable is set.
186 | *
187 | * @param fillColor The color to be drawn behind the drawable
188 | *
189 | * @deprecated Fill color support is going to be removed in the future
190 | */
191 | @Deprecated
192 | public void setFillColor(@ColorInt int fillColor) {
193 | if (fillColor == mFillColor) {
194 | return;
195 | }
196 |
197 | mFillColor = fillColor;
198 | mFillPaint.setColor(fillColor);
199 | invalidate();
200 | }
201 |
202 | /**
203 | * Set a color to be drawn behind the circle-shaped drawable. Note that
204 | * this has no effect if the drawable is opaque or no drawable is set.
205 | *
206 | * @param fillColorRes The color resource to be resolved to a color and
207 | * drawn behind the drawable
208 | *
209 | * @deprecated Fill color support is going to be removed in the future
210 | */
211 | @Deprecated
212 | public void setFillColorResource(@ColorRes int fillColorRes) {
213 | setFillColor(getContext().getResources().getColor(fillColorRes));
214 | }
215 |
216 | public int getBorderWidth() {
217 | return mBorderWidth;
218 | }
219 |
220 | public void setBorderWidth(int borderWidth) {
221 | if (borderWidth == mBorderWidth) {
222 | return;
223 | }
224 |
225 | mBorderWidth = borderWidth;
226 | setup();
227 | }
228 |
229 | public boolean isBorderOverlay() {
230 | return mBorderOverlay;
231 | }
232 |
233 | public void setBorderOverlay(boolean borderOverlay) {
234 | if (borderOverlay == mBorderOverlay) {
235 | return;
236 | }
237 |
238 | mBorderOverlay = borderOverlay;
239 | setup();
240 | }
241 |
242 | public boolean isDisableCircularTransformation() {
243 | return mDisableCircularTransformation;
244 | }
245 |
246 | public void setDisableCircularTransformation(boolean disableCircularTransformation) {
247 | if (mDisableCircularTransformation == disableCircularTransformation) {
248 | return;
249 | }
250 |
251 | mDisableCircularTransformation = disableCircularTransformation;
252 | initializeBitmap();
253 | }
254 |
255 | @Override
256 | public void setImageBitmap(Bitmap bm) {
257 | super.setImageBitmap(bm);
258 | initializeBitmap();
259 | }
260 |
261 | @Override
262 | public void setImageDrawable(Drawable drawable) {
263 | super.setImageDrawable(drawable);
264 | initializeBitmap();
265 | }
266 |
267 | @Override
268 | public void setImageResource(@DrawableRes int resId) {
269 | super.setImageResource(resId);
270 | initializeBitmap();
271 | }
272 |
273 | @Override
274 | public void setImageURI(Uri uri) {
275 | super.setImageURI(uri);
276 | initializeBitmap();
277 | }
278 |
279 | @Override
280 | public void setColorFilter(ColorFilter cf) {
281 | if (cf == mColorFilter) {
282 | return;
283 | }
284 |
285 | mColorFilter = cf;
286 | applyColorFilter();
287 | invalidate();
288 | }
289 |
290 | @Override
291 | public ColorFilter getColorFilter() {
292 | return mColorFilter;
293 | }
294 |
295 | private void applyColorFilter() {
296 | if (mBitmapPaint != null) {
297 | mBitmapPaint.setColorFilter(mColorFilter);
298 | }
299 | }
300 |
301 | private Bitmap getBitmapFromDrawable(Drawable drawable) {
302 | if (drawable == null) {
303 | return null;
304 | }
305 |
306 | if (drawable instanceof BitmapDrawable) {
307 | return ((BitmapDrawable) drawable).getBitmap();
308 | }
309 |
310 | try {
311 | Bitmap bitmap;
312 |
313 | if (drawable instanceof ColorDrawable) {
314 | bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
315 | } else {
316 | bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
317 | }
318 |
319 | Canvas canvas = new Canvas(bitmap);
320 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
321 | drawable.draw(canvas);
322 | return bitmap;
323 | } catch (Exception e) {
324 | e.printStackTrace();
325 | return null;
326 | }
327 | }
328 |
329 | private void initializeBitmap() {
330 | if (mDisableCircularTransformation) {
331 | mBitmap = null;
332 | } else {
333 | mBitmap = getBitmapFromDrawable(getDrawable());
334 | }
335 | setup();
336 | }
337 |
338 | private void setup() {
339 | if (!mReady) {
340 | mSetupPending = true;
341 | return;
342 | }
343 |
344 | if (getWidth() == 0 && getHeight() == 0) {
345 | return;
346 | }
347 |
348 | if (mBitmap == null) {
349 | invalidate();
350 | return;
351 | }
352 |
353 | mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
354 |
355 | mBitmapPaint.setAntiAlias(true);
356 | mBitmapPaint.setShader(mBitmapShader);
357 |
358 | mBorderPaint.setStyle(Paint.Style.STROKE);
359 | mBorderPaint.setAntiAlias(true);
360 | mBorderPaint.setColor(mBorderColor);
361 | mBorderPaint.setStrokeWidth(mBorderWidth);
362 |
363 | mFillPaint.setStyle(Paint.Style.FILL);
364 | mFillPaint.setAntiAlias(true);
365 | mFillPaint.setColor(mFillColor);
366 |
367 | mBitmapHeight = mBitmap.getHeight();
368 | mBitmapWidth = mBitmap.getWidth();
369 |
370 | mBorderRect.set(calculateBounds());
371 | mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2.0f, (mBorderRect.width() - mBorderWidth) / 2.0f);
372 |
373 | mDrawableRect.set(mBorderRect);
374 | if (!mBorderOverlay && mBorderWidth > 0) {
375 | mDrawableRect.inset(mBorderWidth - 1.0f, mBorderWidth - 1.0f);
376 | }
377 | mDrawableRadius = Math.min(mDrawableRect.height() / 2.0f, mDrawableRect.width() / 2.0f);
378 |
379 | applyColorFilter();
380 | updateShaderMatrix();
381 | invalidate();
382 | }
383 |
384 | private RectF calculateBounds() {
385 | int availableWidth = getWidth() - getPaddingLeft() - getPaddingRight();
386 | int availableHeight = getHeight() - getPaddingTop() - getPaddingBottom();
387 |
388 | int sideLength = Math.min(availableWidth, availableHeight);
389 |
390 | float left = getPaddingLeft() + (availableWidth - sideLength) / 2f;
391 | float top = getPaddingTop() + (availableHeight - sideLength) / 2f;
392 |
393 | return new RectF(left, top, left + sideLength, top + sideLength);
394 | }
395 |
396 | private void updateShaderMatrix() {
397 | float scale;
398 | float dx = 0;
399 | float dy = 0;
400 |
401 | mShaderMatrix.set(null);
402 |
403 | if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
404 | scale = mDrawableRect.height() / (float) mBitmapHeight;
405 | dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
406 | } else {
407 | scale = mDrawableRect.width() / (float) mBitmapWidth;
408 | dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
409 | }
410 |
411 | mShaderMatrix.setScale(scale, scale);
412 | mShaderMatrix.postTranslate((int) (dx + 0.5f) + mDrawableRect.left, (int) (dy + 0.5f) + mDrawableRect.top);
413 |
414 | mBitmapShader.setLocalMatrix(mShaderMatrix);
415 | }
416 |
417 | }
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/Comment.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | /**
8 | * Created by Administrator on 2017/11/18.
9 | */
10 |
11 | public class Comment implements Serializable , Cloneable{
12 |
13 | private String avatar;
14 | private String nickName;
15 | private String content;
16 | private String id;
17 | private long createTime;
18 | private String commentId; //直接对应的父评论ID
19 | private String parentId; //对应的一级评论ID
20 | private String theOtherNickName;
21 | private String communityId;
22 |
23 | public String getCommunityId() {
24 | return communityId;
25 | }
26 |
27 | public Comment setCommunityId(String communityId) {
28 | this.communityId = communityId;
29 | return this;
30 | }
31 |
32 | public String getTheOtherNickName() {
33 | return theOtherNickName;
34 | }
35 |
36 | public Comment setTheOtherNickName(String theOtherNickName) {
37 | this.theOtherNickName = theOtherNickName;
38 | return this;
39 | }
40 |
41 | public long getCreateTime() {
42 | return createTime;
43 | }
44 |
45 | public Comment setCreateTime(long createTime) {
46 | this.createTime = createTime;
47 | return this;
48 | }
49 |
50 | public String getCommentId() {
51 | return commentId;
52 | }
53 |
54 | public Comment setCommentId(String commentId) {
55 | this.commentId = commentId;
56 | return this;
57 | }
58 |
59 | private List childComments;
60 |
61 | public List getChildComments() {
62 | return childComments;
63 | }
64 |
65 | public Comment setChildComments(List childComments) {
66 | this.childComments = childComments;
67 | return this;
68 | }
69 |
70 | public Comment addChildComments(Comment comment) {
71 | if (childComments == null)
72 | childComments = new ArrayList<>();
73 | childComments.add(comment);
74 | return this;
75 | }
76 |
77 | public String getParentId() {
78 | return parentId;
79 | }
80 |
81 | public Comment setParentId(String parentId) {
82 | this.parentId = parentId;
83 | return this;
84 | }
85 |
86 | public String getId() {
87 | return id;
88 | }
89 |
90 | public Comment setId(String id) {
91 | this.id = id;
92 | return this;
93 | }
94 |
95 | public String getAvatar() {
96 | return avatar;
97 | }
98 |
99 | public Comment setAvatar(String avatar) {
100 | this.avatar = avatar;
101 | return this;
102 | }
103 |
104 | public String getNickName() {
105 | return nickName;
106 | }
107 |
108 | public Comment setNickName(String nickName) {
109 | this.nickName = nickName;
110 | return this;
111 | }
112 |
113 | public String getContent() {
114 | return content;
115 | }
116 |
117 | public Comment setContent(String content) {
118 | this.content = content;
119 | return this;
120 | }
121 |
122 | @Override
123 | public String toString() {
124 | return "Comment{" +
125 | "avatar='" + avatar + '\'' +
126 | ", nickName='" + nickName + '\'' +
127 | ", content='" + content + '\'' +
128 | ", parentId='" + parentId + '\'' +
129 | ", id='" + id + '\'' +
130 | '}';
131 | }
132 |
133 | @Override
134 | public Comment clone() {
135 | Comment stu = null;
136 | try{
137 | stu = (Comment) super.clone();
138 | }catch(CloneNotSupportedException e) {
139 | e.printStackTrace();
140 | }
141 | return stu;
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/CommentAdapter.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.AdapterView;
10 | import android.widget.ListView;
11 | import android.widget.TextView;
12 | import android.widget.Toast;
13 |
14 | import com.bumptech.glide.Glide;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | /**
20 | * Created by YellowDoing on 2017/11/18.
21 | */
22 |
23 | public class CommentAdapter extends RecyclerView.Adapter {
24 |
25 | private CommunityDetialActivity mContext;
26 | private LayoutInflater mInflater;
27 | private List mComments, mAllComments,mAllCommentsCopy;
28 | private Callback mCallback;
29 | private String mCommunityId;
30 |
31 | public CommentAdapter(CommunityDetialActivity context, String communityId, List comments, Callback callback) {
32 | mContext = context;
33 | mComments = new ArrayList<>();
34 | mAllComments = copy(comments);
35 | mAllCommentsCopy = comments;
36 | mInflater = LayoutInflater.from(mContext);
37 | mCallback = callback;
38 | mCommunityId = communityId;
39 | initData();
40 | }
41 |
42 |
43 | public void add(Comment comment){
44 | mComments.clear();
45 | mAllCommentsCopy.add(comment);
46 | mAllComments = copy(mAllCommentsCopy);
47 | initData();
48 | notifyDataSetChanged();
49 | }
50 |
51 | private List copy(List comments){
52 | List commentList = new ArrayList<>();
53 | for (Comment comment:comments)
54 | commentList.add(comment.clone());
55 | return commentList;
56 | }
57 |
58 |
59 | private void initData() {
60 | //筛选出一级评论
61 | for (Comment comment : mAllComments)
62 | if (comment.getCommentId().equals(mCommunityId))
63 | mComments.add(comment.setCommunityId(mCommunityId));
64 |
65 | //归类出所有一级评论的子评论
66 | for (Comment comment : mComments)
67 | for (Comment co : mAllComments)
68 | if (comment.getId().equals(co.getParentId())){
69 | comment.addChildComments(co);
70 | comment.setCommentId(mCommunityId);
71 | }
72 |
73 |
74 | //归类出子评论所评论的人的姓名
75 | for (Comment comment : mComments)
76 | if (comment.getChildComments() != null)
77 | for (Comment comment1 : comment.getChildComments())
78 | for (Comment comment2 : comment.getChildComments())
79 | if (!comment1.getId().equals(comment.getId()) && comment1.getId().equals(comment2.getCommentId()))
80 | comment2.setTheOtherNickName(comment1.getNickName());
81 | }
82 |
83 | @Override
84 | public ReplyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
85 | return new ReplyViewHolder(mInflater.inflate(R.layout.list_item_reply, parent, false));
86 | }
87 |
88 | @Override
89 | public void onBindViewHolder(ReplyViewHolder holder, int position) {
90 | final Comment comment = mComments.get(position);
91 | Glide.with(mContext).load(comment.getAvatar()).centerCrop().into(holder.mCvAvatar);
92 | holder.mTvContent.setText(comment.getContent());
93 | holder.mTvNickName.setText(comment.getNickName());
94 | holder.itemView.setOnClickListener(new View.OnClickListener() {
95 | @Override
96 | public void onClick(View v) {
97 | mCallback.commentSelect(comment.getNickName(), comment.getId(), comment.getId());
98 | }
99 | });
100 |
101 | if (comment.getChildComments() != null){
102 | final ChildReplyAdapter adapter = new ChildReplyAdapter(comment, mContext);
103 | holder.mLvReply.setAdapter(adapter);
104 | holder.mLvReply.setOnItemClickListener(new AdapterView.OnItemClickListener() {
105 | @Override
106 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
107 | mCallback.commentSelect(adapter.getItem(position).getNickName(), adapter.getItem(position).getId(), comment.getId());
108 | }
109 | });
110 | }
111 | }
112 |
113 | @Override
114 | public int getItemCount() {
115 | return mComments.size();
116 | }
117 |
118 | class ReplyViewHolder extends RecyclerView.ViewHolder {
119 |
120 | CircleImageView mCvAvatar;
121 | TextView mTvNickName, mTvContent;
122 | MyListView mLvReply;
123 |
124 | public ReplyViewHolder(View itemView) {
125 | super(itemView);
126 | mCvAvatar = (CircleImageView) itemView.findViewById(R.id.iv_avatar);
127 | mTvNickName = (TextView) itemView.findViewById(R.id.tv_nick_name);
128 | mTvContent = (TextView) itemView.findViewById(R.id.tv_content);
129 | mLvReply = (MyListView) itemView.findViewById(R.id.lv_child_reply);
130 | }
131 | }
132 |
133 | interface Callback {
134 | void commentSelect(String nickName, String commentId, String parentId);
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/CommentDetailActivity.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.view.View;
8 | import android.view.inputmethod.InputMethodManager;
9 | import android.widget.AdapterView;
10 | import android.widget.EditText;
11 | import android.widget.TextView;
12 | import android.widget.Toast;
13 |
14 | import com.bumptech.glide.Glide;
15 |
16 |
17 | /**
18 | * Created by YellowDoing on 2017/11/26.
19 | */
20 |
21 | public class CommentDetailActivity extends Activity {
22 |
23 | private MyListView mMyListView;
24 | private CircleImageView mCivAvatar;
25 | private TextView mTvNickName, mTvContent, mTvReply;
26 | private Comment mComment;
27 | private EditText mEtReply;
28 |
29 | @Override
30 | protected void onCreate(@Nullable Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_comment_detail);
33 |
34 | mMyListView = (MyListView) findViewById(R.id.list_view);
35 | mCivAvatar = (CircleImageView) findViewById(R.id.civ_avatar);
36 | mTvNickName = (TextView) findViewById(R.id.tv_nick_name);
37 | mTvContent = (TextView) findViewById(R.id.tv_content);
38 | mTvReply = (TextView) findViewById(R.id.tv_reply);
39 | mEtReply = (EditText) findViewById(R.id.et_reply);
40 |
41 | mComment = (Comment) getIntent().getSerializableExtra("comment");
42 |
43 | Glide.with(this).load(mComment.getAvatar()).centerCrop().into(mCivAvatar);
44 | mTvNickName.setText(mComment.getNickName());
45 | mTvContent.setText(mComment.getContent());
46 | mEtReply.setTag(mComment.getId());
47 |
48 | mMyListView.setAdapter(new ChildReplyAdapter2(mComment, this));
49 | mMyListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
50 | @Override
51 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
52 | Comment comment = mComment.getChildComments().get(position);
53 | mEtReply.setHint("回复:" + comment.getNickName());
54 | mEtReply.setTag(comment.getId());
55 | mEtReply.requestFocus();
56 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
57 | imm.showSoftInput(mEtReply, 0);
58 | }
59 | });
60 |
61 | mTvReply.setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View v) {
64 | comment();
65 | }
66 | });
67 |
68 | findViewById(R.id.iv_back).setOnClickListener(new View.OnClickListener() {
69 | @Override
70 | public void onClick(View v) {
71 | finish();
72 | }
73 | });
74 | }
75 |
76 | /**
77 | * 评论
78 | */
79 | private void comment() {
80 | CommunityFragment.getCommunityInterface().comment(new CommunityInterface.CommentSubsriber2() {
81 | @Override
82 | public void onComplete(Comment c) {
83 |
84 | Comment comment = new Comment();
85 | if (!mComment.getId().equals(mEtReply.getTag()))
86 | comment.setTheOtherNickName(mEtReply.getHint().toString().replace("回复:", ""));
87 |
88 | comment.setContent(mEtReply.getText().toString());
89 | comment.setNickName(c.getNickName());
90 | ((ChildReplyAdapter2) mMyListView.getAdapter()).add(comment);
91 |
92 | mEtReply.setTag(mComment.getId());
93 | mEtReply.setText("");
94 | mEtReply.setHint("说点什么吧...~");
95 | Toast.makeText(CommentDetailActivity.this, "评论成功", Toast.LENGTH_SHORT).show();
96 | ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
97 | .hideSoftInputFromWindow(CommentDetailActivity.this.getCurrentFocus()
98 | .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
99 | }
100 | }, mComment.getCommunityId(), mComment.getId(), (String) mEtReply.getTag(), mEtReply.getText().toString());
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/Community.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 |
6 | /**
7 | * Created by YellowDoing on 2017/11/17.
8 | */
9 |
10 | public class Community implements Serializable {
11 |
12 | private String avatar;
13 | private String content;
14 | private String nickName;
15 | private int likeNum;
16 | private boolean isLike;
17 | private ArrayList imagePaths;
18 | private int replyNum;
19 | private String createTime;
20 | private String id;
21 |
22 | public String getId() {
23 | return id;
24 | }
25 |
26 | public Community setId(String id) {
27 | this.id = id;
28 | return this;
29 | }
30 |
31 | public String getCreateTime() {
32 | return createTime;
33 | }
34 |
35 | public Community setCreateTime(String createTime) {
36 | this.createTime = createTime;
37 | return this;
38 | }
39 |
40 | public String getContent() {
41 | return content;
42 | }
43 |
44 | public Community setContent(String content) {
45 | this.content = content;
46 | return this;
47 | }
48 |
49 | public String getAvatar() {
50 | return avatar;
51 | }
52 |
53 | public Community setAvatar(String avatar) {
54 | this.avatar = avatar;
55 | return this;
56 | }
57 |
58 | public String getNickName() {
59 | return nickName;
60 | }
61 |
62 | public Community setNickName(String nickName) {
63 | this.nickName = nickName;
64 | return this;
65 | }
66 |
67 | public int getLikeNum() {
68 | return likeNum;
69 | }
70 |
71 | public Community setLikeNum(int likeNum) {
72 | this.likeNum = likeNum;
73 | return this;
74 | }
75 |
76 | public boolean isLike() {
77 | return isLike;
78 | }
79 |
80 | public Community setLike(boolean like) {
81 | isLike = like;
82 | return this;
83 | }
84 |
85 | public ArrayList getImagePaths() {
86 | return imagePaths;
87 | }
88 |
89 | public Community setImagePaths(ArrayList imagePaths) {
90 | this.imagePaths = imagePaths;
91 | return this;
92 | }
93 |
94 | public int getReplyNum() {
95 | return replyNum;
96 | }
97 |
98 | public Community setReplyNum(int replyNum) {
99 | this.replyNum = replyNum;
100 | return this;
101 | }
102 |
103 | @Override
104 | public String toString() {
105 | return "Community{" +
106 | "avatar='" + avatar + '\'' +
107 | ", content='" + content + '\'' +
108 | ", nickName='" + nickName + '\'' +
109 | ", likeNum=" + likeNum +
110 | ", isLike=" + isLike +
111 | ", imagePaths=" + imagePaths +
112 | ", replyNum=" + replyNum +
113 | '}';
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/CommunityAdapter.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 |
4 | import android.app.Activity;
5 | import android.content.Intent;
6 | import android.support.v7.widget.GridLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ImageView;
12 | import android.widget.LinearLayout;
13 | import android.widget.TextView;
14 |
15 | import com.bumptech.glide.Glide;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 |
21 | /**
22 | * Created by YellowDing on 2017/10/18.
23 | *
24 | */
25 |
26 | public class CommunityAdapter extends RecyclerView.Adapter {
27 |
28 | private List mDataList;
29 | private Activity mContext;
30 | private LayoutInflater mInflater;
31 | private CommunityInterface mInterface;
32 |
33 | public CommunityAdapter(Activity context, CommunityInterface anInterface) {
34 | mDataList = new ArrayList<>();
35 | mContext = context;
36 | mInflater = LayoutInflater.from(mContext);
37 | mInterface = anInterface;
38 | }
39 |
40 |
41 | public void add(List list) {
42 | mDataList.addAll(list);
43 | notifyDataSetChanged();
44 | }
45 |
46 | public void set(List list) {
47 | mDataList = list;
48 | notifyDataSetChanged();
49 | }
50 |
51 | @Override
52 | public CommunityViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
53 | return new CommunityViewHolder(mInflater.inflate(R.layout.list_item_community, parent, false));
54 | }
55 |
56 | @Override
57 | public void onBindViewHolder(final CommunityAdapter.CommunityViewHolder holder, int position) {
58 |
59 | //接口返回的图片地址
60 | final Community community = mDataList.get(position);
61 |
62 | final ArrayList imagePaths = community.getImagePaths();
63 |
64 | if (holder.mContainer.getChildCount() > 0)
65 | holder.mContainer.removeAllViews();
66 |
67 | if (imagePaths != null && imagePaths.size() > 0) {
68 | RecyclerView recyclerView = new RecyclerView(mContext);
69 | recyclerView.setLayoutManager(new GridLayoutManager(mContext, 3));
70 | recyclerView.setAdapter(new ImageAdapter(mContext, imagePaths));
71 | // TODO: 2017/11/21 空白区域点击部分需要做处理
72 | holder.mContainer.addView(recyclerView);
73 | }
74 |
75 | holder.mTvReplyNum.setText(String.valueOf(community.getReplyNum()));
76 | holder.mTvCreateTime.setText(isNull(community.getCreateTime()));
77 | holder.mTvNickName.setText(isNull(community.getNickName()));
78 | Glide.with(mContext).load(isNull(community.getAvatar())).centerCrop().into(holder.mIvAvatar);
79 | holder.mTvLikeNum.setText(String.valueOf(community.getLikeNum()));
80 | if (isNull(community.getContent()).trim().equals("")) holder.mTvContent.setVisibility(View.GONE);
81 | else {
82 | holder.mTvContent.setVisibility(View.VISIBLE);
83 | holder.mTvContent.setText(community.getContent());
84 | }
85 |
86 | //接口返回该贴是否已喜欢
87 | if (community.isLike()) {
88 | holder.mIvLike.setImageResource(R.drawable.ic_zan_hover);
89 | holder.mTvLikeNum.setTextColor(mContext.getResources().getColor(R.color.like_num));
90 | } else {
91 | holder.mIvLike.setImageResource(R.drawable.ic_zan);
92 | holder.mTvLikeNum.setTextColor(mContext.getResources().getColor(R.color.gray));
93 | }
94 |
95 | //接口回调点赞点击事件
96 | holder.mIvLike.setOnClickListener(new View.OnClickListener() {
97 |
98 | @Override
99 | public void onClick(View v) {
100 | if (!community.isLike()) mInterface.like(new CommunityInterface.Subsriber() {
101 | @Override
102 | public void onComplete() {
103 | holder.mTvLikeNum.setText(String.valueOf(Integer.parseInt(holder.mTvLikeNum.getText().toString()) + 1));
104 | holder.mTvLikeNum.setTextColor(mContext.getResources().getColor(R.color.like_num));
105 | holder.mIvLike.setImageResource(R.drawable.ic_zan_hover);
106 | community.setLike(true);
107 | }
108 | }, community.getId());
109 | else mInterface.unLike(new CommunityInterface.Subsriber() {
110 | @Override
111 | public void onComplete() {
112 | holder.mTvLikeNum.setText(String.valueOf(Integer.parseInt(holder.mTvLikeNum.getText().toString()) - 1));
113 | holder.mTvLikeNum.setTextColor(mContext.getResources().getColor(R.color.gray));
114 | holder.mIvLike.setImageResource(R.drawable.ic_zan);
115 | community.setLike(false);
116 | }
117 | }, community.getId());
118 | }
119 | });
120 |
121 | //帖子点击事件
122 | holder.itemView.setOnClickListener(new View.OnClickListener() {
123 | @Override
124 | public void onClick(View v) {
125 | mContext.startActivity(new Intent(mContext, CommunityDetialActivity.class)
126 | .putExtra("community", community));
127 | }
128 | });
129 |
130 | //回复
131 | holder.mIvReply.setOnClickListener(new View.OnClickListener() {
132 | @Override
133 | public void onClick(View v) {
134 | // TODO: 2017/11/15 回复功能
135 | }
136 | });
137 |
138 | }
139 |
140 | @Override
141 | public int getItemCount() {
142 | return mDataList.size();
143 | }
144 |
145 | public class CommunityViewHolder extends RecyclerView.ViewHolder {
146 | public CircleImageView mIvAvatar;
147 | private ImageView mIvReply, mIvLike;
148 | public TextView mTvNickName, mTvContent, mTvCreateTime, mTvLikeNum, mTvReplyNum;
149 | private LinearLayout mContainer;
150 |
151 | public CommunityViewHolder(View itemView) {
152 | super(itemView);
153 | mIvReply = (ImageView) itemView.findViewById(R.id.iv_reply);
154 | mIvLike = (ImageView) itemView.findViewById(R.id.iv_like);
155 | mTvReplyNum = (TextView) itemView.findViewById(R.id.tv_reply_num);
156 | mTvLikeNum = (TextView) itemView.findViewById(R.id.tv_like_num);
157 | mIvAvatar = (CircleImageView) itemView.findViewById(R.id.iv_avatar);
158 | mTvNickName = (TextView) itemView.findViewById(R.id.tv_name);
159 | mTvContent = (TextView) itemView.findViewById(R.id.tv_content);
160 | mTvCreateTime = (TextView) itemView.findViewById(R.id.tv_create_time);
161 | mContainer = (LinearLayout) itemView.findViewById(R.id.container);
162 | }
163 | }
164 |
165 | private String isNull(String str) {
166 | return str == null ? "" : str;
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/CommunityDetialActivity.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.app.Activity;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.IntentFilter;
8 | import android.os.Bundle;
9 | import android.support.annotation.Nullable;
10 | import android.support.v4.content.LocalBroadcastManager;
11 | import android.support.v7.widget.DividerItemDecoration;
12 | import android.support.v7.widget.GridLayoutManager;
13 | import android.support.v7.widget.LinearLayoutManager;
14 | import android.support.v7.widget.RecyclerView;
15 | import android.util.Log;
16 | import android.util.Pair;
17 | import android.view.View;
18 | import android.view.inputmethod.InputMethodManager;
19 | import android.widget.EditText;
20 | import android.widget.ImageView;
21 | import android.widget.TextView;
22 | import android.widget.Toast;
23 | import com.bumptech.glide.Glide;
24 | import com.ufreedom.uikit.FloatingText;
25 | import java.util.ArrayList;
26 | import java.util.List;
27 | /**
28 | * Created by YellowDoing on 2017/11/13.
29 | */
30 |
31 | public class CommunityDetialActivity extends Activity implements View.OnClickListener, CommentAdapter.Callback {
32 |
33 | private CircleImageView mIvHead;
34 | private RecyclerView mIvImages, mRvReplies;
35 | private TextView mTvContent, mTvNickName, mTvReply, mTvLikeNum;
36 | private EditText mEtReply;
37 | private LocalBroadcastManager mManager;
38 | private int mCurrentPage;
39 | private Community mCommunity;
40 | private CommentAdapter mAdapter;
41 | private String theOhterNickName;
42 | private ImageView mIvLike;
43 | public static final int REQUEST_CODE_REPLY = 13;
44 |
45 | @Override
46 | protected void onCreate(@Nullable Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 | iniView();
49 | initData();
50 | }
51 |
52 | private void iniView() {
53 | setContentView(R.layout.activity_community_detail);
54 | findViewById(R.id.iv_back).setOnClickListener(this);
55 | mIvHead = (CircleImageView) findViewById(R.id.iv_head);
56 | mIvImages = (RecyclerView) findViewById(R.id.rv_images);
57 | mIvLike = (ImageView) findViewById(R.id.iv_like);
58 | mTvLikeNum = (TextView) findViewById(R.id.tv_like_num);
59 | mRvReplies = (RecyclerView) findViewById(R.id.rv_replys);
60 | mRvReplies.setLayoutManager(new LinearLayoutManager(this));
61 | mRvReplies.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
62 | mTvNickName = (TextView) findViewById(R.id.tv_nick_name);
63 | mTvReply = (TextView) findViewById(R.id.tv_reply);
64 | mEtReply = (EditText) findViewById(R.id.et_reply);
65 | mTvContent = (TextView) findViewById(R.id.tv_content);
66 | mRvReplies.setAdapter(mAdapter);
67 | mTvReply.setOnClickListener(this);
68 | mIvLike.setOnClickListener(this);
69 | }
70 |
71 |
72 | @Override
73 | public void commentSelect(String nickName, String commentId, String parentId) {
74 | mEtReply.setTag(new Pair<>(commentId, parentId));
75 | theOhterNickName = nickName;
76 | mEtReply.setHint("回复: " + theOhterNickName);
77 | mEtReply.requestFocus();
78 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
79 | imm.showSoftInput(mEtReply, 0);
80 | }
81 |
82 | private void initData() {
83 | mCommunity = (Community) getIntent().getSerializableExtra("community");
84 | mAdapter = new CommentAdapter(this, mCommunity.getId(), new ArrayList(), this);
85 | Glide.with(this).load(mCommunity.getAvatar()).centerCrop().into(mIvHead);
86 | mTvNickName.setText(mCommunity.getNickName());
87 | if (mCommunity.getContent() == null || mCommunity.getContent().trim().equals(""))
88 | mTvContent.setVisibility(View.GONE);
89 | else
90 | mTvContent.setText(mCommunity.getContent());
91 |
92 | if (mCommunity.getImagePaths() != null)
93 | if (mCommunity.getImagePaths().size() > 0) {
94 | mIvImages.setLayoutManager(new GridLayoutManager(this, 3));
95 | mIvImages.setAdapter(new ImageAdapter(this, mCommunity.getImagePaths()));
96 | }
97 |
98 | if (mCommunity.isLike()) {
99 | mIvLike.setBackgroundResource(R.drawable.zan_style_2);
100 | mIvLike.setImageResource(R.drawable.ic_zan_hover);
101 | mTvLikeNum.setTextColor(getResources().getColor(R.color.like_num));
102 | }
103 | mTvLikeNum.setText(mCommunity.getLikeNum() + "");
104 |
105 | mEtReply.setTag(new Pair<>(mCommunity.getId(), mCommunity.getId()));
106 | mTvContent.setText(mCommunity.getContent());
107 | mTvNickName.setText(mCommunity.getNickName());
108 |
109 | loadComments();
110 |
111 | }
112 |
113 | /**
114 | * 加载评论列表
115 | */
116 | private void loadComments() {
117 | mCurrentPage = 1;
118 | CommunityFragment.getCommunityInterface().loadComments(new CommunityInterface.CommentSubsriber() {
119 | @Override
120 | public void onComplete(List communityList) {
121 | if (communityList != null) {
122 | mAdapter = new CommentAdapter(CommunityDetialActivity.this, mCommunity.getId(), communityList, CommunityDetialActivity.this);
123 | mRvReplies.setAdapter(mAdapter);
124 | }
125 | }
126 | }, mCommunity.getId(), mCurrentPage);
127 | }
128 |
129 |
130 | @Override
131 | public void onClick(View v) {
132 | int id = v.getId();
133 | if (id == R.id.iv_back)
134 | finish();
135 | else if (id == R.id.tv_reply)
136 | comment();
137 | else if (id == R.id.iv_like)
138 | if (mCommunity.isLike())
139 | unLike();
140 | else
141 | like();
142 | }
143 |
144 |
145 | /**
146 | * 点赞
147 | */
148 | private void like() {
149 | mIvLike.setOnClickListener(null);
150 | CommunityFragment.getCommunityInterface().like(new CommunityInterface.Subsriber() {
151 | @Override
152 | public void onComplete() {
153 | mIvLike.setBackgroundResource(R.drawable.zan_style_2);
154 | mIvLike.setImageResource(R.drawable.ic_zan_hover);
155 | mTvLikeNum.setTextColor(getResources().getColor(R.color.like_num));
156 | mTvLikeNum.setText(String.valueOf(Integer.valueOf(mTvLikeNum.getText().toString()) + 1));
157 | mCommunity.setLike(true);
158 | FloatingText floatingText = new FloatingText.FloatingTextBuilder(CommunityDetialActivity.this)
159 | .textColor(getResources().getColor(R.color.like_num)) // floating text color
160 | .textSize(100) // floating text size
161 | .textContent("+1") // floating text content
162 | .build();
163 | floatingText.attach2Window();
164 | floatingText.startFloating(mTvLikeNum);
165 | mIvLike.setOnClickListener(CommunityDetialActivity.this);
166 | }
167 | }, mCommunity.getId());
168 | }
169 |
170 | /**
171 | * 取赞
172 | */
173 | private void unLike() {
174 | mIvLike.setOnClickListener(null);
175 | CommunityFragment.getCommunityInterface().unLike(new CommunityInterface.Subsriber() {
176 | @Override
177 | public void onComplete() {
178 | mIvLike.setBackgroundResource(R.drawable.zan_style);
179 | mIvLike.setImageResource(R.drawable.ic_zan);
180 | mTvLikeNum.setTextColor(getResources().getColor(R.color.gray));
181 | mTvLikeNum.setText(String.valueOf(Integer.valueOf(mTvLikeNum.getText().toString()) - 1));
182 | mCommunity.setLike(false);
183 | mIvLike.setOnClickListener(CommunityDetialActivity.this);
184 | }
185 | }, mCommunity.getId());
186 | }
187 |
188 |
189 | /**
190 | * 评论
191 | */
192 | private void comment() {
193 | Pair pair = (Pair) mEtReply.getTag();
194 |
195 | CommunityFragment.getCommunityInterface().comment(new CommunityInterface.CommentSubsriber2() {
196 | @Override
197 | public void onComplete(Comment comment) {
198 | Toast.makeText(CommunityDetialActivity.this, "评论成功", Toast.LENGTH_SHORT).show();
199 | ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
200 | .hideSoftInputFromWindow(CommunityDetialActivity.this.getCurrentFocus()
201 | .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
202 | mEtReply.setText("");
203 | mEtReply.setTag(new Pair<>(mCommunity.getId(), mCommunity.getId()));
204 | theOhterNickName = null;
205 | ((CommentAdapter)mRvReplies.getAdapter()).add(comment);
206 | }
207 | },mCommunity.getId(),pair.second,pair.first,mEtReply.getText().toString());
208 |
209 | }
210 |
211 |
212 | @Override
213 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
214 | super.onActivityResult(requestCode, resultCode, data);
215 | if (resultCode == RESULT_OK) {
216 | switch (requestCode) {
217 | case REQUEST_CODE_REPLY:
218 |
219 | break;
220 | }
221 | }
222 | }
223 | }
224 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/CommunityFragment.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.DividerItemDecoration;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import java.util.List;
15 |
16 |
17 |
18 | public class CommunityFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener{
19 |
20 | private RecyclerView mRecyclerView;
21 | private View mView;
22 | private CommunityAdapter mAdapter;
23 | private int mCurrentPage;
24 | public static CommunityInterface sCommunityInterface;
25 | private SwipeRefreshLayout mSwipeRefreshLayout;
26 |
27 | /**
28 | * 必须要设置接口
29 | */
30 | public CommunityFragment setCommunityInterface(CommunityInterface communityInterface) {
31 | sCommunityInterface = communityInterface;
32 | if (mSwipeRefreshLayout != null) {
33 | mAdapter = new CommunityAdapter(getActivity(), sCommunityInterface);
34 | mRecyclerView.setAdapter(mAdapter);
35 | onRefresh();
36 | }
37 | return this;
38 | }
39 |
40 | public static CommunityInterface getCommunityInterface() {
41 | return sCommunityInterface;
42 | }
43 |
44 | @Override
45 | public void onCreate(@Nullable Bundle savedInstanceState) {
46 | super.onCreate(savedInstanceState);
47 | }
48 |
49 | @Nullable
50 | @Override
51 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
52 | mView = inflater.inflate(R.layout.fragment_communicty, container, false);
53 | initViw(mView);
54 | return mView;
55 | }
56 |
57 |
58 | public void initViw(View view) {
59 | mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swiperereshlayout);
60 | mSwipeRefreshLayout.setOnRefreshListener(this);
61 | mRecyclerView = (RecyclerView) view.findViewById(R.id.rv_community);
62 | mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
63 | mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
64 |
65 |
66 | if (sCommunityInterface != null) {
67 | mAdapter = new CommunityAdapter(getActivity(), sCommunityInterface);
68 | mRecyclerView.setAdapter(mAdapter);
69 | onRefresh();
70 | }
71 | }
72 |
73 |
74 | /**
75 | * 下拉刷新
76 | */
77 | @Override
78 | public void onRefresh() {
79 | mCurrentPage = 1;
80 | sCommunityInterface.loadCommunityList(new CommunityInterface.CommunitySubsriber() {
81 | @Override
82 | public void onComplete(List communityList) {
83 | mAdapter.set(communityList);
84 | mSwipeRefreshLayout.setRefreshing(false);
85 | }
86 | }, mCurrentPage);
87 | }
88 |
89 |
90 |
91 | /*
92 | @Override
93 | public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
94 | mCurrentPage++;
95 | sCommunityInterface.loadCommunityList(new CommunityInterface.CommunitySubsriber() {
96 | @Override
97 | public void onComplete(List communityList) {
98 | mAdapter.add(communityList);
99 | }
100 | }, mCurrentPage);
101 | return false;
102 | }*/
103 |
104 | }
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/CommunityInterface.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 |
4 | import android.view.View;
5 |
6 | import java.io.Serializable;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 |
11 | /**
12 | * Created by YellowDoing on 2017/11/13.
13 | */
14 |
15 | public interface CommunityInterface{
16 |
17 | void loadCommunityList(CommunitySubsriber subsriber,int page);
18 |
19 | /**
20 | * @param subsriber 接口回调
21 | * @param communityId 帖子的Id
22 | * @param commentId 所评论的评论的Id
23 | * @param parentId 父评论Id
24 | * @param content 评论的内容
25 | */
26 | void comment(CommentSubsriber2 subsriber,String communityId,String parentId,String commentId,String content);
27 |
28 | void loadComments(CommentSubsriber subsriber,String communityId,int page);
29 |
30 | void like(Subsriber subsriber,String communityId);
31 |
32 | void unLike(Subsriber subsriber,String communityId);
33 |
34 | void post(Subsriber subsriber,ArrayList imagePaths,String content);
35 |
36 | interface CommunitySubsriber{
37 | void onComplete(List communityList);
38 | }
39 |
40 | interface CommentSubsriber{
41 | void onComplete(List communityList);
42 | }
43 |
44 | interface CommentSubsriber2{
45 | void onComplete(Comment comment);
46 | }
47 |
48 | interface Subsriber{
49 | void onComplete();
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/ImageAdapter.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.util.DisplayMetrics;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.WindowManager;
11 | import android.widget.ImageView;
12 | import android.widget.LinearLayout;
13 | import com.bumptech.glide.Glide;
14 | import java.util.ArrayList;
15 | import me.iwf.photopicker.PhotoPreview;
16 |
17 | /**
18 | * Created by YellowDoing on 2017/11/11.
19 | *
20 | */
21 |
22 | public class ImageAdapter extends RecyclerView.Adapter {
23 |
24 | private Activity mContext;
25 | private LayoutInflater mInflater;
26 | private ArrayList mImagePaths;
27 | private int viewWH;
28 |
29 | public ImageAdapter(Activity context, ArrayList imagePaths) {
30 | mContext = context;
31 | mInflater = LayoutInflater.from(mContext);
32 | mImagePaths = imagePaths;
33 | }
34 |
35 | @Override
36 | public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
37 | View view = mInflater.inflate(R.layout.list_item_image, parent, false);
38 | if (viewWH == 0)
39 | if (mContext instanceof CommunityDetialActivity)
40 | viewWH = (getScreenWidth(mContext) - dip2px(mContext, 40)) / 3;
41 | else
42 | viewWH = (getScreenWidth(mContext) - dip2px(mContext, 72)) / 3;
43 |
44 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(viewWH, viewWH);
45 | view.setLayoutParams(params);
46 | return new ImageViewHolder(view);
47 | }
48 |
49 | @Override
50 | public void onBindViewHolder(final ImageViewHolder holder, final int position) {
51 |
52 | Glide.with(mContext).load(mImagePaths.get(position)).placeholder(R.drawable.hospital_bitmap).centerCrop().into(holder.mImageView);
53 |
54 | holder.mImageView.setOnClickListener(new View.OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | PhotoPreview.builder()
58 | .setPhotos(mImagePaths)
59 | .setCurrentItem(position)
60 | .setShowDeleteButton(false)
61 | .start(mContext);
62 | }
63 | });
64 | }
65 |
66 | @Override
67 | public int getItemCount() {
68 | return mImagePaths.size();
69 | }
70 |
71 | class ImageViewHolder extends RecyclerView.ViewHolder {
72 | ImageView mImageView;
73 |
74 | public ImageViewHolder(View itemView) {
75 | super(itemView);
76 | mImageView = (ImageView) itemView.findViewById(R.id.image);
77 | }
78 | }
79 |
80 | private int getScreenWidth(Activity activity) {
81 | WindowManager manager = activity.getWindowManager();
82 | DisplayMetrics outMetrics = new DisplayMetrics();
83 | manager.getDefaultDisplay().getMetrics(outMetrics);
84 | return outMetrics.widthPixels;
85 | }
86 |
87 | /**
88 | * 根据手机的分辨率从dp的单位转成为px(像素)
89 | */
90 | private int dip2px(Context context, float dpValue) {
91 | final float scale = context.getResources().getDisplayMetrics().density;
92 | return (int) (dpValue * scale + 0.5f);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/ImageSelectAdapter.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.LinearLayout;
10 |
11 | import com.bumptech.glide.Glide;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | import me.iwf.photopicker.PhotoPicker;
17 | import me.iwf.photopicker.PhotoPreview;
18 |
19 | /**
20 | * Created by YellowDoing on 2017/11/7.
21 | */
22 |
23 | public class ImageSelectAdapter extends RecyclerView.Adapter {
24 |
25 |
26 | private PostActivity mContext;
27 | private ArrayList mPaths;
28 | private int dp_8,dp_72;
29 |
30 |
31 | public ImageSelectAdapter(PostActivity context) {
32 | mContext = context;
33 | mPaths = new ArrayList<>();
34 | dp_8 = dip2px(8);
35 | dp_72 = dip2px(72);
36 | }
37 |
38 | public void add(ArrayList paths){
39 | mPaths.addAll(paths);
40 | notifyDataSetChanged();
41 | }
42 |
43 | public void reset(ArrayList paths){
44 | mPaths = paths;
45 | notifyDataSetChanged();
46 | }
47 |
48 | public ArrayList getPaths(){
49 | return mPaths;
50 | }
51 |
52 | @Override
53 | public ImageSelectViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
54 | return new ImageSelectViewHolder(new ImageView(mContext));
55 | }
56 |
57 | @Override
58 | public void onBindViewHolder(ImageSelectViewHolder holder, final int position) {
59 |
60 | if (position == mPaths.size()) {
61 | holder.mImageView.setImageResource(R.drawable.ic_add_picture);
62 | holder.mImageView.setOnClickListener(new View.OnClickListener() {
63 | @Override
64 | public void onClick(View v) {
65 | PhotoPicker.builder()
66 | .setPreviewEnabled(true)
67 | .setShowGif(false)
68 | .setPhotoCount(9 - mPaths.size())
69 | .setShowCamera(false)
70 | .setGridColumnCount(3)
71 | .start(mContext, PhotoPicker.REQUEST_CODE);
72 | }
73 | });
74 | } else {
75 | Glide.with(mContext).load(mPaths.get(position)).centerCrop().into(holder.mImageView);
76 | holder.mImageView.setOnClickListener(new View.OnClickListener() {
77 | @Override
78 | public void onClick(View v) {
79 | PhotoPreview.builder()
80 | .setPhotos(mPaths)
81 | .setShowDeleteButton(true)
82 | .setCurrentItem(position)
83 | .start(mContext, PhotoPreview.REQUEST_CODE);
84 | }
85 | });
86 | }
87 | }
88 |
89 | @Override
90 | public int getItemCount() {
91 | if (mPaths.size() < 9)
92 | return mPaths.size() + 1;
93 | else
94 | return 9;
95 | }
96 |
97 | class ImageSelectViewHolder extends RecyclerView.ViewHolder{
98 | ImageView mImageView;
99 | public ImageSelectViewHolder(ImageView itemView) {
100 | super(itemView);
101 | mImageView = itemView;
102 |
103 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(dp_72,dp_72);
104 | params.setMargins(0,dp_8,0,0);
105 | mImageView.setLayoutParams(params);
106 | }
107 |
108 | }
109 |
110 | public int dip2px(float dpValue){
111 | final float scale = mContext.getResources().getDisplayMetrics().density;
112 | return (int)(dpValue*scale+0.5f);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/MyListView.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.ListView;
6 |
7 | /**
8 | * Created by YellowDoing on 2017/11/26.
9 | */
10 |
11 | public class MyListView extends ListView {
12 |
13 |
14 | public MyListView(Context context) {
15 | super(context);
16 | }
17 |
18 | public MyListView(Context context, AttributeSet attrs) {
19 | super(context, attrs);
20 | }
21 |
22 | public MyListView(Context context, AttributeSet attrs, int defStyleAttr) {
23 | super(context, attrs, defStyleAttr);
24 | }
25 |
26 | @Override
27 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
28 | int expandSpec = MeasureSpec.makeMeasureSpec(
29 | Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
30 |
31 | super.onMeasure(widthMeasureSpec, expandSpec);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/communityUI/src/main/java/hg/yellowdoing/communityui/PostActivity.java:
--------------------------------------------------------------------------------
1 | package hg.yellowdoing.communityui;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v4.content.LocalBroadcastManager;
7 | import android.support.v7.app.AlertDialog;
8 | import android.support.v7.widget.GridLayoutManager;
9 | import android.support.v7.widget.LinearLayoutManager;
10 | import android.support.v7.widget.RecyclerView;
11 | import android.view.View;
12 | import android.widget.EditText;
13 | import android.widget.ProgressBar;
14 |
15 | import me.iwf.photopicker.PhotoPicker;
16 | import me.iwf.photopicker.PhotoPreview;
17 |
18 | /**
19 | * Created by YellowDoing on 2017/11/18.
20 | */
21 |
22 | public class PostActivity extends Activity implements View.OnClickListener {
23 |
24 |
25 | private RecyclerView mRecyclerView;
26 | private ImageSelectAdapter mAdapter;
27 | private EditText mEtContent;
28 | private AlertDialog.Builder mDialog;
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_post);
34 | initView();
35 | mDialog = new AlertDialog.Builder(this).setView(new ProgressBar(this));
36 | }
37 |
38 | private void initView() {
39 | mEtContent = (EditText) findViewById(R.id.et_content);
40 | findViewById(R.id.iv_back).setOnClickListener(this);
41 | findViewById(R.id.tv_submit).setOnClickListener(this);
42 | mAdapter = new ImageSelectAdapter(this);
43 | mRecyclerView = (RecyclerView) findViewById(R.id.rv_select_images);
44 | mRecyclerView.setLayoutManager(new GridLayoutManager(this, 4, LinearLayoutManager.VERTICAL, false));
45 | mRecyclerView.setAdapter(mAdapter);
46 | }
47 |
48 | @Override
49 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
50 | super.onActivityResult(requestCode, resultCode, data);
51 | if (resultCode == RESULT_OK) {
52 | switch (requestCode) {
53 | case PhotoPicker.REQUEST_CODE: //选择图片返回
54 | mAdapter.add(data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS));
55 | break;
56 | case PhotoPreview.REQUEST_CODE: //预览图片删除后返回
57 | mAdapter.reset(data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS));
58 | break;
59 | }
60 | }
61 | }
62 |
63 |
64 | @Override
65 | public void onClick(View v) {
66 | int id = v.getId();
67 | if (id == R.id.iv_back) finish();
68 | else if (id == R.id.tv_submit) post(); //发帖
69 | }
70 |
71 | private void post() {
72 | final AlertDialog loadingView = mDialog.show();
73 |
74 | Community community = new Community();
75 | community.setContent(mEtContent.getText().toString());
76 | community.setImagePaths(mAdapter.getPaths());
77 |
78 | CommunityFragment.getCommunityInterface().post(new CommunityInterface.Subsriber() {
79 | @Override
80 | public void onComplete() {
81 | LocalBroadcastManager.getInstance(PostActivity.this).sendBroadcast(new Intent());
82 | loadingView.cancel();
83 | finish();
84 | }
85 | },community.getImagePaths(),community.getContent());
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-hdpi/ic_add_picture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-hdpi/ic_add_picture.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-hdpi/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-hdpi/ic_back.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-hdpi/ic_reply.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-hdpi/ic_reply.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-hdpi/ic_zan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-hdpi/ic_zan.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-hdpi/ic_zan_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-hdpi/ic_zan_hover.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-mdpi/edit_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-mdpi/edit_text_cursor.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-mdpi/ic_add_picture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-mdpi/ic_add_picture.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-mdpi/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-mdpi/ic_back.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-mdpi/ic_reply.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-mdpi/ic_reply.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-mdpi/ic_zan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-mdpi/ic_zan.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-mdpi/ic_zan_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-mdpi/ic_zan_hover.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-mdpi/text_item_reply.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xhdpi/ic_add_picture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xhdpi/ic_add_picture.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xhdpi/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xhdpi/ic_back.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xhdpi/ic_reply.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xhdpi/ic_reply.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xhdpi/ic_zan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xhdpi/ic_zan.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xhdpi/ic_zan_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xhdpi/ic_zan_hover.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xxhdpi/hospital_bitmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xxhdpi/hospital_bitmap.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xxhdpi/ic_add_picture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xxhdpi/ic_add_picture.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xxhdpi/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xxhdpi/ic_back.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xxhdpi/ic_reply.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xxhdpi/ic_reply.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xxhdpi/ic_zan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xxhdpi/ic_zan.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable-xxhdpi/ic_zan_hover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/communityUI/src/main/res/drawable-xxhdpi/ic_zan_hover.png
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable/zan_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/drawable/zan_style_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/activity_comment_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
20 |
21 |
29 |
30 |
35 |
36 |
37 |
43 |
44 |
48 |
55 |
56 |
60 |
61 |
69 |
70 |
71 |
72 |
73 |
81 |
82 |
83 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
107 |
108 |
123 |
124 |
136 |
137 |
138 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/activity_community_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
20 |
21 |
29 |
30 |
35 |
36 |
37 |
38 |
44 |
45 |
49 |
50 |
58 |
59 |
63 |
64 |
68 |
69 |
76 |
77 |
81 |
82 |
83 |
84 |
85 |
94 |
95 |
102 |
103 |
110 |
111 |
118 |
119 |
128 |
129 |
130 |
131 |
132 |
137 |
138 |
144 |
145 |
146 |
147 |
148 |
155 |
156 |
171 |
172 |
184 |
185 |
186 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/activity_post.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
17 |
18 |
26 |
27 |
35 |
36 |
41 |
42 |
43 |
51 |
52 |
53 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/fragment_communicty.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/list_item_child_reply.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
22 |
23 |
29 |
30 |
36 |
37 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/list_item_child_reply_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
19 |
20 |
25 |
26 |
31 |
32 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/list_item_community.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
17 |
18 |
22 |
23 |
28 |
29 |
35 |
36 |
43 |
44 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
68 |
69 |
70 |
77 |
78 |
85 |
86 |
99 |
100 |
107 |
108 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/list_item_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/list_item_more.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/list_item_reply.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
25 |
26 |
35 |
46 |
47 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/layout/reply_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
25 |
26 |
38 |
--------------------------------------------------------------------------------
/communityUI/src/main/res/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | communitUI
6 | 发帖
7 | 输入内容...
8 | 发布
9 | 回复
10 | 详情
11 | 评论详情
12 |
13 |
14 |
15 |
16 | 4dp
17 | 8dp
18 | 12dp
19 | 16dp
20 | 20dp
21 | 24dp
22 | 40dp
23 | 48dp
24 | 160dp
25 |
26 | 16sp
27 |
28 |
29 |
30 | #adadad
31 | #355998
32 | #000000
33 | #E75975
34 | #ffffff
35 | #ff2d2d
36 | #f8f7fd
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
51 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YellowDoing/communityUI/c9510548607b2196870547b5825178ed6a2775ff/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=file:///Users/ganhuang/Downloads//gradle-4.1-all.zip
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':communityUI'
2 |
--------------------------------------------------------------------------------