修复异常 Fragment 创建传值问题
This commit is contained in:
parent
6a3c15e3e7
commit
bf7bc6b786
@ -46,16 +46,16 @@ public class GoogleFragment extends Fragment {
|
||||
public GoogleFragment() {
|
||||
}
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public GoogleFragment(String urls) {
|
||||
url = urls;
|
||||
Log.e("google", "111aa");
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
view = inflater.inflate(R.layout.activity_recharge, container, false);
|
||||
|
||||
assert getArguments() != null;
|
||||
url = getArguments().getString("url");
|
||||
|
||||
|
||||
if(StringUtil.isEmpty(url)){
|
||||
Log.e(TAG, "URL为空" );
|
||||
return view;
|
||||
|
@ -3,6 +3,7 @@ package com.yunbao.main.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -114,34 +115,89 @@ public class MyWalletActivity extends AbsActivity {
|
||||
});
|
||||
});
|
||||
|
||||
WalletFragment walletFragment;
|
||||
GoogleFragment googleFragment1;
|
||||
GoogleFragment googleFragment2;
|
||||
|
||||
final String[] titles = {mContext.getString(R.string.diamond), mContext.getString(R.string.coins), mContext.getString(R.string.golden_beans)};
|
||||
if (getIntent().getStringExtra("tag") != null) {
|
||||
Log.i("tss", "首充");
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == false) {
|
||||
//链接版本
|
||||
fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")),
|
||||
new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")),
|
||||
new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"))};
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
} else {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")),
|
||||
new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")),
|
||||
new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"))};
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
}
|
||||
} else {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == false) {
|
||||
Log.i("tss", "不是首充");
|
||||
//链接版本
|
||||
fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")),
|
||||
new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")),
|
||||
new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"))};
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
|
||||
} else {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")),
|
||||
new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0")),
|
||||
new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"))};
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
}
|
||||
}
|
||||
|
||||
fragments = new Fragment[]{googleFragment1,
|
||||
googleFragment2,
|
||||
walletFragment};
|
||||
|
||||
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator);
|
||||
CommonNavigator commonNavigator = new CommonNavigator(this);
|
||||
commonNavigator.setAdjustMode(true);
|
||||
@ -163,11 +219,11 @@ public class MyWalletActivity extends AbsActivity {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
vp_content.setCurrentItem(index);
|
||||
if (index==0){
|
||||
if (index == 0) {
|
||||
MobclickAgent.onEvent(mContext, "recharge_zs", "用户在充值页面选择左右切换到钻石或者点到钻石");
|
||||
}else if (index==1){
|
||||
} else if (index == 1) {
|
||||
MobclickAgent.onEvent(mContext, "recharge_xb", "用户在充值页面选择左右切换到星币或者点到星币");
|
||||
}else if (index==2){
|
||||
} else if (index == 2) {
|
||||
MobclickAgent.onEvent(mContext, "recharge_jd", "用户在充值页面选择左右切换到金豆或者点到金豆");
|
||||
}
|
||||
}
|
||||
|
@ -25,24 +25,23 @@ public class WalletFragment extends Fragment {
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
private Activity mContext;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public WalletFragment(Activity context, String urls) {
|
||||
Log.e("google", "222aa");
|
||||
url = urls;
|
||||
mContext = context;
|
||||
public WalletFragment() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//通过参数中的布局填充获取对应布局
|
||||
|
||||
assert getArguments() != null;
|
||||
url = getArguments().getString("url");
|
||||
|
||||
view = inflater.inflate(R.layout.activity_recharge, container, false);
|
||||
rlWebview = (WebView) view.findViewById(R.id.rlWebview);
|
||||
Log.e("ttt", url);
|
||||
rlWebview.loadUrl(url);
|
||||
|
||||
|
||||
WebSettings webSettings = rlWebview.getSettings();
|
||||
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
@ -53,7 +52,7 @@ public class WalletFragment extends Fragment {
|
||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
|
||||
|
||||
rlWebview.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, rlWebview).setPageClose(true), "androidObject");
|
||||
rlWebview.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(getActivity(), rlWebview).setPageClose(true), "androidObject");
|
||||
|
||||
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user