use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class StickerDialogFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
RecyclerView stickerRecyclerView = view.findViewById(R.id.rv_stickerDialog);
progressBar = view.findViewById(R.id.fl_stickerDialog_progressContainer);
groupNameTv = view.findViewById(R.id.tv_stickerDialog_groupName);
addOrRemoveTv = view.findViewById(R.id.tv_stickerDialog_add);
previewIv = view.findViewById(R.id.iv_stickerDialog_preview);
stickerCell = view.findViewById(R.id.iv_stickerDialog_lottiePreview);
retryView = view.findViewById(R.id.retryView);
addOrRemoveProgressBar = view.findViewById(R.id.pb_stickerDialog_addOrRemove);
addOrRemoveProgressBar.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
progressBar.getIndeterminateDrawable().setColorFilter(new Theme().getPrimaryDarkColor(getContext()), PorterDuff.Mode.SRC_IN);
stickerRecyclerView.setAdapter(adapter);
stickerCell.setFailureListener(result -> Log.e(TAG, "setFailureListener: ", result));
viewModel.getProgressMutableLiveData().observe(getViewLifecycleOwner(), visibility -> progressBar.setVisibility(visibility));
viewModel.getStickersMutableLiveData().observe(getViewLifecycleOwner(), structIGStickerGroup -> {
if (!stickerGroup.hasData())
stickerGroup = structIGStickerGroup;
adapter.setIgStickers(structIGStickerGroup.getStickers());
groupNameTv.setText(structIGStickerGroup.getName());
});
viewModel.getAddOrRemoveStickerLiveData().observe(getViewLifecycleOwner(), resourceId -> {
addOrRemoveTv.setText(getResources().getString(resourceId, HelperCalander.isPersianUnicode ? HelperCalander.convertToUnicodeFarsiNumber(String.valueOf(stickerGroup.getStickersSize())) : String.valueOf(stickerGroup.getStickersSize())));
addOrRemoveTv.setVisibility(View.VISIBLE);
});
adapter.setListener(new StickerAdapter.AddStickerDialogListener() {
@Override
public void onStickerClick(StructIGSticker structIGSticker) {
viewModel.onStickerInListModeClick(structIGSticker);
}
@Override
public void onStickerLongClick(StructIGSticker structIGSticker) {
}
});
viewModel.getOpenPreviewViewLiveData().observe(getViewLifecycleOwner(), structIGSticker -> {
// TODO: 12/8/19 must create custom dialog for add just once view for handle stickers view type
if (structIGSticker != null && previewIv.getVisibility() == View.GONE) {
if (structIGSticker.getType() == StructIGSticker.ANIMATED_STICKER) {
stickerCell.playAnimation(structIGSticker.getPath());
stickerCell.animate().alpha(1.0f).setDuration(100).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
stickerCell.setVisibility(View.VISIBLE);
}
});
} else if (structIGSticker.getType() == StructIGSticker.NORMAL_STICKER) {
if (getContext() != null)
Glide.with(getContext()).load(structIGSticker.getPath()).into(previewIv);
previewIv.animate().alpha(1.0f).setDuration(100).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
previewIv.setVisibility(View.VISIBLE);
}
});
}
if (readOnlyChat) {
addOrRemoveTv.setVisibility(View.GONE);
} else {
addOrRemoveTv.setText(getResources().getString(R.string.send));
addOrRemoveTv.setVisibility(View.VISIBLE);
}
} else if (previewIv.getVisibility() == View.VISIBLE) {
previewIv.animate().alpha(0.0f).setDuration(150).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
previewIv.setVisibility(View.GONE);
}
});
} else if (stickerCell.getVisibility() == View.VISIBLE) {
stickerCell.animate().alpha(0.0f).setDuration(150).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
stickerCell.setVisibility(View.GONE);
}
});
}
});
viewModel.getSendMessageLiveData().observe(getViewLifecycleOwner(), structIGSticker -> {
if (listener != null) {
listener.sendMessage(structIGSticker);
dismiss();
}
});
viewModel.getAddOrRemoveProgressLiveData().observe(getViewLifecycleOwner(), visibility -> addOrRemoveProgressBar.setVisibility(visibility));
viewModel.getRetryViewLiveData().observe(getViewLifecycleOwner(), visibility -> retryView.setVisibility(visibility));
previewIv.setOnClickListener(v -> viewModel.onPreviewImageClicked());
stickerCell.setOnClickListener(v -> viewModel.onPreviewImageClicked());
viewModel.getCloseDialogMutableLiveData().observe(getViewLifecycleOwner(), close -> dismiss());
addOrRemoveTv.setOnClickListener(v -> viewModel.onAddOrRemoveStickerClicked());
retryView.setOnClickListener(v -> viewModel.onRetryViewClicked());
viewModel.getSticker();
}
use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class TypeChartViewHolder method bindView.
public void bindView(String[] labels, ArrayList<BarEntry> barEntries) {
int maxSize = 0;
int totalWith = (int) ViewMaker.pixelsToDp((float) Resources.getSystem().getDisplayMetrics().widthPixels, itemView.getContext());
for (int i = 0; i < labels.length; i++) {
if (labels[i].length() > 13) {
labels[i] = labels[i].substring(0, 10) + "...";
}
if (labels[i].length() > maxSize) {
maxSize = labels[i].length();
}
}
BarDataSet set1;
chart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(labels));
set1 = new BarDataSet(barEntries, "Data Set");
ArrayList<Integer> colors = new ArrayList<>();
colors.add(new Theme().getAccentColor(chart.getContext()));
set1.setColors(colors);
set1.setDrawValues(true);
set1.setValueTypeface(ResourcesCompat.getFont(chart.getContext(), R.font.main_font));
set1.setValueTextColor(new Theme().getTitleTextColor(chart.getContext()));
set1.setValueTextSize(ViewMaker.dpToPixel(3));
set1.setValueFormatter(new ValueFormatter() {
@Override
public String getFormattedValue(float value) {
String myValue;
// number 22.154456 => show 2 digit of float 22.15 if crashed just show number -> 22
try {
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
myValue = df.format(value);
} catch (Exception e) {
myValue = String.valueOf((long) Math.floor(value));
}
if (HelperCalander.isPersianUnicode)
myValue = convertToUnicodeFarsiNumber(myValue);
return myValue + "%";
}
});
// set1.setBarBorderWidth(set1.getBarBorderWidth() == 1.f ? 0.f : 1.f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
chart.setData(data);
chart.setFitBars(true);
chart.setVisibleXRangeMaximum((float) totalWith / (maxSize * 6));
chart.invalidate();
chart.getData().notifyDataChanged();
}
use of net.iGap.module.Theme 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.module.Theme in project iGap-Android by KianIranian-STDG.
the class ArcMenu method init.
private void init(TypedArray attr) {
Resources resources = getResources();
try {
mDrawable = attr.getDrawable(R.styleable.ArcMenu_menu_scr);
} catch (Exception e) {
e.printStackTrace();
}
// mColorStateList = attr.getColorStateList(R.styleable.ArcMenu_menu_color);
mColorStateList = ColorStateList.valueOf(new Theme().getPrimaryColor(getContext()));
mFinalRadius = attr.getDimension(R.styleable.ArcMenu_menu_radius, resources.getDimension(R.dimen.dp100));
mElevation = attr.getDimension(R.styleable.ArcMenu_menu_elevation, resources.getDimension(R.dimen.dp6));
mQuadrantAngle = attr.getInteger(R.styleable.ArcMenu_menu_angle, 90);
mMenuSideEnum = MenuSideEnum.fromId(attr.getInt(R.styleable.ArcMenu_menu_open, 0));
mAnimationTime = attr.getInteger(R.styleable.ArcMenu_menu_animation_time, ANIMATION_TIME);
revConfig = attr.getBoolean(R.styleable.ArcMenu_menu_config, false);
mCurrentRadius = 0;
if (mDrawable == null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mDrawable = resources.getDrawable(R.mipmap.plus, null);
} else {
if (revConfig)
mDrawable = resources.getDrawable(R.drawable.ic_gps_layer);
else
mDrawable = resources.getDrawable(R.mipmap.plus);
}
}
mRippleColor = attr.getColor(R.styleable.ArcMenu_menu_ripple_color, getThemeAccentColor(getContext(), R.attr.colorControlHighlight));
// }
if (mMenuSideEnum == MenuSideEnum.ARC_LEFT) {
if (revConfig) {
if (!HelperCalander.isPersianUnicode)
mQuadrantAngle = -mQuadrantAngle;
} else {
if (HelperCalander.isPersianUnicode)
mQuadrantAngle = -mQuadrantAngle;
}
} else {
mQuadrantAngle = -mQuadrantAngle;
}
menuMargin = attr.getDimensionPixelSize(R.styleable.ArcMenu_menu_margin, resources.getDimensionPixelSize(R.dimen.dp8));
}
use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class StoryGalleryFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
fragmentView = new LinearLayout(context);
rootView = (LinearLayout) fragmentView;
rootView.setOrientation(LinearLayout.VERTICAL);
if (tfMain == null)
tfMain = ResourcesCompat.getFont(getContext(), R.font.main_font);
toolbarView = new FrameLayout(context);
toolbarView.setBackgroundResource(new Theme().getToolbarDrawableSharpe(getContext()));
backIcon = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
backIcon.setText(getString(R.string.icon_back));
backIcon.setTextColor(context.getResources().getColor(R.color.white));
backIcon.setTextSize(22);
backIcon.setGravity(Gravity.CENTER);
toolbarView.addView(backIcon, LayoutCreator.createFrame(40, 40, Gravity.LEFT | Gravity.CENTER_VERTICAL, 8, 0, 0, 0));
sendIcon = new MaterialDesignTextView(new ContextThemeWrapper(context, R.style.myIconToolbarStyle));
sendIcon.setText(getString(R.string.icon_send));
sendIcon.setTextColor(context.getResources().getColor(R.color.white));
sendIcon.setTextSize(22);
sendIcon.setVisibility(View.GONE);
sendIcon.setGravity(Gravity.CENTER);
toolbarView.addView(sendIcon, LayoutCreator.createFrame(40, 40, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 8, 0, 0, 0));
toolbarTitle = new AppCompatTextView(context);
toolbarTitle.setText(getString(R.string.gallery));
toolbarTitle.setTypeface(tfMain);
toolbarTitle.setTextSize(22);
toolbarTitle.setTextColor(getResources().getColor(R.color.whit_background));
toolbarView.addView(toolbarTitle, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, 0, 0, 0, 0));
rootView.addView(toolbarView, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, 60, Gravity.CENTER | Gravity.TOP));
nestedScrollableHost = new NestedScrollableHost(context);
mainRecyclerView = new RecyclerView(context);
mainRecyclerView.setLayoutManager(new GridLayoutManager(context, 4));
nestedScrollableHost.addView(mainRecyclerView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.CENTER));
rootView.addView(nestedScrollableHost, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, 0, 1F, Gravity.CENTER));
return rootView;
}
Aggregations