Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当列表大小较大时,在Recyclerview上滚动时崩溃_Android_Scroll_Android Recyclerview_Load - Fatal编程技术网

Android 当列表大小较大时,在Recyclerview上滚动时崩溃

Android 当列表大小较大时,在Recyclerview上滚动时崩溃,android,scroll,android-recyclerview,load,Android,Scroll,Android Recyclerview,Load,我从webservice加载recyclerview数据。当列表大小较大时,活动在滚动时崩溃。但该活动仅在棒棒糖设备上崩溃。在Marshmellow设备中,它工作良好。有人能帮忙吗?提前谢谢 公共类ActivityDisplayTasksforRating扩展AppCompativeActivity实现CustomDatePickerListener{ boolean shouldExecuteOnResume; private RecyclerView recyclerVw_rating;

我从webservice加载recyclerview数据。当列表大小较大时,活动在滚动时崩溃。但该活动仅在棒棒糖设备上崩溃。在Marshmellow设备中,它工作良好。有人能帮忙吗?提前谢谢

公共类ActivityDisplayTasksforRating扩展AppCompativeActivity实现CustomDatePickerListener{

boolean shouldExecuteOnResume;

private RecyclerView recyclerVw_rating;
private TaskRatingAdapter mAdapter;
private LinearLayout lLayout_no_data;
private NetworkClass networkClass = new NetworkClass();
private String mUserId, mStartDate, mEndDate;
private List<TaskApprovalListNew.OverdueRatingReport> mTaskApprovalList = new ArrayList<>();
private ImageView btn_Sync, imgVw_menu, imgV_calendarList;
private TextView txtVw_start_end_date,txtVw_dashboardTitle;
private CustomProgress mcustomprogress;
private CircularImageView imgVw_profile_image;
private String mProfile_image_url;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rating);
    shouldExecuteOnResume = false;
    getViewCasting(); // Casting the views


    Intent intent = getIntent();

    if (intent.hasExtra("profile_image"))
    {
        mProfile_image_url = intent.getStringExtra("profile_image");
    }


    if (mProfile_image_url!=null)
    {
        Picasso.with(ActivityDisplayTasksforRating.this).load(mProfile_image_url).error(R.drawable.zoonooz).memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).placeholder(R.drawable.zoonooz).skipMemoryCache().into(imgVw_profile_image);
    }

    txtVw_dashboardTitle.setText("Task Approval List");
    imgV_calendarList.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            // shows the custom date picker dialog
            CustomDatePicker alertDialog = new CustomDatePicker(ActivityDisplayTasksforRating.this, true, ActivityDisplayTasksforRating.this);
            alertDialog.getWindow ().setBackgroundDrawableResource(android.R.color.transparent);
            alertDialog.show();
        }
    });

    getTaskDataforRating(mStartDate, mEndDate);
}

public void getViewCasting() {
    recyclerVw_rating = (RecyclerView) findViewById(R.id.recyclerVw_common);
    lLayout_no_data = (LinearLayout) findViewById(R.id.lLayout_no_data);
    btn_Sync = (ImageView) findViewById(R.id.btn_Sync);
    imgVw_menu = (ImageView) findViewById(R.id.imgVw_menu);
    imgV_calendarList = (ImageView) findViewById(R.id.imgV_calendarList);
    txtVw_start_end_date = (TextView) findViewById(R.id.txtVw_start_end_date);
    txtVw_dashboardTitle = (TextView) findViewById(R.id.txtVw_dashboardTitle);
    imgVw_profile_image = (CircularImageView)findViewById(R.id.imgVw_profile_image);

    imgV_calendarList.setVisibility(View.VISIBLE);
    imgVw_menu.setVisibility(View.GONE);
    btn_Sync.setVisibility(View.GONE);
}


public void initRecyclerview()
{
    if (mTaskApprovalList.size()>0) {
        System.out.println("=========list size"+mTaskApprovalList.size());

        recyclerVw_rating.setHasFixedSize(true);
        RecyclerView.LayoutManager layoutManager = new GridLayoutManager(ActivityDisplayTasksforRating.this, 1);
        recyclerVw_rating.setLayoutManager(layoutManager);
        mAdapter = new TaskRatingAdapter(ActivityDisplayTasksforRating.this, mTaskApprovalList);
        recyclerVw_rating.setAdapter(mAdapter);
    }else
    {
        System.out.println("=========List empty");
        recyclerVw_rating.setVisibility(View.GONE);
        lLayout_no_data.setVisibility(View.VISIBLE);
    }
}

