Commit 178a5715 authored by fallenstardust's avatar fallenstardust

添加先行卡有新版本时的提醒

在开启拓展卡包后才检查先行卡远端版本号
parent 821095bb
package cn.garymb.ygomobile.ui.home;
import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST;
import static cn.garymb.ygomobile.Constants.URL_YGO233_DATAVER;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.RectF;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
......@@ -24,7 +20,6 @@ import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
......@@ -33,17 +28,11 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.app.hubert.guide.NewbieGuide;
import com.app.hubert.guide.core.Controller;
import com.app.hubert.guide.listener.OnHighlightDrewListener;
import com.app.hubert.guide.listener.OnLayoutInflatedListener;
import com.app.hubert.guide.model.GuidePage;
import com.app.hubert.guide.model.HighLight;
import com.app.hubert.guide.model.HighlightOptions;
import com.ourygo.assistant.base.listener.OnDuelAssistantListener;
import com.ourygo.assistant.util.DuelAssistantManagement;
import com.ourygo.assistant.util.Util;
......@@ -86,10 +75,15 @@ import cn.garymb.ygomobile.ui.plus.VUiKit;
import cn.garymb.ygomobile.ui.widget.Shimmer;
import cn.garymb.ygomobile.ui.widget.ShimmerTextView;
import cn.garymb.ygomobile.utils.FileLogUtil;
import cn.garymb.ygomobile.utils.OkhttpUtil;
import cn.garymb.ygomobile.utils.SharedPreferenceUtil;
import cn.garymb.ygomobile.utils.YGOUtil;
import ocgcore.CardManager;
import ocgcore.DataManager;
import ocgcore.data.Card;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListener, View.OnClickListener {
......@@ -104,6 +98,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
private RelativeLayout ll_back;
ShimmerTextView tv;
ShimmerTextView tv2;
Shimmer shimmer;
private SwipeMenuRecyclerView mServerList;
private ServerListAdapter mServerListAdapter;
......@@ -123,6 +118,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
private CardView cv_watch_replay;
//辅助功能
private CardView cv_download_ex;
private LinearLayoutCompat ll_new_notice;
//外连
private CardView cv_donation;
private CardView cv_help;
......@@ -145,6 +141,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this);
}
findExPansionsDataVer();
//showNewbieGuide("homePage");
return layoutView;
}
......@@ -181,6 +178,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
cv_watch_replay.setOnClickListener(this);
cv_download_ex = view.findViewById(R.id.action_download_ex);
cv_download_ex.setOnClickListener(this);
ll_new_notice = view.findViewById(R.id.ll_new_notice);
/*
cv_download_ex.setOnLongClickListener(new View.OnLongClickListener() {
@Override
......@@ -197,7 +195,9 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
ll_back = view.findViewById(R.id.return_to_duel);
ll_back.setOnClickListener(this);
tv = (ShimmerTextView) view.findViewById(R.id.shimmer_tv);
tv2 = (ShimmerTextView) view.findViewById(R.id.shimmer_tv2);
toggleAnimation(tv);
toggleAnimation(tv2);
mImageLoader = new ImageLoader(false);
mCardManager = DataManager.get().getCardManager();
......@@ -265,6 +265,26 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
}
};
private void findExPansionsDataVer() {
if (AppsSettings.get().isReadExpansions()) {
String oldVer = SharedPreferenceUtil.getExpansionDataVer();
OkhttpUtil.get(URL_YGO233_DATAVER, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
findExPansionsDataVer();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
WebActivity.dataVer = response.body().string();
}
});
if (!WebActivity.dataVer.equals(oldVer)) {
ll_new_notice.setVisibility(View.VISIBLE);
}
}
}
private void findMcNews() {
isMcNewsLoadException = false;
tv_banner_loading.setVisibility(View.VISIBLE);
......@@ -445,12 +465,12 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
}
}
public void toggleAnimation(View target) {
public void toggleAnimation(ShimmerTextView target) {
if (shimmer != null && shimmer.isAnimating()) {
shimmer.cancel();
} else {
shimmer = new Shimmer();
shimmer.start(tv);
shimmer.start(target);
}
}
......@@ -662,6 +682,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
break;
case R.id.action_download_ex:
WebActivity.open(getContext(), getString(R.string.action_download_expansions), Constants.URL_YGO233_ADVANCE);
ll_new_notice.setVisibility(View.GONE);
break;
case R.id.action_help: {
final DialogPlus dialog = new DialogPlus(getContext());
......
......@@ -50,6 +50,14 @@ public class SharedPreferenceUtil {
return getShareRecord().getInt("StartTimes", 0);
}
public static void setExpansionDataVer(String json){
getShareRecord().edit().putString("ExpansionsDataVer", json).commit();
};
public static String getExpansionDataVer() {
return getShareRecord().getString("ExpansionsDataVer", null);
}
public static String getUserName() {
return getShareRecord().getString("userName", null);
}
......
......@@ -119,6 +119,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_marginStart="-263dp"
android:layout_marginLeft="1dp"
android:layout_toEndOf="@id/logo_small"
android:gravity="center"
android:text="@string/return_to_duel"
......@@ -432,6 +434,30 @@
android:textSize="10sp"
android:textStyle="bold" />
</RelativeLayout>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/ll_new_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:orientation="horizontal"
android:visibility="visible">
<cn.garymb.ygomobile.ui.widget.ShimmerTextView
android:id="@+id/shimmer_tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="NEW!"
android:textColor="@color/holo_orange_bright"
android:textSize="15sp"
android:textStyle="bold|italic" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="@drawable/ic_expansions" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.cardview.widget.CardView>
</LinearLayout>
</LinearLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment