Merge branch 'improves_stream_tl' into develop
This commit is contained in:
commit
28f1cf0958
|
@ -178,11 +178,11 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
Helper.canPin = false;
|
Helper.canPin = false;
|
||||||
Helper.fillMapEmoji(getApplicationContext());
|
Helper.fillMapEmoji(getApplicationContext());
|
||||||
//Here, the user is authenticated
|
//Here, the user is authenticated
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
|
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||||
toolbar_search = (SearchView) toolbar.findViewById(R.id.toolbar_search);
|
toolbar_search = toolbar.findViewById(R.id.toolbar_search);
|
||||||
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
|
tabLayout = findViewById(R.id.tabLayout);
|
||||||
TabLayout.Tab tabHome = tabLayout.newTab();
|
TabLayout.Tab tabHome = tabLayout.newTab();
|
||||||
TabLayout.Tab tabNotif = tabLayout.newTab();
|
TabLayout.Tab tabNotif = tabLayout.newTab();
|
||||||
TabLayout.Tab tabLocal = tabLayout.newTab();
|
TabLayout.Tab tabLocal = tabLayout.newTab();
|
||||||
|
@ -193,23 +193,23 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
tabPublic.setCustomView(R.layout.tab_badge);
|
tabPublic.setCustomView(R.layout.tab_badge);
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||||
ImageView iconHome = (ImageView) tabHome.getCustomView().findViewById(R.id.tab_icon);
|
ImageView iconHome = tabHome.getCustomView().findViewById(R.id.tab_icon);
|
||||||
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
iconHome.setImageResource(R.drawable.ic_action_home_tl);
|
iconHome.setImageResource(R.drawable.ic_action_home_tl);
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||||
ImageView iconNotif = (ImageView) tabNotif.getCustomView().findViewById(R.id.tab_icon);
|
ImageView iconNotif = tabNotif.getCustomView().findViewById(R.id.tab_icon);
|
||||||
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
iconNotif.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
iconNotif.setImageResource(R.drawable.ic_notifications_tl);
|
iconNotif.setImageResource(R.drawable.ic_notifications_tl);
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||||
ImageView iconLocal = (ImageView) tabLocal.getCustomView().findViewById(R.id.tab_icon);
|
ImageView iconLocal = tabLocal.getCustomView().findViewById(R.id.tab_icon);
|
||||||
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
iconLocal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
iconLocal.setImageResource(R.drawable.ic_action_users_tl);
|
iconLocal.setImageResource(R.drawable.ic_action_users_tl);
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
@SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId")
|
||||||
ImageView iconGlobal = (ImageView) tabPublic.getCustomView().findViewById(R.id.tab_icon);
|
ImageView iconGlobal = tabPublic.getCustomView().findViewById(R.id.tab_icon);
|
||||||
iconGlobal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
iconGlobal.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN);
|
||||||
iconGlobal.setImageResource(R.drawable.ic_action_globe_tl);
|
iconGlobal.setImageResource(R.drawable.ic_action_globe_tl);
|
||||||
|
|
||||||
|
@ -375,14 +375,14 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
viewPager = (ViewPager) findViewById(R.id.viewpager);
|
viewPager = findViewById(R.id.viewpager);
|
||||||
int countPage = 2;
|
int countPage = 2;
|
||||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true))
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true))
|
||||||
countPage++;
|
countPage++;
|
||||||
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true))
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true))
|
||||||
countPage++;
|
countPage++;
|
||||||
viewPager.setOffscreenPageLimit(countPage);
|
viewPager.setOffscreenPageLimit(countPage);
|
||||||
main_app_container = (RelativeLayout) findViewById(R.id.main_app_container);
|
main_app_container = findViewById(R.id.main_app_container);
|
||||||
PagerAdapter adapter = new PagerAdapter
|
PagerAdapter adapter = new PagerAdapter
|
||||||
(getSupportFragmentManager(), tabLayout.getTabCount());
|
(getSupportFragmentManager(), tabLayout.getTabCount());
|
||||||
viewPager.setAdapter(adapter);
|
viewPager.setAdapter(adapter);
|
||||||
|
@ -406,7 +406,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
toot.setVisibility(View.VISIBLE);
|
toot.setVisibility(View.VISIBLE);
|
||||||
else
|
else
|
||||||
toot.setVisibility(View.GONE);
|
toot.setVisibility(View.GONE);
|
||||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
viewPager.setVisibility(View.VISIBLE);
|
viewPager.setVisibility(View.VISIBLE);
|
||||||
Helper.switchLayout(BaseMainActivity.this);
|
Helper.switchLayout(BaseMainActivity.this);
|
||||||
main_app_container.setVisibility(View.GONE);
|
main_app_container.setVisibility(View.GONE);
|
||||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
}
|
}
|
||||||
if( tab.getPosition() != 1 )
|
if( tab.getPosition() != 1 )
|
||||||
|
@ -454,7 +454,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
||||||
navigationView.setNavigationItemSelectedListener(this);
|
navigationView.setNavigationItemSelectedListener(this);
|
||||||
|
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
//Defines the current locale of the device in a static variable
|
//Defines the current locale of the device in a static variable
|
||||||
currentLocale = Helper.currentLocale(getApplicationContext());
|
currentLocale = Helper.currentLocale(getApplicationContext());
|
||||||
|
|
||||||
toot = (FloatingActionButton) findViewById(R.id.toot);
|
toot = findViewById(R.id.toot);
|
||||||
toot.setOnClickListener(new View.OnClickListener() {
|
toot.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -606,12 +606,12 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
options = new DisplayImageOptions.Builder().displayer(new RoundedBitmapDisplayer(20)).cacheInMemory(false)
|
options = new DisplayImageOptions.Builder().displayer(new RoundedBitmapDisplayer(20)).cacheInMemory(false)
|
||||||
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
.cacheOnDisk(true).resetViewBeforeLoading(true).build();
|
||||||
|
|
||||||
final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
final DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
|
|
||||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||||
toggle.setDrawerIndicatorEnabled(false);
|
toggle.setDrawerIndicatorEnabled(false);
|
||||||
ImageView iconbar = (ImageView) toolbar.findViewById(R.id.iconbar);
|
ImageView iconbar = toolbar.findViewById(R.id.iconbar);
|
||||||
iconbar.setOnClickListener(new View.OnClickListener() {
|
iconbar.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -621,7 +621,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
Helper.loadPictureIcon(BaseMainActivity.this, account.getAvatar(),iconbar);
|
Helper.loadPictureIcon(BaseMainActivity.this, account.getAvatar(),iconbar);
|
||||||
headerLayout = navigationView.getHeaderView(0);
|
headerLayout = navigationView.getHeaderView(0);
|
||||||
mamageNewIntent(getIntent());
|
mamageNewIntent(getIntent());
|
||||||
final ImageView menuMore = (ImageView) headerLayout.findViewById(R.id.header_option_menu);
|
final ImageView menuMore = headerLayout.findViewById(R.id.header_option_menu);
|
||||||
menuMore.setOnClickListener(new View.OnClickListener() {
|
menuMore.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -695,10 +695,10 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
@SuppressLint("InflateParams") View popup_quick_settings = getLayoutInflater().inflate( R.layout.popup_text_size, null );
|
@SuppressLint("InflateParams") View popup_quick_settings = getLayoutInflater().inflate( R.layout.popup_text_size, null );
|
||||||
builder.setView(popup_quick_settings);
|
builder.setView(popup_quick_settings);
|
||||||
|
|
||||||
SeekBar set_text_size = (SeekBar) popup_quick_settings.findViewById(R.id.set_text_size);
|
SeekBar set_text_size = popup_quick_settings.findViewById(R.id.set_text_size);
|
||||||
SeekBar set_icon_size = (SeekBar) popup_quick_settings.findViewById(R.id.set_icon_size);
|
SeekBar set_icon_size = popup_quick_settings.findViewById(R.id.set_icon_size);
|
||||||
final TextView set_text_size_value = (TextView) popup_quick_settings.findViewById(R.id.set_text_size_value);
|
final TextView set_text_size_value = popup_quick_settings.findViewById(R.id.set_text_size_value);
|
||||||
final TextView set_icon_size_value = (TextView) popup_quick_settings.findViewById(R.id.set_icon_size_value);
|
final TextView set_icon_size_value = popup_quick_settings.findViewById(R.id.set_icon_size_value);
|
||||||
set_text_size_value.setText(String.format("%s%%",String.valueOf(textSize)));
|
set_text_size_value.setText(String.format("%s%%",String.valueOf(textSize)));
|
||||||
set_icon_size_value.setText(String.format("%s%%",String.valueOf(iconSize)));
|
set_icon_size_value.setText(String.format("%s%%",String.valueOf(iconSize)));
|
||||||
|
|
||||||
|
@ -764,7 +764,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
|
navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearLayout owner_container = (LinearLayout) headerLayout.findViewById(R.id.main_header_container);
|
LinearLayout owner_container = headerLayout.findViewById(R.id.main_header_container);
|
||||||
owner_container.setOnClickListener(new View.OnClickListener() {
|
owner_container.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -792,8 +792,8 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
@SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.popup_quick_settings, null);
|
@SuppressLint("InflateParams") View dialogView = inflater.inflate(R.layout.popup_quick_settings, null);
|
||||||
dialogBuilder.setView(dialogView);
|
dialogBuilder.setView(dialogView);
|
||||||
|
|
||||||
final SwitchCompat set_push_hometimeline = (SwitchCompat) dialogView.findViewById(R.id.set_push_hometimeline);
|
final SwitchCompat set_push_hometimeline = dialogView.findViewById(R.id.set_push_hometimeline);
|
||||||
final SwitchCompat set_push_notification = (SwitchCompat) dialogView.findViewById(R.id.set_push_notification);
|
final SwitchCompat set_push_notification = dialogView.findViewById(R.id.set_push_notification);
|
||||||
boolean notif_hometimeline = sharedpreferences.getBoolean(Helper.SET_NOTIF_HOMETIMELINE, true);
|
boolean notif_hometimeline = sharedpreferences.getBoolean(Helper.SET_NOTIF_HOMETIMELINE, true);
|
||||||
boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
|
boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
|
||||||
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
||||||
|
@ -851,7 +851,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
String userIdIntent;
|
String userIdIntent;
|
||||||
boolean matchingIntent = false;
|
boolean matchingIntent = false;
|
||||||
if( extras.containsKey(INTENT_ACTION) ){
|
if( extras.containsKey(INTENT_ACTION) ){
|
||||||
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
||||||
userIdIntent = extras.getString(PREF_KEY_ID); //Id of the account in the intent
|
userIdIntent = extras.getString(PREF_KEY_ID); //Id of the account in the intent
|
||||||
if (extras.getInt(INTENT_ACTION) == NOTIFICATION_INTENT){
|
if (extras.getInt(INTENT_ACTION) == NOTIFICATION_INTENT){
|
||||||
changeUser(BaseMainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
|
changeUser(BaseMainActivity.this, userIdIntent, false); //Connects the account which is related to the notification
|
||||||
|
@ -946,7 +946,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
} else {
|
} else {
|
||||||
|
@ -968,7 +968,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
viewPager.setVisibility(View.VISIBLE);
|
viewPager.setVisibility(View.VISIBLE);
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
tabLayout.setVisibility(View.VISIBLE);
|
||||||
toolbarTitle.setVisibility(View.GONE);
|
toolbarTitle.setVisibility(View.GONE);
|
||||||
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
||||||
unCheckAllMenuItems(navigationView);
|
unCheckAllMenuItems(navigationView);
|
||||||
toot.setVisibility(View.VISIBLE);
|
toot.setVisibility(View.VISIBLE);
|
||||||
//Manages theme for icon colors
|
//Manages theme for icon colors
|
||||||
|
@ -1079,8 +1079,10 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
homeFragment.refresh(status);
|
homeFragment.refresh(status);
|
||||||
}
|
}
|
||||||
} else if (eventStreaming == StreamingService.EventStreaming.DELETE) {
|
} else if (eventStreaming == StreamingService.EventStreaming.DELETE) {
|
||||||
|
//noinspection unused
|
||||||
String id = b.getString("id");
|
String id = b.getString("id");
|
||||||
if (notificationsFragment != null) {
|
if (notificationsFragment != null) {
|
||||||
|
//noinspection StatementWithEmptyBody
|
||||||
if (notificationsFragment.getUserVisibleHint()) {
|
if (notificationsFragment.getUserVisibleHint()) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1140,7 +1142,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
startActivity(remoteFollow);
|
startActivity(remoteFollow);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
final NavigationView navigationView = findViewById(R.id.nav_view);
|
||||||
unCheckAllMenuItems(navigationView);
|
unCheckAllMenuItems(navigationView);
|
||||||
item.setChecked(true);
|
item.setChecked(true);
|
||||||
//Remove the search bar
|
//Remove the search bar
|
||||||
|
@ -1210,7 +1212,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
populateTitleWithTag(fragmentTag, item.getTitle().toString(), item.getItemId());
|
populateTitleWithTag(fragmentTag, item.getTitle().toString(), item.getItemId());
|
||||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1252,6 +1254,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
protected void onActivityResult(int requestCode, int resultCode,
|
protected void onActivityResult(int requestCode, int resultCode,
|
||||||
Intent data) {
|
Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
//noinspection StatementWithEmptyBody
|
||||||
if (requestCode == ERROR_DIALOG_REQUEST_CODE) {
|
if (requestCode == ERROR_DIALOG_REQUEST_CODE) {
|
||||||
// Adding a fragment via GooglePlayServicesUtil.showErrorDialogFragment
|
// Adding a fragment via GooglePlayServicesUtil.showErrorDialogFragment
|
||||||
// before the instance state is restored throws an error. So instead,
|
// before the instance state is restored throws an error. So instead,
|
||||||
|
@ -1320,7 +1323,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.LOCAL);
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.LOCAL);
|
||||||
statusFragment.setArguments(bundle);
|
statusFragment.setArguments(bundle);
|
||||||
return statusFragment;
|
return statusFragment;
|
||||||
}else if( position == 2 && !display_local){
|
}else if(position == 2){
|
||||||
statusFragment = new DisplayStatusFragment();
|
statusFragment = new DisplayStatusFragment();
|
||||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PUBLIC);
|
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.PUBLIC);
|
||||||
statusFragment.setArguments(bundle);
|
statusFragment.setArguments(bundle);
|
||||||
|
@ -1372,7 +1375,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
View tabHome = tabLayout.getTabAt(0).getCustomView();
|
View tabHome = tabLayout.getTabAt(0).getCustomView();
|
||||||
if( tabHome == null)
|
if( tabHome == null)
|
||||||
return;
|
return;
|
||||||
TextView tabCounterHome = (TextView) tabHome.findViewById(R.id.tab_counter);
|
TextView tabCounterHome = tabHome.findViewById(R.id.tab_counter);
|
||||||
tabCounterHome.setText(String.valueOf(countNewStatus));
|
tabCounterHome.setText(String.valueOf(countNewStatus));
|
||||||
if( countNewStatus> 0){
|
if( countNewStatus> 0){
|
||||||
//New data are available
|
//New data are available
|
||||||
|
@ -1390,7 +1393,7 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
View tabNotif = tabLayout.getTabAt(1).getCustomView();
|
View tabNotif = tabLayout.getTabAt(1).getCustomView();
|
||||||
if( tabNotif == null)
|
if( tabNotif == null)
|
||||||
return;
|
return;
|
||||||
TextView tabCounterNotif = (TextView) tabNotif.findViewById(R.id.tab_counter);
|
TextView tabCounterNotif = tabNotif.findViewById(R.id.tab_counter);
|
||||||
tabCounterNotif.setText(String.valueOf(countNewNotifications));
|
tabCounterNotif.setText(String.valueOf(countNewNotifications));
|
||||||
if( countNewNotifications > 0){
|
if( countNewNotifications > 0){
|
||||||
tabCounterNotif.setVisibility(View.VISIBLE);
|
tabCounterNotif.setVisibility(View.VISIBLE);
|
||||||
|
@ -1399,17 +1402,10 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isActivityVisible() {
|
|
||||||
return activityVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void activityResumed() {
|
private static void activityResumed() {
|
||||||
activityVisible = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void activityPaused() {
|
private static void activityPaused() {
|
||||||
activityVisible = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean activityVisible;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
private TabLayout tabLayout;
|
private TabLayout tabLayout;
|
||||||
private TextView account_note, account_follow_request;
|
private TextView account_note, account_follow_request;
|
||||||
private String userId;
|
private String userId;
|
||||||
private static int instanceValue = 0;
|
|
||||||
private Relationship relationship;
|
private Relationship relationship;
|
||||||
private boolean showMediaOnly, showPinned;
|
private boolean showMediaOnly, showPinned;
|
||||||
private ImageView pp_actionBar;
|
private ImageView pp_actionBar;
|
||||||
|
@ -148,7 +147,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
}
|
}
|
||||||
setContentView(R.layout.activity_show_account);
|
setContentView(R.layout.activity_show_account);
|
||||||
setTitle("");
|
setTitle("");
|
||||||
instanceValue += 1;
|
|
||||||
pins = new ArrayList<>();
|
pins = new ArrayList<>();
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle b = getIntent().getExtras();
|
||||||
account_follow = findViewById(R.id.account_follow);
|
account_follow = findViewById(R.id.account_follow);
|
||||||
|
@ -673,7 +671,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
bundle.putBoolean("hideHeader",true);
|
bundle.putBoolean("hideHeader",true);
|
||||||
bundle.putBoolean("showMediaOnly",showMediaOnly);
|
bundle.putBoolean("showMediaOnly",showMediaOnly);
|
||||||
bundle.putBoolean("showPinned",showPinned);
|
bundle.putBoolean("showPinned",showPinned);
|
||||||
bundle.putString("hideHeaderValue",String.valueOf(instanceValue));
|
|
||||||
displayStatusFragment.setArguments(bundle);
|
displayStatusFragment.setArguments(bundle);
|
||||||
return displayStatusFragment;
|
return displayStatusFragment;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -681,7 +678,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWING);
|
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWING);
|
||||||
bundle.putString("targetedId", accountId);
|
bundle.putString("targetedId", accountId);
|
||||||
bundle.putBoolean("hideHeader",true);
|
bundle.putBoolean("hideHeader",true);
|
||||||
bundle.putString("hideHeaderValue",String.valueOf(instanceValue));
|
|
||||||
displayAccountsFragment.setArguments(bundle);
|
displayAccountsFragment.setArguments(bundle);
|
||||||
return displayAccountsFragment;
|
return displayAccountsFragment;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -689,7 +685,6 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
|
||||||
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWERS);
|
bundle.putSerializable("type", RetrieveAccountsAsyncTask.Type.FOLLOWERS);
|
||||||
bundle.putString("targetedId", accountId);
|
bundle.putString("targetedId", accountId);
|
||||||
bundle.putBoolean("hideHeader",true);
|
bundle.putBoolean("hideHeader",true);
|
||||||
bundle.putString("hideHeaderValue",String.valueOf(instanceValue));
|
|
||||||
displayAccountsFragment.setArguments(bundle);
|
displayAccountsFragment.setArguments(bundle);
|
||||||
return displayAccountsFragment;
|
return displayAccountsFragment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,12 @@ package fr.gouv.etalab.mastodon.fragments;
|
||||||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -66,7 +64,6 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
||||||
private String targetedId;
|
private String targetedId;
|
||||||
private boolean swiped;
|
private boolean swiped;
|
||||||
private ListView lv_accounts;
|
private ListView lv_accounts;
|
||||||
private String instanceValue;
|
|
||||||
boolean hideHeader;
|
boolean hideHeader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,7 +80,6 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
||||||
type = (RetrieveAccountsAsyncTask.Type) bundle.get("type");
|
type = (RetrieveAccountsAsyncTask.Type) bundle.get("type");
|
||||||
targetedId = bundle.getString("targetedId", null);
|
targetedId = bundle.getString("targetedId", null);
|
||||||
hideHeader = bundle.getBoolean("hideHeader", false);
|
hideHeader = bundle.getBoolean("hideHeader", false);
|
||||||
instanceValue = bundle.getString("hideHeaderValue", null);
|
|
||||||
if( bundle.containsKey("accounts")){
|
if( bundle.containsKey("accounts")){
|
||||||
ArrayList<Parcelable> accountsReceived = bundle.getParcelableArrayList("accounts");
|
ArrayList<Parcelable> accountsReceived = bundle.getParcelableArrayList("accounts");
|
||||||
assert accountsReceived != null;
|
assert accountsReceived != null;
|
||||||
|
@ -98,13 +94,12 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
||||||
flag_loading = true;
|
flag_loading = true;
|
||||||
swiped = false;
|
swiped = false;
|
||||||
|
|
||||||
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer);
|
swipeRefreshLayout = rootView.findViewById(R.id.swipeContainer);
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
lv_accounts = rootView.findViewById(R.id.lv_accounts);
|
||||||
lv_accounts = (ListView) rootView.findViewById(R.id.lv_accounts);
|
|
||||||
|
|
||||||
mainLoader = (RelativeLayout) rootView.findViewById(R.id.loader);
|
mainLoader = rootView.findViewById(R.id.loader);
|
||||||
nextElementLoader = (RelativeLayout) rootView.findViewById(R.id.loading_next_accounts);
|
nextElementLoader = rootView.findViewById(R.id.loading_next_accounts);
|
||||||
textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
|
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||||
mainLoader.setVisibility(View.VISIBLE);
|
mainLoader.setVisibility(View.VISIBLE);
|
||||||
nextElementLoader.setVisibility(View.GONE);
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
accountsListAdapter = new AccountsListAdapter(context, type, targetedId, this.accounts);
|
accountsListAdapter = new AccountsListAdapter(context, type, targetedId, this.accounts);
|
||||||
|
@ -115,31 +110,11 @@ public class DisplayAccountsFragment extends Fragment implements OnRetrieveAccou
|
||||||
if (hideHeader && Build.VERSION.SDK_INT >= 21)
|
if (hideHeader && Build.VERSION.SDK_INT >= 21)
|
||||||
ViewCompat.setNestedScrollingEnabled(lv_accounts, true);
|
ViewCompat.setNestedScrollingEnabled(lv_accounts, true);
|
||||||
lv_accounts.setOnScrollListener(new AbsListView.OnScrollListener() {
|
lv_accounts.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
int lastFirstVisibleItem = 0;
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||||
|
|
||||||
}
|
}
|
||||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||||
if (hideHeader && Build.VERSION.SDK_INT < 21) {
|
|
||||||
if(firstVisibleItem == 0 && Helper.listIsAtTop(lv_accounts)){
|
|
||||||
Intent intent = new Intent(Helper.HEADER_ACCOUNT+instanceValue);
|
|
||||||
intent.putExtra("hide", false);
|
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
|
||||||
}else if (view.getId() == lv_accounts.getId() && totalItemCount > visibleItemCount) {
|
|
||||||
final int currentFirstVisibleItem = lv_accounts.getFirstVisiblePosition();
|
|
||||||
if (currentFirstVisibleItem > lastFirstVisibleItem) {
|
|
||||||
Intent intent = new Intent(Helper.HEADER_ACCOUNT + instanceValue);
|
|
||||||
intent.putExtra("hide", true);
|
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
|
||||||
} else if (currentFirstVisibleItem < lastFirstVisibleItem) {
|
|
||||||
Intent intent = new Intent(Helper.HEADER_ACCOUNT + instanceValue);
|
|
||||||
intent.putExtra("hide", false);
|
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
|
||||||
}
|
|
||||||
lastFirstVisibleItem = currentFirstVisibleItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||||
if (!flag_loading) {
|
if (!flag_loading) {
|
||||||
flag_loading = true;
|
flag_loading = true;
|
||||||
|
|
|
@ -61,6 +61,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
private StatusListAdapter statusListAdapter;
|
private StatusListAdapter statusListAdapter;
|
||||||
private String max_id;
|
private String max_id;
|
||||||
private List<Status> statuses;
|
private List<Status> statuses;
|
||||||
|
private ArrayList<String> knownId;
|
||||||
private RetrieveFeedsAsyncTask.Type type;
|
private RetrieveFeedsAsyncTask.Type type;
|
||||||
private RelativeLayout mainLoader, nextElementLoader, textviewNoAction;
|
private RelativeLayout mainLoader, nextElementLoader, textviewNoAction;
|
||||||
private boolean firstLoad;
|
private boolean firstLoad;
|
||||||
|
@ -73,8 +74,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
private int behaviorWithAttachments;
|
private int behaviorWithAttachments;
|
||||||
private boolean showMediaOnly, showPinned;
|
private boolean showMediaOnly, showPinned;
|
||||||
private int positionSpinnerTrans;
|
private int positionSpinnerTrans;
|
||||||
private boolean hideHeader;
|
|
||||||
private String instanceValue;
|
|
||||||
private String lastReadStatus;
|
private String lastReadStatus;
|
||||||
private Intent streamingFederatedIntent, streamingLocalIntent;
|
private Intent streamingFederatedIntent, streamingLocalIntent;
|
||||||
|
|
||||||
|
@ -85,17 +84,17 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View rootView = inflater.inflate(R.layout.fragment_status, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_status, container, false);
|
||||||
statuses = new ArrayList<>();
|
statuses = new ArrayList<>();
|
||||||
|
knownId = new ArrayList<>();
|
||||||
context = getContext();
|
context = getContext();
|
||||||
Bundle bundle = this.getArguments();
|
Bundle bundle = this.getArguments();
|
||||||
boolean comesFromSearch = false;
|
boolean comesFromSearch = false;
|
||||||
hideHeader = false;
|
boolean hideHeader = false;
|
||||||
showMediaOnly = false;
|
showMediaOnly = false;
|
||||||
showPinned = false;
|
showPinned = false;
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
type = (RetrieveFeedsAsyncTask.Type) bundle.get("type");
|
type = (RetrieveFeedsAsyncTask.Type) bundle.get("type");
|
||||||
targetedId = bundle.getString("targetedId", null);
|
targetedId = bundle.getString("targetedId", null);
|
||||||
tag = bundle.getString("tag", null);
|
tag = bundle.getString("tag", null);
|
||||||
instanceValue = bundle.getString("hideHeaderValue", null);
|
|
||||||
hideHeader = bundle.getBoolean("hideHeader", false);
|
hideHeader = bundle.getBoolean("hideHeader", false);
|
||||||
showMediaOnly = bundle.getBoolean("showMediaOnly",false);
|
showMediaOnly = bundle.getBoolean("showMediaOnly",false);
|
||||||
showPinned = bundle.getBoolean("showPinned",false);
|
showPinned = bundle.getBoolean("showPinned",false);
|
||||||
|
@ -104,6 +103,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
assert statusesReceived != null;
|
assert statusesReceived != null;
|
||||||
for(Parcelable status: statusesReceived){
|
for(Parcelable status: statusesReceived){
|
||||||
statuses.add((Status) status);
|
statuses.add((Status) status);
|
||||||
|
knownId.add(((Status) status).getId());
|
||||||
}
|
}
|
||||||
comesFromSearch = true;
|
comesFromSearch = true;
|
||||||
}
|
}
|
||||||
|
@ -116,15 +116,15 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
isOnWifi = Helper.isOnWIFI(context);
|
isOnWifi = Helper.isOnWIFI(context);
|
||||||
positionSpinnerTrans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
positionSpinnerTrans = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
|
||||||
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeContainer);
|
swipeRefreshLayout = rootView.findViewById(R.id.swipeContainer);
|
||||||
behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
if( type == RetrieveFeedsAsyncTask.Type.HOME)
|
if( type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||||
lastReadStatus = sharedpreferences.getString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, null);
|
lastReadStatus = sharedpreferences.getString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, null);
|
||||||
lv_status = (ListView) rootView.findViewById(R.id.lv_status);
|
lv_status = rootView.findViewById(R.id.lv_status);
|
||||||
mainLoader = (RelativeLayout) rootView.findViewById(R.id.loader);
|
mainLoader = rootView.findViewById(R.id.loader);
|
||||||
nextElementLoader = (RelativeLayout) rootView.findViewById(R.id.loading_next_status);
|
nextElementLoader = rootView.findViewById(R.id.loading_next_status);
|
||||||
textviewNoAction = (RelativeLayout) rootView.findViewById(R.id.no_action);
|
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||||
mainLoader.setVisibility(View.VISIBLE);
|
mainLoader.setVisibility(View.VISIBLE);
|
||||||
nextElementLoader.setVisibility(View.GONE);
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
|
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, this.statuses);
|
||||||
|
@ -132,11 +132,10 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
if( !comesFromSearch){
|
if( !comesFromSearch){
|
||||||
|
|
||||||
//Hide account header when scrolling for ShowAccountActivity
|
//Hide account header when scrolling for ShowAccountActivity
|
||||||
if (hideHeader )
|
if (hideHeader)
|
||||||
ViewCompat.setNestedScrollingEnabled(lv_status, true);
|
ViewCompat.setNestedScrollingEnabled(lv_status, true);
|
||||||
|
|
||||||
lv_status.setOnScrollListener(new AbsListView.OnScrollListener() {
|
lv_status.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
int lastFirstVisibleItem = 0;
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||||
|
|
||||||
|
@ -166,6 +165,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
public void onRefresh() {
|
public void onRefresh() {
|
||||||
max_id = null;
|
max_id = null;
|
||||||
statuses = new ArrayList<>();
|
statuses = new ArrayList<>();
|
||||||
|
knownId = new ArrayList<>();
|
||||||
firstLoad = true;
|
firstLoad = true;
|
||||||
flag_loading = true;
|
flag_loading = true;
|
||||||
swiped = true;
|
swiped = true;
|
||||||
|
@ -253,10 +253,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
}
|
}
|
||||||
|
|
||||||
if( statuses != null && statuses.size() > 0) {
|
if( statuses != null && statuses.size() > 0) {
|
||||||
ArrayList<String> knownId = new ArrayList<>();
|
|
||||||
for(Status st: this.statuses){
|
|
||||||
knownId.add(st.getId());
|
|
||||||
}
|
|
||||||
for(Status tmpStatus: statuses){
|
for(Status tmpStatus: statuses){
|
||||||
if( !knownId.contains(tmpStatus.getId())) {
|
if( !knownId.contains(tmpStatus.getId())) {
|
||||||
if( type == RetrieveFeedsAsyncTask.Type.HOME && firstLoad && lastReadStatus != null && Long.parseLong(tmpStatus.getId()) > Long.parseLong(lastReadStatus)){
|
if( type == RetrieveFeedsAsyncTask.Type.HOME && firstLoad && lastReadStatus != null && Long.parseLong(tmpStatus.getId()) > Long.parseLong(lastReadStatus)){
|
||||||
|
@ -266,6 +262,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
tmpStatus.setNew(false);
|
tmpStatus.setNew(false);
|
||||||
}
|
}
|
||||||
this.statuses.add(tmpStatus);
|
this.statuses.add(tmpStatus);
|
||||||
|
knownId.add(tmpStatus.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +304,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
if( type == RetrieveFeedsAsyncTask.Type.HOME) {
|
if( type == RetrieveFeedsAsyncTask.Type.HOME) {
|
||||||
if (context == null)
|
if (context == null)
|
||||||
return;
|
return;
|
||||||
if (status != null) {
|
if (status != null && !knownId.contains(status.getId())) {
|
||||||
//Update the id of the last toot retrieved
|
//Update the id of the last toot retrieved
|
||||||
MainActivity.lastHomeId = status.getId();
|
MainActivity.lastHomeId = status.getId();
|
||||||
int index = lv_status.getFirstVisiblePosition() + 1;
|
int index = lv_status.getFirstVisiblePosition() + 1;
|
||||||
|
@ -315,6 +312,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
int top = (v == null) ? 0 : v.getTop();
|
int top = (v == null) ? 0 : v.getTop();
|
||||||
status.setReplies(new ArrayList<Status>());
|
status.setReplies(new ArrayList<Status>());
|
||||||
statuses.add(0,status);
|
statuses.add(0,status);
|
||||||
|
knownId.add(0,status.getId());
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||||
if( !status.getAccount().getId().equals(userId))
|
if( !status.getAccount().getId().equals(userId))
|
||||||
|
@ -327,17 +325,21 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
}else if(type == RetrieveFeedsAsyncTask.Type.PUBLIC || type == RetrieveFeedsAsyncTask.Type.LOCAL){
|
}else if(type == RetrieveFeedsAsyncTask.Type.PUBLIC || type == RetrieveFeedsAsyncTask.Type.LOCAL){
|
||||||
if (context == null)
|
if (context == null)
|
||||||
return;
|
return;
|
||||||
//Avoids the array to be too big...
|
if (status != null && !knownId.contains(status.getId())) {
|
||||||
if (status != null) {
|
status.setReplies(new ArrayList<Status>());
|
||||||
|
status.setNew(false);
|
||||||
if (lv_status.getFirstVisiblePosition() == 0) {
|
if (lv_status.getFirstVisiblePosition() == 0) {
|
||||||
status.setReplies(new ArrayList<Status>());
|
|
||||||
status.setNew(false);
|
|
||||||
statuses.add(0, status);
|
statuses.add(0, status);
|
||||||
statusListAdapter.notifyDataSetChanged();
|
statusListAdapter.notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
status.setReplies(new ArrayList<Status>());
|
int index = lv_status.getFirstVisiblePosition() + 1;
|
||||||
|
View v = lv_status.getChildAt(0);
|
||||||
|
int top = (v == null) ? 0 : v.getTop();
|
||||||
statuses.add(0, status);
|
statuses.add(0, status);
|
||||||
|
statusListAdapter.notifyDataSetChanged();
|
||||||
|
lv_status.setSelectionFromTop(index, top);
|
||||||
}
|
}
|
||||||
|
knownId.add(0, status.getId());
|
||||||
if (textviewNoAction.getVisibility() == View.VISIBLE)
|
if (textviewNoAction.getVisibility() == View.VISIBLE)
|
||||||
textviewNoAction.setVisibility(View.GONE);
|
textviewNoAction.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -518,10 +520,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
@Override
|
@Override
|
||||||
public void onRetrieveMissingFeeds(List<Status> statuses) {
|
public void onRetrieveMissingFeeds(List<Status> statuses) {
|
||||||
if( statuses != null && statuses.size() > 0) {
|
if( statuses != null && statuses.size() > 0) {
|
||||||
ArrayList<String> knownId = new ArrayList<>();
|
|
||||||
for (Status st : this.statuses) {
|
|
||||||
knownId.add(st.getId());
|
|
||||||
}
|
|
||||||
if( lv_status.getFirstVisiblePosition() > 1 ) {
|
if( lv_status.getFirstVisiblePosition() > 1 ) {
|
||||||
int index = lv_status.getFirstVisiblePosition() + statuses.size();
|
int index = lv_status.getFirstVisiblePosition() + statuses.size();
|
||||||
View v = lv_status.getChildAt(0);
|
View v = lv_status.getChildAt(0);
|
||||||
|
@ -530,6 +528,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
if (!knownId.contains(statuses.get(i).getId())) {
|
if (!knownId.contains(statuses.get(i).getId())) {
|
||||||
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||||
statuses.get(i).setNew(true);
|
statuses.get(i).setNew(true);
|
||||||
|
knownId.add(0, statuses.get(i).getId());
|
||||||
statuses.get(i).setReplies(new ArrayList<Status>());
|
statuses.get(i).setReplies(new ArrayList<Status>());
|
||||||
this.statuses.add(0, statuses.get(i));
|
this.statuses.add(0, statuses.get(i));
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
@ -545,6 +544,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
if (!knownId.contains(statuses.get(i).getId())) {
|
if (!knownId.contains(statuses.get(i).getId())) {
|
||||||
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
if (type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||||
statuses.get(i).setNew(true);
|
statuses.get(i).setNew(true);
|
||||||
|
knownId.add(0,statuses.get(i).getId());
|
||||||
statuses.get(i).setReplies(new ArrayList<Status>());
|
statuses.get(i).setReplies(new ArrayList<Status>());
|
||||||
this.statuses.add(0, statuses.get(i));
|
this.statuses.add(0, statuses.get(i));
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
|
Loading…
Reference in New Issue