xl121 1 yıl önce
ebeveyn
işleme
27502a7e17
24 değiştirilmiş dosya ile 1276 ekleme ve 50 silme
  1. 11 2
      TMessagesProj/src/main/AndroidManifest.xml
  2. 1 0
      TMessagesProj/src/main/java/org/telegram/cricdit/net/LogInterceptor.java
  3. 3 2
      TMessagesProj/src/main/java/org/telegram/messenger/GcmPushListenerService.java
  4. 78 0
      TMessagesProj/src/main/java/org/telegram/onecric/adapter/SubscribeTypeAdapter.java
  5. 10 0
      TMessagesProj/src/main/java/org/telegram/onecric/mvp/bean/CricketMatchBean.java
  6. 43 0
      TMessagesProj/src/main/java/org/telegram/onecric/mvp/bean/SubscribeTypeBean.java
  7. 40 0
      TMessagesProj/src/main/java/org/telegram/onecric/mvp/presenter/SubscribePresenter.java
  8. 14 6
      TMessagesProj/src/main/java/org/telegram/onecric/net/ApiStores.java
  9. 121 10
      TMessagesProj/src/main/java/org/telegram/onecric/ui/activity/CricketDetailActivity.java
  10. 542 0
      TMessagesProj/src/main/java/org/telegram/onecric/ui/activity/NewCricketDetailActivity.java
  11. 93 4
      TMessagesProj/src/main/java/org/telegram/onecric/utils/DialogUtil.java
  12. 10 9
      TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
  13. 10 0
      TMessagesProj/src/main/res/anim/bottomview_anim_enter.xml
  14. 10 0
      TMessagesProj/src/main/res/anim/bottomview_anim_exit.xml
  15. 7 0
      TMessagesProj/src/main/res/drawable/shape_c8c8c8_5dp_rec.xml
  16. 7 0
      TMessagesProj/src/main/res/drawable/shape_c_e05526_10dp_rec.xml
  17. 18 5
      TMessagesProj/src/main/res/layout/activity_cricket_detail.xml
  18. 212 0
      TMessagesProj/src/main/res/layout/dialog_select_subscribe.xml
  19. 31 0
      TMessagesProj/src/main/res/layout/subscribe_type_item.xml
  20. BIN
      TMessagesProj/src/main/res/mipmap-xxhdpi/subscribe.png
  21. BIN
      TMessagesProj/src/main/res/mipmap-xxhdpi/unsubscribe.png
  22. BIN
      TMessagesProj/src/main/res/mipmap-xxxhdpi/subscribe.png
  23. BIN
      TMessagesProj/src/main/res/mipmap-xxxhdpi/unsubscribe.png
  24. 15 12
      TMessagesProj/src/main/res/values/styles.xml

+ 11 - 2
TMessagesProj/src/main/AndroidManifest.xml

@@ -43,8 +43,8 @@
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />
-<!--    <uses-permission android:name="android.permission.READ_CONTACTS" />-->
-<!--    <uses-permission android:name="android.permission.WRITE_CONTACTS" />-->
+    <!--    <uses-permission android:name="android.permission.READ_CONTACTS" />-->
+    <!--    <uses-permission android:name="android.permission.WRITE_CONTACTS" />-->
     <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
     <uses-permission android:name="android.permission.READ_PROFILE" />
     <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
@@ -765,6 +765,15 @@
 
         <service android:name="org.telegram.cricdit.service.SyncDataService" />
 
+        <service
+            android:name=".GcmPushListenerService"
+            android:exported="false">
+            <intent-filter>
+                <action android:name="com.google.firebase.MESSAGING_EVENT" />
+            </intent-filter>
+        </service>
+
+
     </application>
 
 </manifest>

+ 1 - 0
TMessagesProj/src/main/java/org/telegram/cricdit/net/LogInterceptor.java

@@ -25,6 +25,7 @@ public class LogInterceptor implements Interceptor {
     @Override
     public Response intercept(@NonNull Chain chain) throws IOException {
         Request request = chain.request();
+        if(request.body()!=null)
         Log.e(tag, "request:" + request.body().toString());
         long t1 = System.nanoTime();
         Response response = chain.proceed(chain.request());

+ 3 - 2
TMessagesProj/src/main/java/org/telegram/messenger/GcmPushListenerService.java

@@ -71,6 +71,7 @@ public class GcmPushListenerService extends FirebaseMessagingService {
         if (bundle.size() > 0) {
             intent.setClass(this, CricketDetailActivity.class);
             intent.putExtra("matchId", Integer.parseInt(bundle.get("matchId")));
+            intent.putExtra("isNotification", true);
             PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
                     PendingIntent.FLAG_IMMUTABLE);
 
@@ -78,8 +79,8 @@ public class GcmPushListenerService extends FirebaseMessagingService {
             Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
             NotificationCompat.Builder notificationBuilder =
                     new NotificationCompat.Builder(this, channelId)
-                            .setSmallIcon(R.mipmap.ic_launcher)
-                            .setContentTitle("FCM Message")
+                            .setSmallIcon(R.drawable.launcher_icon)
+                            .setContentTitle(remoteMessage.getNotification().getTitle())
                             .setContentText(remoteMessage.getNotification().getBody())
                             .setAutoCancel(true)
                             .setSound(defaultSoundUri)

+ 78 - 0
TMessagesProj/src/main/java/org/telegram/onecric/adapter/SubscribeTypeAdapter.java

@@ -0,0 +1,78 @@
+package org.telegram.onecric.adapter;
+
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.Switch;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.BaseViewHolder;
+
+import org.telegram.messenger.R;
+import org.telegram.onecric.mvp.bean.SubscribeTypeBean;
+
+import java.util.List;
+
+/**
+ * 开发公司:东莞市梦幻科技有限公司
+ * 时间:2022/8/27
+ */
+public class SubscribeTypeAdapter extends BaseQuickAdapter<SubscribeTypeBean, BaseViewHolder> {
+    private Switch aSwitch;
+
+    public SubscribeTypeAdapter(Switch aSwitch, int layoutResId, @Nullable List<SubscribeTypeBean> data) {
+        super(layoutResId, data);
+        this.aSwitch = aSwitch;
+    }
+
+    @Override
+    protected void convert(@NonNull BaseViewHolder helper, SubscribeTypeBean item) {
+        TextView tv_name = helper.getView(R.id.tv_name);
+        tv_name.setText(item.getName());
+        CheckBox checkbox = helper.getView(R.id.checkbox);
+        if (aSwitch.isChecked()) {
+            checkbox.setEnabled(true);
+        } else {
+            checkbox.setEnabled(false);
+        }
+        checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                if (isChecked) {
+                    item.setIs_subscribe(1);
+                } else {
+                    item.setIs_subscribe(0);
+                }
+            }
+        });
+        List<SubscribeTypeBean> list = getData();
+        aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                if (!isChecked) {
+                    for (SubscribeTypeBean item : list) {
+                        item.setSelect_subscribe(item.getIs_subscribe());
+                        if (item.getIs_subscribe() == 1) {
+                            item.setIs_subscribe(0);
+                        }
+                    }
+                } else {
+                    for (SubscribeTypeBean item : list) {
+                        if (item.getSelect_subscribe() == 1) {
+                            item.setIs_subscribe(1);
+                        }
+                    }
+                }
+                notifyDataSetChanged();
+            }
+        });
+        if (item.getIs_subscribe() == 1) {
+            checkbox.setChecked(true);
+        } else {
+            checkbox.setChecked(false);
+        }
+    }
+}

+ 10 - 0
TMessagesProj/src/main/java/org/telegram/onecric/mvp/bean/CricketMatchBean.java

