每日冲刺5
语音功能出现bug,交由其他队员实现
package com.llw.goodtrash.contract; import android.annotation.SuppressLint; import com.llw.goodtrash.api.ApiService; import com.llw.goodtrash.model.TrashResponse; import com.llw.mvplibrary.base.BasePresenter; import com.llw.mvplibrary.base.BaseView; import com.llw.mvplibrary.network.NetworkApi; import com.llw.mvplibrary.network.observer.BaseObserver; /** * 语音文字输入页面访问网络 * * @author llw * @date 2021/4/1 16:03 */ public class VoiceContract { public static class VoicePresenter extends BasePresenter<VoiceView> { /** * 搜索物品 * * @param word 物品名 */ @SuppressLint("CheckResult") public void searchGoods(String word) { ApiService service = NetworkApi.createService(ApiService.class); service.searchGoods(word).compose(NetworkApi.applySchedulers(new BaseObserver<TrashResponse>() { @Override public void onSuccess(TrashResponse groupResponse) { if (getView() != null) { getView().getSearchResponse(groupResponse); } } @Override public void onFailure(Throwable e) { if (getView() != null) { getView().getSearchResponseFailed(e); } } })); } } public interface VoiceView extends BaseView { /** * 搜索物品返回 * * @param response */ void getSearchResponse(TrashResponse response); /** * 搜索物品异常返回 * * @param throwable */ void getSearchResponseFailed(Throwable throwable); } }
@Override protected VoiceContract.VoicePresenter createPresenter() { return new VoiceContract.VoicePresenter(); } /** * 搜索物品返回数据 * * @param response */ @Override public void getSearchResponse(TrashResponse response) { //隐藏加载弹窗 hideLoadingDialog(); if (response.getCode() == Constant.SUCCESS_CODE) { //请求成功 进行数据的渲染 if (response.getNewslist() != null && response.getNewslist().size() > 0) { newslistBeanList.clear(); newslistBeanList.addAll(response.getNewslist()); //刷新适配器 searchGoodsAdapter.notifyDataSetChanged(); } else { showMsg("触及到了知识盲区"); } } else { //显示请求接口失败的原因 showMsg(response.getMsg()); } } /** * 搜索物品失败返回 * * @param throwable 异常信息 */ @Override public void getSearchResponseFailed(Throwable throwable) { hideLoadingDialog(); Log.e(TAG, throwable.toString()); }
进行mvp框架搭建工作
package com.llw.mvplibrary; import android.app.Activity; import java.util.ArrayList; import java.util.List; /** * 管理Activity * @author llw */ public class ActivityManager { //保存所有创建的Activity private List<Activity> activityList = new ArrayList<>(); /** * 添加Activity * @param activity */ public void addActivity(Activity activity){ if(activity != null){ activityList.add(activity); } } /** * 移除Activity * @param activity */ public void removeActivity(Activity activity){ if(activity != null){ activityList.remove(activity); } } /** * 关闭所有Activity */ public void finishAllActivity(){ for (Activity activity : activityList) { activity.finish(); } } }
package com.llw.mvplibrary; import android.app.Application; import android.content.Context; /** * 基类Application * @author llw */ public class BaseApplication extends Application { private static ActivityManager activityManager; private static BaseApplication application; private static Context context; @Override public void onCreate() { super.onCreate(); //声明Activity管理 activityManager = new ActivityManager(); context = getApplicationContext(); application = this; } public static BaseApplication getApplication() { return application; } public static Context getContext() { return context; } public static ActivityManager getActivityManager() { return activityManager; } }
初步开始搭建
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南