| | |
| | | import android.graphics.Color; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentActivity; |
| | | |
| | | import android.util.Log; |
| | | import android.view.KeyEvent; |
| | | import android.view.MotionEvent; |
| | | import android.view.View; |
| | |
| | | import android.widget.Toast; |
| | | |
| | | import com.app.hubert.guide.util.ScreenUtils; |
| | | import com.coloros.mcssdk.PushManager; |
| | | import com.huawei.android.hms.agent.HMSAgent; |
| | | import com.huawei.android.hms.agent.push.handler.GetTokenHandler; |
| | | import com.tejia.lijin.app.entity.TrendsCategory; |
| | | import com.tejia.lijin.app.ui.dialog.GoodsDetailJumpLoaingDialog; |
| | | import com.tejia.lijin.app.ui.recommend.GoodsDetailActivity; |
| | | import com.tejia.lijin.app.ui.trends.SendCircleFragmet; |
| | | import com.tejia.lijin.app.util.Constant; |
| | | import com.tejia.lijin.app.util.TopStatusSettings; |
| | | import com.tejia.lijin.app.util.ui.HomeUIUtil; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.vivo.push.PushClient; |
| | | import com.wpc.library.okhttp.OkHttpUtils; |
| | | import com.wpc.library.util.FragmentSwitchHelper; |
| | | import com.wpc.library.util.MobileUtil; |
| | | import com.wpc.library.util.NetUtils; |
| | | import com.wpc.library.util.common.StringUtils; |
| | | import com.xiaomi.mipush.sdk.MiPushMessage; |
| | | import com.heytap.msp.push.HeytapPushManager; |
| | | import com.tejia.lijin.app.BasicTextHttpResponseHandler; |
| | | import com.tejia.lijin.app.BuXinConstant; |
| | | import com.tejia.lijin.app.R; |
| | |
| | | import com.tejia.lijin.app.callBack.LonginTaobaoCallback; |
| | | import com.tejia.lijin.app.callBack.MessagePush; |
| | | import com.tejia.lijin.app.entity.EventMessageEntity; |
| | | import com.tejia.lijin.app.entity.TrendsCategory; |
| | | import com.tejia.lijin.app.entity.eventbus.HomeTabChangeEvent; |
| | | import com.tejia.lijin.app.entity.eventbus.UserProtocolEvent; |
| | | import com.tejia.lijin.app.receiver.HWPushMessageReceiver; |
| | | import com.tejia.lijin.app.receiver.MiPushMessageReceiver; |
| | | import com.tejia.lijin.app.service.OPPOPushService; |
| | | import com.tejia.lijin.app.service.VIVOPushService; |
| | | import com.tejia.lijin.app.ui.BrandRebate.BrandFragment; |
| | | import com.tejia.lijin.app.ui.HMPushReceiveActivity; |
| | | import com.tejia.lijin.app.ui.PushOpenClickActivity; |
| | | import com.tejia.lijin.app.ui.dialog.LoginFirstDialog; |
| | | import com.tejia.lijin.app.ui.mine.ShoppingTrolleyActivity; |
| | | import com.tejia.lijin.app.util.DragFloatActionButton; |
| | |
| | | import com.tejia.lijin.app.util.clipboard.ClipboardUtil; |
| | | import com.tejia.lijin.app.util.clipboard.IClipboardContentListener; |
| | | import com.tejia.lijin.app.util.ui.ClipboardContentRecommendUtil; |
| | | import com.tejia.lijin.app.util.ui.HomeUIUtil; |
| | | import com.tejia.lijin.app.util.umengCustomEvent.MainCustomEvent; |
| | | import com.tejia.lijin.app.util.user.UserUtil; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.vivo.push.PushClient; |
| | | import com.wpc.library.okhttp.OkHttpUtils; |
| | | import com.wpc.library.util.FragmentSwitchHelper; |
| | | import com.wpc.library.util.NetUtils; |
| | | import com.wpc.library.util.common.StringUtils; |
| | | import com.xiaomi.mipush.sdk.MiPushMessage; |
| | | import com.yeshi.push.PushAppInfoFactory; |
| | | import com.yeshi.push.PushUtil; |
| | | import com.yeshi.push.entity.PushApps; |
| | | import com.yeshi.push.entity.PushRomType; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONArray; |
| | |
| | | import java.text.ParseException; |
| | | import java.util.List; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.fragment.app.FragmentActivity; |
| | | import de.greenrobot.event.EventBus; |
| | | |
| | | import static com.tejia.lijin.app.receiver.HWPushMessageReceiver.ACTION_TOKEN; |
| | | import static com.tejia.lijin.app.receiver.HWPushMessageReceiver.ACTION_UPDATEUI; |
| | | |
| | | |
| | | /** |
| | | * 主页 |
| | | */ |
| | | public class MainActivity extends FragmentActivity |
| | | implements HWPushMessageReceiver.IPushCallback, DragFloatActionInterface { |
| | | implements DragFloatActionInterface { |
| | | |
| | | private RadioGroup rg_nav; |
| | | private View v_no_login; |
| | |
| | | |
| | | spkefu = getSharedPreferences("kefurecord", Context.MODE_PRIVATE);//是否打开过客服 记录 |
| | | |
| | | if (MobileUtil.getDeviceBrand().equalsIgnoreCase("HUAWEI") |
| | | || MobileUtil.getDeviceBrand().equalsIgnoreCase("HONOR")) { |
| | | HWPushMessageReceiver.registerPushCallback(this);//推送集成到ToolUtil里面了 |
| | | getToken(); |
| | | } |
| | | |
| | | //获取 取消悬浮控件的宽高 |
| | | ViewTreeObserver vto2 = img.getViewTreeObserver(); |
| | | vto2.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { |
| | |
| | | choiceTab(fromTab, fromSubTab); |
| | | } else |
| | | ((RadioButton) findViewById(R.id.rb_nav_recommend)).setChecked(true); |
| | | registeredOPPOId();//上传OPPO_RegId |
| | | // onPush_OFF_NO();//检测是否打开推送 |
| | | registeredVIVOId();//上传VIVO_RegId |
| | | |
| | | //注册推送 |
| | | initPush(); |
| | | |
| | | |
| | | } |
| | | |
| | | private void initPush() { |
| | | PushApps pushApps = new PushApps(); |
| | | pushApps.setHw(PushAppInfoFactory.createHuaWei(getResources().getString(R.string.push_hw_appid))); |
| | | pushApps.setOppo(PushAppInfoFactory.createOPPO(getResources().getString(R.string.push_oppo_app_key), getResources().getString(R.string.push_oppo_app_secret))); |
| | | pushApps.setVivo(PushAppInfoFactory.createVIVO(getResources().getString(R.string.push_vivo_app_id), getResources().getString(R.string.push_vivo_api_key))); |
| | | pushApps.setXm(PushAppInfoFactory.createXM(getResources().getString(R.string.mipush_appid), getResources().getString(R.string.mipush_appkey))); |
| | | PushUtil.inintPush(ShoppingApplication.application, pushApps, new PushUtil.ITokenListener() { |
| | | |
| | | @Override |
| | | public void onToken(PushRomType romType, String regId) { |
| | | ShoppingApi.bindPushToken(getApplicationContext(), UserUtil.getUid(getApplicationContext()), romType, regId, null); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void choiceTab(Integer tab, Integer subTab) { |
| | |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /***注册VIVO_ID**/ |
| | | private void registeredVIVOId() { |
| | | if (PushClient.getInstance(img.getContext()).isSupport()) { |
| | | if (NetUtils.isNetConnected(img.getContext())) { |
| | | ToolUtil.registeredVIVORegId(img.getContext()); |
| | | } else { |
| | | startService(new Intent(img.getContext(), VIVOPushService.class)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 注册oppoid |
| | | */ |
| | | private void registeredOPPOId() { |
| | | if (PushManager.isSupportPush(getApplicationContext())) { |
| | | if (NetUtils.isNetConnected(getApplicationContext())) { |
| | | ToolUtil.registeredOPPOId(getApplicationContext()); |
| | | } else { |
| | | startService(new Intent(getApplicationContext(), OPPOPushService.class)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /* |
| | | 华为推送获取token |
| | | */ |
| | | private void getToken() { |
| | | Log.e("mResult", "get token: begin"); |
| | | HMSAgent.Push.getToken(new GetTokenHandler() { |
| | | @Override |
| | | public void onResult(int rst) { |
| | | Log.e("mResult", "get token end: " + rst); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | SharedPreferences sp; |
| | |
| | | acbutton.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | PushOpenClickActivity.resumeJumpActivity(this); |
| | | } |
| | | |
| | | private void getRecommendInfoFromClipboard() { |
| | |
| | | |
| | | private static long lastBindHWTime = 0; |
| | | |
| | | @Override |
| | | public void onReceive(Intent intent) { |
| | | Log.e("eee", "onReceive: "); |
| | | if (intent != null) { |
| | | String token = ""; |
| | | String action = intent.getAction(); |
| | | Bundle b = intent.getExtras(); |
| | | if (b != null && ACTION_TOKEN.equals(action)) { |
| | | token = b.getString(ACTION_TOKEN); |
| | | } else if (b != null && ACTION_UPDATEUI.equals(action)) { |
| | | } |
| | | Log.e("eee", "onReceive: token" + token); |
| | | SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); |
| | | if (MobileUtil.getDeviceBrand().equalsIgnoreCase("HUAWEI") |
| | | || MobileUtil.getDeviceBrand().equalsIgnoreCase("HONOR")) { |
| | | Log.e("eee", "HONOR: "); |
| | | //防止多次请求 |
| | | if (System.currentTimeMillis() - lastBindHWTime > 1000 * 5) {//5s后再请求 |
| | | lastBindHWTime = System.currentTimeMillis(); |
| | | Log.e("eee", "上传token"); |
| | | ShoppingApi.bindHMPush(MainActivity.this, token, UserUtil.getUid(ShoppingApplication.application), null); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 开启或关闭推送 |
| | | */ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void onNewIntent(Intent intent) { |
| | | super.onNewIntent(intent); |
| | | int p = intent.getIntExtra("p", 0); |
| | | switch (p) { |
| | | case 0: |
| | | rg_nav.check(R.id.rb_nav_recommend); |
| | | |
| | | break; |
| | | case 1: |
| | | rg_nav.check(R.id.rb_nav_hot_sale); |
| | | break; |
| | | case 2: |
| | | rg_nav.check(R.id.rb_nav_better_goods); |
| | | break; |
| | | case 3: |
| | | rg_nav.check(R.id.rb_nav_mine); |
| | | break; |
| | | } |
| | | |
| | | } |
| | | } |