public void getTaskDataforRating(final String start_date, final String end_date)
{
    try {

        if (NetworkClass.isOnline(ActivityDisplayTasksforRating.this)) {

            if (mTaskApprovalList.size()>0)
            {
                mTaskApprovalList.clear();
            }

            Retrofit retrofit = networkClass.callretrofit();

            APIInterfaces service = retrofit.create(APIInterfaces.class);

            mUserId = PreferenceConnector.readString(ActivityDisplayTasksforRating.this, PreferenceConnector.USER_ID, "");

            Call<TaskApprovalListNew> call = service.getTasksforApprovalList(mUserId, start_date, end_date); // "6"

            mcustomprogress = new CustomProgress();
            mcustomprogress.showCustomDialog(this);
            mcustomprogress.setText("Fetching data");


            call.enqueue(new Callback<TaskApprovalListNew>() {
                @Override
                public void onResponse(Call<TaskApprovalListNew> call, retrofit2.Response<TaskApprovalListNew> response) {

                    if (response.body() != null) if (response.isSuccessful()) {

                        String status = response.body().getStatus();

                        mTaskApprovalList = response.body().getOverdueRatingReport();

                        if (status.equals("NTE_01")) {

                            initRecyclerview();
                        } else {
                            initRecyclerview();
                        }

                        if (mcustomprogress != null) {
                            mcustomprogress.dismiss();
                        }
                    }
                }

                @Override
                public void onFailure(Call<TaskApprovalListNew> call, Throwable t) {
                    if (mcustomprogress != null) {
                        mcustomprogress.dismiss();
                    }
                    Toast.makeText(ActivityDisplayTasksforRating.this, "Failure :" + t.getMessage().toString(), Toast.LENGTH_LONG).show();
                }
            });
        } else {
            if (mcustomprogress != null) {
                mcustomprogress.dismiss();
            }
            Toast.makeText(ActivityDisplayTasksforRating.this, "Please connect to internet", Toast.LENGTH_LONG).show();

        }
    } catch (Exception e) {
        e.printStackTrace();
        Log.d("Exception", e.getMessage());
    }
}



public class TaskRatingAdapter extends RecyclerView.Adapter<TaskRatingAdapter.ViewHolder>{

    private Context mContext;
    private List<TaskApprovalListNew.OverdueRatingReport> mManagerProjectsList = new ArrayList<>();

