use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class TabItem method init.
private void init(@Nullable AttributeSet attributeSet) {
parseAttr(attributeSet);
if (haveAvatarImage) {
if (imageView == null) {
imageView = new CircleImageView(getContext());
imageView.setBackgroundResource(new Theme().getUserProfileTabSelector(getContext()));
imageView.setPadding((int) getResources().getDimension(R.dimen.dp2), (int) getResources().getDimension(R.dimen.dp2), (int) getResources().getDimension(R.dimen.dp2), (int) getResources().getDimension(R.dimen.dp2));
if (avatarHandler == null) {
avatarHandler = new AvatarHandler();
avatarHandler.registerChangeFromOtherAvatarHandler();
avatarHandler.getAvatar(new ParamWithAvatarType(imageView, AccountManager.getInstance().getCurrentUser().getId()).avatarType(AvatarHandler.AvatarType.USER).showMain());
}
}
} else {
if (imageView == null)
imageView = new AppCompatImageView(getContext());
}
if (textView == null)
textView = new AppCompatTextView(getContext());
textView.setTypeface(ResourcesCompat.getFont(getContext(), R.font.main_font_bold));
textView.setText(text);
int[][] states = new int[][] { // selected
new int[] { android.R.attr.state_selected }, // none
new int[] { -android.R.attr.state_selected } };
int[] colors = new int[] { new Theme().getAccentColor(textView.getContext()), new Theme().getSubTitleColor(textView.getContext()) };
ColorStateList myList = new ColorStateList(states, colors);
textView.setTextColor(myList);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 9);
addView(imageView);
addView(textView);
setOnClickListener(this);
}
use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class TabItem method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (haveAvatarImage && avatarHandler == null) {
avatarHandler = new AvatarHandler();
avatarHandler.registerChangeFromOtherAvatarHandler();
avatarHandler.getAvatar(new ParamWithAvatarType(imageView, AccountManager.getInstance().getCurrentUser().getId()).avatarType(AvatarHandler.AvatarType.USER).showMain());
}
}
use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class MainFragment method confirmActionForClearHistoryOfSelected.
private void confirmActionForClearHistoryOfSelected() {
int selectedRoomCount = selectedRoom.size();
FrameLayout frameLayout = new FrameLayout(context);
if (selectedRoomCount == 1) {
RealmRoom room = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoom.class).equalTo("id", selectedRoom.get(0)).findFirst();
});
CircleImageView imageView = new CircleImageView(context);
AvatarHandler handler = new AvatarHandler();
handler.getAvatar(new ParamWithAvatarType(imageView, room.getOwnerId()).avatarType(AvatarHandler.AvatarType.ROOM).showMain(), true);
frameLayout.addView(imageView, LayoutCreator.createFrame(55, 55, isAppRtl ? Gravity.RIGHT : Gravity.LEFT, 8, 8, 8, 8));
}
TextView titleTextView = new TextView(context);
titleTextView.setTypeface(ResourcesCompat.getFont(context, R.font.main_font_bold));
if (selectedRoomCount == 1)
titleTextView.setText(getString(R.string.clear_history));
else
titleTextView.setText(String.format(Locale.US, "%s %d %s", getString(R.string.clear_history), selectedRoomCount, getString(R.string.chat)));
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
titleTextView.setTextColor(Theme.getInstance().getTitleTextColor(context));
if (selectedRoomCount == 1) {
frameLayout.addView(titleTextView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, isAppRtl ? Gravity.RIGHT : Gravity.LEFT, isAppRtl ? 20 : 70, 20, isAppRtl ? 70 : 20, 20));
} else {
frameLayout.addView(titleTextView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, isAppRtl ? Gravity.RIGHT : Gravity.LEFT, 20, 20, 20, 20));
}
TextView confirmTextView = new TextView(context);
confirmTextView.setTypeface(ResourcesCompat.getFont(context, R.font.main_font));
if (selectedRoomCount == 1) {
RealmRoom realmRoom = getMessageDataStorage().getRoom(selectedRoom.get(0));
String channelName = realmRoom.title;
confirmTextView.setText(String.format(getString(R.string.clear_selected_history), channelName));
} else {
confirmTextView.setText(R.string.do_you_want_clear_history_this);
}
confirmTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
confirmTextView.setTextColor(Theme.getInstance().getTitleTextColor(context));
frameLayout.addView(confirmTextView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, isAppRtl ? Gravity.RIGHT : Gravity.LEFT, 20, 70, 20, 8));
MaterialDialog.Builder builder = new MaterialDialog.Builder(G.fragmentActivity);
builder.customView(frameLayout, false);
builder.positiveText(G.fragmentActivity.getResources().getString(R.string.B_ok)).negativeText(G.fragmentActivity.getResources().getString(R.string.B_cancel)).negativeColor(Color.GRAY).onPositive((dialog, which) -> {
dialog.dismiss();
for (long roomId : selectedRoom) {
clearHistory(roomId, false);
}
disableMultiSelect();
}).onNegative((dialog, which) -> dialog.dismiss()).show();
}
use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class MainFragment method confirmActionForRemoveSelected.
private void confirmActionForRemoveSelected() {
int selectedRoomCount = selectedRoom.size();
FrameLayout frameLayout = new FrameLayout(context);
if (selectedRoomCount == 1) {
CircleImageView imageView = new CircleImageView(context);
AvatarHandler handler = new AvatarHandler();
RealmRoom room = DbManager.getInstance().doRealmTask(realm -> {
return realm.where(RealmRoom.class).equalTo("id", selectedRoom.get(0)).findFirst();
});
handler.getAvatar(new ParamWithAvatarType(imageView, room.getOwnerId()).avatarType(room.getType() != ProtoGlobal.Room.Type.CHAT ? AvatarHandler.AvatarType.ROOM : AvatarHandler.AvatarType.USER).showMain(), true);
frameLayout.addView(imageView, LayoutCreator.createFrame(55, 55, isAppRtl ? Gravity.RIGHT : Gravity.LEFT, 8, 8, 8, 8));
}
TextView titleTextView = new TextView(context);
if (selectedRoomCount == 1) {
titleTextView.setText(getString(R.string.left));
} else {
titleTextView.setText(String.format(Locale.US, "%s %d %s", getString(R.string.delete), selectedRoomCount, getString(R.string.chat)));
}
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
titleTextView.setTypeface(ResourcesCompat.getFont(context, R.font.main_font_bold));
titleTextView.setTextColor(Theme.getInstance().getTitleTextColor(context));
int leftMargin = 20;
int rightMargin = 20;
if (selectedRoomCount == 1) {
if (isAppRtl)
rightMargin = 70;
else
leftMargin = 70;
}
frameLayout.addView(titleTextView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, isAppRtl ? Gravity.RIGHT : Gravity.LEFT, leftMargin, 20, rightMargin, 20));
TextView confirmTextView = new TextView(context);
if (selectedRoomCount == 1) {
RealmRoom realmRoom = getMessageDataStorage().getRoom(selectedRoom.get(0));
if (realmRoom != null) {
String channelName = realmRoom.title;
if (realmRoom.getType() == CHAT) {
confirmTextView.setText(getString(R.string.delete_chat_content));
} else {
confirmTextView.setText(String.format(getString(R.string.leave_confirm), channelName));
}
}
} else {
confirmTextView.setText(R.string.delete_selected_chat);
}
confirmTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
confirmTextView.setTypeface(ResourcesCompat.getFont(context, R.font.main_font));
confirmTextView.setTextColor(Theme.getInstance().getTitleTextColor(context));
frameLayout.addView(confirmTextView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, isAppRtl ? Gravity.RIGHT : Gravity.LEFT, 20, 70, 20, 8));
MaterialDialog.Builder builder = new MaterialDialog.Builder(G.fragmentActivity);
builder.customView(frameLayout, false);
builder.positiveText(G.fragmentActivity.getResources().getString(R.string.B_ok)).negativeText(G.fragmentActivity.getResources().getString(R.string.B_cancel)).negativeColor(Color.GRAY).onPositive((dialog, which) -> {
dialog.dismiss();
if (selectedRoom.size() > 0) {
for (int i = 0; i < selectedRoom.size(); i++) {
RealmRoom item = getMessageDataStorage().getRoom(selectedRoom.get(i));
if (item != null) {
deleteChat(item, false);
}
}
}
disableMultiSelect();
}).onNegative((dialog, which) -> dialog.dismiss()).show();
}
use of net.iGap.helper.avatar.ParamWithAvatarType in project iGap-Android by KianIranian-STDG.
the class BeepTunesMainFragment method initToolBar.
private void initToolBar(ViewGroup viewGroup) {
HelperToolbar helperToolbar = HelperToolbar.create().setContext(getContext()).setLifecycleOwner(getViewLifecycleOwner()).setSearchBoxShown(true).setLogoShown(true).setListener(this).setRightSmallAvatarShown(true).setLeftIcon(R.string.icon_back);
viewGroup.addView(helperToolbar.getView());
avatarHandler.getAvatar(new ParamWithAvatarType(helperToolbar.getAvatarSmall(), AccountManager.getInstance().getCurrentUser().getId()).avatarType(AvatarHandler.AvatarType.USER).showMain());
}
Aggregations