Commit e1f15d9a authored by feihuaduo's avatar feihuaduo

修复无更新时检查更新对话框不关闭的问题

新增剪贴板关键字卡查(c#卡片关键字),软件运行时复制即可卡查
parent 868dee72
package cn.garymb.ygomobile.ui.cards; package cn.garymb.ygomobile.ui.cards;
public class CardSearchAcitivity extends CardSearchActivityImpl{ public class CardSearchAcitivity extends CardSearchActivityImpl{
public static final String SEARCH_MESSAGE="searchMessage";
} }
package cn.garymb.ygomobile.ui.cards; package cn.garymb.ygomobile.ui.cards;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
...@@ -8,6 +9,8 @@ import android.support.v7.widget.FastScrollLinearLayoutManager; ...@@ -8,6 +9,8 @@ import android.support.v7.widget.FastScrollLinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerViewItemListener; import android.support.v7.widget.RecyclerViewItemListener;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
...@@ -28,6 +31,7 @@ import cn.garymb.ygomobile.ui.activities.WebActivity; ...@@ -28,6 +31,7 @@ import cn.garymb.ygomobile.ui.activities.WebActivity;
import cn.garymb.ygomobile.ui.adapters.CardListAdapter; import cn.garymb.ygomobile.ui.adapters.CardListAdapter;
import cn.garymb.ygomobile.ui.plus.AOnGestureListener; import cn.garymb.ygomobile.ui.plus.AOnGestureListener;
import cn.garymb.ygomobile.ui.plus.DialogPlus; import cn.garymb.ygomobile.ui.plus.DialogPlus;
import cn.garymb.ygomobile.ui.plus.ServiceDuelAssistant;
import cn.garymb.ygomobile.ui.plus.VUiKit; import cn.garymb.ygomobile.ui.plus.VUiKit;
import ocgcore.DataManager; import ocgcore.DataManager;
import ocgcore.LimitManager; import ocgcore.LimitManager;
...@@ -36,6 +40,7 @@ import ocgcore.data.Card; ...@@ -36,6 +40,7 @@ import ocgcore.data.Card;
import ocgcore.data.LimitList; import ocgcore.data.LimitList;
class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack { class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack {
protected DrawerLayout mDrawerlayout; protected DrawerLayout mDrawerlayout;
private RecyclerView mListView; private RecyclerView mListView;
protected CardSearcher mCardSelector; protected CardSearcher mCardSelector;
...@@ -46,10 +51,17 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack ...@@ -46,10 +51,17 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
protected LimitManager mLimitManager = DataManager.get().getLimitManager(); protected LimitManager mLimitManager = DataManager.get().getLimitManager();
private ImageLoader mImageLoader; private ImageLoader mImageLoader;
private String intentSearchMessage;
private boolean isFirstCardSearch=true;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search); setContentView(R.layout.activity_search);
if(TextUtils.isEmpty(getIntent().getStringExtra(CardSearchAcitivity.SEARCH_MESSAGE))){
ServiceDuelAssistant.cardSearchMessage="";
}
Toolbar toolbar = $(R.id.toolbar); Toolbar toolbar = $(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
enableBackHome(); enableBackHome();
...@@ -85,9 +97,25 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack ...@@ -85,9 +97,25 @@ class CardSearchActivityImpl extends BaseActivity implements CardLoader.CallBack
isLoad = true; isLoad = true;
mCardLoader.loadData(); mCardLoader.loadData();
mCardSelector.initItems(); mCardSelector.initItems();
intentSearch();
isFirstCardSearch=false;
}); });
} }
@Override
protected void onRestart() {
super.onRestart();
if (!isFirstCardSearch){
intentSearch();
}
}
private void intentSearch(){
// intentSearchMessage=getIntent().getStringExtra(CardSearchAcitivity.SEARCH_MESSAGE);
mCardSelector.search(ServiceDuelAssistant.cardSearchMessage);
}
protected void setListeners() { protected void setListeners() {
mListView.addOnItemTouchListener(new RecyclerViewItemListener(mListView, new RecyclerViewItemListener.OnItemListener() { mListView.addOnItemTouchListener(new RecyclerViewItemListener(mListView, new RecyclerViewItemListener.OnItemListener() {
@Override @Override
......
...@@ -491,6 +491,14 @@ public class CardSearcher implements View.OnClickListener { ...@@ -491,6 +491,14 @@ public class CardSearcher implements View.OnClickListener {
} }
} }
public void search(String message){
if (TextUtils.isEmpty(message)){
message="";
}
prefixWord.setText(message);
search();
}
private void search() { private void search() {
if (dataLoader != null) { if (dataLoader != null) {
dataLoader.search(text(prefixWord), text(suffixWord), getSelect(attributeSpinner) dataLoader.search(text(prefixWord), text(suffixWord), getSelect(attributeSpinner)
......
...@@ -422,6 +422,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -422,6 +422,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
@Override @Override
public void onNoUpdateAvailable() { public void onNoUpdateAvailable() {
if (isToastNoUpdata){ if (isToastNoUpdata){
builder.dismiss();
Toast.makeText(context, R.string.Already_Lastest, Toast.LENGTH_SHORT).show(); Toast.makeText(context, R.string.Already_Lastest, Toast.LENGTH_SHORT).show();
} }
} }
...@@ -430,6 +431,8 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -430,6 +431,8 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
final String versionName,updateMessage; final String versionName,updateMessage;
versionName = appBean.getVersionName(); versionName = appBean.getVersionName();
updateMessage = appBean.getReleaseNote(); updateMessage = appBean.getReleaseNote();
builder.hideProgressBar();
builder.showTitleBar();
builder.setTitle(context.getResources().getString(R.string.Update_Found) + versionName); builder.setTitle(context.getResources().getString(R.string.Update_Found) + versionName);
builder.setMessage(updateMessage); builder.setMessage(updateMessage);
builder.setRightButtonText(R.string.Download); builder.setRightButtonText(R.string.Download);
......
...@@ -10,6 +10,8 @@ import android.graphics.PixelFormat; ...@@ -10,6 +10,8 @@ import android.graphics.PixelFormat;
import android.os.Build; import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -28,6 +30,7 @@ import cn.garymb.ygomobile.bean.ServerInfo; ...@@ -28,6 +30,7 @@ import cn.garymb.ygomobile.bean.ServerInfo;
import cn.garymb.ygomobile.bean.ServerList; import cn.garymb.ygomobile.bean.ServerList;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.adapters.ServerListAdapter; import cn.garymb.ygomobile.ui.adapters.ServerListAdapter;
import cn.garymb.ygomobile.ui.cards.CardSearchAcitivity;
import cn.garymb.ygomobile.ui.home.ServerListManager; import cn.garymb.ygomobile.ui.home.ServerListManager;
import cn.garymb.ygomobile.utils.IOUtils; import cn.garymb.ygomobile.utils.IOUtils;
import cn.garymb.ygomobile.utils.XmlUtils; import cn.garymb.ygomobile.utils.XmlUtils;
...@@ -36,6 +39,11 @@ import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST; ...@@ -36,6 +39,11 @@ import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST;
public class ServiceDuelAssistant extends Service { public class ServiceDuelAssistant extends Service {
public static String cardSearchMessage;
//卡查关键字
private String[] cardSearchKey = new String[]{"c#", "C#"};
private LinearLayout mFloatLayout; private LinearLayout mFloatLayout;
private TextView ds_text; private TextView ds_text;
private Button ds_join, ds_qx; private Button ds_join, ds_qx;
...@@ -76,7 +84,7 @@ public class ServiceDuelAssistant extends Service { ...@@ -76,7 +84,7 @@ public class ServiceDuelAssistant extends Service {
// TODO: Implement this method // TODO: Implement this method
super.onCreate(); super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForeground(1,new Notification()); startForeground(1, new Notification());
} }
//lc = new ArrayList<Card>(); //lc = new ArrayList<Card>();
...@@ -91,27 +99,40 @@ public class ServiceDuelAssistant extends Service { ...@@ -91,27 +99,40 @@ public class ServiceDuelAssistant extends Service {
public void onPrimaryClipChanged() { public void onPrimaryClipChanged() {
ClipData clipData = cm.getPrimaryClip(); ClipData clipData = cm.getPrimaryClip();
CharSequence cs = clipData.getItemAt(0).getText(); CharSequence cs = clipData.getItemAt(0).getText();
final String ss; final String clipMessage;
if (cs != null) { if (cs != null) {
ss = cs.toString(); clipMessage = cs.toString();
} else { } else {
ss = ""; clipMessage = null;
}
//如果复制的内容为空则不执行下面的代码
if (TextUtils.isEmpty(clipMessage)) {
return;
} }
/*final int ssi=ss.indexOf("卡查");
if (ssi != -1) {
cxCard(ss, ssi);
} else {*/
int start = -1; int start = -1;
for (String st : passwordPrefix) { for (String st : passwordPrefix) {
start = ss.indexOf(st); start = clipMessage.indexOf(st);
if (start != -1) { if (start != -1) {
break; break;
} }
} }
if (start != -1) { if (start != -1) {
joinRoom(ss, start); joinRoom(clipMessage, start);
} else {
for (String s : cardSearchKey) {
int cardSearchStart=clipMessage.indexOf(s);
if ( cardSearchStart!= -1) {
//卡查内容
cardSearchMessage=clipMessage.substring(cardSearchStart+s.length(),clipMessage.length());
Intent intent = new Intent(ServiceDuelAssistant.this, CardSearchAcitivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(CardSearchAcitivity.SEARCH_MESSAGE,cardSearchMessage);
startActivity(intent);
}
}
} }
} }
......
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