| | |
| | | import com.lcjian.library.util.common.ClipboardUtil; |
| | | import com.lcjian.library.util.common.PackageUtils2; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.util.security.AEScrypt; |
| | | import com.lcjian.library.util.security.DEScrypt; |
| | | import com.lcjian.library.util.security.MD5Utils; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.UserInfo; |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | import com.weikou.beibeivideo.util.JumpActivityUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | @JavascriptInterface |
| | | public String getUid() { |
| | | return mContext.getSharedPreferences("user", MODE_PRIVATE).getString("uid", ""); |
| | | return mContext.getSharedPreferences("user", MODE_PRIVATE).getString("LoginUid", ""); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public String getUserInfo() throws JSONException { |
| | | JSONObject data=new JSONObject(); |
| | | data.put("device",BeibeiVideoAPI.getDeviceId(mContext)); |
| | | UserInfo user = UserUtil.getLoginUserInfo(mContext); |
| | | if(user!=null){ |
| | | //获取用户头像与昵称 |
| | | data.put("login",true); |
| | | JSONObject userJSON=new JSONObject(); |
| | | userJSON.put("id",user.getId()); |
| | | userJSON.put("nickName",user.getNickname()); |
| | | userJSON.put("portrait",user.getPortrait()); |
| | | data.put("user",userJSON); |
| | | |
| | | }else{ |
| | | data.put("login",false); |
| | | } |
| | | return data.toString(); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public String getAppName(){ |
| | | return mContext.getString(R.string.app_name); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public String getVersion() { |
| | |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public void jumpWeb(String url) { |
| | | Intent intent = new Intent(mContext, BrowserActivity.class); |
| | | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | intent.putExtra("url", url); |
| | | mContext.startActivity(intent); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public String getRequestBaseParams(String json) { |
| | | LinkedHashMap<String, String> params = new LinkedHashMap<>(); |
| | | int version = PackageUtils2.getVersionCode(mContext); |
| | |
| | | |
| | | params.put("Package", mContext.getPackageName()); |
| | | params.put("Version", version + ""); |
| | | params.put("Device", SystemCommon.getDeviceId(mContext)); |
| | | params.put("Time",System.currentTimeMillis()+""); |
| | | params.put("Device", BeibeiVideoAPI.getDeviceId(mContext)); |
| | | params.put("Time", System.currentTimeMillis() + ""); |
| | | LinkedHashMap<String, String> map = BeibeiVideoAPI.validateParams(params, mContext); |
| | | |
| | | Gson gson = new Gson(); |
| | |
| | | public void clearClipboard() { |
| | | ClipboardUtil.emptyClipboard(mContext); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public String apiDecode(String result) { |
| | | return DEScrypt.decode(result); |
| | | } |
| | | |
| | | @JavascriptInterface |
| | | public String apiEncode(String result) { |
| | | return DEScrypt.encode(result); |
| | | } |
| | | |
| | | } |