Fix an issue when parsing
This commit is contained in:
parent
fb107e6274
commit
eb6a87c776
|
@ -5050,22 +5050,24 @@ public class API {
|
||||||
Report report = new Report();
|
Report report = new Report();
|
||||||
try {
|
try {
|
||||||
report.setId(resobj.getString("id"));
|
report.setId(resobj.getString("id"));
|
||||||
report.setAction_taken(resobj.getString("action_taken"));
|
report.setAction_taken(resobj.getBoolean("action_taken"));
|
||||||
report.setComment(resobj.getString("comment"));
|
report.setComment(resobj.getString("comment"));
|
||||||
report.setCreated_at(Helper.mstStringToDate(context, resobj.getString("created_at")));
|
report.setCreated_at(Helper.mstStringToDate(context, resobj.getString("created_at")));
|
||||||
report.setUpdated_at(Helper.mstStringToDate(context, resobj.getString("updated_at")));
|
report.setUpdated_at(Helper.mstStringToDate(context, resobj.getString("updated_at")));
|
||||||
if( !resobj.isNull("account")) {
|
if( !resobj.isNull("account")) {
|
||||||
report.setAccount(parseAccountResponse(context, resobj.getJSONObject("account")));
|
report.setAccount(parseAccountAdminResponse(context, resobj.getJSONObject("account")));
|
||||||
}
|
}
|
||||||
if( !resobj.isNull("target_account")) {
|
if( !resobj.isNull("target_account")) {
|
||||||
report.setTarget_account(parseAccountResponse(context, resobj.getJSONObject("target_account")));
|
report.setTarget_account(parseAccountAdminResponse(context, resobj.getJSONObject("target_account")));
|
||||||
}
|
}
|
||||||
if( !resobj.isNull("assigned_account")) {
|
if( !resobj.isNull("assigned_account")) {
|
||||||
report.setAssigned_account(parseAccountResponse(context, resobj.getJSONObject("assigned_account")));
|
report.setAssigned_account(parseAccountAdminResponse(context, resobj.getJSONObject("assigned_account")));
|
||||||
|
}
|
||||||
|
if( !resobj.isNull("action_taken_by_account")) {
|
||||||
|
report.setAction_taken_by_account(parseAccountAdminResponse(context, resobj.getJSONObject("action_taken_by_account")));
|
||||||
}
|
}
|
||||||
report.setAction_taken_by_account_id(resobj.getString("action_taken_by_account_id"));
|
|
||||||
report.setStatuses(parseStatuses(context, resobj.getJSONArray("statuses")));
|
report.setStatuses(parseStatuses(context, resobj.getJSONArray("statuses")));
|
||||||
}catch (Exception ignored){}
|
}catch (Exception ignored){ignored.printStackTrace();}
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5107,11 +5109,27 @@ public class API {
|
||||||
accountAdmin.setEmail(resobj.getString("email"));
|
accountAdmin.setEmail(resobj.getString("email"));
|
||||||
accountAdmin.setRole(resobj.getString("role"));
|
accountAdmin.setRole(resobj.getString("role"));
|
||||||
accountAdmin.setIp(resobj.getString("ip"));
|
accountAdmin.setIp(resobj.getString("ip"));
|
||||||
accountAdmin.setConfirmed(resobj.getBoolean("confirmed"));
|
|
||||||
accountAdmin.setSuspended(resobj.getBoolean("suspended"));
|
|
||||||
accountAdmin.setSilenced(resobj.getBoolean("silenced"));
|
|
||||||
accountAdmin.setDisabled(resobj.getBoolean("disabled"));
|
|
||||||
accountAdmin.setAccount(parseAccountResponse(context, resobj.getJSONObject("account")));
|
accountAdmin.setAccount(parseAccountResponse(context, resobj.getJSONObject("account")));
|
||||||
|
if( !resobj.isNull("confirmed")) {
|
||||||
|
accountAdmin.setConfirmed(resobj.getBoolean("confirmed"));
|
||||||
|
}else{
|
||||||
|
accountAdmin.setConfirmed(true);
|
||||||
|
}
|
||||||
|
if( !resobj.isNull("suspended")) {
|
||||||
|
accountAdmin.setSuspended(resobj.getBoolean("suspended"));
|
||||||
|
}else{
|
||||||
|
accountAdmin.setSuspended(false);
|
||||||
|
}
|
||||||
|
if( !resobj.isNull("silenced")) {
|
||||||
|
accountAdmin.setSilenced(resobj.getBoolean("silenced"));
|
||||||
|
}else{
|
||||||
|
accountAdmin.setSilenced(false);
|
||||||
|
}
|
||||||
|
if( !resobj.isNull("disabled")) {
|
||||||
|
accountAdmin.setDisabled(resobj.getBoolean("disabled"));
|
||||||
|
}else{
|
||||||
|
accountAdmin.setDisabled(false);
|
||||||
|
}
|
||||||
}catch (Exception ignored){}
|
}catch (Exception ignored){}
|
||||||
return accountAdmin;
|
return accountAdmin;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,14 @@ import java.util.List;
|
||||||
public class Report implements Parcelable {
|
public class Report implements Parcelable {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String action_taken;
|
private boolean action_taken;
|
||||||
private String comment;
|
private String comment;
|
||||||
private Date created_at;
|
private Date created_at;
|
||||||
private Date updated_at;
|
private Date updated_at;
|
||||||
private Account account;
|
private AccountAdmin account;
|
||||||
private Account target_account;
|
private AccountAdmin target_account;
|
||||||
private Account assigned_account;
|
private AccountAdmin assigned_account;
|
||||||
private String action_taken_by_account_id;
|
private AccountAdmin action_taken_by_account;
|
||||||
private List<Status> statuses;
|
private List<Status> statuses;
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,13 +43,6 @@ public class Report implements Parcelable {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAction_taken() {
|
|
||||||
return action_taken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAction_taken(String action_taken) {
|
|
||||||
this.action_taken = action_taken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getComment() {
|
public String getComment() {
|
||||||
return comment;
|
return comment;
|
||||||
|
@ -75,15 +68,6 @@ public class Report implements Parcelable {
|
||||||
this.updated_at = updated_at;
|
this.updated_at = updated_at;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getAction_taken_by_account_id() {
|
|
||||||
return action_taken_by_account_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAction_taken_by_account_id(String action_taken_by_account_id) {
|
|
||||||
this.action_taken_by_account_id = action_taken_by_account_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Status> getStatuses() {
|
public List<Status> getStatuses() {
|
||||||
return statuses;
|
return statuses;
|
||||||
}
|
}
|
||||||
|
@ -96,30 +80,46 @@ public class Report implements Parcelable {
|
||||||
public Report() {
|
public Report() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Account getAccount() {
|
public AccountAdmin getAccount() {
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccount(Account account) {
|
public void setAccount(AccountAdmin account) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Account getTarget_account() {
|
public AccountAdmin getTarget_account() {
|
||||||
return target_account;
|
return target_account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget_account(Account target_account) {
|
public void setTarget_account(AccountAdmin target_account) {
|
||||||
this.target_account = target_account;
|
this.target_account = target_account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Account getAssigned_account() {
|
public AccountAdmin getAssigned_account() {
|
||||||
return assigned_account;
|
return assigned_account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAssigned_account(Account assigned_account) {
|
public void setAssigned_account(AccountAdmin assigned_account) {
|
||||||
this.assigned_account = assigned_account;
|
this.assigned_account = assigned_account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAction_taken() {
|
||||||
|
return action_taken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction_taken(boolean action_taken) {
|
||||||
|
this.action_taken = action_taken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountAdmin getAction_taken_by_account() {
|
||||||
|
return action_taken_by_account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction_taken_by_account(AccountAdmin action_taken_by_account) {
|
||||||
|
this.action_taken_by_account = action_taken_by_account;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -128,29 +128,29 @@ public class Report implements Parcelable {
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeString(this.id);
|
dest.writeString(this.id);
|
||||||
dest.writeString(this.action_taken);
|
dest.writeByte(this.action_taken ? (byte) 1 : (byte) 0);
|
||||||
dest.writeString(this.comment);
|
dest.writeString(this.comment);
|
||||||
dest.writeLong(this.created_at != null ? this.created_at.getTime() : -1);
|
dest.writeLong(this.created_at != null ? this.created_at.getTime() : -1);
|
||||||
dest.writeLong(this.updated_at != null ? this.updated_at.getTime() : -1);
|
dest.writeLong(this.updated_at != null ? this.updated_at.getTime() : -1);
|
||||||
dest.writeParcelable(this.account, flags);
|
dest.writeParcelable(this.account, flags);
|
||||||
dest.writeParcelable(this.target_account, flags);
|
dest.writeParcelable(this.target_account, flags);
|
||||||
dest.writeParcelable(this.assigned_account, flags);
|
dest.writeParcelable(this.assigned_account, flags);
|
||||||
dest.writeString(this.action_taken_by_account_id);
|
dest.writeParcelable(this.action_taken_by_account, flags);
|
||||||
dest.writeTypedList(this.statuses);
|
dest.writeTypedList(this.statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Report(Parcel in) {
|
protected Report(Parcel in) {
|
||||||
this.id = in.readString();
|
this.id = in.readString();
|
||||||
this.action_taken = in.readString();
|
this.action_taken = in.readByte() != 0;
|
||||||
this.comment = in.readString();
|
this.comment = in.readString();
|
||||||
long tmpCreated_at = in.readLong();
|
long tmpCreated_at = in.readLong();
|
||||||
this.created_at = tmpCreated_at == -1 ? null : new Date(tmpCreated_at);
|
this.created_at = tmpCreated_at == -1 ? null : new Date(tmpCreated_at);
|
||||||
long tmpUpdated_at = in.readLong();
|
long tmpUpdated_at = in.readLong();
|
||||||
this.updated_at = tmpUpdated_at == -1 ? null : new Date(tmpUpdated_at);
|
this.updated_at = tmpUpdated_at == -1 ? null : new Date(tmpUpdated_at);
|
||||||
this.account = in.readParcelable(Account.class.getClassLoader());
|
this.account = in.readParcelable(AccountAdmin.class.getClassLoader());
|
||||||
this.target_account = in.readParcelable(Account.class.getClassLoader());
|
this.target_account = in.readParcelable(AccountAdmin.class.getClassLoader());
|
||||||
this.assigned_account = in.readParcelable(Account.class.getClassLoader());
|
this.assigned_account = in.readParcelable(AccountAdmin.class.getClassLoader());
|
||||||
this.action_taken_by_account_id = in.readString();
|
this.action_taken_by_account = in.readParcelable(AccountAdmin.class.getClassLoader());
|
||||||
this.statuses = in.createTypedArrayList(Status.CREATOR);
|
this.statuses = in.createTypedArrayList(Status.CREATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,6 @@ package app.fedilab.android.drawers;
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
|
||||||
import android.text.Html;
|
|
||||||
import android.text.util.Linkify;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -28,7 +25,6 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
|
@ -72,12 +68,12 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||||
final ReportsListAdapter.ViewHolder holder = (ReportsListAdapter.ViewHolder) viewHolder;
|
final ReportsListAdapter.ViewHolder holder = (ReportsListAdapter.ViewHolder) viewHolder;
|
||||||
Report report = reports.get(position);
|
Report report = reports.get(position);
|
||||||
Account account = report.getAccount();
|
Account account = report.getAccount().getAccount();
|
||||||
Account target_account = report.getTarget_account();
|
Account target_account = report.getTarget_account().getAccount();
|
||||||
|
|
||||||
|
|
||||||
account.makeAccountNameEmoji(context, ReportsListAdapter.this, account);
|
/*account.makeAccountNameEmoji(context, ReportsListAdapter.this, account);
|
||||||
target_account.makeAccountNameEmoji(context, ReportsListAdapter.this, target_account);
|
target_account.makeAccountNameEmoji(context, ReportsListAdapter.this, target_account);*/
|
||||||
if( account.getdisplayNameSpan() == null || account.getdisplayNameSpan().toString().trim().equals("")) {
|
if( account.getdisplayNameSpan() == null || account.getdisplayNameSpan().toString().trim().equals("")) {
|
||||||
if( account.getDisplay_name() != null && !account.getDisplay_name().trim().equals(""))
|
if( account.getDisplay_name() != null && !account.getDisplay_name().trim().equals(""))
|
||||||
holder.account_dn_reporter.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
holder.account_dn_reporter.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
|
||||||
|
@ -95,7 +91,8 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
||||||
holder.account_dn.setText( target_account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
holder.account_dn.setText( target_account.getdisplayNameSpan(), TextView.BufferType.SPANNABLE);
|
||||||
|
|
||||||
|
|
||||||
Helper.loadGiF(context, account.getAvatar(), holder.account_pp);
|
|
||||||
|
Helper.loadGiF(context, target_account.getAvatar(), holder.account_pp);
|
||||||
Helper.loadGiF(context, account.getAvatar(), holder.account_pp_reporter);
|
Helper.loadGiF(context, account.getAvatar(), holder.account_pp_reporter);
|
||||||
holder.account_un.setText(String.format("@%s",account.getUsername()));
|
holder.account_un.setText(String.format("@%s",account.getUsername()));
|
||||||
holder.account_ac.setText(account.getAcct());
|
holder.account_ac.setText(account.getAcct());
|
||||||
|
@ -104,7 +101,7 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
||||||
else
|
else
|
||||||
holder.account_ac.setVisibility(View.VISIBLE);
|
holder.account_ac.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
holder.report_action_taken.setText(report.getAction_taken());
|
holder.report_comment.setText(report.getComment());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +145,7 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
||||||
TextView account_ac;
|
TextView account_ac;
|
||||||
TextView account_dn, account_dn_reporter;
|
TextView account_dn, account_dn_reporter;
|
||||||
TextView account_un;
|
TextView account_un;
|
||||||
TextView report_action_taken;
|
TextView report_comment;
|
||||||
|
|
||||||
LinearLayout account_container;
|
LinearLayout account_container;
|
||||||
|
|
||||||
|
@ -160,7 +157,7 @@ public class ReportsListAdapter extends RecyclerView.Adapter implements OnRetrie
|
||||||
account_dn_reporter = itemView.findViewById(R.id.account_dn_reporter);
|
account_dn_reporter = itemView.findViewById(R.id.account_dn_reporter);
|
||||||
account_ac = itemView.findViewById(R.id.account_ac);
|
account_ac = itemView.findViewById(R.id.account_ac);
|
||||||
account_un = itemView.findViewById(R.id.account_un);
|
account_un = itemView.findViewById(R.id.account_un);
|
||||||
report_action_taken = itemView.findViewById(R.id.report_action_taken);
|
report_comment = itemView.findViewById(R.id.report_comment);
|
||||||
account_container = itemView.findViewById(R.id.account_container);
|
account_container = itemView.findViewById(R.id.account_container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -79,6 +80,7 @@
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:contentDescription="@string/profile_picture"/>
|
android:contentDescription="@string/profile_picture"/>
|
||||||
<TextView
|
<TextView
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
android:id="@+id/account_dn_reporter"
|
android:id="@+id/account_dn_reporter"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:layout_width="80dp"
|
android:layout_width="80dp"
|
||||||
|
@ -86,9 +88,9 @@
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:id="@+id/report_action_taken"
|
android:id="@+id/report_comment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Loading…
Reference in New Issue