Я сделал фрагмент, адаптер и геттер и сеттер для отображения имени и изображения с залпом. Ничего не отображается - PullRequest
0 голосов
/ 17 февраля 2019

Я сделал фрагмент, адаптер, а также метод получения и установки для отображения имени и изображения с залпом. Но я не получаю отображение имени и изображения на фрагменте. Я получаю сообщение об ошибке, как показано ниже: Ничего не отображается.Я сделал фрагмент, адаптер, и получатель и установщик для отображения имени и изображения с залпом, но я не получаю отображение имени и изображения на фрагменте. Я получаю ошибку, как показано ниже: Ничего не отображается

02-17 02:39:29.177 12180-12180/novumlogic.payment D/Volley: Register Response3: {"category":[{"name":"Fruits Vegetables & Non-Veg","id":"5c65b5ea7ab58d1d1411c4ec","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Art Craft & Stationary","id":"5c65b60c7ab58d1d1411c4ed","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Milk parlour & Bakery","id":"5c65b6107ab58d1d1411c4ee","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Tour & Travel","id":"5c65b6127ab58d1d1411c4ef","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Jewelry","id":"5c65b6157ab58d1d1411c4f0","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Health Check up & Labs","id":"5c65b6187ab58d1d1411c4f1","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Fuel & Gas","id":"5c65b61b7ab58d1d1411c4f2","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Lifestyle","id":"5c65b61e7ab58d1d1411c4f3","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Lifestyle & Gym","id":"5c65b6217ab58d1d1411c4f4","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Fitness & Gym","id":"5c65b6247ab58d1d1411c4f5","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Medicine shop","id":"5c65b6277ab58d1d1411c4f6","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Hospital & Clinic","id":"5c65b62a7ab58d1d1411c4f7","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Automobile & Garage","id":"5c65b62c7ab58d1d1411c4f8","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Beauty Salon & Spa","id":"5c65b62e7ab58d1d1411c4f9","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Hotel & Restaurant","id":"5c65b6317ab58d1d1411c4fa","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Mall & Super Markets","id":"5c65b6347ab58d1d1411c4fb","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Grocery & Puja Shop","id":"5c65b6367ab58d1d1411c4fc","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Electronic Appliances","id":"5c65b6397ab58d1d1411c4fd","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Kitchen & Utilities","id":"5c65b63c7ab58d1d1411c4fe","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Home Decor & Nursery","id":"5c65b63f7ab58d1d1411c4ff","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Institutions & extra activities","id":"5c65b6417ab58d1d1411c500","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"}]}
02-17 02:39:29.178 12180-12180/novumlogic.payment D/Volley: Register Response4: [{"name":"Fruits Vegetables & Non-Veg","id":"5c65b5ea7ab58d1d1411c4ec","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Art Craft & Stationary","id":"5c65b60c7ab58d1d1411c4ed","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Milk parlour & Bakery","id":"5c65b6107ab58d1d1411c4ee","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Tour & Travel","id":"5c65b6127ab58d1d1411c4ef","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Jewelry","id":"5c65b6157ab58d1d1411c4f0","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Health Check up & Labs","id":"5c65b6187ab58d1d1411c4f1","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Fuel & Gas","id":"5c65b61b7ab58d1d1411c4f2","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Lifestyle","id":"5c65b61e7ab58d1d1411c4f3","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Lifestyle & Gym","id":"5c65b6217ab58d1d1411c4f4","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Fitness & Gym","id":"5c65b6247ab58d1d1411c4f5","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Medicine shop","id":"5c65b6277ab58d1d1411c4f6","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Hospital & Clinic","id":"5c65b62a7ab58d1d1411c4f7","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Automobile & Garage","id":"5c65b62c7ab58d1d1411c4f8","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Beauty Salon & Spa","id":"5c65b62e7ab58d1d1411c4f9","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Hotel & Restaurant","id":"5c65b6317ab58d1d1411c4fa","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Mall & Super Markets","id":"5c65b6347ab58d1d1411c4fb","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Grocery & Puja Shop","id":"5c65b6367ab58d1d1411c4fc","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Electronic Appliances","id":"5c65b6397ab58d1d1411c4fd","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Kitchen & Utilities","id":"5c65b63c7ab58d1d1411c4fe","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Home Decor & Nursery","id":"5c65b63f7ab58d1d1411c4ff","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"},{"name":"Institutions & extra activities","id":"5c65b6417ab58d1d1411c500","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"}]
    Register Response5: {"name":"Fruits Vegetables & Non-Veg","id":"5c65b5ea7ab58d1d1411c4ec","image":"https:\/\/theboatgalley.com\/wp-content\/uploads\/VeggiesFB.jpg"}
02-17 02:39:29.179 12180-12180/novumlogic.payment W/System.err: org.json.JSONException: No value for image
        at org.json.JSONObject.get(JSONObject.java:389)
        at org.json.JSONObject.getString(JSONObject.java:550)
        at novumlogic.payment.home.CateFragment$1.onResponse(CateFragment.java:107)
        at novumlogic.payment.home.CateFragment$1.onResponse(CateFragment.java:81)
        at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:78)
        at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
02-17 02:39:29.180 12180-12180/novumlogic.payment W/System.err:     at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:106)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6123)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

CateFragment

public class CateFragment extends Fragment
{
    View rootView;
    RecyclerView recyclerViewInstitutions;
            CustomListAdapter institutionAdapter;
            ArrayList<Movie> institutions;



        String stateName,serviceName,userImageUrl;

public CateFragment() {

        }



@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        }

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_institutions, container, false);
        recyclerViewInstitutions = (RecyclerView) rootView.findViewById(R.id.recycler_view_institutions);
        LinearLayoutManager llm = new LinearLayoutManager(getContext());
        llm.setOrientation(LinearLayoutManager.VERTICAL);
//        recyclerView.addItemDecoration(new DividerItemDecoration(getContext(),10));
        recyclerViewInstitutions.setLayoutManager(llm);
        institutions = new ArrayList<>();
        institutionAdapter = new CustomListAdapter(institutions);
        recyclerViewInstitutions.setAdapter(institutionAdapter);





        getClientsList();
        return rootView;
        }

private void getClientsList() {
    String tag_string_req = "req_register";
        String url = AppConfig.Base_Url +AppConfig.App_api+AppConfig.URL_Cat;


        final StringRequest jsonObjReq = new StringRequest(Request.Method.GET,url, new Response.Listener<String>() {

           @Override
public void onResponse( String response) {

        try {

            String jsonObjReq = null;
            JSONObject obj = new JSONObject(String.valueOf(response));
            String status = obj.getString("status");
            String message =obj.getString("message");
            Log.d(TAG, "Register Response1: " + status);
            Log.d(TAG, "Register Response2: " + message);
            JSONObject obj1=new JSONObject(String.valueOf(obj));
            JSONObject result = obj.getJSONObject("result");
            Log.d(TAG, "Register Response3: " + result);
            JSONArray category=result.getJSONArray("category");
            Log.d(TAG, "Register Response4: " + category);

            for(int i=0;i<category.length();i++)
            {
                JSONObject object= category.getJSONObject(i);
                Log.d(TAG, "Register Response5: " + object);
                Movie institution = new Movie();
                institution.setOrganization_name(object.getString("name"));
                institution.setOrganizationId(object.getString("id"));
                institution.setOrgLogo(obj.getString("image"));
                institutions.add(institution);
            }






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

        }, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
        Toast.makeText(getContext(), "Error", Toast.LENGTH_SHORT).show();
        }
        });
        Appcontrol.getInstance().addToRequestQueue(jsonObjReq,tag_string_req);
        }
        }

CustomListAdapter

public class CustomListAdapter extends RecyclerView.Adapter<CustomListAdapter.MyViewHolder> {
    int count;
    ArrayList<Movie> institutions;

    ImageLoader imageLoader = Appcontrol.getInstance().getImageLoader();
    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_institutions_tab, parent, false);
        return new MyViewHolder(v);
    }

    public CustomListAdapter(ArrayList<Movie> institutions) {
        this.institutions = institutions;
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {

        final Movie mainFeedData = institutions.get(position);

        holder.instituteName.setText(mainFeedData.getOrganization_name());
        holder.instituteLocation.setText(mainFeedData.getOrgAddress());
        holder.thumbnail.setImageIcon(Icon.createWithContentUri(mainFeedData.getOrgLogo()));

        if (mainFeedData.getOrgLogo()==null){
            holder.thumbnail.setDefaultImageResId(R.drawable.image_not_found);
        }
        else {
            holder.thumbnail.setImageUrl(mainFeedData.getOrgLogo(), imageLoader);
            Log.d("image1234","adapter-->"+mainFeedData.getOrgLogo().toString());
        }

        if (mainFeedData.getOrgLogo()==null){
            holder.clinetbanner.setDefaultImageResId(R.drawable.image_not_found);
        }
        else {
            holder.clinetbanner.setImageUrl(mainFeedData.getOrgWal(),imageLoader);
            Log.d("image1234","adapter-->"+mainFeedData.getOrgWal().toString());

        }



        //holder.thumbnail.setImageIcon(Icon.createWithContentUri(mainFeedData.getOrgLogo()));
//        holder.instituteLocation.setText(mainFeedData.getOrgDesc());
        holder.thumbnail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /*Intent intent = new Intent(v.getContext(), FullViewOfClientsProceed.class);
                intent.putExtra("clientName", mainFeedData.getOrganization_name());

                intent.putExtra("state", mainFeedData.getOrgAddress());
                intent.putExtra("clientLogoPath", mainFeedData.getOrgLogo());
                intent.putExtra("clientImagePath",mainFeedData.getOrgWal());
                intent.putExtra("clientId",mainFeedData.getOrganizationId());
                intent.putExtra("landing_page",mainFeedData.getOrgDesc());
*/
                Log.d("clientId_thumbnail",""+mainFeedData.getOrganizationId());
            //  Log.d("land",""+mainFeedData.getOrgDesc());

                //v.getContext().startActivity(intent);
            }
        });
        holder.instituteLocation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /*Intent intent = new Intent(v.getContext(), FullViewOfClientsProceed.class);
                v.getContext().startActivity(intent);
                intent.putExtra("clientName", mainFeedData.getOrganization_name());
                intent.putExtra("state", mainFeedData.getOrgAddress());
                intent.putExtra("clientLogoPath", mainFeedData.getOrgLogo());
                intent.putExtra("clientImagePath",mainFeedData.getOrgWal());
                intent.putExtra("clientId",mainFeedData.getOrganizationId());
                intent.putExtra("landing_page",mainFeedData.getOrgDesc());*/
                Log.d("clientId_location",""+mainFeedData.getOrganizationId());
            }
        });
        holder.instituteName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /*Intent intent = new Intent(v.getContext(), FullViewOfClientsProceed.class);
                intent.putExtra("clientName", mainFeedData.getOrganization_name());
                intent.putExtra("state", mainFeedData.getOrgAddress());
                intent.putExtra("clientLogoPath", mainFeedData.getOrgLogo());
                intent.putExtra("clientImagePath",mainFeedData.getOrgWal());
                Log.d("clientId_instituteNm",""+mainFeedData.getOrganizationId());
                intent.putExtra("landing_page",mainFeedData.getOrgDesc());*/
            //  Log.d("urllll",""+mainFeedData.getOrgDesc());
            //  intent.putExtra("clientId",mainFeedData.getOrganizationId());

            //  v.getContext().startActivity(intent);
            }
        });
        holder.clinetbanner.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /*Intent intent = new Intent(v.getContext(), FullViewOfClientsProceed.class);
                intent.putExtra("clientName", mainFeedData.getOrganization_name());
                intent.putExtra("state", mainFeedData.getOrgAddress());
                intent.putExtra("clientLogoPath", mainFeedData.getOrgLogo());
                intent.putExtra("clientImagePath",mainFeedData.getOrgWal());*/
                Log.d("clientId_banner",""+mainFeedData.getOrganizationId());
                /*intent.putExtra("clientId",mainFeedData.getOrganizationId());
                intent.putExtra("landing_page",mainFeedData.getOrgDesc());
                v.getContext().startActivity(intent);*/

            }
        });
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        ImageView instituteLogo,institutePic;
        NetworkImageView thumbnail,clinetbanner;
        TextView instituteName,instituteLocation;
        public MyViewHolder(View itemView) {
            super(itemView);


            thumbnail = (NetworkImageView) itemView .findViewById(R.id.thumbnail);
            clinetbanner =(NetworkImageView) itemView.findViewById(R.id.clinetbanner);
            //instituteLogo = (ImageView)itemView.findViewById(R.id.iv_instituteLogo);
            //institutePic = (ImageView)itemView.findViewById(R.id.iv_institutePic);
            //thumbnail =(NetworkImageView)itemView.findViewById(R.id.thumbnail);

            instituteName = (TextView)itemView.findViewById(R.id.tv_instituteName);
            instituteLocation = (TextView)itemView.findViewById(R.id.tv_instituteLocation);
        }
    }

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

Фильм

public class Movie {
    String organizationId;
    String organization_name;
    ;
    String image;
    String orgWal;
    String orgAddress;


    public Movie() {
    }

    public String getOrganizationId() {
        return organizationId;
    }

    public void setOrganizationId(String organizationId) {
        this.organizationId = organizationId;
    }

    public String getOrganization_name() {
        return organization_name;
    }

    public void setOrganization_name(String organization_name) {
        this.organization_name = organization_name;
    }



    public String getOrgLogo() {
        return image;
    }

    public void setOrgLogo(String image) {
        this.image = image;
    }

    public String getOrgWal() {
        return orgWal;
    }


    public String getOrgAddress() {
        return orgAddress;
    }


}

фрагмент_институции.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">
<android.support.design.widget.CollapsingToolbarLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/collaps"
    android:fitsSystemWindows="true"


    app:expandedTitleMarginStart="48dp"

    app:expandedTitleMarginEnd="64dp"
    >

    <FrameLayout
        android:id="@+id/institutions_tab_fragments"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <com.cooltechworks.views.shimmer.ShimmerRecyclerView
            android:id="@+id/recycler_view_institutions"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:id="@+id/noDataFound"
            android:visibility="invisible"
            >
            <include
                layout="@layout/no_data_found"
                >

            </include>

        </LinearLayout>

    </FrameLayout>

</android.support.design.widget.CollapsingToolbarLayout>
    <android.support.v4.widget.NestedScrollView

    android:id="@+id/scroll"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:clipToPadding="false"

    app:layout_behavior="@string/appbar_scrolling_view_behavior">


</android.support.v4.widget.NestedScrollView>

item_institution_tab.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:orientation="vertical"
    android:layout_marginTop="10dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">

        <com.android.volley.toolbox.NetworkImageView
            android:id="@+id/thumbnail"
            android:layout_width="60dp"
            android:src="@drawable/image_not_found"
            android:layout_height="30sp"
            android:scaleType="fitXY"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"


            />

        <!--TODO instituteLogo-->
        <!--<ImageView
            android:id="@+id/iv_instituteLogo"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="0.8"
            android:src="@drawable/coaicon" />-->

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:orientation="vertical">

            <!--TODO instituteName-->
            <TextView
                android:id="@+id/tv_instituteName"
                android:layout_width="match_parent"
                android:layout_height="20sp"
                android:text="Council of Architecture" />

            <!--TODO instituteLocation-->
            <TextView
                android:id="@+id/tv_instituteLocation"
                android:layout_width="match_parent"
                android:layout_height="20sp"

                android:text="New Delhi" />
        </LinearLayout>
    </LinearLayout>

    <!--TODO institutePic-->

    <com.android.volley.toolbox.NetworkImageView
        android:id="@+id/clinetbanner"
        android:layout_width="match_parent"
        android:layout_height="150sp"
        android:src="@drawable/image_not_found"

        />

   <!-- <ImageView
        android:id="@+id/iv_institutePic"
        android:layout_marginTop="15dp"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:src="@drawable/institude_architecture"
        android:scaleType="centerCrop"/>-->


    <!--<com.android.volley.toolbox.NetworkImageView
        android:id="@+id/thumbnail"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_alignParentLeft="true"
        android:layout_marginRight="8dp" />-->


</LinearLayout>
...