| | |
| | | import android.net.wifi.WifiManager; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.annotation.Nullable; |
| | | import android.support.v4.app.LoaderManager; |
| | | import android.support.v4.content.CursorLoader; |
| | | import android.support.v4.content.Loader; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.loader.app.LoaderManager; |
| | | import androidx.loader.content.CursorLoader; |
| | | import androidx.loader.content.Loader; |
| | | |
| | | import android.util.Log; |
| | | import android.view.KeyEvent; |
| | | import android.view.View; |
| | | import android.view.Window; |
| | | import android.view.WindowManager; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.RadioButton; |
| | | import android.widget.RadioGroup; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.load.DataSource; |
| | | import com.bumptech.glide.load.engine.GlideException; |
| | | import com.bumptech.glide.request.RequestListener; |
| | | import com.bumptech.glide.request.target.SimpleTarget; |
| | | import com.bumptech.glide.request.target.Target; |
| | | import com.bumptech.glide.request.transition.Transition; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.db.MessageTable; |
| | | import com.weikou.beibeivideo.entity.NewComment; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.ui.BaseActivity; |
| | | import com.weikou.beibeivideo.ui.baidu.BaiDuNewsFragment; |
| | | import com.weikou.beibeivideo.ui.baidu.BaiDuVideosFragment; |
| | |
| | | import com.weikou.beibeivideo.ui.mine.BrowserActivity; |
| | | import com.weikou.beibeivideo.ui.mine.SystemMessageActivity; |
| | | import com.weikou.beibeivideo.ui.mine.WatchHistoryActivity; |
| | | import com.weikou.beibeivideo.ui.push.PushOpenClickActivity; |
| | | import com.weikou.beibeivideo.ui.recommend.SearchActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | | import com.weikou.beibeivideo.util.ExitDialog; |
| | | import com.weikou.beibeivideo.util.LoginFirstDialog; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.util.ad.manager.SearchResultAdManager; |
| | | import com.ysh.wpc.appupdate.AppUpdate; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | import com.yeshi.appupdate.AppUpdate; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONArray; |
| | | import org.json.JSONObject; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStreamReader; |
| | | import java.lang.reflect.Type; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | |
| | | public class MainActivity extends BaseActivity implements |
| | | LoaderManager.LoaderCallbacks<Cursor>, View.OnClickListener { |
| | | |
| | | private static final String TGA = "MainActivity"; |
| | | private ImageView iv_taobao; |
| | | |
| | | private ImageView iv_red_dot; |
| | |
| | | |
| | | exitDialog = exitDialogBuilder.create(); |
| | | exitDialog.setCanceledOnTouchOutside(true); |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | Window window = getWindow(); |
| | | window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, |
| | | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | int result = 0; |
| | | int resourceId = getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
| | | result); |
| | | findViewById(R.id.v_status_bar).setLayoutParams(params); |
| | | findViewById(R.id.v_status_bar).setVisibility(View.VISIBLE); |
| | | } else { |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | // 将imei mac lat lng存入sharedpreference中 |
| | | SharedPreferences mPre = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | WifiManager wifi = (WifiManager) this.getApplicationContext().getSystemService(Context.WIFI_SERVICE); |
| | | WifiInfo info = wifi.getConnectionInfo(); |
| | | |
| | | Editor editor = mPre.edit(); |
| | | if (StringUtils.isEmpty(getMacAddress())) { |
| | | editor.putString("mac", info.getMacAddress()); |
| | | } else { |
| | | editor.putString("mac", getMacAddress()); |
| | | } |
| | | editor.commit(); |
| | | |
| | | tv_search = findViewById(R.id.tv_activity_main_search); |
| | | |
| | |
| | | iv_taobao.setOnClickListener(this); |
| | | iv_red_dot = findViewById(R.id.iv_red_dot); |
| | | fl_right_ad = findViewById(R.id.fl_right_ad); |
| | | |
| | | /* |
| | | * 计算状态栏高度并设置 |
| | | */ |
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
| | | Window window = getWindow(); |
| | | window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, |
| | | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
| | | int result = 0; |
| | | int resourceId = getResources().getIdentifier("status_bar_height", |
| | | "dimen", "android"); |
| | | if (resourceId > 0) { |
| | | result = getResources().getDimensionPixelSize(resourceId); |
| | | } |
| | | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, |
| | | result); |
| | | findViewById(R.id.v_status_bar).setLayoutParams(params); |
| | | } else { |
| | | findViewById(R.id.v_status_bar).setVisibility(View.GONE); |
| | | } |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | |
| | | initialer.run(); |
| | | |
| | |
| | | }); |
| | | setRightTopAD(); |
| | | preLoadCommonAD(); |
| | | |
| | | |
| | | if (BeibeiConstant.IS_TEST) { |
| | | tv_search.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | VideoInfo videoInfo = new VideoInfo(); |
| | | videoInfo.setId("8065880"); |
| | | videoInfo.setThirdType("0"); |
| | | Intent intent = new Intent(MainActivity.this, SearchActivity.class); |
| | | intent.putExtra("video_info", videoInfo); |
| | | startActivity(intent); |
| | | } |
| | | }, 2000); |
| | | } |
| | | |
| | | //拉取详情问题 |
| | | UserUtil.updateUserInfo(getApplicationContext(), null); |
| | | } |
| | | |
| | | |
| | |
| | | addDownloadBuxin(preferences.getString("shopurl", "")); |
| | | } |
| | | EventBus.getDefault().register(this); |
| | | |
| | | PushOpenClickActivity.resumeJumpActivity(this); |
| | | } |
| | | |
| | | |
| | |
| | | EventBus.getDefault().unregister(this); |
| | | } |
| | | |
| | | /* |
| | | * **************************************************************** |
| | | * 子函数:获得本地MAC地址 |
| | | * **************************************************************** |
| | | */ |
| | | private String getMacAddress() { |
| | | String result = ""; |
| | | String Mac = ""; |
| | | result = callCmd("busybox ifconfig", "HWaddr"); |
| | | |
| | | // 如果返回的result == null,则说明网络不可取 |
| | | if (result == null) { |
| | | return "网络出错,请检查网络"; |
| | | } |
| | | |
| | | // 对该行数据进行解析 |
| | | // 例如:eth0 Link encap:Ethernet HWaddr 00:16:E8:3E:DF:67 |
| | | if (result.length() > 0 && result.contains("HWaddr") == true) { |
| | | Mac = result.substring(result.indexOf("HWaddr") + 6, |
| | | result.length() - 1); |
| | | if (Mac.length() > 1) { |
| | | Mac = Mac.replaceAll(" ", ""); |
| | | result = ""; |
| | | String[] tmp = Mac.split(":"); |
| | | for (int i = 0; i < tmp.length; ++i) { |
| | | result += tmp[i]; |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private String callCmd(String cmd, String filter) { |
| | | String result = ""; |
| | |
| | | |
| | | @Override |
| | | public void run() { |
| | | // ((RadioButton) findViewById(R.id.rb_nav_recommend)) |
| | | // .setChecked(true); |
| | | // startDownloadService(); |
| | | AppUpdate.setAppUpdateKey(BeibeiConstant.UPDATE_ID); |
| | | AppUpdate.setAppUpdateActivity(MainActivity.this, false); |
| | | AppUpdate.initAppUpdate(); |
| | | // getScoreOpen(); |
| | | } |
| | | }; |
| | | |
| | | |
| | | private String buXinPackageName = "com.yeshi.ec.miduo"; |
| | | |
| | | private void mateAppMarket1() { |
| | | final List<ApplicationInfo> list = MarketUtils.filterInstalledPkgs(this, getPackageName()); |
| | | if (list != null && list.size() > 0) { |
| | | if (Build.BRAND.equalsIgnoreCase("XiaoMi")) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).packageName.equalsIgnoreCase("com.xiaomi.market")) { |
| | | MarketUtils.launchAppDetailtoDownload(MainActivity.this, buXinPackageName, list.get(i).packageName); |
| | | break; |
| | | } else if ((!list.get(i).packageName |
| | | .equalsIgnoreCase("com.xiaomi.market")) |
| | | && (i == list.size() - 1)) { |
| | | MarketUtils.launchAppDetailtoDownload( |
| | | MainActivity.this, |
| | | buXinPackageName, |
| | | list.get(0).packageName); |
| | | } |
| | | } |
| | | } else if (Build.BRAND.equalsIgnoreCase("MeiZu")) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).packageName.equalsIgnoreCase("com.meizu.mstore")) { |
| | | MarketUtils.launchAppDetailtoDownload(MainActivity.this, buXinPackageName, list.get(i).packageName); |
| | | break; |
| | | } else if ((!list.get(i).packageName |
| | | .equalsIgnoreCase("com.meizu.mstore")) |
| | | && (i == list.size() - 1)) { |
| | | MarketUtils.launchAppDetailtoDownload( |
| | | MainActivity.this, |
| | | buXinPackageName, |
| | | list.get(0).packageName); |
| | | } |
| | | } |
| | | } else if (Build.BRAND.equalsIgnoreCase("CoolPad")) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).packageName.equalsIgnoreCase("com.yulong.android.coolmart")) { |
| | | MarketUtils.launchAppDetailtoDownload(MainActivity.this, buXinPackageName, list.get(i).packageName); |
| | | break; |
| | | } else if ((!list.get(i).packageName |
| | | .equalsIgnoreCase("com.yulong.android.coolmart")) |
| | | && (i == list.size() - 1)) { |
| | | MarketUtils.launchAppDetailtoDownload( |
| | | MainActivity.this, buXinPackageName, |
| | | list.get(0).packageName); |
| | | } |
| | | } |
| | | } else if (Build.BRAND.equalsIgnoreCase("OPPO")) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).packageName.equalsIgnoreCase("com.oppo.market")) { |
| | | MarketUtils.launchAppDetailtoDownload(MainActivity.this, buXinPackageName, list.get(i).packageName); |
| | | break; |
| | | } else if ((!list.get(i).packageName |
| | | .equalsIgnoreCase("com.oppo.market")) |
| | | && (i == list.size() - 1)) { |
| | | MarketUtils.launchAppDetailtoDownload( |
| | | MainActivity.this, buXinPackageName, |
| | | list.get(0).packageName); |
| | | } |
| | | } |
| | | } else if (Build.BRAND.equalsIgnoreCase("vivo")) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).packageName.equalsIgnoreCase("com.bbk.appstore")) { |
| | | MarketUtils.launchAppDetailtoDownload(MainActivity.this, buXinPackageName, list.get(i).packageName); |
| | | break; |
| | | } else if ((!list.get(i).packageName |
| | | .equalsIgnoreCase("com.bbk.appstore")) |
| | | && (i == list.size() - 1)) { |
| | | MarketUtils.launchAppDetailtoDownload( |
| | | MainActivity.this, buXinPackageName, |
| | | list.get(0).packageName); |
| | | } |
| | | } |
| | | } else if (Build.BRAND.equalsIgnoreCase("HuaWei")) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).packageName.equalsIgnoreCase("com.huawei.appmarket")) { |
| | | MarketUtils.launchAppDetailtoDownload(MainActivity.this, buXinPackageName, list.get(i).packageName); |
| | | break; |
| | | } else if ((!list.get(i).packageName |
| | | .equalsIgnoreCase("com.huawei.appmarket")) |
| | | && (i == list.size() - 1)) { |
| | | MarketUtils.launchAppDetailtoDownload( |
| | | MainActivity.this, buXinPackageName, |
| | | list.get(0).packageName); |
| | | } |
| | | } |
| | | } else { |
| | | MarketUtils.launchAppDetailtoDownload(MainActivity.this, buXinPackageName, list.get(0).packageName); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void getScoreOpen() { |
| | | SharedPreferences preferences = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | BeibeiVideoAPI.getScoreOpen(this, uid, |
| | | new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | } |
| | | }); |
| | | } |
| | | |
| | | ExitDialog exitDialog = null; |
| | | ExitDialog.Builder exitDialogBuilder = null; |
| | |
| | | SharedPreferences preferences = getSharedPreferences("user", |
| | | Context.MODE_PRIVATE); |
| | | String uid = preferences.getString("uid", ""); |
| | | BeibeiVideoAPI.getHotSearch(this, uid, |
| | | BeibeiVideoAPI.getSearchRank(this, |
| | | new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, |
| | | Header[] headers, JSONObject jsonObject) |
| | | throws Exception { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | List<String> hotSearchs = gson.fromJson(jsonObject |
| | | .getJSONObject("Data").getJSONArray("data") |
| | | .toString(), new TypeToken<List<String>>() { |
| | | }.getType()); |
| | | Random random = new Random(); |
| | | int p = random.nextInt(hotSearchs.size()); |
| | | tv_search.setText(hotSearchs.get(p)); |
| | | JSONObject data = jsonObject.getJSONObject("Data").getJSONObject("data"); |
| | | if (data != null) |
| | | for (Iterator<String> its = data.keys(); its.hasNext(); ) { |
| | | String key = its.next(); |
| | | if (key.contains("热搜")) { |
| | | Type type = new TypeToken<List<String>>() { |
| | | }.getType(); |
| | | Gson gson = new Gson(); |
| | | JSONArray array = data.optJSONArray(key); |
| | | if (array != null) { |
| | | List<String> list = gson.fromJson(array.toString(), type); |
| | | if (list != null && list.size() > 0) { |
| | | Random random = new Random(); |
| | | int p = random.nextInt(list.size()); |
| | | tv_search.setText(list.get(p)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | protected void onNewIntent(Intent intent) { |
| | | Log.i(TGA, "onNewIntent"); |
| | | String position = intent.getStringExtra("position"); |
| | | if (StringUtils.isEmpty(position)) |
| | | return; |
| | | switch (Integer.parseInt(position)) { |
| | | case 0: |
| | | rg_nav.check(R.id.rb_nav_recommend); |
| | | break; |
| | | case 1: |
| | | rg_nav.check(R.id.rb_nav_discover); |
| | | break; |
| | | case 2: |
| | | rg_nav.check(R.id.rb_guess_like); |
| | | break; |
| | | case 3: |
| | | rg_nav.check(R.id.rb_nav_category); |
| | | break; |
| | | case 4: |
| | | rg_nav.check(R.id.rb_nav_mine); |
| | | break; |
| | | } |
| | | |
| | | |
| | | super.onNewIntent(intent); |
| | | |
| | | |
| | | } |
| | | } |