diff --git a/app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java b/app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java index 34c6951977..e55028b456 100644 --- a/app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java +++ b/app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java @@ -967,6 +967,7 @@ public void run() { if (Authentication.isLoggedIn) { new AsyncNotificationBadge().executeOnExecutor( AsyncTask.THREAD_POOL_EXECUTOR); + new SyncMultiReddits().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } if (!Reddit.appRestart.getString(CheckForMail.SUBS_TO_GET, "").isEmpty()) { new CheckForMail.AsyncGetSubs(MainActivity.this).executeOnExecutor( @@ -1482,21 +1483,14 @@ public void doDrawer() { if (Authentication.isLoggedIn && Authentication.didOnline) { header = inflater.inflate(R.layout.drawer_loggedin, drawerSubList, false); + RelativeLayout multiReddits = header.findViewById(R.id.multi); headerMain = header; hea = header.findViewById(R.id.back); drawerSubList.addHeaderView(header, null, false); ((TextView) header.findViewById(R.id.name)).setText(Authentication.name); - header.findViewById(R.id.multi).setOnClickListener(new OnSingleClickListener() { - @Override - public void onSingleClick(View view) { - if (runAfterLoad == null) { - Intent inte = new Intent(MainActivity.this, MultiredditOverview.class); - MainActivity.this.startActivity(inte); - } - } - }); - header.findViewById(R.id.multi).setOnLongClickListener(new View.OnLongClickListener() { + + multiReddits.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { new MaterialDialog.Builder(MainActivity.this).inputRange(3, 20) @@ -1529,6 +1523,23 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) return true; } }); + LinearLayout multireddits_area = header.findViewById(R.id.expand_multireddits); + + 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.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.godown_multireddits)).start(); + header.findViewById(R.id.godown_multireddits).setContentDescription(getResources().getString(R.string.btn_expand)); + } + + } + }); header.findViewById(R.id.discover).setOnClickListener(new OnSingleClickListener() { @Override @@ -1820,6 +1831,7 @@ public void onSingleClick(View view) { } else if (Authentication.didOnline) { header = inflater.inflate(R.layout.drawer_loggedout, drawerSubList, false); + LinearLayout multiReddits = header.findViewById(R.id.multi); drawerSubList.addHeaderView(header, null, false); headerMain = header; hea = header.findViewById(R.id.back); @@ -1973,7 +1985,7 @@ public void onSingleClick(View view) { }); headerMain = header; - header.findViewById(R.id.multi).setOnClickListener(new View.OnClickListener() { + multiReddits.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new MaterialDialog.Builder(MainActivity.this).inputRange(3, 20) @@ -4832,6 +4844,35 @@ protected Subreddit doInBackground(String... params) { } } + public class SyncMultiReddits extends AsyncTask { + @Override + protected Void doInBackground(Void... params) { + UserSubscriptions.syncMultiReddits(MainActivity.this); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + LinearLayout multiredditsArea = headerMain.findViewById(R.id.expand_multireddits); + + for (MultiReddit multiReddit : UserSubscriptions.multireddits) { + final View t = + getLayoutInflater().inflate(R.layout.multireddit_textview_white, multiredditsArea, + false); + ((TextView) t.findViewById(R.id.name)).setText(multiReddit.getDisplayName()); + + t.setOnClickListener(v -> { + Intent intent = new Intent(MainActivity.this, MultiredditOverview.class); + + intent.putExtra(MultiredditOverview.EXTRA_MULTI, multiReddit.getFullName()); + startActivity(intent); + }); + + multiredditsArea.addView(t); + } + } + } + public class AsyncNotificationBadge extends AsyncTask { int count; diff --git a/app/src/main/res/layout/drawer_loggedin.xml b/app/src/main/res/layout/drawer_loggedin.xml index 32b3592568..f591d6e9fa 100644 --- a/app/src/main/res/layout/drawer_loggedin.xml +++ b/app/src/main/res/layout/drawer_loggedin.xml @@ -407,15 +407,21 @@ - + - - - + + + + + + + + + + + \ No newline at end of file