Fix an issue with TL in a list

This commit is contained in:
Thomas 2022-09-13 11:35:03 +02:00
parent 0b76f3a219
commit 4e480812bf
3 changed files with 34 additions and 8 deletions

View File

@ -124,6 +124,7 @@ import app.fedilab.android.client.entities.app.DomainsBlock;
import app.fedilab.android.client.entities.app.Pinned;
import app.fedilab.android.client.entities.app.PinnedTimeline;
import app.fedilab.android.client.entities.app.StatusDraft;
import app.fedilab.android.client.entities.app.Timeline;
import app.fedilab.android.databinding.ActivityMainBinding;
import app.fedilab.android.databinding.NavHeaderMainBinding;
import app.fedilab.android.exception.DBException;
@ -308,11 +309,26 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_NOTIFICATION) {
final Handler handler = new Handler();
handler.postDelayed(() -> {
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this);
boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false);
if (!singleBar) {
int position = BottomMenu.getPosition(bottomMenu, R.id.nav_notifications);
if (position > 0) {
binding.bottomNavView.getMenu().getItem(position).setChecked(true);
binding.viewPager.setCurrentItem(position);
}
} else {
int position = 0;
for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) {
if (pinnedTimeline.type == Timeline.TimeLineEnum.NOTIFICATION) {
binding.bottomNavView.getMenu().getItem(position).setChecked(true);
binding.viewPager.setCurrentItem(position);
break;
}
position++;
}
}
}, 1000);
intent.removeExtra(Helper.INTENT_ACTION);

View File

@ -35,7 +35,7 @@ public class Status implements Serializable, Cloneable {
@SerializedName("id")
public String id;
@SerializedName("created_at")
public Date created_at;
public Date created_at = new Date();
@SerializedName("in_reply_to_id")
public String in_reply_to_id;
@SerializedName("in_reply_to_account_id")

View File

@ -51,7 +51,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
import app.fedilab.android.BaseMainActivity;
@ -332,6 +331,7 @@ public class PinnedTimelineHelper {
Pinned finalPinned = pinned;
int finalToRemove1 = toRemove;
activityMainBinding.moreTimelines.setOnClickListener(v -> {
PopupMenu popup = new PopupMenu(new ContextThemeWrapper(activity, Helper.popupStyle()), v);
try {
@ -343,6 +343,7 @@ public class PinnedTimelineHelper {
e.printStackTrace();
}
int i = 0;
int j = 0;
for (PinnedTimeline pinnedTimeline : finalPinned.pinnedTimelines) {
MenuItem item = null;
switch (pinnedTimeline.type) {
@ -380,13 +381,22 @@ public class PinnedTimelineHelper {
break;
}
if (item != null) {
int finalI = i;
int finalI;
if (singleBar) {
finalI = i;
} else {
finalI = BOTTOM_TIMELINE_COUNT - finalToRemove1 + j;
}
item.setOnMenuItemClickListener(item1 -> {
if (finalI < activityMainBinding.tabLayout.getTabCount() && activityMainBinding.tabLayout.getTabAt(finalI) != null) {
Objects.requireNonNull(activityMainBinding.tabLayout.getTabAt(finalI)).select();
TabLayout.Tab tab = activityMainBinding.tabLayout.getTabAt(finalI);
if (tab != null) {
tab.select();
}
}
return false;
});
j++;
}
i++;
}