@@ -31,6 +31,16 @@ public class CricketMatchBean implements Serializable {
     private String date;
     private String opponent_name;
 
+    public int getIs_subscribe() {
+        return is_subscribe;
+    }
+
+    public void setIs_subscribe(int is_subscribe) {
+        this.is_subscribe = is_subscribe;
+    }
+
+    private int is_subscribe;
+
     public int getId() {
         return id;
     }

+ 43 - 0
TMessagesProj/src/main/java/org/telegram/onecric/mvp/bean/SubscribeTypeBean.java

@@ -0,0 +1,43 @@
+package org.telegram.onecric.mvp.bean;
+
+public class SubscribeTypeBean {
+    private String type;
+
+    private String name;
+
+    private int is_subscribe;
+
+    public int getSelect_subscribe() {
+        return select_subscribe;
+    }
+
+    public void setSelect_subscribe(int select_subscribe) {
+        this.select_subscribe = select_subscribe;
+    }
+
+    private int select_subscribe;
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getType() {
+        return this.type;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setIs_subscribe(int is_subscribe) {
+        this.is_subscribe = is_subscribe;
+    }
+
+    public int getIs_subscribe() {
+        return this.is_subscribe;
+    }
+}

+ 40 - 0
TMessagesProj/src/main/java/org/telegram/onecric/mvp/presenter/SubscribePresenter.java

@@ -0,0 +1,40 @@
+package org.telegram.onecric.mvp.presenter;
+
+import com.alibaba.fastjson.JSONObject;
+
+
+import org.telegram.onecric.base.BasePresenter;
+import org.telegram.onecric.net.ApiCallback;
+import org.telegram.onecric.net.ApiClient;
+import org.telegram.onecric.net.ApiStores;
+
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.schedulers.Schedulers;
+
+public class SubscribePresenter extends BasePresenter {
+
+    public void doSubscribe(String mid, String type, DisposableObserver observer) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("mid", mid);
+        jsonObject.put("type", type);
+        ApiClient.retrofit().create(ApiStores.class)
+                .doSubscribe(getRequestBody(jsonObject))
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribeWith(observer);
+//        addSubscription(apiStores.doSubscribe(getRequestBody(jsonObject)), observer);
+    }
+
+    public void getSubscribeType(int mid, DisposableObserver observer) {
+        ApiClient.retrofit().create(ApiStores.class)
+                .getSubscribeType(mid)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribeWith(observer);
+//        JSONObject jsonObject = new JSONObject();
+//        jsonObject.put("mid", mid);
+//        addSubscription(apiStores.getSubscribeType(getRequestBody(jsonObject)), observer);
+    }
+
+}

+ 14 - 6
TMessagesProj/src/main/java/org/telegram/onecric/net/ApiStores.java

@@ -689,12 +689,12 @@ public interface ApiStores {
     //获取篮球赛事列表
     @GET("api/Basketball_database/tournamentList")
     Observable<JsonObject> getBasketBallMatchDataList(@Query("country_id") int country_id,
-                                            @Query("category_id") int category_id);
+                                                      @Query("category_id") int category_id);
 
     //获取篮球赛事列表
     @GET("api/Football_database/tournamentList")
     Observable<JsonObject> getFootBallMatchDataList(@Query("country_id") int country_id,
-                                            @Query("category_id") int category_id);
+                                                    @Query("category_id") int category_id);
 
     //获取篮球赛事详情
     @GET("api/Basketball_database/competitionInfo")
@@ -715,7 +715,7 @@ public interface ApiStores {
     //获取篮球球员列表
     @GET("api/Basketball_database/teamMember")
     Observable<JsonObject> getBasketballMatchDataBestMember(@Query("id") int id,
-                                                          @Query("type") int type);
+                                                            @Query("type") int type);
 
     //获取足球赛事详情
     @GET("api/football_database/competitionInfo")
@@ -731,17 +731,17 @@ public interface ApiStores {
     //获取足球赛程积分
     @GET("api/Football_database/integral")
     Observable<JsonObject> getFootballMatchDataRanking(@Query("season_id") int season_id,
-                                                     @Query("integral_type") int integral_type);
+                                                       @Query("integral_type") int integral_type);
 
     //获取足球球队列表
     @GET("api/Football_database/TeamData")
     Observable<JsonObject> getFootballMatchDataBestTeam(@Query("id") int id,
-                                                          @Query("type") int type);
+                                                        @Query("type") int type);
 
     //获取足球球员列表
     @GET("api/Football_database/teamMember")
     Observable<JsonObject> getFootballMatchDataBestMember(@Query("id") int id,
-                                                            @Query("type") int type);
+                                                          @Query("type") int type);
 
     //获取轮播图
     @GET("api/banner/getBannerList")
@@ -830,4 +830,12 @@ public interface ApiStores {
     //获取赛事详情-scorecard
     @POST("api/Cricket/cricket_match_detail_scorecard")
     Observable<JsonObject> getMatchScorecard(@Body RequestBody body);
+
+    //订阅赛事消息推送   todo 完成
+    @POST("api/Cricket/subscribe_add")
+    Observable<JsonObject> doSubscribe(@Body RequestBody body);
+
+    //获取订阅推送消息的类型
+    @GET("api/Cricket/subscribe_type")
+    Observable<JsonObject> getSubscribeType(@Query("mid") int mid);
 }

+ 121 - 10
TMessagesProj/src/main/java/org/telegram/onecric/ui/activity/CricketDetailActivity.java

@@ -19,26 +19,35 @@ import androidx.fragment.app.Fragment;
 import androidx.fragment.app.FragmentPagerAdapter;
 import androidx.viewpager.widget.ViewPager;
 
+import com.alibaba.fastjson.JSONObject;
 import com.google.android.material.tabs.TabLayout;
 import com.lxj.xpopup.XPopup;
 
 import org.telegram.cricdit.utils.ToastUtil;
 import org.telegram.cricdit.view.popup.ReportBottomPopup;
 import org.telegram.messenger.R;
+import org.telegram.messenger.UserConfig;
 import org.telegram.onecric.base.MvpActivity;
 import org.telegram.onecric.config.HttpConstant;
 import org.telegram.onecric.mvp.bean.CricketMatchBean;
+import org.telegram.onecric.mvp.bean.SubscribeTypeBean;
 import org.telegram.onecric.mvp.bean.UpdatesBean;
 import org.telegram.onecric.mvp.presenter.CricketDetailPresenter;
+import org.telegram.onecric.mvp.presenter.SubscribePresenter;
 import org.telegram.onecric.mvp.view.CricketDetailView;
+import org.telegram.onecric.net.ApiCallback;
 import org.telegram.onecric.ui.fragment.CricketFantasyFragment;
 import org.telegram.onecric.ui.fragment.CricketInfoFragment;
 import org.telegram.onecric.ui.fragment.CricketLiveFragment;
 import org.telegram.onecric.ui.fragment.CricketScorecardFragment;
 import org.telegram.onecric.ui.fragment.CricketSquadFragment;
 import org.telegram.onecric.ui.fragment.CricketUpdatesFragment;
+import org.telegram.onecric.utils.DialogUtil;
 import org.telegram.onecric.utils.GlideUtil;
 import org.telegram.onecric.utils.ShareUtil;