    // Passing Project List
    public TaskRatingAdapter(Context context, List<TaskApprovalListNew.OverdueRatingReport> project_list) {

        mContext = context;
        this.mManagerProjectsList = project_list;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_tasks_for_rating, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {

        System.out.println("=========Position"+position);
        System.out.println("=========Task Name"+mManagerProjectsList.get(position).getTaskName());


        String profile_image = mManagerProjectsList.get(position).getProfileImage();

        if (profile_image!=null)
        {
            Picasso.with(ActivityDisplayTasksforRating.this).load(profile_image).error(R.drawable.zoonooz).memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).placeholder(R.drawable.zoonooz).skipMemoryCache().into(holder.imgVw_user_image);
        }

        holder.txtVw_author.setText(mManagerProjectsList.get(position).getUserName());
        holder.txtVw_task_title.setText(mManagerProjectsList.get(position).getTaskName());
        holder.txtVw_proj_name.setText(mManagerProjectsList.get(position).getProject_name());

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(ActivityDisplayTasksforRating.this, TaskRatingActivity.class);
                intent.putExtra("task_id",mManagerProjectsList.get(position).getTaskId());
                intent.putExtra("total_hours",mManagerProjectsList.get(position).getTotalHours());
                intent.putExtra("user_id",mManagerProjectsList.get(position).getUserId()); // Passing the task_id, total_hours and user id to sync activity
                startActivity(intent);
            }
        });

    }

    @Override
    public int getItemCount() {
        return mManagerProjectsList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView txtVw_task_title,txtVw_proj_name,txtVw_author,txtVw_task_day,txtVw_task_month,txtVw_task_year,txtVw_task_start_time;;
        private CircularImageView imgVw_user_image;

        public ViewHolder(View view) {
            super(view);
            txtVw_task_title = (TextView) view.findViewById(R.id.txtVw_task_title);
            txtVw_proj_name = (TextView) view.findViewById(R.id.txtVw_proj_name);
            txtVw_author = (TextView) view.findViewById(R.id.txtVw_author);
            txtVw_task_day = (TextView) view.findViewById(R.id.txtVw_task_day);
            txtVw_task_month = (TextView) view.findViewById(R.id.txtVw_task_month);
            txtVw_task_year = (TextView) view.findViewById(R.id.txtVw_task_year);
            txtVw_task_start_time = (TextView) view.findViewById(R.id.txtVw_task_start_time);
            imgVw_user_image = (CircularImageView) view.findViewById(R.id.imgVw_user_image);
        }
    }

}
boolean应该执行恢复;
私人回收站查看回收站W_评级;
私人任务适应器;
私人线路布局图无数据;
专用网络类NetworkClass=新网络类();
私有字符串mUserId、mStartDate、mEndDate;
私有列表mTaskApprovalList=新建ArrayList();
私有图像视图btn_同步、imgVw_菜单、imgV_日历列表;
私有文本视图txtVw_开始_结束_日期,txtVw_仪表盘标题;
私人定制进程;
私人CircularImageView imgVw_profile_image;
私有字符串文件\图像\ url;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rating);
shouldExecuteOnResume=false;
getViewCasting();//转换视图
Intent=getIntent();
if(intent.hasExtra(“profile_image”))
{
mProfile_image_url=intent.getStringExtra(“profile_image”);
}
if(mProfile\u image\u url!=null)
{
Picasso.with(ActivityDisplayTasksforRating.this).load(mProfile\u image\u url).error(R.drawable.zoonooz).memoryPolicy(memoryPolicy.NO\u CACHE,memoryPolicy.NO\u STORE).占位符(R.drawable.zoonooz).skipMemoryCache().放入(imgVw\u profile\u image);
}
txtVw_dashboardTitle.setText(“任务批准列表”);
imgV_calendarList.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图){
//显示“自定义日期选择器”对话框
CustomDatePicker alertDialog=新建CustomDatePicker(ActivityDisplayTasksforRating.this,true,ActivityDisplayTasksforRating.this);
alertDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
alertDialog.show();
}
});
getTaskDataforRating(mStartDate、mEndDate);
}
public void getViewCasting(){
recyclerVw_评级=(RecyclerView)findViewById(R.id.recyclerVw_公共);
lLayout\u no\u数据=(线性布局)findViewById(R.id.lLayout\u no\u数据);
btn_Sync=(ImageView)findviewbyd(R.id.btn_Sync);
imgVw_菜单=(ImageView)findViewById(R.id.imgVw_菜单);
imgV_calendarList=(ImageView)findViewById(R.id.imgV_calendarList);
txtVw_开始_结束_日期=(TextView)findViewById(R.id.txtVw_开始_结束_日期);
txtVw_dashboardTitle=(TextView)findViewById(R.id.txtVw_dashboardTitle);
imgVw_profile_image=(CircularImageView)findViewById(R.id.imgVw_profile_image);
imgV_calendarList.setVisibility(View.VISIBLE);
imgVw_menu.setVisibility(View.GONE);
btn_Sync.setVisibility(View.GONE);
}
public void initRecyclerview()
{
如果(mTaskApprovalList.size()>0){
System.out.println(“==========列表大小”+mTaskApprovalList.size());
recyclerVw_rating.setHasFixedSize(真);
RecyclerView.LayoutManager LayoutManager=新建GridLayoutManager(ActivityDisplayTasksforRating.this,1);
设置布局管理器(布局管理器);
mAdapter=new TaskRatingAdapter(ActivityDisplayTasksforRating.this,mTaskApprovalList);
回收器额定值设置适配器(mAdapter);
}否则
{
System.out.println(“=============列表为空”);
recyclerVw_rating.setVisibility(视图已消失);
lLayout_no_data.setVisibility(View.VISIBLE);
}
}
public void getTaskDataforRating(最终字符串开始日期、最终字符串结束日期)
{
试一试{
if(NetworkClass.isOnline(ActivityDisplayTasksforRating.this)){
如果(mTaskApprovalList.size()>0)
{
mTaskApprovalList.clear();
}
改装改装=networkClass.CallRefundation();
APIInterfaces服务=翻新.create(APIInterfaces.class);
mUserId=PreferenceConnector.readString(ActivityDisplayTasksforRating.this,PreferenceConnector.USER_ID,“”);
Call Call=service.getTasksforApprovalList(mUserId,开始日期,结束日期);/“6”
mcustomprogress=新的CustomProgress();
mcustomprogress.showCustomDialog(this);
mcustomprogress.setText(“获取数据”);
call.enqueue(新回调(){
@凌驾
公共void onResponse(呼叫,改装2.响应){
if(response.body()!=null)if(response.issusccessful()){
字符串状态=response.body().getStatus();
mTaskApprovalList=response.body().getOverdueRatingReport();
if(状态等于(“NTE_01”)){
initRecyclerview();
}否则{
initRecyclerview();
}
if(mcustomprogress!=null){
mcustomprogress.disclose();
}
}
}
@凌驾
失败时公共无效(调用调用,可丢弃的t){
if(mcustomprogress!=null){
mcustomprogress.disclose();
}
Toast.makeText(ActivityDisplayTasksforRating.this,“失败:+t.getMessage().toString(),Toast.LENGTH_LONG).show();
}
});
}否则{
if(mcustomprogress!=null){
mcustomprogress.disclose();
}
Toast.makeText(ActivityDisplayTasksforRating.this,“请连接到internet”,Toast.LENGTH\u LONG.show();
}
}捕获(例外e){
e、 printStackTrace();
Log.d(“异常”,例如getMessage());
}
}
公共类TaskRatingAdapter扩展