Fix an issue with TL in a list
This commit is contained in:
parent
0b76f3a219
commit
4e480812bf
|
@ -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.Pinned;
|
||||||
import app.fedilab.android.client.entities.app.PinnedTimeline;
|
import app.fedilab.android.client.entities.app.PinnedTimeline;
|
||||||
import app.fedilab.android.client.entities.app.StatusDraft;
|
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.ActivityMainBinding;
|
||||||
import app.fedilab.android.databinding.NavHeaderMainBinding;
|
import app.fedilab.android.databinding.NavHeaderMainBinding;
|
||||||
import app.fedilab.android.exception.DBException;
|
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) {
|
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_NOTIFICATION) {
|
||||||
final Handler handler = new Handler();
|
final Handler handler = new Handler();
|
||||||
handler.postDelayed(() -> {
|
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);
|
int position = BottomMenu.getPosition(bottomMenu, R.id.nav_notifications);
|
||||||
if (position > 0) {
|
if (position > 0) {
|
||||||
binding.bottomNavView.getMenu().getItem(position).setChecked(true);
|
binding.bottomNavView.getMenu().getItem(position).setChecked(true);
|
||||||
binding.viewPager.setCurrentItem(position);
|
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);
|
}, 1000);
|
||||||
intent.removeExtra(Helper.INTENT_ACTION);
|
intent.removeExtra(Helper.INTENT_ACTION);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class Status implements Serializable, Cloneable {
|
||||||
@SerializedName("id")
|
@SerializedName("id")
|
||||||
public String id;
|
public String id;
|
||||||
@SerializedName("created_at")
|
@SerializedName("created_at")
|
||||||
public Date created_at;
|
public Date created_at = new Date();
|
||||||
@SerializedName("in_reply_to_id")
|
@SerializedName("in_reply_to_id")
|
||||||
public String in_reply_to_id;
|
public String in_reply_to_id;
|
||||||
@SerializedName("in_reply_to_account_id")
|
@SerializedName("in_reply_to_account_id")
|
||||||
|
|
|
@ -51,7 +51,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import app.fedilab.android.BaseMainActivity;
|
import app.fedilab.android.BaseMainActivity;
|
||||||
|
@ -332,6 +331,7 @@ public class PinnedTimelineHelper {
|
||||||
|
|
||||||
|
|
||||||
Pinned finalPinned = pinned;
|
Pinned finalPinned = pinned;
|
||||||
|
int finalToRemove1 = toRemove;
|
||||||
activityMainBinding.moreTimelines.setOnClickListener(v -> {
|
activityMainBinding.moreTimelines.setOnClickListener(v -> {
|
||||||
PopupMenu popup = new PopupMenu(new ContextThemeWrapper(activity, Helper.popupStyle()), v);
|
PopupMenu popup = new PopupMenu(new ContextThemeWrapper(activity, Helper.popupStyle()), v);
|
||||||
try {
|
try {
|
||||||
|
@ -343,6 +343,7 @@ public class PinnedTimelineHelper {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
for (PinnedTimeline pinnedTimeline : finalPinned.pinnedTimelines) {
|
for (PinnedTimeline pinnedTimeline : finalPinned.pinnedTimelines) {
|
||||||
MenuItem item = null;
|
MenuItem item = null;
|
||||||
switch (pinnedTimeline.type) {
|
switch (pinnedTimeline.type) {
|
||||||
|
@ -380,13 +381,22 @@ public class PinnedTimelineHelper {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
int finalI = i;
|
int finalI;
|
||||||
|
if (singleBar) {
|
||||||
|
finalI = i;
|
||||||
|
} else {
|
||||||
|
finalI = BOTTOM_TIMELINE_COUNT - finalToRemove1 + j;
|
||||||
|
}
|
||||||
item.setOnMenuItemClickListener(item1 -> {
|
item.setOnMenuItemClickListener(item1 -> {
|
||||||
if (finalI < activityMainBinding.tabLayout.getTabCount() && activityMainBinding.tabLayout.getTabAt(finalI) != null) {
|
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;
|
return false;
|
||||||
});
|
});
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue