|
@@ -1,6 +1,8 @@
|
|
|
package com.cooleshow.teacher.ui.main;
|
|
|
|
|
|
import android.Manifest;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.MenuItem;
|
|
@@ -39,6 +41,8 @@ import androidx.fragment.app.Fragment;
|
|
|
|
|
|
import io.rong.imlib.RongIMClient;
|
|
|
|
|
|
+import static com.cooleshow.base.constanst.Constants.MAIN_PAGE_SELECT_POTION_KEY;
|
|
|
+
|
|
|
/**
|
|
|
* Author by pq, Date on 2022/4/20.
|
|
|
*/
|
|
@@ -49,12 +53,25 @@ public class MainActivity extends BaseMVPActivity<ActivityMainBinding, MainPrese
|
|
|
private MineFragment mMineFragment;
|
|
|
private MallFragment shopMallFragment;
|
|
|
|
|
|
+ /**
|
|
|
+ * 打开首页并选中指定tab
|
|
|
+ *
|
|
|
+ * @param context
|
|
|
+ * @param pos
|
|
|
+ */
|
|
|
+ public static void openAndSelectPos(Context context, int pos) {
|
|
|
+ Intent intent = new Intent(context, MainActivity.class);
|
|
|
+ intent.putExtra(MAIN_PAGE_SELECT_POTION_KEY, pos);
|
|
|
+ context.startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
QMUIStatusBarHelper.setStatusBarLightMode(this);
|
|
|
EventBus.getDefault().register(this);
|
|
|
+ parseIntent(getIntent());
|
|
|
}
|
|
|
|
|
|
@NonNull
|
|
@@ -64,6 +81,23 @@ public class MainActivity extends BaseMVPActivity<ActivityMainBinding, MainPrese
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ protected void onNewIntent(Intent intent) {
|
|
|
+ super.onNewIntent(intent);
|
|
|
+ parseIntent(getIntent());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void parseIntent(Intent intent) {
|
|
|
+ if (intent.hasExtra(MAIN_PAGE_SELECT_POTION_KEY)) {
|
|
|
+ //跳转选中某个tab
|
|
|
+ int selectPos = intent.getIntExtra(MAIN_PAGE_SELECT_POTION_KEY, 0);
|
|
|
+ if (selectPos >= mFragments.size()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ setPositionItem(selectPos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
protected void initView() {
|
|
|
HomePageAdapter homePageAdapter = new HomePageAdapter(this);
|
|
|
mHomeFragment = new HomeFragment();
|
|
@@ -90,6 +124,9 @@ public class MainActivity extends BaseMVPActivity<ActivityMainBinding, MainPrese
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public void setPositionItem(int position) {
|
|
|
+ viewBinding.navigation.setSelectedItemId(getViewBinding().navigation.getMenu().getItem(position).getItemId());
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public void onBackPressed() {
|