0

如何从以下设计中进行过滤器概念?我在这里附上了两个屏幕设计。

  1. 仪表板片段 -> 具有带有基本适配器的 Listview。 在此处输入图像描述

上面的ListView代码如下

仪表板重构

public class DashBoardRefactor extends Fragment {

    public static ProgressDialog progress;
    public static List<DashListModel> dashRowList1 = new ArrayList<DashListModel>();
    public static View footerView;
    // @Bind(R.id.dashListView)
    public static ListView dashListView;
    int preCount = 2, scroll_Inc = 10, lastCount;
    boolean flag = true;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.dashboard_fragment, container, false);

        ButterKnife.bind(this, v);
        setHasOptionsMenu(true);
        progress = new ProgressDialog(getActivity());
        dashListView = (ListView) v.findViewById(R.id.dashListView);
        footerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.dashboard_list_footer, null, false);
        dashListView.addFooterView(footerView);
        footerView.setVisibility(View.GONE);
        dashRowList1.clear();
        dashboardViewTask();

        dashListView.setOnScrollListener(new EndlessScrollListener(getActivity(), dashListView, footerView));
        return v;
    }

    public void dashboardViewTask() {
        progress.setMessage("Loading...");
        progress.setCanceledOnTouchOutside(false);
        progress.setCancelable(false);
        progress.show();
        //    footerView.setVisibility(View.VISIBLE);
        Map<String, String> params = new HashMap<String, String>();
        Log.e("candidate_id", "candidate_id---->" + SessionStores.getBullHornId(getActivity()));
        params.put("candidate_id", SessionStores.getBullHornId(getActivity()));
        params.put("employmentPreference", SessionStores.getEmploymentPreference(getActivity()));
        params.put("page", "1");
        new DashBoardTask(getActivity(), params, dashListView, footerView);
    }

    @Override
    public void onCreateOptionsMenu(
            Menu menu, MenuInflater inflater) {
        if (menu != null) {
            menu.removeItem(R.id.menu_notify);
        }
        inflater.inflate(R.menu.menu_options, menu);
        MenuItem item = menu.findItem(R.id.menu_filter);
        item.setVisible(true);
        getActivity().invalidateOptionsMenu();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle item selection
        switch (item.getItemId()) {
            case R.id.his__menu_accept:
                Toast.makeText(getActivity(), "clicked dashboard  menu accept", Toast.LENGTH_LONG).show();
                return true;
            case R.id.menu_filter:
                // click evnt for filter
                Toast.makeText(getActivity(), "clicked dashboard  filter", Toast.LENGTH_LONG).show();
                Intent filter_intent = new Intent(getActivity(), DashBoardFilterScreen.class);
                startActivity(filter_intent);
                getActivity().overridePendingTransition(R.anim.trans_left_in, R.anim.trans_left_out);
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    public void onPause() {
        super.onPause();
        // dashboardViewTask();
    }
}

仪表板任务:

public class DashBoardTask {
   
    public static String candidateIdNo;
    public static Integer isBookmarked;
     public ListAdapter dashListAdapter;
    ListView dashListView;
    View footerView;
    String fromdate_formated = "";
    String todate_formated = "";
    private Context context;
    private JSONObject jObject = null;
    private String result, authorizationKey;
    private Map<String, String> params;

    public DashBoardTask(Context context, Map<String, String> params, ListView dashListView, View footerView) {
        this.context = context;
        Log.e("context ", "DashBoardTask: " + context);
        this.dashListView = dashListView;
        Dashboard.dashRowList.clear();
        this.params = params;
        this.footerView = footerView;
        ResponseTask();

    }

    private void ResponseTask() {
        authorizationKey = Constants.ACCESS_TOKEN;
        new ServerResponse(ApiClass.getApiUrl(Constants.DASHBOARD_VIEW)).getJSONObjectfromURL(ServerResponse.RequestType.POST, params, authorizationKey, context, "", new VolleyResponseListener() {

            @Override
            public void onError(String message) {
                if (DashBoardRefactor.progress.isShowing()) {
                    DashBoardRefactor.progress.dismiss();
                }
            }

            @Override
            public void onResponse(String response) {
                String dateEnd = "", startDate = "";
                result = response.toString();
                try {
                    jObject = new JSONObject(result);
                    if (jObject != null) {

                        Integer totalJobList = jObject.getInt("page_count");
                        Integer total = jObject.getInt("total");
                        Integer count = jObject.getInt("count");
                        Integer start = jObject.getInt("start");
                        if (footerView.isShown() && count == 0) {
                            footerView.setVisibility(View.GONE);
                        }

                        Integer Status = jObject.getInt("status");
                        if (Status == 1) {
                            SessionStores.savetotalJobList(totalJobList, context);
                           JSONArray dataObject = jObject.getJSONArray("data");
                            Dashboard.dashRowList.clear();
                            for (int i = 0; i < dataObject.length(); i++) {
                                Log.e("length", "lenght----->" + dataObject.length());
                                JSONObject jobDetail = dataObject.getJSONObject(i);
                                Log.e("jobDetail", "jobDetail----->" + jobDetail);
                                Integer goalsName = jobDetail.getInt("id");
                                String compnyTitle = jobDetail.getString("title");
                                String description = jobDetail.getString("description");
                                Integer salary = jobDetail.getInt("salary");
                                String dateAdded = jobDetail.getString("dateAdded");

                                if (jobDetail.getString("startDate") != null && !jobDetail.getString("startDate").isEmpty() && !jobDetail.getString("startDate").equals("null")) {
                                    startDate = jobDetail.getString("startDate");
                                } else {
                                    Log.e("Task Null", "Task Null----startDate->");
                                }
                                if (jobDetail.getString("dateEnd") != null && !jobDetail.getString("dateEnd").isEmpty() && !jobDetail.getString("dateEnd").equals("null")) {
                                    dateEnd = jobDetail.getString("dateEnd");
                                } else {
                                    Log.e("Task Null", "Task Null----->");
                                }
                                isBookmarked = jobDetail.getInt("isBookmarked");
                                Integer startSalary = jobDetail.getInt("customFloat1");
                                Integer endSalary = jobDetail.getInt("customFloat2");

                                JSONObject cmpanyName = jobDetail.getJSONObject("clientCorporation");
                                String compnyNamede = cmpanyName.getString("name");
                                String city = jobDetail.getString("customText1");

                                JSONObject candidateId = jobDetail.getJSONObject("clientContact");
                                candidateIdNo = candidateId.getString("id");


                                DashListModel dashListItem = new DashListModel();

                                dashListItem.setDashCompanyName(compnyNamede);
                                dashListItem.setDashJobDescription(description);
                                dashListItem.setDashJobPosition(compnyTitle);
                                dashListItem.setDashJobCity(city);
                                // dashListItem.setDashJobState(state);
                                dashListItem.setDashSalary(startSalary.toString());
                                dashListItem.setDashJobAvailableDate(dateAdded);
                                dashListItem.setDashId(goalsName.toString());
                                dashListItem.setDashIsBookMarked(isBookmarked.toString());
                                dashListItem.setDashEndSalary(endSalary.toString());
                                dashListItem.setToDate(dateEnd);

                                ////////////////////////////////////


                                String fromDate = null, toDate = null, postedDate = null;
                                if (startDate.length() > 11) {
                                    Log.e("11", "11---->");
                                    fromDate = Utils.convertFromUnixDateAdded(startDate);

                                } else if (startDate.length() == 10) {

                                    Log.e("10", "10----->");
                                    fromDate = Utils.convertFromUnix(startDate);

                                }

                                if (dateEnd.length() > 11) {
                                    Log.e("11", "11---->");
                                    toDate = Utils.convertFromUnixDateAdded(dateEnd);
                                } else if (dateEnd.length() == 10) {
                                    Log.e("10", "10----->");
                                    toDate = Utils.convertFromUnix(dateEnd);
                                }

                                if (dateAdded.length() > 11) {
                                    Log.e("11", "11---->");
                                    postedDate = Utils.convertFromUnixDateAdded(dateAdded);
                                } else if (dateAdded.length() == 10) {
                                    Log.e("10", "10----->");
                                    postedDate = Utils.convertFromUnix(dateAdded);
                                }

                                try {
                                    if (!fromDate.isEmpty() || !fromDate.equalsIgnoreCase("null")) {
                                        String[] fromDateSplit = fromDate.split("/");
                                        String fromMonth = fromDateSplit[0];
                                        String fromDat = fromDateSplit[1];
                                        String fromYear = fromDateSplit[2];
                                        String fromMonthName = new DateFormatSymbols().getMonths()[Integer.parseInt(fromMonth) - 1];
                                        fromdate_formated = fromMonthName.substring(0, 3) + " " + fromDat + getDayOfMonthSuffix(Integer.parseInt(fromDat));
                                        Log.e("fromdate", "fromdate---->" + fromDate);
                                        Log.e("toDate", "toDate---->" + toDate);

                                        Log.e("fromMonth", "fromMonth---->" + fromMonth);
                                        Log.e("fromDat", "fromDat---->" + fromDat);
                                        Log.e("fromYear", "fromYear---->" + fromYear);

                                    }
                                    if (!toDate.isEmpty() || !toDate.equalsIgnoreCase("null")) {
                                        String[] toDateSplit = toDate.split("/");
                                        String toMonth = toDateSplit[0];
                                        String toDat = toDateSplit[1];
                                        String toYear = toDateSplit[2];
                                        String toMonthName = new DateFormatSymbols().getMonths()[Integer.parseInt(toMonth) - 1];

                                        todate_formated = toMonthName.substring(0, 3) + " " + toDat + getDayOfMonthSuffix(Integer.parseInt(toDat)) + " " + toYear;
                                        Log.e("________________", "-------------------->");

                                        Log.e("toMonth", "toMonth---->" + toMonth);
                                        Log.e("toDat", "toDat---->" + toDat);
                                        Log.e("toYear", "toYear---->" + toYear);
                                        Log.e("________________", "-------------------->");
                                        Log.e("toMonthName", "toMonthName---->" + toMonthName);

                                    }


                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                                dashListItem.setPostedDate(postedDate);
                                dashListItem.setFromDate(fromdate_formated);
                                dashListItem.setEndDate(todate_formated);

                                /////////////////////////////////////////
                                // Dashboard.dashRowList.add(dashListItem);
                                DashBoardRefactor.dashRowList1.add(dashListItem);

                            }

                            // get listview current position - used to maintain scroll position
                            int currentPosition = dashListView.getFirstVisiblePosition();
                            dashListAdapter = new DashListAdapter(context, DashBoardRefactor.dashRowList1, dashListView);
                            dashListView.setAdapter(dashListAdapter);
                            ((BaseAdapter) dashListAdapter).notifyDataSetChanged();

                            if (currentPosition != 0) {
                                // Setting new scroll position
                                dashListView.setSelectionFromTop(currentPosition + 1, 0);
                            }
                        } else if (Status==0 && count==0 && start==0){
                            String Message = jObject.getString("message");
                            Utils.ShowAlert(context, Message);
                        }
                        if (footerView.isShown()) {
                            footerView.setVisibility(View.GONE);
                        }
                        //progress.dismiss();
                        if (DashBoardRefactor.progress.isShowing()) {
                            try {
                                DashBoardRefactor.progress.dismiss();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }


                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        });
    
    }

    }
}

DashList 模型:

public class DashListModel {
    private String dashCompanyName;
    private String dashJobPosition;
    private String dashJobPostedDate;
    private String dashJobDescription;
    private String dashSalary;
    private String dashJobCity;
    private String dashJobState;
    private String dashJobAvailableDate;
    private String dashId, dashIsBookmarked;
    private String dashEndSalary;
    private String toDate;
    private String postedDate, fromdate, enddate;

    public String getDashCompanyName() {
        return dashCompanyName;
    }

    public void setDashCompanyName(String dashCompanyName) {
        this.dashCompanyName = dashCompanyName;
    }

    public String getDashJobPosition() {
        return dashJobPosition;
    }

    public void setDashJobPosition(String dashJobPosition) {
        this.dashJobPosition = dashJobPosition;
    }

    public String getDashJobDescription() {
        return dashJobDescription;
    }

    public void setDashJobDescription(String dashJobDescription) {
        this.dashJobDescription = dashJobDescription;
    }

    public String getDashJobPostedDate() {
        return dashJobPostedDate;
    }

    public void setDashJobPostedDate(String dashJobPostedDate) {
        this.dashJobPostedDate = dashJobPostedDate;
    }

    public String getDashSalary() {
        return dashSalary;
    }

    public void setDashSalary(String dashSalary) {
        this.dashSalary = dashSalary;
    }

    public String getDashJobCity() {
        return dashJobCity;
    }

    public void setDashJobCity(String dashJobCity) {
        this.dashJobCity = dashJobCity;
    }


   /* public String getDashJobState() {
        return dashJobState;
    }

    public void setDashJobState(String dashJobState) {
        this.dashJobState = dashJobState;
    }*/

    public String getDashJobAvailableDate() {
        return dashJobAvailableDate;
    }


    public void setDashJobAvailableDate(String dashJobAvailableDate) {
        this.dashJobAvailableDate = dashJobAvailableDate;
    }

    public String getDashId() {
        return dashId;
    }

    public void setDashId(String dashId) {
        this.dashId = dashId;
    }


    public String getDashIsBookmarked() {
        return dashIsBookmarked;
    }

    public void setDashIsBookMarked(String dashIsBookmarked) {
        this.dashIsBookmarked = dashIsBookmarked;
    }


    public String getDashEndSalary() {
        return dashEndSalary;
    }

    public void setDashEndSalary(String dashEndSalary) {
        this.dashEndSalary = dashEndSalary;
    }

    public String getToDate() {
        return toDate;
    }

    public void setToDate(String toDate) {
        this.toDate = toDate;
    }

    public String getPostedDate() {
        return postedDate;
    }

    public void setPostedDate(String postedDate) {
        this.postedDate = postedDate;
    }

    public String getFromDate() {
        return fromdate;
    }

    public void setFromDate(String fromdate) {
        this.fromdate = fromdate;
    }

    public String getEndDate() {
        return enddate;
    }

    public void setEndDate(String enddate) {
        this.enddate = enddate;
    }

破折号适配器:

包 com.peoplecaddie.adapter;

公共类 DashListAdapter 扩展 BaseAdapter {

    public static ListView dashListView;
    Context c;
    private LayoutInflater inflater;
    private List<DashListModel> dashRowList;


    public DashListAdapter(Context c, List<DashListModel> dashRowList, ListView dashListView) {
        this.c = c;
        this.dashListView = dashListView;
        this.dashRowList = dashRowList;
    }

    @Override
    public int getCount() {
        return this.dashRowList.size();
    }

    @Override
    public Object getItem(int position) {
        return dashRowList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder dashHolder;
        if (inflater == null)
            inflater = (LayoutInflater) c
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        if (convertView == null)
            convertView = inflater.inflate(R.layout.dashboard_jobdetails_list, null);

        final DashListModel dashModel = dashRowList.get(position);
        dashHolder = new ViewHolder(convertView);


        dashHolder.dash_company_name.setText(dashModel.getDashCompanyName());
        dashHolder.dash_position_name.setText(dashModel.getDashJobPosition());
        dashHolder.dash_posted_date.setText(dashModel.getPostedDate());
        dashHolder.dash_job_description.setText(Utils.stripHtml(dashModel.getDashJobDescription()));
        dashHolder.dash_salary.setText(dashModel.getDashSalary() + " - " + dashModel.getDashEndSalary());
        dashHolder.dash_available_date.setText(dashModel.getFromDate() + " - " + dashModel.getEndDate());
        dashHolder.book_jobCity.setText(dashModel.getDashJobCity());
        if (dashModel.getDashIsBookmarked().equalsIgnoreCase("1")) {
            dashHolder.bookmark_img.setImageResource(R.drawable.bookmark);
        } else if (dashModel.getDashIsBookmarked().equalsIgnoreCase("0")) {
            dashHolder.bookmark_img.setImageResource(R.drawable.blue_tag_img);
        }

        dashHolder.bookmark_img.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                if (dashModel.getDashIsBookmarked().equalsIgnoreCase("0")) {
                    dashModel.setDashIsBookMarked("1");
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("candidate_id", SessionStores.getBullHornId(c));
                    params.put("joborder_id", dashModel.getDashId());
                    BackGroundTasks bookmark_add_bg_tasks = new BackGroundTasks(c, new JSONObject(params), Constants.BOOKMARK_ADD_TAG);
                    bookmark_add_bg_tasks.ResponseTask(new BackGroundTasks.VolleyCallbackOnEdit() {
                        @Override
                        public void onSuccess(String result) {
                            String resp_resultsd = result;
                            Log.e("insidecallback", " bookmark_add_bg_tasks----->" + resp_resultsd);
                            // finish();
                            dashHolder.bookmark_img.setImageResource(R.drawable.bookmark);
                            notifyDataSetChanged();
                        }
                    });

                } else if (dashModel.getDashIsBookmarked().equalsIgnoreCase("1")) {
                    dashModel.setDashIsBookMarked("0");
                    Log.e("imgchange", " imgchange");

                    Map<String, String> params = new HashMap<String, String>();
                    params.put("candidate_id", SessionStores.getBullHornId(c));
                    params.put("joborder_id", dashModel.getDashId());

                    BackGroundTasks bookmark_delete_bg_tasks = new BackGroundTasks(c, new JSONObject(params), Constants.BOOKMARK_DELETE_TAG);
                    bookmark_delete_bg_tasks.ResponseTask(new BackGroundTasks.VolleyCallbackOnEdit() {
                        @Override
                        public void onSuccess(String result) {
                            String resp_resultsd = result;
                            Log.e("insidecallback", " bookmark_delete_bg_tasks----->" + resp_resultsd);
                            // finish();
                            dashHolder.bookmark_img.setImageResource(R.drawable.blue_tag_img);
                            notifyDataSetChanged();
                        }
                    });
                }

            }
        });

        return convertView;
    }


    static class ViewHolder {
        @Bind(R.id.book_company_name)
        TextView dash_company_name;
         private RelativeLayout.LayoutParams viewLayParams;
            public ViewHolder(View view) {
            ButterKnife.bind(this, view);


        }
    }


}

澄清:

  1. 如何在单击仪表板片段上的筛选按钮时进行筛选。请建议方法。我在这里也附上了我的过滤器设计。

Dashboard Fragment--> Filter Button-> Filter screen-> 过滤后的结果应该在 DashBoard Fragment 上查看。

在此处输入图像描述

单击应用按钮后,根据过滤器屏幕的输入,它会过滤列表视图,结果来自后端团队。我必须在仪表板片段上显示该结果。

请澄清这个过滤器的概念。

4

0 回答 0