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

Commit b99f08a

Browse files
committed
Multireddit dropdown code review changes
1 parent c8c2ce1 commit b99f08a

File tree

3 files changed

+21
-44
lines changed

3 files changed

+21
-44
lines changed

app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ public void doDrawer() {
14831483
if (Authentication.isLoggedIn && Authentication.didOnline) {
14841484

14851485
header = inflater.inflate(R.layout.drawer_loggedin, drawerSubList, false);
1486-
LinearLayout multiReddits = header.findViewById(R.id.multi);
1486+
RelativeLayout multiReddits = header.findViewById(R.id.multi);
14871487
headerMain = header;
14881488
hea = header.findViewById(R.id.back);
14891489

@@ -1523,20 +1523,19 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which)
15231523
return true;
15241524
}
15251525
});
1526-
LinearLayout multireddits_area = header.findViewById(R.id.multireddits_area);
1526+
LinearLayout multireddits_area = header.findViewById(R.id.expand_multireddits);
15271527

1528-
multireddits_area.setVisibility(View.GONE);
1529-
findViewById(R.id.multireddits_flip).setOnClickListener(new View.OnClickListener() {
1528+
findViewById(R.id.godown_multireddits).setOnClickListener(new View.OnClickListener() {
15301529
@Override
15311530
public void onClick(View v) {
15321531
if (multireddits_area.getVisibility() == View.GONE) {
15331532
expand(multireddits_area);
1534-
flipAnimator(false, header.findViewById(R.id.multireddits_flip)).start();
1535-
header.findViewById(R.id.multireddits_flip).setContentDescription(getResources().getString(R.string.btn_collapse));
1533+
flipAnimator(false, header.findViewById(R.id.godown_multireddits)).start();
1534+
header.findViewById(R.id.godown_multireddits).setContentDescription(getResources().getString(R.string.btn_collapse));
15361535
} else {
15371536
collapse(multireddits_area);
1538-
flipAnimator(true, header.findViewById(R.id.multireddits_flip)).start();
1539-
header.findViewById(R.id.multireddits_flip).setContentDescription(getResources().getString(R.string.btn_expand));
1537+
flipAnimator(true, header.findViewById(R.id.godown_multireddits)).start();
1538+
header.findViewById(R.id.godown_multireddits).setContentDescription(getResources().getString(R.string.btn_expand));
15401539
}
15411540

15421541
}
@@ -4848,35 +4847,17 @@ protected Subreddit doInBackground(String... params) {
48484847
public class SyncMultiReddits extends AsyncTask<Void, Void, Void> {
48494848
@Override
48504849
protected Void doInBackground(Void... params) {
4851-
try {
4852-
UserSubscriptions.syncMultiReddits(MainActivity.this);
4853-
} catch (final Exception e) {
4854-
runOnUiThread(new Runnable() {
4855-
@Override
4856-
public void run() {
4857-
new AlertDialogWrapper.Builder(MainActivity.this)
4858-
.setTitle(R.string.err_title)
4859-
.setMessage(e instanceof ApiException ? getString(R.string.misc_err) + ": " + ((ApiException) e).getExplanation() + "\n" + getString(R.string.misc_retry) : getString(R.string.misc_err))
4860-
.setNeutralButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
4861-
@Override
4862-
public void onClick(DialogInterface dialogInterface, int i) {
4863-
finish();
4864-
}
4865-
}).create().show();
4866-
}
4867-
});
4868-
e.printStackTrace();
4869-
}
4850+
UserSubscriptions.syncMultiReddits(MainActivity.this);
48704851
return null;
48714852
}
48724853

48734854
@Override
48744855
protected void onPostExecute(Void aVoid) {
4875-
LinearLayout multireddits_area = headerMain.findViewById(R.id.multireddits_area);
4856+
LinearLayout multiredditsArea = headerMain.findViewById(R.id.expand_multireddits);
48764857

48774858
for (MultiReddit multiReddit : UserSubscriptions.multireddits) {
48784859
final View t =
4879-
getLayoutInflater().inflate(R.layout.multireddit_textview_white, multireddits_area,
4860+
getLayoutInflater().inflate(R.layout.multireddit_textview_white, multiredditsArea,
48804861
false);
48814862
((TextView) t.findViewById(R.id.name)).setText(multiReddit.getDisplayName());
48824863

@@ -4887,7 +4868,7 @@ protected void onPostExecute(Void aVoid) {
48874868
startActivity(intent);
48884869
});
48894870

4890-
multireddits_area.addView(t);
4871+
multiredditsArea.addView(t);
48914872
}
48924873
}
48934874
}

app/src/main/res/layout/drawer_loggedin.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,13 @@
408408
</RelativeLayout>
409409

410410
<RelativeLayout
411-
android:id="@+id/multireddits"
411+
android:id="@+id/multi"
412412
android:layout_width="match_parent"
413413
android:layout_height="48dp"
414414
android:background="?android:selectableItemBackground"
415415
android:orientation="horizontal"
416416
android:paddingStart="0dp">
417417
<LinearLayout
418-
android:id="@+id/multi"
419418
android:layout_width="match_parent"
420419
android:layout_height="48dp"
421420
android:background="?android:selectableItemBackground"
@@ -443,7 +442,7 @@
443442

444443
</LinearLayout>
445444
<ImageView
446-
android:id="@+id/multireddits_flip"
445+
android:id="@+id/godown_multireddits"
447446
android:layout_width="48dp"
448447
android:layout_height="48dp"
449448
android:layout_alignParentEnd="true"
@@ -460,11 +459,12 @@
460459
app:srcCompat="@drawable/down" />
461460
</RelativeLayout>
462461
<LinearLayout
463-
android:id="@+id/multireddits_area"
462+
android:id="@+id/expand_multireddits"
464463
android:layout_width="match_parent"
465464
android:layout_height="wrap_content"
466465
android:background="?attr/activity_background"
467-
android:orientation="vertical">
466+
android:orientation="vertical"
467+
android:visibility="gone">
468468
</LinearLayout>
469469
<LinearLayout
470470
android:id="@+id/support"

app/src/main/res/layout/multireddit_textview_white.xml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,17 @@
22
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
android:layout_width="match_parent"
5+
android:layout_height="48dp"
56
android:paddingStart="18dp"
6-
android:paddingEnd="18dp"
7-
android:layout_height="48dp">
7+
android:paddingEnd="18dp">
88

99
<TextView
1010
android:id="@+id/name"
1111
android:layout_width="wrap_content"
1212
android:layout_height="48dp"
13-
android:textColor="#fff"
14-
android:gravity="center_vertical"
1513
android:layout_alignParentBottom="true"
14+
android:gravity="center_vertical"
1615
android:text="multireddit"
17-
android:textSize="14sp"
18-
/>
19-
20-
21-
16+
android:textColor="#fff"
17+
android:textSize="14sp" />
2218
</RelativeLayout>

0 commit comments

Comments
 (0)