+import org.telegram.ui.ActionBar.BaseFragment;
+import org.telegram.ui.LaunchActivity;
+import org.telegram.ui.LoginActivity;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -48,6 +57,11 @@ import java.util.List;
  * 时间:2022/8/27
  */
 public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> implements CricketDetailView, View.OnClickListener {
+
+    private boolean isNotification;
+    private ImageView subscribeIv;
+
+
     public static void forward(Context context, int matchId) {
         Intent intent = new Intent(context, CricketDetailActivity.class);
         intent.putExtra("matchId", matchId);
@@ -103,6 +117,7 @@ public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> i
     @Override
     protected void initView() {
         mMatchId = getIntent().getIntExtra("matchId", 0);
+        isNotification = getIntent().getBooleanExtra("isNotification", false);
         ll_content = findViewById(R.id.ll_content);
         cl_one = findViewById(R.id.cl_one);
         tv_home_name = findViewById(R.id.tv_home_name);
@@ -127,21 +142,22 @@ public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> i
         mFlWebview2 = findViewById(R.id.fl_webview2);
         mWvAnimation = findViewById(R.id.wv_animation);
         mWvVideo = findViewById(R.id.wv_video);
+        subscribeIv = findViewById(R.id.iv_subscribe);
 
         findViewById(R.id.tv_animation).setOnClickListener(this);
         findViewById(R.id.tv_video).setOnClickListener(this);
         findViewById(R.id.iv_back_three).setOnClickListener(this);
         findViewById(R.id.iv_back_four).setOnClickListener(this);
 
-        ((ImageView)findViewById(R.id.iv_right)).setBackgroundResource(R.mipmap.icon_share2);
-        ((ImageView)findViewById(R.id.iv_right)).setOnClickListener(new View.OnClickListener() {
+        ((ImageView) findViewById(R.id.iv_right)).setBackgroundResource(R.mipmap.icon_share2);
+        ((ImageView) findViewById(R.id.iv_right)).setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 ShareUtil.shareText(mActivity, "", HttpConstant.CRICKET_DETAIL_URL + mMatchId);
             }
         });
 
-        ((ImageView)findViewById(R.id.inner_report)).setOnClickListener(new View.OnClickListener() {
+        ((ImageView) findViewById(R.id.inner_report)).setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 new XPopup.Builder(CricketDetailActivity.this)
@@ -179,6 +195,9 @@ public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> i
         initViewPager();
         mvpPresenter.getDetail(mMatchId);
         mvpPresenter.getUpdatesDetail(mMatchId);
+        if (isNotification) {
+            mViewPager.setCurrentItem(2);
+        }
     }
 
     private void initViewPager() {
@@ -233,13 +252,13 @@ public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> i
     public void getDataSuccess(CricketMatchBean model) {
         if (model != null) {
             mModel = model;
-            ((CricketFantasyFragment)mViewList.get(0)).getData(mMatchId, model.getHome_name(), model.getHome_logo(), model.getAway_name(), model.getAway_logo());
+            ((CricketFantasyFragment) mViewList.get(0)).getData(mMatchId, model.getHome_name(), model.getHome_logo(), model.getAway_name(), model.getAway_logo());
             if (!TextUtils.isEmpty(model.getTournament_id())) {
-                ((CricketInfoFragment)mViewList.get(1)).getList(model.getHome_id(), model.getAway_id(), Integer.valueOf(model.getTournament_id()));
+                ((CricketInfoFragment) mViewList.get(1)).getList(model.getHome_id(), model.getAway_id(), Integer.valueOf(model.getTournament_id()));
             }
             //TODO 暂时屏蔽
 //            ((CricketSquadFragment)mViewList.get(5)).getList(mMatchId, model.getHome_name(), model.getHome_logo(), model.getAway_name(), model.getAway_logo());
-            ((CricketSquadFragment)mViewList.get(4)).getList(mMatchId, model.getHome_name(), model.getHome_logo(), model.getAway_name(), model.getAway_logo());
+            ((CricketSquadFragment) mViewList.get(4)).getList(mMatchId, model.getHome_name(), model.getHome_logo(), model.getAway_name(), model.getAway_logo());
 
             if (model.getStatus() == 0) {
                 cl_one.setVisibility(View.GONE);
@@ -259,7 +278,7 @@ public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> i
                     SpannableStringBuilder builder = new SpannableStringBuilder(strOne + strTwo);
                     builder.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.c_DC3C23)), strOne.length(), (strOne.length() + strTwo.length()), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
                     tv_center.setText(builder);
-                }else {
+                } else {
                     tv_center.setText(strOne);
                 }
                 String str = "";
@@ -270,7 +289,7 @@ public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> i
                     str = str + model.getVenue_name();
                 }
                 tv_desc_two.setText(str);
-            }else {
+            } else {
                 cl_one.setVisibility(View.VISIBLE);
                 cl_two.setVisibility(View.GONE);
                 if (!TextUtils.isEmpty(model.getHome_name())) {
@@ -297,12 +316,41 @@ public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> i
                     tv_desc.setText(model.getMatch_result());
                 }
             }
+            if (model.getStatus() == 2) {
+                subscribeIv.setVisibility(View.GONE);
+            } else {
+                subscribeIv.setVisibility(View.VISIBLE);// TODO: 2023/2/15  这里在订阅接口调试好后要放开为visible
+                if (model.getIs_subscribe() == 1) {//已经订阅过了
+                    subscribeIv.setImageResource(R.mipmap.subscribe);
+                } else {
+                    subscribeIv.setImageResource(R.mipmap.unsubscribe);
+                }
+                subscribeIv.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        if (!UserConfig.getInstance(UserConfig.selectedAccount).isClientActivated()) {
+                            ToastUtil.show(CricketDetailActivity.this, getString(R.string.please_login));
+                            // TODO: 2023/3/16  需要跳转到登陆界面
+//                            return;
+                        }
+                        getSubscribeType(model, subscribeIv);
+                        // TODO: 2023/2/14  订阅消息推送
+//                    //这里先弹出一个订阅消息的内容选择框  待选择好后点击确定订阅按钮再调用订阅接口
+//                    DialogUtil.showSelectSubscribeDialog(mContext, item.getHome_name() + " VS " + item.getAway_name(), new DialogUtil.SelectSubscribeBack() {
+//                        @Override
+//                        public void onSelectSubscribe(String type) {
+//                            doSubscribe(item.getMatch_id() + "", , subscribeIv);
+//                        }
+//                    });
+                    }
+                });
+            }
             //初始化动画直播地址
             initWebViewOne(mModel.getLive_path());
             //初始化视频直播地址
 //            initWebViewTwo(mModel.getLive_url());
             //请求记分卡数据
-            ((CricketScorecardFragment)mViewList.get(3)).getData(mModel);
+            ((CricketScorecardFragment) mViewList.get(3)).getData(mModel);
         }
     }
 
@@ -378,7 +426,7 @@ public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> i
 
     @Override
     public void getDataFail(String msg) {
-        ToastUtil.show(mActivity,msg);
+        ToastUtil.show(mActivity, msg);
         finish();
     }
 
@@ -414,4 +462,67 @@ public class CricketDetailActivity extends MvpActivity<CricketDetailPresenter> i
             mWvVideo.destroy();
         }
     }
+
+    private void doSubscribe(String matchId, String type, ImageView subscribeIv) {//订阅推送消息
+        new SubscribePresenter().doSubscribe(matchId, type, new ApiCallback() {
+            @Override
+            public void onSuccess(String data, String msg) {
+                if (!TextUtils.isEmpty(type)) {
+                    subscribeIv.setImageResource(R.mipmap.subscribe);
+                } else {
+                    subscribeIv.setImageResource(R.mipmap.unsubscribe);
+                }
+            }
+
+            @Override
+            public void onFailure(String msg) {
+                ToastUtil.show(CricketDetailActivity.this, msg);
+            }
+
+            @Override
+            public void onError(String msg) {
+                ToastUtil.show(CricketDetailActivity.this, msg);
+            }
+
+            @Override
+            public void onFinish() {
+
+            }
+        });
+    }
+
+    private void getSubscribeType(CricketMatchBean item, ImageView subscribeIv) {//订阅推送消息
+        showLoadingDialog();
+        new SubscribePresenter().getSubscribeType(item.getId(), new ApiCallback() {
+            @Override
+            public void onSuccess(String data, String msg) {
+                dismissLoadingDialog();
+                if (data != null) {
+                    List<SubscribeTypeBean> list = JSONObject.parseArray(JSONObject.parseObject(data).getString("list"), SubscribeTypeBean.class);
+                    //这里先弹出一个订阅消息的内容选择框  待选择好后点击确定订阅按钮再调用订阅接口
+                    DialogUtil.showSelectSubscribeDialog(CricketDetailActivity.this, item.getHome_name() + " VS " + item.getAway_name(), list, new DialogUtil.SelectSubscribeBack() {
+                        @Override
+                        public void onSelectSubscribe(String type) {
+                            doSubscribe(item.getId() + "", type, subscribeIv);
+                        }
+                    });
+                }
+            }
+
+            @Override
+            public void onFailure(String msg) {
+                dismissLoadingDialog();
+            }
+
+            @Override
+            public void onError(String msg) {
+                dismissLoadingDialog();
+            }
+
+            @Override
+            public void onFinish() {
+                dismissLoadingDialog();
+            }
+        });
+    }
 }

+ 542 - 0
TMessagesProj/src/main/java/org/telegram/onecric/ui/activity/NewCricketDetailActivity.java

