use of org.aisen.weibo.sina.sinasdk.bean.Group in project AisenWeiBo by wangdan.
the class OfflineUtils method toggleOffline.
/**
* 触发一次离线,如果没有设置过离线分组,优先设置后再离线
*
* @param context
*/
public static void toggleOffline(final Activity context) {
if (!AppContext.isLoggedIn())
return;
List<Group> groups = SinaDB.getOfflineSqlite().select(new Extra(AppContext.getAccount().getUser().getIdstr(), null), Group.class);
if (groups.size() == 0) {
Logger.d(TAG, "离线分组未设置过");
new AlertDialogWrapper.Builder(context).setMessage(R.string.offline_none_groups_remind).setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showOfflineGroupsModifyDialog(context, new ArrayList<Group>(), new OnOfflineGroupSetCallback() {
@Override
public void onChanged(List<Group> newGroups) {
// 设置离线分组
Logger.d(TAG, "设置离线分组%d个", newGroups.size());
if (newGroups.size() > 0) {
SinaDB.getOfflineSqlite().insert(getLoggedExtra(null), newGroups);
toggleOffline(context);
}
}
}, R.string.offline_groups_dialog);
}
}).show();
} else {
OfflineService.startOffline((ArrayList) groups);
}
}
use of org.aisen.weibo.sina.sinasdk.bean.Group in project AisenWeiBo by wangdan.
the class OfflineUtils method showOfflineGroupsModifyDialog.
/**
* 显示一个Dialog,用来设置分组
*
* @param activity
* @param selectedGroups
* @param callback
* @param titleId
*/
public static void showOfflineGroupsModifyDialog(Activity activity, List<Group> selectedGroups, final OnOfflineGroupSetCallback callback, int titleId) {
String[] items = new String[AppContext.getAccount().getGroups().getLists().size()];
final boolean[] editCheckedItems = new boolean[AppContext.getAccount().getGroups().getLists().size()];
for (int i = 0; i < AppContext.getAccount().getGroups().getLists().size(); i++) {
Group group = AppContext.getAccount().getGroups().getLists().get(i);
items[i] = group.getName();
editCheckedItems[i] = false;
for (Group groupSelectd : selectedGroups) {
if (groupSelectd.getId().equals(group.getIdstr())) {
editCheckedItems[i] = true;
break;
}
}
}
AlertDialogWrapper.Builder dialogBuilder = new AlertDialogWrapper.Builder(activity).setTitle(titleId).setMultiChoiceItems(items, editCheckedItems, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
editCheckedItems[which] = isChecked;
}
});
dialogBuilder.setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// 艹,这个控件这里有bug
GlobalContext.getInstance().getHandler().postDelayed(new Runnable() {
@Override
public void run() {
List<Group> groups = new ArrayList<Group>();
for (int i = 0; i < editCheckedItems.length; i++) {
if (editCheckedItems[i]) {
groups.add(AppContext.getAccount().getGroups().getLists().get(i));
}
}
callback.onChanged(groups);
}
}, 300);
}
}).show();
}
use of org.aisen.weibo.sina.sinasdk.bean.Group in project AisenWeiBo by wangdan.
the class MainActivity method setupFab.
private void setupFab(Bundle savedInstanceState) {
ArrayList<Group> groupList = new ArrayList<>();
// 全部微博
Group group = new Group();
group.setName(getString(R.string.timeline_all));
group.setId("statusesFriendsTimeLine");
groupList.add(group);
// 互相关注
group = new Group();
group.setName(getString(R.string.timeline_bilateral));
group.setId("statusesBilateralTimeLine");
groupList.add(group);
// 发给我的
group = new Group();
group.setName(getString(R.string.timeline_tome));
group.setId("statusesToMe");
groupList.add(group);
// 分组微博
groupList.addAll(AppContext.getAccount().getGroups().getLists());
fabGroupsFragment = (FabGroupsFragment) getFragmentManager().findFragmentById(R.id.fragmentFabGroups);
fabGroupsFragment.resetSelectedPosition();
fabGroupsFragment.setItems(groupList);
View sheetView = findViewById(R.id.fab_sheet);
View overlay = findViewById(R.id.overlay);
int sheetColor = getResources().getColor(R.color.comm_white);
int fabColor = MDHelper.resolveColor(this, R.attr.colorPrimary, Color.BLACK);
materialSheetFab = new MaterialSheetFab(fabBtn, sheetView, overlay, sheetColor, fabColor);
materialSheetFab.setEventListener(new MaterialSheetFabEventListener() {
@Override
public void onShowSheet() {
super.onShowSheet();
fabGroupsFragment.show();
MobclickAgent.onEvent(MainActivity.this, "fab_groups");
}
});
materialSheetFab.showFab();
}
use of org.aisen.weibo.sina.sinasdk.bean.Group in project AisenWeiBo by wangdan.
the class ProfileAboutFragment method setGroupList.
public void setGroupList() {
if (mGroupMemberListed == null)
return;
if (groupDialog != null && groupDialog.isShowing())
groupDialog.dismiss();
String[] items = new String[AppContext.getAccount().getGroups().getLists().size()];
final boolean[] checkedItems = new boolean[AppContext.getAccount().getGroups().getLists().size()];
final boolean[] editCheckedItems = new boolean[AppContext.getAccount().getGroups().getLists().size()];
for (int i = 0; i < AppContext.getAccount().getGroups().getLists().size(); i++) {
Group group = AppContext.getAccount().getGroups().getLists().get(i);
items[i] = group.getName();
checkedItems[i] = false;
editCheckedItems[i] = false;
for (GroupListed groupListed : mGroupMemberListed.getLists()) {
if (groupListed.getIdstr().equals(group.getIdstr())) {
checkedItems[i] = true;
editCheckedItems[i] = true;
break;
}
}
}
// View customTitle = View.inflate(getActivity(), R.layout.lay_group_dialogtitle, null);
// customTitle.findViewById(R.id.btnSettings).setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// // 设置分组
// GroupSortFragment.lanuch(getActivity());
// }
// });
AlertDialogWrapper.Builder dialogBuilder = new AlertDialogWrapper.Builder(getActivity()).setTitle(R.string.profile_group_setting).setMultiChoiceItems(items, editCheckedItems, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
editCheckedItems[which] = isChecked;
}
});
try {
try {
// 解决有些设备版本较低的BUG,没查这个方法的最低版本要求
dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
groupDialog = null;
}
});
} catch (NoSuchMethodError e) {
e.printStackTrace();
}
} catch (Exception e) {
}
groupDialog = dialogBuilder.setNegativeButton(R.string.cancel, null).setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new SetGroupTask().execute(checkedItems, editCheckedItems);
}
}).show();
}
use of org.aisen.weibo.sina.sinasdk.bean.Group in project AisenWeiBo by wangdan.
the class PublishStatusFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_publish, menu);
// 添加分组
if (AppContext.getAccount().getGroups() == null || AppContext.getAccount().getGroups().getLists().size() == 0) {
} else {
SubMenu subMenu = menu.addSubMenu(R.id.publish, 333, 2, GlobalContext.getInstance().getResources().getString(R.string.group_selected_visiable));
for (int i = 0; i < AppContext.getAccount().getGroups().getLists().size(); i++) {
Group group = AppContext.getAccount().getGroups().getLists().get(i);
subMenu.add(100, i, i, group.getName());
}
}
}
Aggregations