完成粗糙的帖子详情框架,细节待补充 https://gitlab.ghzs.com/pm/halo-app-issues/-/issues/967

This commit is contained in:
juntao
2020-08-11 18:25:43 +08:00
parent 96fc6cc183
commit fbd3a42e81
31 changed files with 1551 additions and 607 deletions

View File

@ -12,6 +12,8 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.gh.gamecenter.CommentDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
@ -38,7 +40,6 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
import androidx.core.content.ContextCompat;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
@ -50,9 +51,13 @@ import retrofit2.HttpException;
public class CommentUtils {
public static void setCommentTime(TextView textView, long time) {
textView.setText(getCommentTime(time));
}
public static String getCommentTime(long timestamp) {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
try {
long day = time * 1000;
long day = timestamp * 1000;
String year = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));
format.applyPattern("yyyy");
String currentYear = format.format(day);
@ -63,35 +68,34 @@ public class CommentUtils {
int hour = (int) (min / (60 * 60));
if (hour == 0) {
if (min < 60) {
textView.setText("刚刚");
return "刚刚";
} else {
textView.setText(String.format(Locale.getDefault(), "%d分钟前", (int) (min / 60)));
return String.format(Locale.getDefault(), "%d分钟前", (int) (min / 60));
}
} else {
textView.setText(String.format(Locale.getDefault(), "%d小时前", hour));
return String.format(Locale.getDefault(), "%d小时前", hour);
}
} else if (day >= today - 86400 * 1000 && day < today) {
format.applyPattern("HH:mm");
textView.setText("昨天 ");
return "昨天 ";
} else if (day >= today - 86400 * 1000 * 7 && day < today - 86400 * 1000) {
format.applyPattern("HH:mm");
long days = (today - day) / 86400000 + 1;
textView.setText(String.format(Locale.getDefault(), "%d天前 ", days));
return String.format(Locale.getDefault(), "%d天前 ", days);
} else if (day < today - 86400 * 1000 * 7 && year.equals(currentYear)) {
format.applyPattern("MM-dd");
textView.setText(format.format(day));
return format.format(day);
} else {
format.applyPattern("yyyy-MM-dd");
textView.setText(format.format(day));
return format.format(day);
}
} catch (ParseException e) {
e.printStackTrace();
format.applyPattern("yyyy-MM-dd");
textView.setText(format.format(time * 1000));
return format.format(timestamp * 1000);
}
}
public static void showReportDialog(final CommentEntity commentEntity,
final Context context,
final boolean showConversation,