@@ -0,0 +1,542 @@
+//package org.telegram.onecric.ui.activity;
+//
+//import android.app.Activity;
+//import android.content.Context;
+//import android.content.Intent;
+//import android.text.SpannableStringBuilder;
+//import android.text.Spanned;
+//import android.text.TextUtils;
+//import android.text.style.ForegroundColorSpan;
+//import android.view.View;
+//import android.view.ViewGroup;
+//import android.webkit.WebSettings;
+//import android.webkit.WebView;
+//import android.widget.FrameLayout;
+//import android.widget.ImageView;
+//import android.widget.LinearLayout;
+//import android.widget.TextView;
+//
+//import androidx.fragment.app.Fragment;
+//import androidx.fragment.app.FragmentPagerAdapter;
+//import androidx.viewpager.widget.ViewPager;
+//
+//import com.alibaba.fastjson.JSONObject;
+//import com.google.android.material.tabs.TabLayout;
+//import com.lxj.xpopup.XPopup;
+//
+//import org.telegram.cricdit.base.BaseTabActivity;
+//import org.telegram.cricdit.utils.ToastUtil;
+//import org.telegram.cricdit.view.popup.ReportBottomPopup;
+//import org.telegram.messenger.R;
+//import org.telegram.messenger.UserConfig;
+//import org.telegram.onecric.base.MvpActivity;
+//import org.telegram.onecric.config.HttpConstant;
+//import org.telegram.onecric.mvp.bean.CricketMatchBean;
+//import org.telegram.onecric.mvp.bean.SubscribeTypeBean;
+//import org.telegram.onecric.mvp.bean.UpdatesBean;
+//import org.telegram.onecric.mvp.presenter.CricketDetailPresenter;
+//import org.telegram.onecric.mvp.presenter.SubscribePresenter;
+//import org.telegram.onecric.mvp.view.CricketDetailView;
+//import org.telegram.onecric.net.ApiCallback;
+//import org.telegram.onecric.ui.fragment.CricketFantasyFragment;
+//import org.telegram.onecric.ui.fragment.CricketInfoFragment;
+//import org.telegram.onecric.ui.fragment.CricketLiveFragment;
+//import org.telegram.onecric.ui.fragment.CricketScorecardFragment;
+//import org.telegram.onecric.ui.fragment.CricketSquadFragment;
+//import org.telegram.onecric.utils.DialogUtil;
+//import org.telegram.onecric.utils.GlideUtil;
+//import org.telegram.onecric.utils.ShareUtil;
+//
+//import java.util.ArrayList;
+//import java.util.List;
+//
+///**
+// * 开发公司:东莞市梦幻科技有限公司
+// * 时间:2022/8/27
+// */
+//public class NewCricketDetailActivity extends BaseTabActivity<CricketDetailPresenter> implements CricketDetailView, View.OnClickListener {
+//
+//    private boolean isNotification;
+//    private ImageView subscribeIv;
+//
+//
+//    public static void forward(Context context, int matchId) {
+//        Intent intent = new Intent(context, NewCricketDetailActivity.class);
+//        intent.putExtra("matchId", matchId);
+//        context.startActivity(intent);
+//    }
+//
+//    private int mMatchId;
+//    private FrameLayout mFlWebview1;
+//    private WebView mWvAnimation;
+//    private FrameLayout mFlWebview2;
+//    private WebView mWvVideo;
+//    private LinearLayout ll_content;
+//    //已开始
+//    private ViewGroup cl_one;
+//    private TextView tv_home_name;
+//    private ImageView iv_home_logo;
+//    private TextView tv_home_score;
+//    private TextView tv_home_round;
+//    private TextView tv_away_name;
+//    private ImageView iv_away_logo;
+//    private TextView tv_away_score;
+//    private TextView tv_away_round;
+//    private TextView tv_desc;
+//    //未开始
+//    private ViewGroup cl_two;
+//    private TextView tv_home_name_two;
+//    private ImageView iv_home_logo_two;
+//    private TextView tv_center;
+//    private ImageView iv_away_logo_two;
+//    private TextView tv_away_name_two;
+//    private TextView tv_desc_two;
+//    private TabLayout tabLayout;
+//    public ViewPager mViewPager;
+//    private List<Fragment> mViewList;
+//
+//    private CricketMatchBean mModel;
+//
+////    @Override
+////    public boolean getStatusBarTextColor() {
+////        return true;
+////    }
+//
+//    @Override
+//    protected int getLayoutResId() {
+//        return R.layout.activity_cricket_detail;
+//    }
+//
+//    @Override
+//    public String setActionBarTitle() {
+//        return null;
+//    }
+//
+//    @Override
+//    protected CricketDetailPresenter createPresenter() {
+//        return new CricketDetailPresenter(this);
+//    }
+//
+//    @Override
+//    protected void initView(View view) {
+//        mMatchId = getIntent().getIntExtra("matchId", 0);
+//        isNotification = getIntent().getBooleanExtra("isNotification", false);
+//        ll_content = view.findViewById(R.id.ll_content);
+//        cl_one = view.findViewById(R.id.cl_one);
+//        tv_home_name = view.findViewById(R.id.tv_home_name);
+//        iv_home_logo = view.findViewById(R.id.iv_home_logo);
+//        tv_home_score = view.findViewById(R.id.tv_home_score);
+//        tv_home_round = view.findViewById(R.id.tv_home_round);
+//        tv_away_name = view.findViewById(R.id.tv_away_name);
+//        iv_away_logo = view.findViewById(R.id.iv_away_logo);
+//        tv_away_score = view.findViewById(R.id.tv_away_score);
+//        tv_away_round = view.findViewById(R.id.tv_away_round);
+//        tv_desc = view.findViewById(R.id.tv_desc);
+//        cl_two = view.findViewById(R.id.cl_two);
+//        tv_home_name_two = view.findViewById(R.id.tv_home_name_two);
+//        iv_home_logo_two = view.findViewById(R.id.iv_home_logo_two);
+//        tv_center = view.findViewById(R.id.tv_center);
+//        iv_away_logo_two = view.findViewById(R.id.iv_away_logo_two);
+//        tv_away_name_two = view.findViewById(R.id.tv_away_name_two);
+//        tv_desc_two = view.findViewById(R.id.tv_desc_two);
+//        tabLayout = view.findViewById(R.id.tab_layout);
+//        mViewPager = view.findViewById(R.id.view_pager);
+//        mFlWebview1 = view.findViewById(R.id.fl_webview1);
+//        mFlWebview2 = view.findViewById(R.id.fl_webview2);
+//        mWvAnimation = view.findViewById(R.id.wv_animation);
+//        mWvVideo = view.findViewById(R.id.wv_video);
+//        subscribeIv = view.findViewById(R.id.iv_subscribe);
+//
+//        view.findViewById(R.id.tv_animation).setOnClickListener(this);
+//        view.findViewById(R.id.tv_video).setOnClickListener(this);
+//        view.findViewById(R.id.iv_back_three).setOnClickListener(this);
+//        view.findViewById(R.id.iv_back_four).setOnClickListener(this);
+//
+//        ((ImageView) view.findViewById(R.id.iv_right)).setBackgroundResource(R.mipmap.icon_share2);
+//        ((ImageView) view.findViewById(R.id.iv_right)).setOnClickListener(new View.OnClickListener() {
+//            @Override
+//            public void onClick(View v) {
+//                ShareUtil.shareText(getContext(), "", HttpConstant.CRICKET_DETAIL_URL + mMatchId);
+//            }
+//        });
+//
+//        ((ImageView) view.findViewById(R.id.inner_report)).setOnClickListener(new View.OnClickListener() {
+//            @Override
+//            public void onClick(View v) {
+//                new XPopup.Builder(getContext())
+//                        .moveUpToKeyboard(false) //如果不加这个,评论弹窗会移动到软键盘上面
+//                        .enableDrag(true)
+//                        .isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
+//                        .asCustom(new ReportBottomPopup(getContext()))
+//                        .show();
+//            }
+//        });
+//
+//        initData();
+//
+//    }
+//
+//    protected void initData() {
+//        tabLayout.addTab(tabLayout.newTab().setText(getContext().getString(R.string.fantasy)));
+//        tabLayout.addTab(tabLayout.newTab().setText(getContext().getString(R.string.info)));
+//        tabLayout.addTab(tabLayout.newTab().setText(getContext().getString(R.string.live)));
+//        tabLayout.addTab(tabLayout.newTab().setText(getContext().getString(R.string.scorecard)));
+////        tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.highlights)));
+//        //TODO 暂时屏蔽
+////        tabLayout.addTab(tabLayout.newTab().setText(getString(R.string.updates)));
+//        tabLayout.addTab(tabLayout.newTab().setText(getContext().getString(R.string.squad)));
+//
+//        mViewList = new ArrayList<>();
+//        mViewList.add(CricketFantasyFragment.newInstance());
+//        mViewList.add(CricketInfoFragment.newInstance(mMatchId));
+//        mViewList.add(CricketLiveFragment.newInstance(mMatchId));
+//        mViewList.add(CricketScorecardFragment.newInstance());
+////        mViewList.add(CricketFantasyFragment.newInstance());
+//        //TODO 暂时屏蔽
+////        mViewList.add(CricketUpdatesFragment.newInstance());
+//        mViewList.add(CricketSquadFragment.newInstance());
+//
+//        initViewPager();
+//        mvpPresenter.getDetail(mMatchId);
+//        mvpPresenter.getUpdatesDetail(mMatchId);
+//        if (isNotification) {
+//            mViewPager.setCurrentItem(2);
+//        }
+//    }
+//
+//    private void initViewPager() {
+//        tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
+//            @Override
+//            public void onTabSelected(TabLayout.Tab tab) {
+//                mViewPager.setCurrentItem(tab.getPosition());
+//            }
+//
+//            @Override
+//            public void onTabUnselected(TabLayout.Tab tab) {
+//
+//            }
+//
+//            @Override
+//            public void onTabReselected(TabLayout.Tab tab) {
+//
+//            }
+//        });
+//        //初始化viewpager
+//        mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
+//            @Override
+//            public void onPageScrolled(int i, float v, int i1) {
+//
+//            }
+//
+//            @Override
+//            public void onPageSelected(int i) {
+//                tabLayout.getTabAt(i).select();
+//            }
+//
+//            @Override
+//            public void onPageScrollStateChanged(int i) {
+//
+//            }
+//        });
+//        mViewPager.setOffscreenPageLimit(mViewList.size());
+//        mViewPager.setAdapter(new FragmentPagerAdapter() {
+//            @Override
+//            public Fragment getItem(int i) {
+//                return mViewList.get(i);
+//            }
+//
+//            @Override
+//            public int getCount() {
+//                return mViewList.size();
+//            }
+//        });
+//    }
+//
+//    @Override
+//    public void showLoading() {
+//
+//    }
+//
+//    @Override
+//    public void hideLoading() {
+//
+//    }
+//
+//    @Override
+//    public void getDataSuccess(CricketMatchBean model) {
+//        if (model != null) {
+//            mModel = model;
+//            ((CricketFantasyFragment) mViewList.get(0)).getData(mMatchId, model.getHome_name(), model.getHome_logo(), model.getAway_name(), model.getAway_logo());
+//            if (!TextUtils.isEmpty(model.getTournament_id())) {
+//                ((CricketInfoFragment) mViewList.get(1)).getList(model.getHome_id(), model.getAway_id(), Integer.valueOf(model.getTournament_id()));
+//            }
+//            //TODO 暂时屏蔽
+////            ((CricketSquadFragment)mViewList.get(5)).getList(mMatchId, model.getHome_name(), model.getHome_logo(), model.getAway_name(), model.getAway_logo());
+//            ((CricketSquadFragment) mViewList.get(4)).getList(mMatchId, model.getHome_name(), model.getHome_logo(), model.getAway_name(), model.getAway_logo());
+//
+//            if (model.getStatus() == 0) {
+//                cl_one.setVisibility(View.GONE);
+//                cl_two.setVisibility(View.VISIBLE);
+//                if (!TextUtils.isEmpty(model.getHome_name())) {
+//                    tv_home_name_two.setText(model.getHome_name());
+//                }
+//                GlideUtil.loadTeamImageDefault(this, model.getHome_logo(), iv_home_logo_two);
+//
+//                if (!TextUtils.isEmpty(model.getAway_name())) {
+//                    tv_away_name_two.setText(model.getAway_name());
+//                }
+//                GlideUtil.loadTeamImageDefault(this, model.getAway_logo(), iv_away_logo_two);
+//                String strOne = getContext().getString(R.string.match_starts_in);
+//                if (!TextUtils.isEmpty(model.getLive_time())) {
+//                    String strTwo = model.getLive_time();
+//                    SpannableStringBuilder builder = new SpannableStringBuilder(strOne + strTwo);
+//                    builder.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.c_DC3C23)), strOne.length(), (strOne.length() + strTwo.length()), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
+//                    tv_center.setText(builder);
+//                } else {
+//                    tv_center.setText(strOne);
+//                }
+//                String str = "";
+//                if (!TextUtils.isEmpty(model.getMatch_result())) {
+//                    str = model.getMatch_result() + "\n";
+//                }
+//                if (!TextUtils.isEmpty(model.getVenue_name())) {
+//                    str = str + model.getVenue_name();
+//                }
+//                tv_desc_two.setText(str);
+//            } else {
+//                cl_one.setVisibility(View.VISIBLE);
+//                cl_two.setVisibility(View.GONE);
+//                if (!TextUtils.isEmpty(model.getHome_name())) {
+//                    tv_home_name.setText(model.getHome_name());
+//                }
+//                GlideUtil.loadTeamImageDefault(this, model.getHome_logo(), iv_home_logo);
+//                if (!TextUtils.isEmpty(model.getHome_display_score())) {
+//                    tv_home_score.setText(model.getHome_display_score());
+//                }
+//                if (!TextUtils.isEmpty(model.getHome_display_overs())) {
+//                    tv_home_round.setText("(" + model.getHome_display_overs() + ")");
+//                }
+//                if (!TextUtils.isEmpty(model.getAway_name())) {
+//                    tv_away_name.setText(model.getAway_name());
+//                }
+//                GlideUtil.loadTeamImageDefault(this, model.getAway_logo(), iv_away_logo);
+//                if (!TextUtils.isEmpty(model.getAway_display_score())) {
+//                    tv_away_score.setText(model.getAway_display_score());
+//                }
+//                if (!TextUtils.isEmpty(model.getAway_display_overs())) {
+//                    tv_away_round.setText("(" + model.getAway_display_overs() + ")");
+//                }
+//                if (!TextUtils.isEmpty(model.getMatch_result())) {
+//                    tv_desc.setText(model.getMatch_result());
+//                }
+//            }
+//            if (model.getStatus() == 2) {
+//                subscribeIv.setVisibility(View.GONE);
+//            } else {
+//                subscribeIv.setVisibility(View.VISIBLE);// TODO: 2023/2/15  这里在订阅接口调试好后要放开为visible
+//                if (model.getIs_subscribe() == 1) {//已经订阅过了
+//                    subscribeIv.setImageResource(R.mipmap.subscribe);
+//                } else {
+//                    subscribeIv.setImageResource(R.mipmap.unsubscribe);
+//                }
+//                subscribeIv.setOnClickListener(new View.OnClickListener() {
+//                    @Override
+//                    public void onClick(View v) {
+//                        if (!UserConfig.getInstance(UserConfig.selectedAccount).isClientActivated()) {
+//                            ToastUtil.show(NewCricketDetailActivity.this, getString(R.string.please_login));
+//                            // TODO: 2023/3/16  需要跳转到登陆界面
+////                            return;
+//                        }
+//                        getSubscribeType(model, subscribeIv);
+//                        // TODO: 2023/2/14  订阅消息推送
+////                    //这里先弹出一个订阅消息的内容选择框  待选择好后点击确定订阅按钮再调用订阅接口
+////                    DialogUtil.showSelectSubscribeDialog(mContext, item.getHome_name() + " VS " + item.getAway_name(), new DialogUtil.SelectSubscribeBack() {
+////                        @Override
+////                        public void onSelectSubscribe(String type) {
+////                            doSubscribe(item.getMatch_id() + "", , subscribeIv);
+////                        }
+////                    });
+//                    }
+//                });
+//            }
+//            //初始化动画直播地址
+//            initWebViewOne(mModel.getLive_path());
+//            //初始化视频直播地址
+////            initWebViewTwo(mModel.getLive_url());
+//            //请求记分卡数据
+//            ((CricketScorecardFragment) mViewList.get(3)).getData(mModel);
+//        }
+//    }
+//
+//    @Override
+//    public void getUpdatesDataSuccess(List<UpdatesBean> list) {
+//        //TODO 暂时屏蔽
+////        ((CricketUpdatesFragment)mViewList.get(4)).setData(list);
+//    }
+//
+//    private void initWebViewOne(String url) {
+//        if (TextUtils.isEmpty(url)) {
+//            return;
+//        }
+//        /* 设置支持Js */
+//        mWvAnimation.getSettings().setJavaScriptEnabled(true);
+//        /* 设置为true表示支持使用js打开新的窗口 */
+//        mWvAnimation.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
+//
+//        /* 设置缓存模式 */
+//        mWvAnimation.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
+//        mWvAnimation.getSettings().setDomStorageEnabled(true);
+//
+//        /* 设置为使用webview推荐的窗口 */
+////        mWebView.getSettings().setUseWideViewPort(true);
+//        /* 设置为使用屏幕自适配 */
+//        mWvAnimation.getSettings().setLoadWithOverviewMode(true);
+//        /* 设置是否允许webview使用缩放的功能,我这里设为false,不允许 */
+//        mWvAnimation.getSettings().setBuiltInZoomControls(false);
+//        /* 提高网页渲染的优先级 */
+//        mWvAnimation.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
+//
+//        /* HTML5的地理位置服务,设置为true,启用地理定位 */
+//        mWvAnimation.getSettings().setGeolocationEnabled(true);
+//        /* 设置可以访问文件 */
+//        mWvAnimation.getSettings().setAllowFileAccess(true);
+//
+//        // 设置UserAgent标识
+////        mWebView.getSettings().setUserAgentString(mWebView.getSettings().getUserAgentString() + " app-shikuimapp");
+//        mWvAnimation.loadUrl(url);
+//    }
+//
+//    private void initWebViewTwo(String url) {
+//        if (TextUtils.isEmpty(url)) {
+//            return;
+//        }
+//        /* 设置支持Js */
+//        mWvVideo.getSettings().setJavaScriptEnabled(true);
+//        /* 设置为true表示支持使用js打开新的窗口 */
+//        mWvVideo.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
+//
+//        /* 设置缓存模式 */
+//        mWvVideo.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
+//        mWvVideo.getSettings().setDomStorageEnabled(true);
+//
+//        /* 设置为使用webview推荐的窗口 */
+////        mWebView.getSettings().setUseWideViewPort(true);
+//        /* 设置为使用屏幕自适配 */
+//        mWvVideo.getSettings().setLoadWithOverviewMode(true);
+//        /* 设置是否允许webview使用缩放的功能,我这里设为false,不允许 */
+//        mWvVideo.getSettings().setBuiltInZoomControls(false);
+//        /* 提高网页渲染的优先级 */
+//        mWvVideo.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
+//
+//        /* HTML5的地理位置服务,设置为true,启用地理定位 */
+//        mWvVideo.getSettings().setGeolocationEnabled(true);
+//        /* 设置可以访问文件 */
+//        mWvVideo.getSettings().setAllowFileAccess(true);
+//
+//        // 设置UserAgent标识
+////        mWebView.getSettings().setUserAgentString(mWebView.getSettings().getUserAgentString() + " app-shikuimapp");
+//        mWvVideo.loadUrl(url);
+//    }
+//
+//    @Override
+//    public void getDataFail(String msg) {
+//        ToastUtil.show(mActivity, msg);
+//        finish();
+//    }
+//
+//    @Override
+//    public void onClick(View v) {
+//        int id = v.getId();
+//        if (id == R.id.tv_animation) {
+//            if (mModel != null) {
+//                mFlWebview1.setVisibility(View.VISIBLE);
+//                mFlWebview2.setVisibility(View.GONE);
+//                ll_content.setVisibility(View.GONE);
+//            }
+//        } else if (id == R.id.tv_video) {
+//            if (mModel != null) {
+//                mFlWebview1.setVisibility(View.GONE);
+//                mFlWebview2.setVisibility(View.VISIBLE);
+//                ll_content.setVisibility(View.GONE);
+//            }
+//        } else if (id == R.id.iv_back_three || id == R.id.iv_back_four) {
+//            mFlWebview1.setVisibility(View.GONE);
+//            mFlWebview2.setVisibility(View.GONE);
+//            ll_content.setVisibility(View.VISIBLE);
+//        }
+//    }
+//
+//    @Override
+//    protected void onDestroy() {
+//        super.onDestroy();
+//        if (mWvAnimation != null) {
+//            mWvAnimation.destroy();
+//        }
+//        if (mWvVideo != null) {
+//            mWvVideo.destroy();
+//        }
+//    }
+//
+//    private void doSubscribe(String matchId, String type, ImageView subscribeIv) {//订阅推送消息
+//        new SubscribePresenter().doSubscribe(matchId, type, new ApiCallback() {
+//            @Override
+//            public void onSuccess(String data, String msg) {
+//                if (!TextUtils.isEmpty(type)) {
+//                    subscribeIv.setImageResource(R.mipmap.subscribe);
+//                } else {
+//                    subscribeIv.setImageResource(R.mipmap.unsubscribe);
+//                }
+//            }
+//
+//            @Override
+//            public void onFailure(String msg) {
+//                ToastUtil.show(NewCricketDetailActivity.this, msg);
+//            }
+//
+//            @Override
+//            public void onError(String msg) {
+//                ToastUtil.show(NewCricketDetailActivity.this, msg);
+//            }
+//
+//            @Override
+//            public void onFinish() {
+//
+//            }
+//        });
+//    }
+//
+//    private void getSubscribeType(CricketMatchBean item, ImageView subscribeIv) {//订阅推送消息
+//        showLoadingDialog();
+//        new SubscribePresenter().getSubscribeType(item.getId(), new ApiCallback() {
+//            @Override
+//            public void onSuccess(String data, String msg) {
+//                dismissLoadingDialog();
+//                if (data != null) {
+//                    List<SubscribeTypeBean> list = JSONObject.parseArray(JSONObject.parseObject(data).getString("list"), SubscribeTypeBean.class);
+//                    //这里先弹出一个订阅消息的内容选择框  待选择好后点击确定订阅按钮再调用订阅接口
+//                    DialogUtil.showSelectSubscribeDialog(NewCricketDetailActivity.this, item.getHome_name() + " VS " + item.getAway_name(), list, new DialogUtil.SelectSubscribeBack() {
+//                        @Override
+//                        public void onSelectSubscribe(String type) {
+//                            doSubscribe(item.getId() + "", type, subscribeIv);
+//                        }
+//                    });
+//                }
+//            }
+//
+//            @Override
+//            public void onFailure(String msg) {
+//                dismissLoadingDialog();
+//            }
+//
+//            @Override
+//            public void onError(String msg) {
+//                dismissLoadingDialog();
+//            }
+//
+//            @Override
+//            public void onFinish() {
+//                dismissLoadingDialog();
+//            }
+//        });
+//    }
+//}

