use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class ViewUserDialogFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
isInShowViewUser = true;
if (tfMain == null)
tfMain = ResourcesCompat.getFont(getContext(), R.font.main_font);
rootView = new FrameLayout(getContext());
dataRootView = new LinearLayout(getContext());
dataRootView.setOrientation(LinearLayout.VERTICAL);
rootView.addView(dataRootView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.CENTER));
if (G.themeColor == Theme.DARK) {
rootView.setBackgroundColor(new Theme().getPrimaryDarkColor(getContext()));
} else {
rootView.setBackgroundColor(Theme.getInstance().getDividerColor(getContext()));
}
HelperToolbar helperToolbar = HelperToolbar.create();
View toolBar = helperToolbar.setContext(getContext()).setLogoShown(true).setListener(this).setDefaultTitle(G.selectedLanguage.equals("fa") ? getString(R.string.story_viewed_by) + " " + HelperCalander.convertToUnicodeFarsiNumber(String.valueOf(count)) + " " + getString(R.string.story_person) : getString(R.string.story_viewed_by) + " " + count).getView();
dataRootView.addView(toolBar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER | Gravity.TOP, 0, 0, 0, 0));
recyclerView = new RecyclerView(getContext());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
dataRootView.addView(recyclerView, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, 0, 1F, Gravity.CENTER));
progressBar = new ProgressBar(getContext());
progressBar.setVisibility(View.GONE);
rootView.addView(progressBar, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER | Gravity.BOTTOM));
listAdapter = new ListAdapter();
listAdapter.setContext(getContext());
return rootView;
}
use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class MainFragment method isUpdateAvailable.
@Override
public void isUpdateAvailable() {
try {
if (getActivity() != null && !getActivity().isFinishing()) {
getActivity().runOnUiThread(() -> {
if (getActivity().hasWindowFocus()) {
new MaterialDialog.Builder(getActivity()).title(R.string.igap_update).titleColor(new Theme().getAccentColor(getActivity())).titleGravity(GravityEnum.CENTER).buttonsGravity(GravityEnum.CENTER).content(R.string.new_version_avilable).contentGravity(GravityEnum.CENTER).negativeText(R.string.ignore).negativeColor(new Theme().getAccentColor(getActivity())).onNegative((dialog, which) -> dialog.dismiss()).positiveText(R.string.startUpdate).onPositive((dialog, which) -> {
try {
String url = BuildConfig.UPDATE_LINK;
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
dialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getActivity(), R.string.need_browser, Toast.LENGTH_SHORT).show();
}
}).show();
}
});
}
} catch (Exception e) {
HelperLog.getInstance().setErrorLog(e);
}
}
use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class FragmentiGapMap method onViewCreated.
@Override
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
HelperTracker.sendTracker(HelperTracker.TRACKER_NEARBY_PAGE);
G.onLocationChanged = this;
G.onGetNearbyCoordinate = this;
G.onMapRegisterState = this;
G.onMapClose = this;
G.onGeoGetComment = this;
G.onMapUsersGet = this;
attentionDialog();
map = view.findViewById(R.id.map);
initToolbar(view);
startMap(view);
// clickDrawMarkActive();
fabStateSwitcher = view.findViewById(R.id.st_fab_state);
/* fabStateSwitcher.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(G.fabBottom)));
fabStateSwitcher.setColorFilter(Color.WHITE);*/
fabStateSwitcher.setBackgroundTintColor();
fabStateSwitcher.setFabSize();
fabStateSwitcher.setStateChangeListener(new StateChangeListener() {
@Override
public void onMenuOpened() {
}
@Override
public void onMenuClosed() {
isMenuButtonAddShown = false;
}
});
btnOrginView = view.findViewById(R.id.ac_fab_orgin);
btnOrginView.setBackgroundTintList(ColorStateList.valueOf(new Theme().getPrimaryColor(getContext())));
btnOrginView.setOnClickListener(view12 -> {
deleteMapFileCash();
if (getActivity() != null && isAdded()) {
changeState = getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).getBoolean("state", false);
if (!changeState) {
deleteMapFileCash();
getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).edit().putBoolean("state", true).apply();
new HelperFragment(G.currentActivity.getSupportFragmentManager(), FragmentiGapMap.getInstance()).setImmediateRemove(true).remove();
new HelperFragment(G.currentActivity.getSupportFragmentManager(), FragmentiGapMap.getInstance()).load();
}
}
if (fabStateSwitcher.isMenuOpened()) {
fabStateSwitcher.toggleMenu();
}
});
btnSatelliteView = view.findViewById(R.id.ac_fab_satellite);
btnSatelliteView.setBackgroundTintList(ColorStateList.valueOf(new Theme().getPrimaryColor(getContext())));
btnSatelliteView.setOnClickListener(view1 -> {
if (getActivity() != null && isAdded()) {
changeState = getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).getBoolean("state", false);
if (changeState) {
deleteMapFileCash();
getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).edit().putBoolean("state", false).apply();
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentiGapMap.getInstance()).setImmediateRemove(true).remove();
if (getActivity() != null) {
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentiGapMap.getInstance()).load();
}
}
}
if (fabStateSwitcher.isMenuOpened()) {
fabStateSwitcher.toggleMenu();
}
});
fabStateSwitcher.fabMenu.setOnClickListener(v -> fabStateSwitcher.toggleMenu());
/* if (HelperCalander.isPersianUnicode)
fabStateSwitcher.chanegMenuItem(false);
else
fabStateSwitcher.chanegMenuItem(true);*/
/* fabStateSwitcher.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
dialog = new MaterialDialog.Builder(G.fragmentActivity).customView(R.layout.chat_popup_dialog_custom, true).build();
View v = dialog.getCustomView();
*/
/* DialogAnimation.animationUp(dialog);*/
/*
dialog.getWindow().setLayout(ViewMaker.dpToPx(220), WindowManager.LayoutParams.WRAP_CONTENT);
DisplayMetrics displayMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
int width = displayMetrics.widthPixels;
WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
if (G.selectedLanguage.equals("en")) {
wmlp.gravity = Gravity.TOP | Gravity.LEFT;
wmlp.x = ViewMaker.dpToPx(10); //x position
} else {
wmlp.gravity = Gravity.TOP | Gravity.RIGHT;
wmlp.x = ViewMaker.dpToPx(10); //x position
}
int s = getActivity().getChangingConfigurations();
*/
/* if (orientation==0){
if (G.isLandscape)
wmlp.y = ViewMaker.dpToPx(160);
else
wmlp.y = ViewMaker.dpToPx(400);
}else */
/*
if (orientation == 1 || orientation == 0) {
//Do some stuff
wmlp.y = ViewMaker.dpToPx(400); //y
} else if (orientation == 2) {
//Do some stuff
wmlp.y = ViewMaker.dpToPx(160); //y
}
dialog.show();
ViewGroup root1 = (ViewGroup) v.findViewById(R.id.dialog_root_item1_notification);
ViewGroup root2 = (ViewGroup) v.findViewById(R.id.dialog_root_item2_notification);
ViewGroup root3 = (ViewGroup) v.findViewById(R.id.dialog_root_item3_notification);
root1.setVisibility(View.GONE);
root2.setVisibility(View.VISIBLE);
root3.setVisibility(View.VISIBLE);
TextView txtItem1 = (TextView) v.findViewById(R.id.dialog_text_item1_notification);
TextView icon1 = (TextView) v.findViewById(R.id.dialog_icon_item1_notification);
txtItem1.setText(G.fragmentActivity.getResources().getString(R.string.satellite_view));
icon1.setText(G.fragmentActivity.getResources().getString(R.string.md_nearby));
TextView txtItem2 = (TextView) v.findViewById(R.id.dialog_text_item2_notification);
TextView icon2 = (TextView) v.findViewById(R.id.dialog_icon_item2_notification);
txtItem2.setText(G.fragmentActivity.getResources().getString(R.string.default_view));
icon2.setText(G.fragmentActivity.getResources().getString(R.string.md_map));
TextView txtItem3 = (TextView) v.findViewById(R.id.dialog_text_item3_notification);
TextView icon3 = (TextView) v.findViewById(R.id.dialog_icon_item3_notification);
txtItem3.setText(G.fragmentActivity.getResources().getString(R.string.satellite_view));
icon3.setText(G.fragmentActivity.getResources().getString(R.string.md_satellite_variant));
root1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
fabGps.setVisibility(View.GONE);
fabStateSwitcher.setVisibility(View.GONE);
rippleMoreMap.setVisibility(View.GONE);
page = pageUserList;
try {
new HelperFragment(FragmentMapUsers.newInstance()).setResourceContainer(R.id.mapContainer_main).setReplace(false).load();
} catch (Exception e) {
e.getStackTrace();
}
}
});
root2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
if (isAdded()) {
changeState = getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE)
.getBoolean("state", false);
if (changeState) {
deleteMapFileCash();
getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).edit().putBoolean("state", false).apply();
new HelperFragment(FragmentiGapMap.getInstance()).remove();
new HelperFragment(FragmentiGapMap.getInstance()).load();
}
}
}
});
root3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
dialog.dismiss();
deleteMapFileCash();
if (isAdded()) {
changeState = getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE)
.getBoolean("state", false);
if (!changeState) {
deleteMapFileCash();
getActivity().getSharedPreferences("KEY_SWITCH_MAP_STATE", Context.MODE_PRIVATE).edit().putBoolean("state", true).apply();
new HelperFragment(FragmentiGapMap.getInstance()).remove();
new HelperFragment(FragmentiGapMap.getInstance()).load();
}
}
}
});
*/
/* SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
//Configuration.getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this));
Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));*/
/*
// map.onDetach();
*/
/* if (changeState)
changeState = false;
else
changeState = true;
map.invalidate();
startMap(view);*/
/*
// setTile(false);
}
});*/
page = 1;
new RequestGeoGetComment().getComment(AccountManager.getInstance().getCurrentUser().getId());
}
use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class DiscoveryFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
HelperTracker.sendTracker(HelperTracker.TRACKER_DISCOVERY_PAGE);
page = getArguments().getInt("page");
if (getContext() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
StatusBarUtil.setColor(getActivity(), new Theme().getPrimaryDarkColor(getContext()), 50);
}
// uncomment this lines after added small avatar and discovery setting
discoveryToolbar = new Toolbar(getContext());
discoveryToolbar.setTitle(G.isAppRtl ? R.string.logo_igap_fa : R.string.logo_igap_en);
if (page != 0) {
discoveryToolbar.setBackIcon(new BackDrawable(false));
} else {
discoveryToolbar.addItem(codeScannerTag, R.string.icon_QR_code, Color.WHITE);
passCodeItem = discoveryToolbar.addItem(passCodeTag, R.string.icon_lock, Color.WHITE);
}
checkPassCodeVisibility();
discoveryToolbar.setListener(i -> {
switch(i) {
case -1:
popBackStackFragment();
break;
case codeScannerTag:
onCodeScannerClickListener();
break;
case passCodeTag:
if (passCodeItem == null) {
return;
}
if (ActivityMain.isLock) {
passCodeItem.setIcon(R.string.icon_unlock);
ActivityMain.isLock = false;
HelperPreferences.getInstance().putBoolean(SHP_SETTING.FILE_NAME, SHP_SETTING.KEY_LOCK_STARTUP_STATE, false);
} else {
passCodeItem.setIcon(R.string.icon_lock);
ActivityMain.isLock = true;
HelperPreferences.getInstance().putBoolean(SHP_SETTING.FILE_NAME, SHP_SETTING.KEY_LOCK_STARTUP_STATE, true);
}
checkPassCodeVisibility();
break;
}
});
ViewGroup layoutToolbar = view.findViewById(R.id.fd_layout_toolbar);
layoutToolbar.addView(discoveryToolbar, LayoutCreator.createLinear(LayoutCreator.MATCH_PARENT, LayoutCreator.dp(56), Gravity.TOP));
pullToRefresh = view.findViewById(R.id.pullToRefresh);
emptyRecycle = view.findViewById(R.id.emptyRecycle);
rcDiscovery = view.findViewById(R.id.rcDiscovery);
rcDiscovery.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// Ensure you call it only once
rcDiscovery.getViewTreeObserver().removeOnGlobalLayoutListener(this);
// Here you can get the size :)
if (rcDiscovery.getAdapter() instanceof DiscoveryAdapter) {
((DiscoveryAdapter) rcDiscovery.getAdapter()).setWidth(rcDiscovery.getWidth());
}
}
});
/**
*detect scroll down or up for tapcell send request
*/
pullToRefresh.setOnRefreshListener(() -> {
scroll = 1;
setRefreshing(true);
boolean isSend = updateOrFetchRecycleViewData();
rcDiscovery.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy <= 0) {
return;
} else {
if (scroll == 1)
BottomNavigationFragment.isShowedAdd = false;
}
scroll++;
}
});
if (!isSend) {
setRefreshing(false);
HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
}
});
emptyRecycle.setOnClickListener(v -> {
boolean isSend = updateOrFetchRecycleViewData();
if (!isSend) {
HelperError.showSnackMessage(getString(R.string.wallet_error_server), false);
}
});
// load user avatar in toolbar
// avatarHandler.getAvatar(new ParamWithAvatarType(mHelperToolbar.getAvatarSmall(), G.userId).avatarType(AvatarHandler.AvatarType.USER).showMain());
rcDiscovery.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
rcDiscovery.setAdapter(new DiscoveryAdapter(getActivity(), rcDiscovery.getWidth(), discoveryArrayList));
if (discoveryArrayList == null) {
tryToUpdateOrFetchRecycleViewData(0);
}
if (needToReload) {
updateOrFetchRecycleViewData();
}
}
use of net.iGap.module.Theme in project iGap-Android by KianIranian-STDG.
the class ElectricityBillListFrag method initRecycler.
private void initRecycler(Map<BillList.Bill, Debit> bills) {
adapter = new ElectricityBillListAdapter(getContext(), bills, (item, btnAction) -> {
// ServiceDebit temp = viewModel.getmMapData().getValue().get(item);
switch(btnAction) {
case PAY:
ServiceDebit tempService = (ServiceDebit) bills.get(item).getData();
viewModel.payServiceBill(tempService.getBillID(), tempService.getPaymentID(), tempService.getTotalElectricityBillDebt() != null ? tempService.getTotalElectricityBillDebt() : tempService.getTotalGasBillDebt(), ProtoMplGetBillToken.MplGetBillToken.Type.NONE_VALUE);
break;
case EDIT:
if (item.getBillTitle() == null) {
showDialog(getResources().getString(R.string.elecBill_error_title), getResources().getString(R.string.elecBill_error_notPossible), getResources().getString(R.string.ok));
return;
}
ElectricityBillAddFrag frag = ElectricityBillAddFrag.newInstance(viewModel.getBillInfo(item), true);
frag.setCompleteListener(new ElectricityBillAddFrag.CompleteListener() {
@Override
public void loadAgain() {
viewModel.getBillsList();
}
});
frag.show(getFragmentManager(), "BillAddEdit");
break;
case DELETE:
final MaterialDialog dialog = new MaterialDialog.Builder(getActivity()).title(R.string.elecBill_deleteBill_title).content(R.string.elecBill_deleteBill_desc).positiveText(R.string.elecBill_deleteBill_pos).negativeText(R.string.elecBill_deleteBill_neg).positiveColor(getContext().getResources().getColor(R.color.red)).widgetColor(new Theme().getAccentColor(getContext())).onPositive((dialog1, which) -> {
viewModel.deleteItem(item);
Toast.makeText(getContext(), "Deleted", Toast.LENGTH_SHORT).show();
}).build();
dialog.show();
break;
case SHOW_DETAIL:
if (item.getBillTitle() == null) {
showDialog(getResources().getString(R.string.elecBill_error_title), getResources().getString(R.string.elecBill_error_notPossible), getResources().getString(R.string.ok));
return;
}
BillInfo temp = viewModel.getBillInfo(item);
new HelperFragment(getFragmentManager(), ElectricityBillPayFrag.newInstance(temp.getBillType(), temp.getBillID(), temp.getTitle(), true)).setReplace(false).load();
break;
case MID_PAY:
MobileDebit tempMid = (MobileDebit) bills.get(item).getData();
viewModel.payServiceBill(tempMid.getMidTerm().getBillID(), tempMid.getMidTerm().getPayID(), tempMid.getMidTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.MID_TERM_VALUE);
break;
case LAST_PAY:
MobileDebit tempLast = (MobileDebit) bills.get(item).getData();
viewModel.payServiceBill(tempLast.getLastTerm().getBillID(), tempLast.getLastTerm().getPayID(), tempLast.getLastTerm().getAmount(), ProtoMplGetBillToken.MplGetBillToken.Type.LAST_TERM_VALUE);
break;
case RELOAD:
viewModel.reloadData(item);
}
});
binding.billRecycler.setAdapter(adapter);
}
Aggregations