Adds counters
This commit is contained in:
parent
d0ffd7449a
commit
28cc83faee
|
@ -438,10 +438,16 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
displayStatusFragment.scrollToTop();
|
||||
break;
|
||||
case 2:
|
||||
if( display_local)
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.LOCAL,0);
|
||||
else if( display_global)
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC,0);
|
||||
break;
|
||||
case 3:
|
||||
displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||
if( displayStatusFragment != null )
|
||||
displayStatusFragment.scrollToTop();
|
||||
updateTimeLine(RetrieveFeedsAsyncTask.Type.PUBLIC,0);
|
||||
break;
|
||||
case 1:
|
||||
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
||||
|
@ -1386,6 +1392,41 @@ public abstract class BaseMainActivity extends AppCompatActivity
|
|||
}
|
||||
}
|
||||
|
||||
public void updateTimeLine(RetrieveFeedsAsyncTask.Type type, int value){
|
||||
if( type == RetrieveFeedsAsyncTask.Type.LOCAL){
|
||||
if( tabLayout.getTabAt(2) != null && display_local){
|
||||
View tabLocal = tabLayout.getTabAt(2).getCustomView();
|
||||
TextView tabCounterLocal = tabLocal.findViewById(R.id.tab_counter);
|
||||
tabCounterLocal.setText(String.valueOf(value));
|
||||
if( value > 0){
|
||||
tabCounterLocal.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
tabCounterLocal.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}else if( type == RetrieveFeedsAsyncTask.Type.PUBLIC){
|
||||
if( tabLayout.getTabAt(3) != null && display_local){
|
||||
View tabPublic = tabLayout.getTabAt(3).getCustomView();
|
||||
TextView tabCounterPublic = tabPublic.findViewById(R.id.tab_counter);
|
||||
tabCounterPublic.setText(String.valueOf(value));
|
||||
if( value > 0){
|
||||
tabCounterPublic.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
tabCounterPublic.setVisibility(View.GONE);
|
||||
}
|
||||
}else if( tabLayout.getTabAt(2) != null && !display_local && display_global){
|
||||
View tabPublic = tabLayout.getTabAt(2).getCustomView();
|
||||
TextView tabCounterPublic = tabPublic.findViewById(R.id.tab_counter);
|
||||
tabCounterPublic.setText(String.valueOf(value));
|
||||
if( value > 0){
|
||||
tabCounterPublic.setVisibility(View.VISIBLE);
|
||||
}else {
|
||||
tabCounterPublic.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateNotifCounter(){
|
||||
if(tabLayout.getTabAt(1) == null)
|
||||
return;
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.support.v4.view.ViewCompat;
|
|||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -528,7 +529,10 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
statusListAdapter.notifyItemRangeInserted(0, inserted - 1);
|
||||
try {
|
||||
((MainActivity) context).updateHomeCounter();
|
||||
if( type == RetrieveFeedsAsyncTask.Type.HOME)
|
||||
((MainActivity) context).updateHomeCounter();
|
||||
else
|
||||
((MainActivity) context).updateTimeLine(type, inserted);
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue