use of org.aisen.weibo.sina.ui.activity.base.MainActivity in project AisenWeiBo by wangdan.
the class OfflineService method preparePicture.
private synchronized void preparePicture() {
// 等微博离线完了再离线图片
if (unOfflineGroups.size() > 0)
return;
// 正在运行
if (BaseActivity.getRunningActivity() instanceof MainActivity) {
TimelineMainFragment.sendBroadcast();
} else {
setOfflineFinished(loggedIn, true);
}
// 清理缓存数据
mPictureMap.clear();
// 微博更新完了
mNotifier.notifyStatusSuccess(mGroups.size(), offlineStatusCount, offlineStatusLengh);
// 只有WIFI情况才离线图片
if (isCanceled()) {
return;
}
// 没有图片
if (mPictures.size() == 0) {
stopSelf();
} else {
// 开始下载队列里的图片
if (OFFLINE_EXECUTOR == null) {
OFFLINE_EXECUTOR = Executors.newFixedThreadPool(AppSettings.offlinePicTaskSize(), sThreadFactory);
}
// 新建线程队列,开始下载图片
List<LoadPictureTask> taskList = new ArrayList<>();
int taskSize = AppSettings.offlinePicTaskSize() > mPictures.size() ? mPictures.size() : AppSettings.offlinePicTaskSize();
for (int i = 0; i < taskSize; i++) {
OfflinePictureBean bean = pollPicture();
if (bean != null)
taskList.add(new LoadPictureTask(bean));
else {
break;
}
}
for (LoadPictureTask task : taskList) {
task.executeOnExecutor(OFFLINE_EXECUTOR);
}
}
}
use of org.aisen.weibo.sina.ui.activity.base.MainActivity in project AisenWeiBo by wangdan.
the class AisenUtils method setTabsText.
public static void setTabsText(Fragment fragment, int index, String text) {
if (fragment.getActivity() == null)
return;
ABaseFragment aFragment = null;
if (fragment.getActivity() instanceof SinaCommonActivity) {
aFragment = (ABaseFragment) fragment.getActivity().getFragmentManager().findFragmentByTag(SinaCommonActivity.FRAGMENT_TAG);
} else if (fragment.getActivity() instanceof MainActivity) {
aFragment = (ABaseFragment) fragment.getActivity().getFragmentManager().findFragmentByTag("MainFragment");
}
if (aFragment != null && aFragment instanceof ATabsTabLayoutFragment) {
ATabsTabLayoutFragment tabsFragment = (ATabsTabLayoutFragment) aFragment;
tabsFragment.getTablayout().getTabAt(index).setText(text);
}
}
Aggregations