光环助手V3.2 RELEASE(20180426-1800)测试问题汇总(1.2.9.10)
This commit is contained in:
@ -5,11 +5,7 @@ import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.gh.gamecenter.LoginActivity;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.manager.UserManager;
|
||||
import com.gh.gamecenter.personal.PersonalFragment;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
* Created by khy on 28/06/17.
|
||||
@ -20,11 +16,6 @@ public class CheckLoginUtils {
|
||||
public static void checkLogin(final Context context, OnLoginListener listener) {
|
||||
// String token = LoginUtils.getToken(context);
|
||||
if (TextUtils.isEmpty(UserManager.getInstance().getToken())) {
|
||||
// 验证登录真实性
|
||||
if (!TextUtils.isEmpty(UserManager.getInstance().getTokenId(context))) {
|
||||
EventBus.getDefault().post(new EBReuse(PersonalFragment.LOGIN_RETRY));
|
||||
return;
|
||||
}
|
||||
AskLogUtils.login(context, "dialog", null);
|
||||
DialogUtils.showWarningDialog(context, "登录提示", "需要登录才能使用该功能喔!", "取消", "快速登录",
|
||||
new DialogUtils.ConfirmListener() {
|
||||
|
||||
@ -72,6 +72,7 @@ public class EntranceUtils {
|
||||
public static final String KEY_SHOW_ANSWER_COMMENT = "showAnswerComment";
|
||||
public static final String KEY_VERSION_UPDATE = "versionUpdate";
|
||||
public static final String KEY_CHECK_QUESTION_CONCERN = "check_question_concern";
|
||||
public static final String KEY_DRAFT_ID = "draft_id";
|
||||
|
||||
public static void jumpActivity(Context context, Bundle bundle) {
|
||||
|
||||
|
||||
@ -21,6 +21,16 @@ public class AnswerEditActivity extends NormalActivity {
|
||||
return getTargetIntent(context, AnswerEditActivity.class, AnswerEditFragment.class, bundle);
|
||||
}
|
||||
|
||||
|
||||
public static Intent getIntent(Context context, String questionId, String questionTitle, String draftId, boolean showInNewPage) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, questionId);
|
||||
bundle.putString(EntranceUtils.KEY_QUESTIONS_TITLE, questionTitle);
|
||||
bundle.putBoolean(EntranceUtils.KEY_ANSWER_OPEN_IN_NEW_PAGE, showInNewPage);
|
||||
bundle.putString(EntranceUtils.KEY_DRAFT_ID, draftId);
|
||||
return getTargetIntent(context, AnswerEditActivity.class, AnswerEditFragment.class, bundle);
|
||||
}
|
||||
|
||||
public static Intent getIntent(Context context, String questionId, String questionTitle) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(EntranceUtils.KEY_QUESTIONS_ID, questionId);
|
||||
|
||||
@ -87,7 +87,7 @@ public class MyDraftFragment extends ListFragment<AnswerEntity, NormalListViewMo
|
||||
mDraftPosition = position;
|
||||
entity = (AnswerEntity) data;
|
||||
startActivityForResult(AnswerEditActivity.getIntent(getContext(), entity.getQuestions().getId()
|
||||
, entity.getQuestions().getTitle()), ANSWER_DRAFT_REQUEST);
|
||||
, entity.getQuestions().getTitle(), entity.getId(), true), ANSWER_DRAFT_REQUEST);
|
||||
break;
|
||||
case R.id.ask_answer_item_title:
|
||||
String tracers = mEntrance + "+(我的草稿)";
|
||||
|
||||
@ -39,6 +39,7 @@ import com.lightgame.utils.Utils;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -84,6 +85,7 @@ public class AnswerEditFragment extends NormalFragment {
|
||||
private String mAnswerId; // 以mAnswerId为标识,如果mAnswerId不为空则是-修改答案(不需要保存草稿) 为空则是-编写答案
|
||||
private String mAnswerContent;
|
||||
|
||||
private String mDraftId;
|
||||
private String mQuestionsId;
|
||||
private String mQuestionsTitle;
|
||||
private boolean mOpenAnswerInNewPage;
|
||||
@ -142,6 +144,7 @@ public class AnswerEditFragment extends NormalFragment {
|
||||
mQuestionsId = arguments.getString(EntranceUtils.KEY_QUESTIONS_ID);
|
||||
mQuestionsTitle = arguments.getString(EntranceUtils.KEY_QUESTIONS_TITLE);
|
||||
mOpenAnswerInNewPage = arguments.getBoolean(EntranceUtils.KEY_ANSWER_OPEN_IN_NEW_PAGE);
|
||||
mDraftId = arguments.getString(EntranceUtils.KEY_DRAFT_ID);
|
||||
if (TextUtils.isEmpty(mAnswerId)) {
|
||||
mBaseHandler.sendEmptyMessageDelayed(1, SAVE_DRAFTS_INTERVAL_TIME); // 启动自动保持
|
||||
}
|
||||
@ -306,6 +309,30 @@ public class AnswerEditFragment extends NormalFragment {
|
||||
public void onFailure(HttpException e) {
|
||||
super.onFailure(e);
|
||||
if (postDialog != null) postDialog.dismissAllowingStateLoss();
|
||||
|
||||
if (e != null && e.code() == 403) {
|
||||
try {
|
||||
JSONObject object = new JSONObject(e.response().errorBody().string());
|
||||
int code = object.getInt("code");
|
||||
if (code == 403037) {
|
||||
DialogUtils.showAlertDialog(getContext(), "发布失败"
|
||||
, "问题已被删除,需要删除草稿吗?"
|
||||
, "删除草稿", "暂不"
|
||||
, () -> {
|
||||
deleteAnswerDraft();
|
||||
}, () -> {
|
||||
if (getActivity() != null) {
|
||||
getActivity().finish();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (JSONException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (LoginUtils.userPostErrorToast(e, getContext(), false)) return;
|
||||
toast("提交失败");
|
||||
AskErrorResponseUtils.errorResponseControl(getContext(), e);
|
||||
@ -313,6 +340,27 @@ public class AnswerEditFragment extends NormalFragment {
|
||||
});
|
||||
}
|
||||
|
||||
void deleteAnswerDraft() {
|
||||
RetrofitManager.getInstance(getContext()).getApi()
|
||||
.deleteAnswerDrafts(UserManager.getInstance().getUserId(), mDraftId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Response<ResponseBody>() {
|
||||
@Override
|
||||
public void onResponse(ResponseBody response) {
|
||||
if (getActivity() != null) {
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException e) {
|
||||
toast(R.string.loading_network_error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
|
||||
@ -18,6 +18,7 @@ import com.gh.base.fragment.BaseFragment;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DataCollectionUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.EntranceUtils;
|
||||
import com.gh.download.DownloadManager;
|
||||
import com.gh.gamecenter.ConcernActivity;
|
||||
@ -182,10 +183,10 @@ public class SearchToolbarFragment extends BaseFragment implements View.OnClickL
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mDownloadView.getLayoutParams();
|
||||
if (Config.isShow()) {
|
||||
mDownloadView.setVisibility(View.VISIBLE);
|
||||
layoutParams.weight = 1.3f;
|
||||
layoutParams.width = DisplayUtils.dip2px(getContext(), 50);
|
||||
} else {
|
||||
mDownloadView.setVisibility(View.INVISIBLE);
|
||||
layoutParams.weight = 0.4f;
|
||||
layoutParams.width = DisplayUtils.dip2px(getContext(), 20);
|
||||
}
|
||||
|
||||
int updateSize = PackageManager.getUpdateListSize();
|
||||
@ -247,10 +248,10 @@ public class SearchToolbarFragment extends BaseFragment implements View.OnClickL
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mDownloadView.getLayoutParams();
|
||||
if (Config.isShow()) {
|
||||
mDownloadView.setVisibility(View.VISIBLE);
|
||||
layoutParams.weight = 1.3f;
|
||||
layoutParams.width = DisplayUtils.dip2px(getContext(), 50);
|
||||
} else {
|
||||
mDownloadView.setVisibility(View.GONE);
|
||||
layoutParams.weight = 0.4f;
|
||||
mDownloadView.setVisibility(View.INVISIBLE);
|
||||
layoutParams.width = DisplayUtils.dip2px(getContext(), 20);
|
||||
}
|
||||
mDownloadView.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.gh.gamecenter.login;
|
||||
|
||||
import android.arch.persistence.db.SupportSQLiteDatabase;
|
||||
import android.arch.persistence.room.Database;
|
||||
import android.arch.persistence.room.Room;
|
||||
import android.arch.persistence.room.RoomDatabase;
|
||||
import android.arch.persistence.room.migration.Migration;
|
||||
import android.content.Context;
|
||||
|
||||
import com.gh.gamecenter.ask.entity.AnswerEntity;
|
||||
@ -15,7 +17,7 @@ import com.gh.gamecenter.room.dao.SignDao;
|
||||
/**
|
||||
* Created by khy on 28/11/17.
|
||||
*/
|
||||
@Database(entities = {LoginTokenEntity.class, UserInfoEntity.class, SignEntity.class, AnswerEntity.class}, version = 4, exportSchema = false)
|
||||
@Database(entities = {LoginTokenEntity.class, UserInfoEntity.class, SignEntity.class, AnswerEntity.class}, version = 3, exportSchema = false)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
|
||||
public abstract AnswerDao answerDao();
|
||||
@ -43,12 +45,21 @@ public abstract class AppDatabase extends RoomDatabase {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
static final Migration MIGRATION_2_3 = new Migration(2, 3) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase database) {
|
||||
database.execSQL("CREATE TABLE SignEntity(id TEXT NOT NULL PRIMARY KEY, experience INTEGER NOT NULL, serialSign INTEGER NOT NULL, coefficients INTEGER NOT NULL, lastTime INTEGER NOT NULL, title TEXT, data TEXT)");
|
||||
database.execSQL("CREATE TABLE AnswerEntity(primaryKey TEXT NOT NULL PRIMARY KEY, communityId TEXT, orderTag INTEGER NOT NULL, id TEXT, sequenceId TEXT, brief TEXT, images TEXT NOT NULL, vote INTEGER NOT NULL, user TEXT NOT NULL, questions TEXT NOT NULL, communityName TEXT, commentCount INTEGER NOT NULL)");
|
||||
}
|
||||
};
|
||||
|
||||
private static AppDatabase buildDatabase(Context context) {
|
||||
return Room.databaseBuilder(context, AppDatabase.class, DATABASE_NAME)
|
||||
.addMigrations(MIGRATION_2_3)
|
||||
//TODO 不允许主线程查询
|
||||
.allowMainThreadQueries()
|
||||
//TODO 提供db升级的策略而不是强行销毁
|
||||
.fallbackToDestructiveMigration()
|
||||
// //TODO 提供db升级的策略而不是强行销毁
|
||||
// .fallbackToDestructiveMigration()
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -88,11 +88,13 @@ class UserRepository {
|
||||
mApiService = RetrofitManager.getInstance(context).getApi();
|
||||
mAppDatabase = database;
|
||||
mCachedId = PreferenceManager.getDefaultSharedPreferences(context).getString(Constants.LOGIN_TOKEN_ID, null);
|
||||
Utils.log("===========::" + mCachedId);
|
||||
if (!TextUtils.isEmpty(mCachedId)) checkLogin();
|
||||
}
|
||||
|
||||
protected void checkLogin() {
|
||||
LoginTokenEntity tokenEntity = mAppDatabase.loginTokenDao().getTokenById(mCachedId);
|
||||
Utils.log("===========checkLogin::" + tokenEntity);
|
||||
if (tokenEntity == null) return;
|
||||
|
||||
TokenEntity accessToken = tokenEntity.getAccessToken();
|
||||
|
||||
Reference in New Issue
Block a user