use of net.iGap.fragments.populaChannel.PopularChannelHomeFragment in project iGap-Android by KianIranian-STDG.
the class BaseViewHolder method handleDiscoveryFieldsClickStatic.
public static void handleDiscoveryFieldsClickStatic(DiscoveryItemField discoveryField, FragmentActivity activity, boolean haveNext) {
if (activity == null || activity.isFinishing()) {
return;
}
if (discoveryField.agreementSlug != null && discoveryField.agreementSlug.length() > 1) {
if (!discoveryField.agreement) {
DiscoveryFragmentAgreement.newInstance(discoveryField, discoveryField.agreementSlug).show(activity.getSupportFragmentManager(), null);
return;
}
}
new RequestClientSetDiscoveryItemClick().setDiscoveryClicked(discoveryField.id);
switch(discoveryField.actionType) {
case PAGE:
/**
* tested *
*/
actionPage(discoveryField.value, activity, haveNext);
break;
case JOIN_LINK:
int index = discoveryField.value.lastIndexOf("/");
if (index >= 0 && index < discoveryField.value.length() - 1) {
String token = discoveryField.value.substring(index + 1);
if (discoveryField.value.toLowerCase().contains("join")) {
HelperUrl.checkAndJoinToRoom(activity, token);
} else {
HelperUrl.checkUsernameAndGoToRoom(activity, token, HelperUrl.ChatEntry.profile);
}
}
break;
case WEB_LINK:
/**
* tested *
*/
SharedPreferences sharedPreferences = activity.getSharedPreferences(SHP_SETTING.FILE_NAME, Context.MODE_PRIVATE);
int checkedInAppBrowser = sharedPreferences.getInt(SHP_SETTING.KEY_IN_APP_BROWSER, 1);
if (checkedInAppBrowser == 1 && !HelperUrl.isNeedOpenWithoutBrowser(discoveryField.value)) {
HelperUrl.openBrowser(discoveryField.value);
} else {
HelperUrl.openWithoutBrowser(discoveryField.value);
}
break;
case IVAND:
new HelperFragment(activity.getSupportFragmentManager(), new FragmentUserScore()).setReplace(false).load();
break;
case IVANDQR:
UserScoreViewModel.scanBarCode(activity);
break;
case IVANDLIST:
new HelperFragment(activity.getSupportFragmentManager(), FragmentIVandActivities.newInstance()).setReplace(false).load();
break;
case WEB_VIEW_LINK:
/**
* tested title needed*
*/
if (HelperUrl.isNeedOpenWithoutBrowser(discoveryField.value)) {
HelperUrl.openWithoutBrowser(discoveryField.value);
} else {
new HelperFragment(activity.getSupportFragmentManager(), FragmentWebView.newInstance(discoveryField.value, discoveryField.refresh, discoveryField.param)).setReplace(false).load();
}
break;
case USERNAME_LINK:
/**
* tested *
*/
HelperUrl.checkUsernameAndGoToRoomWithMessageId(activity, discoveryField.value.replace("@", ""), HelperUrl.ChatEntry.chat, 0, 0);
break;
case TOPUP_MENU:
/**
* tested *
*/
new HelperFragment(activity.getSupportFragmentManager(), ChargeFragment.newInstance()).setReplace(false).load();
break;
case BILL_MENU:
try {
JSONObject jsonObject = new JSONObject(discoveryField.value);
new HelperFragment(activity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills, jsonObject)).setReplace(false).load();
} catch (JSONException e) {
new HelperFragment(activity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills)).setReplace(false).load();
}
break;
case TRAFFIC_BILL_MENU:
/**
* tested *
*/
try {
JSONObject jsonObject = new JSONObject(discoveryField.value);
new HelperFragment(activity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills_crime, jsonObject)).setReplace(false).load();
} catch (JSONException e) {
new HelperFragment(activity.getSupportFragmentManager(), FragmentPaymentBill.newInstance(R.string.pay_bills_crime)).setReplace(false).load();
}
break;
case PHONE_BILL_MENU:
/**
* tested *
*/
new HelperFragment(activity.getSupportFragmentManager(), new FragmentPaymentInquiryTelephone()).setReplace(false).load();
break;
case ELECTRIC_BILL_MENU:
new HelperFragment(activity.getSupportFragmentManager(), new ElectricityBillMainFrag()).setReplace(false).load();
// new HelperFragment(activity.getSupportFragmentManager(), new MobileBankLoginFragment()).setReplace(false).load();
break;
case PARSLAND:
break;
case FUN_SERVICE:
new HelperFragment(activity.getSupportFragmentManager(), new IGashtProvinceFragment()).setReplace(false).load();
break;
case BLOCKCHAIN:
break;
case VIRTUAL_GIFT_CARD:
break;
case NEWS:
NewsMainFrag frag = new NewsMainFrag();
if (!discoveryField.value.equals(""))
frag.setSpecificNewsID(discoveryField.value);
new HelperFragment(activity.getSupportFragmentManager(), frag).setReplace(false).load();
break;
case MOBILE_BILL_MENU:
/**
* tested *
*/
new HelperFragment(activity.getSupportFragmentManager(), new FragmentPaymentInquiryMobile()).setReplace(false).load();
break;
case FINANCIAL_MENU:
/**
* tested *
*/
new HelperFragment(activity.getSupportFragmentManager(), FragmentPayment.newInstance()).setReplace(false).load();
break;
case NEARBY_MENU:
/**
* tested *
*/
try {
HelperPermission.getLocationPermission(activity, new OnGetPermission() {
@Override
public void Allow() throws IOException {
try {
if (!waitingForConfiguration) {
waitingForConfiguration = true;
if (mapUrls == null || mapUrls.isEmpty() || mapUrls.size() == 0) {
G.onGeoGetConfiguration = new OnGeoGetConfiguration() {
@Override
public void onGetConfiguration() {
G.handler.postDelayed(new Runnable() {
@Override
public void run() {
waitingForConfiguration = false;
}
}, 2000);
new HelperFragment(activity.getSupportFragmentManager(), FragmentiGapMap.getInstance()).setReplace(false).load();
}
@Override
public void getConfigurationTimeOut() {
G.handler.postDelayed(new Runnable() {
@Override
public void run() {
waitingForConfiguration = false;
}
}, 2000);
}
};
new RequestGeoGetConfiguration().getConfiguration();
} else {
G.handler.postDelayed(new Runnable() {
@Override
public void run() {
waitingForConfiguration = false;
}
}, 2000);
new HelperFragment(activity.getSupportFragmentManager(), FragmentiGapMap.getInstance()).setReplace(false).load();
}
}
} catch (Exception e) {
e.getStackTrace();
}
}
@Override
public void deny() {
showDeniedPermissionMessage(G.context.getString(R.string.permission_location));
}
});
} catch (IOException e) {
e.printStackTrace();
}
break;
case REQUEST_PHONE:
// this item is for bot
break;
case REQUEST_LOCATION:
// this item is for bot
break;
case BOT_ACTION:
// this item is for bot
break;
case PAY_BY_WALLET:
// coming soon
break;
case PAY_DIRECT:
try {
JSONObject jsonObject = new JSONObject(discoveryField.value);
DirectPayHelper.directPay(jsonObject);
} catch (JSONException e) {
e.printStackTrace();
}
break;
case CALL:
/**
* tested *
*/
dialPhoneNumber(activity, discoveryField.value, activity);
break;
case SHOW_ALERT:
/**
* tested *
*/
new MaterialDialog.Builder(activity).content(discoveryField.value).positiveText(R.string.dialog_ok).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
}
}).show();
break;
case STREAM_PLAY:
// coming soon
break;
case STICKER_SHOP:
/**
* tested *
*/
StickerRepository.getInstance().getUserStickersGroup();
if (discoveryField.value.isEmpty()) {
new HelperFragment(activity.getSupportFragmentManager(), FragmentSettingAddStickers.newInstance("ALL")).setReplace(false).load();
} else {
try {
String title = "";
JSONObject jsonObject = new JSONObject(discoveryField.value);
if (jsonObject.has("title"))
title = jsonObject.getString("title");
if (jsonObject.has("group")) {
String category = jsonObject.getString("group");
if (!category.isEmpty()) {
if (jsonObject.has("type")) {
String type = jsonObject.getString("type");
new HelperFragment(activity.getSupportFragmentManager(), AddStickersFragment.newInstance(category, type, title)).setReplace(false).load();
} else {
new HelperFragment(activity.getSupportFragmentManager(), AddStickersFragment.newInstance(category, "ALL", title)).setReplace(false).load();
}
}
} else if (jsonObject.has("type")) {
String type = jsonObject.getString("type");
new HelperFragment(activity.getSupportFragmentManager(), FragmentSettingAddStickers.newInstance(type)).setReplace(false).load();
} else if (jsonObject.has("id")) {
String id = jsonObject.getString("id");
StickerDialogFragment dialogFragment = StickerDialogFragment.getInstance(id);
dialogFragment.show(activity.getSupportFragmentManager(), "BaseViewHolder");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
break;
case CARD_TO_CARD:
CardToCardHelper.CallCardToCard(activity);
break;
case IVANDSCORE:
new MaterialDialog.Builder(activity).content(R.string.are_you_sure_request).positiveText(R.string.yes).negativeText(R.string.no).onPositive((dialog, which) -> {
dialog.dismiss();
ActivityMain.doIvandScore(discoveryField.value, activity);
}).onNegative((dialog, which) -> {
dialog.dismiss();
}).show();
break;
case NONE:
break;
case POLL:
new HelperFragment(activity.getSupportFragmentManager(), PollFragment.newInstance(Integer.parseInt(HelperString.isNumeric(discoveryField.value) ? discoveryField.value : "0"))).setReplace(false).load();
break;
case POLL_RESULT:
new HelperFragment(activity.getSupportFragmentManager(), ChartFragment.newInstance(Integer.parseInt(HelperString.isNumeric(discoveryField.value) ? discoveryField.value : "0"))).setReplace(false).load();
break;
case FAVORITE_CHANNEL:
if (discoveryField.value.equals(""))
new HelperFragment(activity.getSupportFragmentManager(), new PopularChannelHomeFragment()).setReplace(false).load();
else {
PopularMoreChannelFragment popularMoreChannelFragment = new PopularMoreChannelFragment();
Bundle bundle = new Bundle();
bundle.putString("id", discoveryField.value);
popularMoreChannelFragment.setArguments(bundle);
new HelperFragment(activity.getSupportFragmentManager(), popularMoreChannelFragment).setReplace(false).load();
}
break;
case FINANCIAL_HISTORY:
new HelperFragment(activity.getSupportFragmentManager(), new MplTransactionFragment()).setReplace(false).load();
break;
case INTERNET_PACKAGE_MENU:
new HelperFragment(activity.getSupportFragmentManager(), InternetFragment.newInstance()).setReplace(false).load();
break;
case CHARITY:
try {
JSONObject jsonObject = new JSONObject(discoveryField.value);
if (jsonObject.getInt("price") == 0) {
new MaterialDialog.Builder(activity).title(activity.getResources().getString(R.string.insert_amount_in_rial)).customView(R.layout.charity_custom_amount, false).positiveText(activity.getResources().getString(R.string.B_ok)).negativeText(activity.getResources().getString(R.string.B_cancel)).onPositive((dialog, which) -> {
EditText editText = dialog.getView().findViewById(R.id.editText);
if (editText.getText() != null) {
if (editText.getText().toString().length() > 0) {
int price = Integer.parseInt(editText.getText().toString());
if (price > 10000) {
HelperUrl.showIndeterminateProgressDialog(activity);
try {
dialog.cancel();
sendRequestGetCharityPaymentToken(activity, jsonObject.getString("charityId"), price);
} catch (JSONException e) {
HelperUrl.closeDialogWaiting();
e.printStackTrace();
}
} else {
Toast.makeText(activity, activity.getResources().getString(R.string.amount_must_be_greater_10000), Toast.LENGTH_SHORT).show();
}
}
}
}).build().show();
} else {
HelperUrl.showIndeterminateProgressDialog(activity);
sendRequestGetCharityPaymentToken(activity, jsonObject.getString("charityId"), jsonObject.getInt("price"));
}
} catch (JSONException e) {
HelperUrl.closeDialogWaiting();
e.printStackTrace();
}
break;
case INVITE_FRIEND:
try {
HelperPermission.getContactPermision(activity, new OnGetPermission() {
@Override
public void Allow() {
new HelperFragment(activity.getSupportFragmentManager(), new LocalContactFragment()).setReplace(false).load(true);
}
@Override
public void deny() {
showDeniedPermissionMessage(G.context.getString(R.string.permission_contact));
}
});
} catch (IOException e) {
e.printStackTrace();
}
break;
case QRPAY:
new HelperFragment(activity.getSupportFragmentManager(), ScanCodeQRCodePaymentFragment.newInstance()).setReplace(false).load();
break;
default:
new MaterialDialog.Builder(activity).content(R.string.install_latest_version).positiveText(R.string.ok).onPositive((dialog, which) -> dialog.dismiss()).show();
break;
}
}
use of net.iGap.fragments.populaChannel.PopularChannelHomeFragment in project iGap-Android by KianIranian-STDG.
the class BottomNavigationFragment method setCrawlerMap.
private void setCrawlerMap(int position, String[] uri) {
try {
if (uri != null && uri.length > 0) {
if (!uri[0].equals(DEEP_LINK_DISCOVERY) && position == DISCOVERY_FRAGMENT) {
List<Integer> pages = new ArrayList<>();
for (String s : uri) {
pages.add(Integer.valueOf(s));
}
this.crawlerStruct = new DiscoveryFragment.CrawlerStruct(0, pages);
}
}
} catch (Exception e) {
HelperError.showSnackMessage(getResources().getString(R.string.link_not_valid), false);
}
if (position == bottomNavigation.getCurrentTab()) {
if (bottomNavigation.getSelectedItemPosition() == DISCOVERY_FRAGMENT) {
if (getActivity() != null && getActivity() instanceof ActivityMain)
((ActivityMain) getActivity()).removeAllFragmentFromMain();
if (getActivity() != null) {
DiscoveryFragment discoveryFragment = (DiscoveryFragment) getChildFragmentManager().findFragmentByTag(DiscoveryFragment.class.getName());
if (discoveryFragment != null) {
discoveryFragment.setNeedToCrawl(true);
discoveryFragment.discoveryCrawler(getActivity());
}
}
}
} else {
switch(position) {
case STORY_FRAGMENT:
bottomNavigation.setCurrentItem(STORY_FRAGMENT);
break;
case CALL_FRAGMENT:
bottomNavigation.setCurrentItem(CALL_FRAGMENT);
break;
case CHAT_FRAGMENT:
bottomNavigation.setCurrentItem(CHAT_FRAGMENT);
break;
case DISCOVERY_FRAGMENT:
DiscoveryFragment discoveryFragment = (DiscoveryFragment) getChildFragmentManager().findFragmentByTag(DiscoveryFragment.class.getName());
if (discoveryFragment != null)
discoveryFragment.setNeedToReload(true);
bottomNavigation.setCurrentItem(DISCOVERY_FRAGMENT);
break;
case POPULAR_CHANNEL_FRAGMENT:
if (uri != null)
if (uri.length > 1) {
PopularMoreChannelFragment popularMoreChannelFragment = new PopularMoreChannelFragment();
Bundle bundle = new Bundle();
bundle.putString("id", uri[1]);
popularMoreChannelFragment.setArguments(bundle);
new HelperFragment(getFragmentManager(), popularMoreChannelFragment).setReplace(false).load();
} else {
new HelperFragment(getFragmentManager(), new PopularChannelHomeFragment()).setReplace(false).load();
}
break;
case NEWS_FRAGMENT:
if (uri != null) {
NewsMainFrag frag = new NewsMainFrag();
switch(uri.length) {
case 2:
frag.setSpecificGroupID(uri[1]);
break;
case 3:
frag.setSpecificNewsID(uri[2]);
break;
default:
break;
}
new HelperFragment(getFragmentManager(), frag).setReplace(false).load(false);
}
break;
case PROFILE_FRAGMENT:
bottomNavigation.setCurrentItem(PROFILE_FRAGMENT);
break;
}
}
}
Aggregations