+ 93 - 4
TMessagesProj/src/main/java/org/telegram/onecric/utils/DialogUtil.java

@@ -26,18 +26,27 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.view.Window;
 import android.view.WindowManager;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
 import android.widget.DatePicker;
 import android.widget.EditText;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
+import android.widget.Switch;
 import android.widget.TextView;
 
 
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
 import org.telegram.cricdit.utils.ToastUtil;
 import org.telegram.messenger.R;
+import org.telegram.onecric.adapter.SubscribeTypeAdapter;
+import org.telegram.onecric.mvp.bean.SubscribeTypeBean;
 
 import java.util.ArrayList;
 import java.util.Calendar;
+import java.util.List;
 
 
 /**
@@ -72,7 +81,7 @@ public class DialogUtil {
         return loadingDialog(context, "");
     }
 
-//    public static void showSimpleTipDialog(Context context, String content) {
+    //    public static void showSimpleTipDialog(Context context, String content) {
 //        showSimpleTipDialog(context, null, content);
 //    }
 //
@@ -222,8 +231,8 @@ public class DialogUtil {
             textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DpUtil.dp2px(54)));
             textView.setTextColor(0xff323232);
             textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
-            textView.setGravity(Gravity.CENTER_VERTICAL|Gravity.LEFT);
-            textView.setPadding(DpUtil.dp2px(17), 0 ,0, 0);
+            textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
+            textView.setPadding(DpUtil.dp2px(17), 0, 0, 0);
             textView.setText(array.valueAt(i));
             textView.setTag(array.keyAt(i));
             textView.setOnClickListener(itemListener);
@@ -243,7 +252,8 @@ public class DialogUtil {
 //        });
         dialog.show();
     }
-//
+
+    //
 //    public static void showBuyNobleDialog(Context context, String noble, SimpleCallback callback) {
 //        final Dialog dialog = new Dialog(context, R.style.dialog);
 //        dialog.setContentView(R.layout.dialog_buy_noble);
@@ -894,4 +904,83 @@ public class DialogUtil {
 //        picker.setOnAddressPickListener(listener);
 //        picker.show();
 //    }
+
+    public interface SelectSubscribeBack {
+        void onSelectSubscribe(String type);
+    }
+
+    public static void showSelectSubscribeDialog(Context context, String matchTitle, List<SubscribeTypeBean> list, SelectSubscribeBack callback) {
+        final Dialog dialog = new Dialog(context, R.style.dialog);
+        dialog.setContentView(R.layout.dialog_select_subscribe);
+        dialog.setCancelable(true);
+        dialog.setCanceledOnTouchOutside(true);
+        dialog.getWindow().setWindowAnimations(R.style.bottomToTopAnim);
+        WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
+        params.width = WindowManager.LayoutParams.MATCH_PARENT;
+        params.gravity = Gravity.BOTTOM;
+        dialog.getWindow().setAttributes(params);
+        TextView tv_match_title = (TextView) dialog.findViewById(R.id.tv_match_title);
+        RecyclerView rv_type = (RecyclerView) dialog.findViewById(R.id.rv_type);
+        Switch btn_switch = (Switch) dialog.findViewById(R.id.btn_switch);
+        rv_type.setLayoutManager(new LinearLayoutManager(context));
+        SubscribeTypeAdapter adapter = new SubscribeTypeAdapter(btn_switch, R.layout.subscribe_type_item, list);
+        rv_type.setAdapter(adapter);
+        tv_match_title.setText(matchTitle);
+        TextView tv_save = (TextView) dialog.findViewById(R.id.tv_save);
+        CheckBox checkBox1 = (CheckBox) dialog.findViewById(R.id.checkbox_1);
+        CheckBox checkBox2 = (CheckBox) dialog.findViewById(R.id.checkbox_2);
+        CheckBox checkBox3 = (CheckBox) dialog.findViewById(R.id.checkbox_3);
+        CheckBox checkBox4 = (CheckBox) dialog.findViewById(R.id.checkbox_4);
+        CheckBox checkBox5 = (CheckBox) dialog.findViewById(R.id.checkbox_5);
+        CheckBox checkBox6 = (CheckBox) dialog.findViewById(R.id.checkbox_6);
+        btn_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+            boolean checked1, checked2, checked3, checked4, checked5, checked6;
+
+            @Override
+            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+                if (!isChecked) {
+                    checked1 = checkBox1.isChecked();
+                    checked2 = checkBox2.isChecked();
+                    checked3 = checkBox3.isChecked();
+                    checked4 = checkBox4.isChecked();
+                    checked5 = checkBox5.isChecked();
+                    checked6 = checkBox6.isChecked();
+                    checkBox1.setChecked(false);
+                    checkBox2.setChecked(false);
+                    checkBox3.setChecked(false);
+                    checkBox4.setChecked(false);
+                    checkBox5.setChecked(false);
+                    checkBox6.setChecked(false);
+                } else {
+                    checkBox1.setChecked(checked1);
+                    checkBox2.setChecked(checked2);
+                    checkBox3.setChecked(checked3);
+                    checkBox4.setChecked(checked4);
+                    checkBox5.setChecked(checked5);
+                    checkBox6.setChecked(checked6);
+                }
+            }
+        });
+        tv_save.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                dialog.dismiss();
+                if (callback != null) {
+                    String type = "";
+                    for (int i = 0; i < list.size(); i++) {
+                        if (list.get(i).getIs_subscribe() == 1) {
+                            if (i == 0) {
+                                type += list.get(i).getType();
+                            }
+                            if (i > 0) {
+                                type += "," + list.get(i).getType();
+                            }
+                        }
+                    }
+                    callback.onSelectSubscribe(type);
+                }
+            }
+        });
+        dialog.show();
+    }
 }

+ 10 - 9
TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java

@@ -1549,15 +1549,15 @@ public class LaunchActivity extends BasePermissionsActivity implements ActionBar
 
 
     private void handleNotification(Intent pintent) {
-//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-//            // Create channel to show notifications.
-//            String channelId = getString(R.string.default_notification_channel_id);
-//            String channelName = getString(R.string.default_notification_channel_name);
-//            NotificationManager notificationManager =
-//                    getSystemService(NotificationManager.class);
-//            notificationManager.createNotificationChannel(new NotificationChannel(channelId,
-//                    channelName, NotificationManager.IMPORTANCE_LOW));
-//        }
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            // Create channel to show notifications.
+            String channelId = "fcm_default_channel";
+            String channelName = "match_detail";
+            NotificationManager notificationManager =
+                    getSystemService(NotificationManager.class);
+            notificationManager.createNotificationChannel(new NotificationChannel(channelId,
+                    channelName, NotificationManager.IMPORTANCE_LOW));
+        }
 
         // If a notification message is tapped, any data accompanying the notification
         // message is available in the intent extras. In this sample the launcher
@@ -1578,6 +1578,7 @@ public class LaunchActivity extends BasePermissionsActivity implements ActionBar
             Bundle bundle = pintent.getExtras();
             intent.setClass(this, CricketDetailActivity.class);
             intent.putExtra("matchId", Integer.parseInt(bundle.getString("matchId")));
+            intent.putExtra("isNotification", true);
             startActivity(intent);
         }
     }

+ 10 - 0
TMessagesProj/src/main/res/anim/bottomview_anim_enter.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <translate
+        android:duration="300"
+        android:fromYDelta="100%p"
+        android:toYDelta="0"
+        />
+
+</set>

+ 10 - 0
TMessagesProj/src/main/res/anim/bottomview_anim_exit.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <translate
+        android:duration="300"
+        android:fromYDelta="0"
+        android:toYDelta="100%p"
+        />
+
+</set>

+ 7 - 0
TMessagesProj/src/main/res/drawable/shape_c8c8c8_5dp_rec.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <corners android:radius="5dp"/>
+
+    <solid android:color="@color/c_EEEEEE"/>
+</shape>

+ 7 - 0
TMessagesProj/src/main/res/drawable/shape_c_e05526_10dp_rec.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <solid android:color="@color/c_E05526" />
+
+    <corners android:radius="10dp" />
+</shape>

+ 18 - 5
TMessagesProj/src/main/res/layout/activity_cricket_detail.xml

@@ -38,10 +38,23 @@
                 </LinearLayout>
 
                 <ImageView
+                    android:id="@+id/iv_subscribe"
+                    android:layout_width="50dp"
+                    android:layout_height="50dp"
+                    android:paddingStart="7dp"
+                    android:paddingTop="14dp"
+                    android:paddingEnd="14dp"
+                    android:paddingBottom="14dp"
+                    app:layout_constraintBottom_toBottomOf="@id/btn_left"
+                    app:layout_constraintEnd_toStartOf="@id/inner_report"
+                    app:layout_constraintTop_toTopOf="@id/btn_left"
+                    android:src="@mipmap/unsubscribe"
+                    android:visibility="gone" />
+
+                <ImageView
                     android:id="@+id/iv_right"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_marginRight="20dp"
                     app:layout_constraintBottom_toBottomOf="@id/btn_left"
                     app:layout_constraintRight_toRightOf="parent"
                     app:layout_constraintTop_toTopOf="@id/btn_left" />
@@ -53,13 +66,13 @@
                     android:layout_gravity="end"
                     android:paddingStart="7dp"
                     android:paddingTop="14dp"
-                    app:layout_constraintBottom_toBottomOf="@id/btn_left"
-                    app:layout_constraintEnd_toStartOf="@id/iv_right"
-                    app:layout_constraintTop_toTopOf="@id/btn_left"
                     android:paddingEnd="14dp"
                     android:paddingBottom="14dp"
                     android:src="@drawable/msg_report"
-                    />
+                    app:layout_constraintBottom_toBottomOf="@id/btn_left"
+                    app:layout_constraintEnd_toStartOf="@id/iv_right"
+                    app:layout_constraintTop_toTopOf="@id/btn_left"
+                    app:layout_constraintVertical_bias="0.0" />
 
             </androidx.constraintlayout.widget.ConstraintLayout>
 

+ 212 - 0
TMessagesProj/src/main/res/layout/dialog_select_subscribe.xml

@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@color/white"
+    android:orientation="vertical"
+    android:paddingLeft="10dp"
+    android:paddingTop="20dp"
+    android:paddingRight="10dp"
+    android:paddingBottom="30dp">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center_vertical"
+        android:orientation="horizontal">
+
+        <LinearLayout
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:orientation="vertical">
+
+            <TextView
+                android:id="@+id/tv_match_title"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text=""
+                android:textColor="@color/c_666666"
+                android:textSize="9sp" />
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="5dp"
+                android:text="Get Alerts For This Match"
+                android:textColor="@color/c_333333"
+                android:textSize="11sp"
+                android:textStyle="bold" />
+        </LinearLayout>
+
+        <Switch
+            android:id="@+id/btn_switch"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginRight="12dp"
+            android:checked="true" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/dp_10"
+        android:background="@drawable/shape_c8c8c8_5dp_rec"
+        android:orientation="vertical"
+        android:paddingLeft="10dp"
+        android:paddingTop="20dp"
+        android:paddingRight="10dp"
+        android:paddingBottom="20dp">
+
+
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/rv_type"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" />
+
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:text="Match Started"
+                android:textColor="@color/black"
+                android:textSize="11sp"
+                android:textStyle="normal" />
+
+            <CheckBox
+                android:id="@+id/checkbox_1"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:checked="true" />
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:text="Toss and Line-ups Out"
+                android:textColor="@color/black"
+                android:textSize="11sp"
+                android:textStyle="normal" />
+
+            <CheckBox
+                android:id="@+id/checkbox_2"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:checked="true" />
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:text="Wickets"
+                android:textColor="@color/black"
+                android:textSize="11sp"
+                android:textStyle="normal" />
+
+            <CheckBox
+                android:id="@+id/checkbox_3"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:checked="true" />
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/dp_10"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:text="Milestones"
+                android:textColor="@color/black"
+                android:textSize="11sp"
+                android:textStyle="normal" />
+
+            <CheckBox
+                android:id="@+id/checkbox_4"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:checked="false" />
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:text="Delay and Breaks"
+                android:textColor="@color/black"
+                android:textSize="11sp"
+                android:textStyle="normal" />
+
+            <CheckBox
+                android:id="@+id/checkbox_5"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:checked="false" />
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="10dp"
+            android:visibility="gone">
+
+            <TextView
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:text="Result"
+                android:textColor="@color/black"
+                android:textSize="11sp"
+                android:textStyle="normal" />
+
+            <CheckBox
+                android:id="@+id/checkbox_6"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:checked="true" />
+        </LinearLayout>
+
+    </LinearLayout>
+
+    <TextView
+        android:id="@+id/tv_save"
+        android:layout_width="match_parent"
+        android:layout_height="30dp"
+        android:layout_marginTop="10dp"
+        android:background="@drawable/shape_c_e05526_10dp_rec"
+        android:gravity="center"
+        android:text="SAVE PREFERENCES"
+        android:textColor="@color/white"
+        android:textSize="13sp"
+        android:textStyle="bold" />
+</LinearLayout>

+ 31 - 0
TMessagesProj/src/main/res/layout/subscribe_type_item.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="10dp"
+        android:visibility="visible"
+        tools:ignore="MissingConstraints">
+
+        <TextView
+            android:id="@+id/tv_name"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:text=""
+            android:textColor="@color/black"
+            android:textSize="11sp"
+            android:textStyle="normal" />
+
+        <CheckBox
+            android:id="@+id/checkbox"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:checked="true" />
+    </LinearLayout>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

BIN
TMessagesProj/src/main/res/mipmap-xxhdpi/subscribe.png


BIN
TMessagesProj/src/main/res/mipmap-xxhdpi/unsubscribe.png


BIN
TMessagesProj/src/main/res/mipmap-xxxhdpi/subscribe.png


BIN
TMessagesProj/src/main/res/mipmap-xxxhdpi/unsubscribe.png


+ 15 - 12
TMessagesProj/src/main/res/values/styles.xml

@@ -1,4 +1,4 @@
-<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
+<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
 
     <!--THEMES-->
 
@@ -19,17 +19,17 @@
     </style>
 
     <!--冷启动优化-->
-    <style name="ItemSelectedStyle" >
+    <style name="ItemSelectedStyle">
         <item name="android:selectableItemBackground">@null</item>
         <item name="android:selectableItemBackgroundBorderless">@null</item>
     </style>
 
-<!--    <style name="CustomDateDialog" parent="@android:style/Theme.Dialog">-->
-<!--        <item name="android:windowFrame">@null</item>-->
-<!--        <item name="android:windowNoTitle">true</item>-->
-<!--        <item name="android:windowBackground">@color/transparent</item>-->
-<!--        <item name="android:windowIsTranslucent">true</item>-->
-<!--    </style>-->
+    <!--    <style name="CustomDateDialog" parent="@android:style/Theme.Dialog">-->
+    <!--        <item name="android:windowFrame">@null</item>-->
+    <!--        <item name="android:windowNoTitle">true</item>-->
+    <!--        <item name="android:windowBackground">@color/transparent</item>-->
+    <!--        <item name="android:windowIsTranslucent">true</item>-->
+    <!--    </style>-->
 
     <style name="CustomDateDialog" parent="@android:style/Theme.Dialog">
         <item name="android:windowFrame">@null</item>
@@ -39,7 +39,7 @@
         <item name="android:windowBackground">@color/transparent</item>
         <item name="android:backgroundDimAmount">0.5</item>
         <!--显示区域以外是否使用黑色半透明背景-->
-<!--        <item name="android:backgroundDimEnabled">true</item>-->
+        <!--        <item name="android:backgroundDimEnabled">true</item>-->
     </style>
 
     <style name="UpdateDialog" parent="@android:style/Theme.Dialog">
@@ -340,8 +340,6 @@
     </style>
 
 
-
-
     <!-- 底部弹出动画 -->
     <style name="DialogBottomAnim" parent="android:Animation">
         <item name="android:windowEnterAnimation">@anim/dialog_enter</item>
@@ -365,7 +363,7 @@
         <item name="android:textStyle">bold</item>
     </style>
 
-<!-- semibold -->
+    <!-- semibold -->
     <style name="TvItemTitleStyle">
         <item name="android:fontFamily">@font/noto_sans_display_semibold</item>
         <item name="android:textSize">15sp</item>
@@ -417,4 +415,9 @@
         <item name="android:fontFamily">@font/noto_sans_display_regular</item>
     </style>
 
+    <style name="bottomToTopAnim" parent="android:Animation">
+        <item name="android:windowEnterAnimation">@anim/bottomview_anim_enter</item>
+        <item name="android:windowExitAnimation">@anim/bottomview_anim_exit</item>
+    </style>
+
 </resources>