Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Multireddit dropdown code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
philippTheCat committed Sep 18, 2019
1 parent c8c2ce1 commit b99f08a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ public void doDrawer() {
if (Authentication.isLoggedIn && Authentication.didOnline) {

header = inflater.inflate(R.layout.drawer_loggedin, drawerSubList, false);
LinearLayout multiReddits = header.findViewById(R.id.multi);
RelativeLayout multiReddits = header.findViewById(R.id.multi);
headerMain = header;
hea = header.findViewById(R.id.back);

Expand Down Expand Up @@ -1523,20 +1523,19 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which)
return true;
}
});
LinearLayout multireddits_area = header.findViewById(R.id.multireddits_area);
LinearLayout multireddits_area = header.findViewById(R.id.expand_multireddits);

multireddits_area.setVisibility(View.GONE);
findViewById(R.id.multireddits_flip).setOnClickListener(new View.OnClickListener() {
findViewById(R.id.godown_multireddits).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (multireddits_area.getVisibility() == View.GONE) {
expand(multireddits_area);
flipAnimator(false, header.findViewById(R.id.multireddits_flip)).start();
header.findViewById(R.id.multireddits_flip).setContentDescription(getResources().getString(R.string.btn_collapse));
flipAnimator(false, header.findViewById(R.id.godown_multireddits)).start();
header.findViewById(R.id.godown_multireddits).setContentDescription(getResources().getString(R.string.btn_collapse));
} else {
collapse(multireddits_area);
flipAnimator(true, header.findViewById(R.id.multireddits_flip)).start();
header.findViewById(R.id.multireddits_flip).setContentDescription(getResources().getString(R.string.btn_expand));
flipAnimator(true, header.findViewById(R.id.godown_multireddits)).start();
header.findViewById(R.id.godown_multireddits).setContentDescription(getResources().getString(R.string.btn_expand));
}

}
Expand Down Expand Up @@ -4848,35 +4847,17 @@ protected Subreddit doInBackground(String... params) {
public class SyncMultiReddits extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
try {
UserSubscriptions.syncMultiReddits(MainActivity.this);
} catch (final Exception e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
new AlertDialogWrapper.Builder(MainActivity.this)
.setTitle(R.string.err_title)
.setMessage(e instanceof ApiException ? getString(R.string.misc_err) + ": " + ((ApiException) e).getExplanation() + "\n" + getString(R.string.misc_retry) : getString(R.string.misc_err))
.setNeutralButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
}).create().show();
}
});
e.printStackTrace();
}
UserSubscriptions.syncMultiReddits(MainActivity.this);
return null;
}

@Override
protected void onPostExecute(Void aVoid) {
LinearLayout multireddits_area = headerMain.findViewById(R.id.multireddits_area);
LinearLayout multiredditsArea = headerMain.findViewById(R.id.expand_multireddits);

for (MultiReddit multiReddit : UserSubscriptions.multireddits) {
final View t =
getLayoutInflater().inflate(R.layout.multireddit_textview_white, multireddits_area,
getLayoutInflater().inflate(R.layout.multireddit_textview_white, multiredditsArea,
false);
((TextView) t.findViewById(R.id.name)).setText(multiReddit.getDisplayName());

Expand All @@ -4887,7 +4868,7 @@ protected void onPostExecute(Void aVoid) {
startActivity(intent);
});

multireddits_area.addView(t);
multiredditsArea.addView(t);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/drawer_loggedin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,13 @@
</RelativeLayout>

<RelativeLayout
android:id="@+id/multireddits"
android:id="@+id/multi"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal"
android:paddingStart="0dp">
<LinearLayout
android:id="@+id/multi"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
Expand Down Expand Up @@ -443,7 +442,7 @@

</LinearLayout>
<ImageView
android:id="@+id/multireddits_flip"
android:id="@+id/godown_multireddits"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
Expand All @@ -460,11 +459,12 @@
app:srcCompat="@drawable/down" />
</RelativeLayout>
<LinearLayout
android:id="@+id/multireddits_area"
android:id="@+id/expand_multireddits"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activity_background"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone">
</LinearLayout>
<LinearLayout
android:id="@+id/support"
Expand Down
14 changes: 5 additions & 9 deletions app/src/main/res/layout/multireddit_textview_white.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingStart="18dp"
android:paddingEnd="18dp"
android:layout_height="48dp">
android:paddingEnd="18dp">

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:textColor="#fff"
android:gravity="center_vertical"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:text="multireddit"
android:textSize="14sp"
/>



android:textColor="#fff"
android:textSize="14sp" />
</RelativeLayout>

0 comments on commit b99f08a

Please sign in to comment.