public static void setProgressDialog(final Activity activity, boolean show) { try { if (activity == null) { return; } builder = new MaterialDialog.Builder(activity); LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View dialogView = inflater.inflate(R.layout.item_progress_dialog, null); avLoadingIndicatorView = (AVLoadingIndicatorView) dialogView.findViewById(R.id.avDialog); builder.customView(dialogView, false); if (dialogMaterial != null) { if (dialogMaterial.isShowing()) { dialogMaterial.dismiss(); avLoadingIndicatorView.hide(); } dialogMaterial = null; } else { dialogMaterial = null; } dialogMaterial = builder.build(); dialogMaterial.setCancelable(false); dialogMaterial.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialogMaterial.getWindow().setDimAmount(0.0f); dialogMaterial.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); if (show) { dialogMaterial.dismiss(); dialogMaterial.show(); avLoadingIndicatorView.show(); } else { dialogMaterial.dismiss(); avLoadingIndicatorView.hide(); } } catch (Exception e) { e.printStackTrace(); } }
Friday, 16 November 2018
Set ProgressDialog
Thursday, 24 May 2018
App Permission
public class AppPermissions { private Activity mActivity; @Deprecated public AppPermissions() { } public AppPermissions(Activity activity) { mActivity = activity; } public boolean hasPermission(String permission) { return ActivityCompat.checkSelfPermission(mActivity, permission) == PackageManager.PERMISSION_GRANTED; } public boolean hasPermission(String[] permissionsList) { for (String permission : permissionsList) { if (ActivityCompat.checkSelfPermission(mActivity, permission) != PackageManager.PERMISSION_GRANTED) { return false; } } return true; } public void requestPermission(String permission, int requestCode) { if (ActivityCompat.checkSelfPermission(mActivity, permission) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(mActivity, new String[] { permission }, requestCode); } } public void requestPermission(String[] permissionsList, int requestCode) { List<String> permissionNeeded = new ArrayList<>(); for (String permission : permissionsList) { if (ActivityCompat.checkSelfPermission(mActivity, permission) != PackageManager.PERMISSION_GRANTED) { permissionNeeded.add(permission); } } if (permissionNeeded.size() > 0) { ActivityCompat.requestPermissions(mActivity, permissionNeeded.toArray(new String[permissionNeeded.size()]), requestCode); } } @Deprecated public boolean hasPermission(Activity activity, String permission) { return ActivityCompat.checkSelfPermission(activity, permission) == PackageManager.PERMISSION_GRANTED; } @Deprecated public boolean hasPermission(Activity activity, String[] permissionsList) { for (String permission : permissionsList) { if (ActivityCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) { return false; } } return true; } @Deprecated public void requestPermission(Activity activity, String permission, int requestCode) { if (ActivityCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(activity, new String[] { permission }, requestCode); } } @Deprecated public void requestPermission(Activity activity, String[] permissionsList, int requestCode) { List<String> permissionNeeded = new ArrayList<>(); for (String permission : permissionsList) { if (ActivityCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) { permissionNeeded.add(permission); } } if (permissionNeeded.size() > 0) { ActivityCompat.requestPermissions(activity, permissionNeeded.toArray(new String[permissionNeeded.size()]), requestCode); } } }
Wednesday, 23 May 2018
File upload
public static interface API_Update_Profile_Data { @Multipart @POST("updateprofile_api/update_profiledata/") Call<ResponseBody> Respos(@Part("user_id") RequestBody user_id, @Part("user_type") RequestBody user_type, @Part("name_ara") RequestBody name_ara, @Part("name_eng") RequestBody name_eng, @Part MultipartBody.Part user_image, @Part("mobileno") RequestBody mobileno, @Part("email_id") RequestBody email_id);
private void updateUserData(RequestBody mUserId, RequestBody mUserType, RequestBody name_ara, final RequestBody name_eng, RequestBody mobileno, RequestBody email) { ShowProgressDialog(); File file = null; RequestBody fbody = null; String file_name = null; MultipartBody.Part body = null; try { file = new File(imageUri.getPath()); file_name = file.getName(); file_name = file_name.replace(" ", ""); fbody = RequestBody.create(MediaType.parse("multipart/form-data"), file); body = MultipartBody.Part.createFormData("user_image", file_name, fbody); } catch (Exception e) { e.printStackTrace(); } GetResponce.API_Update_Profile_Data service = Final_API_Data.retrofit.create(GetResponce.API_Update_Profile_Data.class); Call<ResponseBody> result = service.Respos(mUserId, mUserType, name_ara, name_eng, body, mobileno, email); final File finalFile = file; final String finalFile_name = file_name; result.enqueue(new Callback<ResponseBody>() { @Override public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { Log.e("Sucessfully", "Done"); try { String res = response.body().string(); String status = "0"; Log.e("Updat Profile Respo", res); JSONObject jsonObject = new JSONObject(res); status = jsonObject.getString("status"); String message = jsonObject.getString("message"); if (status.equals("1")) { ((MainActivity) getActivity()).popFragments(); MainActivity.tvUserName.setText(etNameEng.getText().toString()); user_image_url = CONSTANT.Customer_Image_Path + finalFile_name; Log.e("User Image", user_image_url); UserData.mUserImage = finalFile_name; try { Glide.with(getActivity()).load(user_image_url).diskCacheStrategy(DiskCacheStrategy.SOURCE).dontAnimate().placeholder(R.drawable.place_add_user_image).into(ivProfilePic); txtAddProfilePhoto.setVisibility(View.GONE); Glide.with(getActivity()).load(user_image_url).diskCacheStrategy(DiskCacheStrategy.SOURCE).dontAnimate().placeholder(R.drawable.icn_car).into(MainActivity.ivUserImageHead); } catch (Exception e) { } Toast.makeText(activity, getString(R.string.your_profile_has_been_saved_successfully), Toast.LENGTH_SHORT).show(); } else if(status.equals("0")){ Toast.makeText(activity, "Email Id already registered, Please try another Id", Toast.LENGTH_LONG).show(); } else { Toast.makeText(activity, getString(R.string.failed_please_try_again), Toast.LENGTH_SHORT).show(); DismissProgressDialog(); return; } DismissProgressDialog(); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(Call<ResponseBody> call, Throwable t) { Log.e("Sucess Fully", t.getMessage()); DismissProgressDialog(); } }); }private RequestBody StringToRequestBody(String s) { return RequestBody.create(MediaType.parse("multipart/form-data"), s); }
Tuesday, 22 May 2018
Viewpager With tabbar
public class HomeViewPagerFragment extends Fragment { private Activity activity; private NonSwipeableViewPager viewPager; public static TabLayout tabLayoutBottom; public static Handler chageTitleHandler; public static Handler homeFragmentSet; public static CustomTextView txtBottomBadgeCount; public static FrameLayout llBadgeBottom; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_home_viewpager_fragment, container, false); activity = getActivity(); findViews(rootView); onClickListner(); viewPager.setAdapter(new MyAdapter(getChildFragmentManager())); setCustomTabView(); ((MainActivity) activity).changeTitle(""); changeTitle(0); chageTitleHandler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { changeTitle(tabLayoutBottom.getSelectedTabPosition()); return false; } }); homeFragmentSet = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { tabLayoutBottom.getTabAt(0).select(); return false; } }); if (AppSharedPrefersec.getInstance(activity).getBooleanData("isLogin")) { getNotificationUnreadCount(); } return rootView; } private void getNotificationUnreadCount() { CommonUtils.getWsseToken(activity); ApiClient.getAPI(AppConstant.URL_NOTIFICATION_COUNT, new Callback<ResponseBody>() { @Override public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { int code = response.code(); String url = response.raw().request().url().toString(); Log.e("Status Code", code + ""); Log.e("Count Url", url + ""); if (code == HttpsURLConnection.HTTP_OK) { try { String result = response.body().string(); Log.e("Url", result + ""); JSONObject jsonObject = new JSONObject(result.toString()); NotificationCount = jsonObject.getString("total"); if (!NotificationCount.isEmpty()) { setCustomTabView(); } } catch (Exception e) { e.printStackTrace(); } } } @Override public void onFailure(Call<ResponseBody> call, Throwable t) { } }); } private void onClickListner() { } private void findViews(View rootView) { viewPager = rootView.findViewById(R.id.viewPagerHome); tabLayoutBottom = (TabLayout) rootView.findViewById(R.id.tabBottomHomeViewpagerFragment); viewPager.setOffscreenPageLimit(2); } TabLayout.OnTabSelectedListener onTabSelectedListener = new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { viewPager.setCurrentItem(tab.getPosition()); changeTitle(tab.getPosition()); } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { } }; private void changeTitle(int currentItem) { switch (currentItem) { case 0: ((MainActivity) activity).changeTitle(""); break; case 1: ((MainActivity) activity).changeTitle(getString(R.string.salons)); break; case 2: ((MainActivity) activity).changeTitle(getString(R.string.timeline)); break; case 3: ((MainActivity) activity).changeTitle(getString(R.string.more)); break; } } private void setCustomTabView() { tabLayoutBottom.removeAllTabs(); tabLayoutBottom.addTab(tabLayoutBottom.newTab().setCustomView(prepareTabView(0))); tabLayoutBottom.addTab(tabLayoutBottom.newTab().setCustomView(prepareTabView(1))); tabLayoutBottom.addTab(tabLayoutBottom.newTab().setCustomView(prepareTabView(2))); tabLayoutBottom.addTab(tabLayoutBottom.newTab().setCustomView(prepareTabView(3))); tabLayoutBottom.setTabGravity(TabLayout.GRAVITY_FILL); tabLayoutBottom.setOnTabSelectedListener(onTabSelectedListener); /* tabLayoutBottom.post(new Runnable() { @Override public void run() { tabLayoutBottom.setupWithViewPager(viewPager); } });*/ } private View prepareTabView(int i) { View view = getLayoutInflater().inflate(R.layout.custom_tab_home, null); ImageView imgTab = (ImageView) view.findViewById(R.id.iv_tabImage); llBadgeBottom = (FrameLayout) view.findViewById(R.id.llBadgeTabBarHome); txtBottomBadgeCount = (CustomTextView) view.findViewById(R.id.txtBadgeTabBarHome); switch (i) { case 0: imgTab.setImageResource(R.drawable.selector_tab_home); llBadgeBottom.setVisibility(View.GONE); break; case 1: imgTab.setImageResource(R.drawable.selector_tab_salon_service); llBadgeBottom.setVisibility(View.GONE); break; case 2: imgTab.setImageResource(R.drawable.selector_tab_time_line); llBadgeBottom.setVisibility(View.GONE); break; case 3: imgTab.setImageResource(R.drawable.selector_tab_more); if (!NotificationCount.isEmpty()) { int not_count = Integer.parseInt(NotificationCount); if (not_count > 0) { txtBottomBadgeCount.setText(NotificationCount); llBadgeBottom.setVisibility(View.VISIBLE); } else { llBadgeBottom.setVisibility(View.GONE); } } else { llBadgeBottom.setVisibility(View.GONE); } break; } return view; } class MyAdapter extends FragmentPagerAdapter { public MyAdapter(FragmentManager fm) { super(fm); } /** * Return fragment with respect to Position . */ @Override public Fragment getItem(int position) { switch (position) { case 0: return new HomeFragment(); case 1: return new SalonServiceFragment(); case 2: return new TimeLineFragment(); case 3: return new MoreFragment(); } return null; } @Override public int getCount() { return 4; } /** * This method returns the title of the tab according to the position. */ @Override public CharSequence getPageTitle(int position) { switch (position) { case 0: String MAP = ""; return MAP; case 1: String NEARBY = ""; return NEARBY; case 2: String FAVORITE = ""; return FAVORITE; case 3: String Fs = ""; return Fs; } return null; } } @Override public void onResume() { super.onResume(); changeTitle(tabLayoutBottom.getSelectedTabPosition()); if (tabLayoutBottom.getSelectedTabPosition() == 2) { //TimeLineFragment.volumeUpVideoHandler.sendMessage(new Message()); } else { //TimeLineFragment.volumeDownVideoHandler.sendMessage(new Message()); } } } XML<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.tpb.CustomViews.NonSwipeableViewPager android:id="@+id/viewPagerHome" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"/> <android.support.design.widget.TabLayout android:id="@+id/tabBottomHomeViewpagerFragment" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/colorPrimary" app:tabIndicatorColor="@null" /> </LinearLayout>
Add Fragment Method
/** * Add Fragment * * @param fragment * @param tag * @param isBacksTack */public void addFragment(Fragment fragment, String tag, boolean isBacksTack) { try { FragmentManager fragmentManager = getSupportFragmentManager(); if (!isBacksTack) { fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); } FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (isBacksTack) { fragmentTransaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right); } fragmentTransaction.add(R.id.content_frame, fragment, tag ); if (isBacksTack) { fragmentTransaction.addToBackStack(tag); } fragmentTransaction.commit(); } catch (Exception e) { e.printStackTrace(); } }
/** * Add Fragment * * @param fragment * @param tag * @param isBacksTack */public void addFragmentFromTab(Fragment fragment, String tag, boolean isBacksTack) { try { FragmentManager fragmentManager = getSupportFragmentManager(); if (!isBacksTack) { fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); } FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (isBacksTack) { fragmentTransaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right); } fragmentTransaction.replace(R.id.content_frame, fragment); if (isBacksTack) { fragmentTransaction.addToBackStack(tag); } fragmentTransaction.commit(); } catch (Exception e) { e.printStackTrace(); } }
Retrofite
public class ApiClient { public static OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Request.Builder builder = chain.request().newBuilder(); builder.addHeader("Accept", "application/json"); builder.addHeader("x-wsse", AppController.getInstance().getHeader()); return chain.proceed(builder.build()); } }).connectTimeout(CONNECTION_TIME_OUT_IN_SECOND, TimeUnit.SECONDS) .writeTimeout(CONNECTION_TIME_OUT_IN_SECOND, TimeUnit.SECONDS) .readTimeout(CONNECTION_TIME_OUT_IN_SECOND, TimeUnit.SECONDS) .build(); private static Retrofit retrofit = null; public static Retrofit getClient() { if (retrofit == null) { retrofit = new Retrofit.Builder() .baseUrl(BaseUrl) .client(client) .addConverterFactory(GsonConverterFactory.create()) .build(); } return retrofit; } public static retrofit2.Call getAPI(String url, retrofit2.Callback<ResponseBody> callback) { ApiInterface apiCall = getClient().create(ApiInterface.class); retrofit2.Call call = apiCall.CommonGet(url); call.enqueue(callback); return call; } public static retrofit2.Call deleteAPI(String url, retrofit2.Callback<ResponseBody> callback) { ApiInterface apiCall = getClient().create(ApiInterface.class); retrofit2.Call call = apiCall.CommonDelete(url); call.enqueue(callback); return call; } }
public interface ApiInterface { //Common Multipart API @POST @Multipart Call<ResponseBody> CommonPostMultipart(@Url String url, @PartMap HashMap<String, RequestBody> map); @POST Call<ResponseBody> CommonPost(@Url String url); @POST @FormUrlEncoded Call<ResponseBody> CommonPostWithMap(@Url String url, @FieldMap HashMap<String, String> map); // Common Get API @GET Call<ResponseBody> CommonGet(@Url String url); //Common PATCH API @PATCH @FormUrlEncoded Call<ResponseBody> CommonPatch(@Url String url, @FieldMap HashMap<String, String> map); //Common PATCH API @DELETE Call<ResponseBody> CommonDelete(@Url String url); }
Adapter
public class AllSalonNew extends RecyclerView.Adapter<AllSalonNew.VHHolderHome> { Activity activity; ArrayList<SalonModel> arrayList = new ArrayList<>(); String from = "Salon"; public AllSalonNew(Activity act, ArrayList<SalonModel> list, String frm) { activity = act; arrayList = list; from = frm; } @Override public AllSalonNew.VHHolderHome onCreateViewHolder(ViewGroup parent, int viewType) { View rootView = LayoutInflater.from(activity).inflate(R.layout.row_all_salon, parent, false); if (rootView.getLayoutParams().width == RecyclerView.LayoutParams.MATCH_PARENT) rootView.getLayoutParams().width = parent.getWidth(); return new AllSalonNew.VHHolderHome(rootView); } View.OnTouchListener listener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE) { v.getParent().requestDisallowInterceptTouchEvent(true); } else { v.getParent().requestDisallowInterceptTouchEvent(false); } return false; } }; @Override public void onBindViewHolder(final AllSalonNew.VHHolderHome holder, final int position) { final SalonModel model = arrayList.get(position); String BannerPath; if (AppController.getCurrentLang().equals("ar")) { holder.txtSalonName.setText(model.getNameNative()); } else { holder.txtSalonName.setText(model.getNameIntl()); } if (model.getBannerName() != null) { BannerPath = AppConstant.IMAGE_PATH_SALON_BANNER + model.getBannerName(); Glide.with(activity).load(BannerPath).into(holder.imgSalonBanner); } String imagePath = AppConstant.IMAGE_PATH_SALON_LOGO + model.getLogoName(); Glide.with(activity).load(imagePath).into(holder.imgSalon); final ArrayList<SalonBranch> branchArrayList = (ArrayList<SalonBranch>) arrayList.get(position).getSalonBranches(); if (!branchArrayList.isEmpty()) { if (branchArrayList.size() == 1) { holder.ratingBar.setVisibility(View.VISIBLE); SalonBranch salonBranchModel = branchArrayList.get(0); if (AppController.getCurrentLang().equals("ar")) { holder.txtSalonName.setText(salonBranchModel.getNameNative()); } else { holder.txtSalonName.setText(salonBranchModel.getNameIntl()); } if (salonBranchModel.getAverageRate() != 0f) { holder.ratingBar.setVisibility(View.VISIBLE); holder.ratingBar.setStar((int) (salonBranchModel.getAverageRate())); } else { holder.ratingBar.setVisibility(View.GONE); } if (AppController.getCurrentLang().equals("ar")) { holder.txtSalonArea.setText(salonBranchModel.getCity() != null ? salonBranchModel.getCity().getNameNative() : ""); } else { holder.txtSalonArea.setText(salonBranchModel.getCity() != null ? salonBranchModel.getCity().getNameIntl() : ""); } if (!branchArrayList.get(0).getServices().isEmpty()) { int homeServiceCount = 0; for (ServiceModel serviceModel : branchArrayList.get(0).getServices()) { if (serviceModel.getIsHomeService()) { homeServiceCount++; } } if (homeServiceCount > 0) { holder.Redirect = "Home"; holder.imgHomeService.setVisibility(View.VISIBLE); } else { holder.Redirect = "Salon"; holder.imgHomeService.setVisibility(View.GONE); } } } else { holder.txtSalonArea.setVisibility(View.VISIBLE); holder.txtSalonArea.setText(R.string.branches); setMoreSalonList(branchArrayList, holder); } } else { holder.ratingBar.setVisibility(View.GONE); holder.txtSalonArea.setVisibility(View.GONE); } if (model.isOpen()) { holder.recyclerView.setVisibility(View.VISIBLE); } else { holder.recyclerView.setVisibility(View.GONE); holder.imgHomeService.setVisibility(View.VISIBLE); } holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!branchArrayList.isEmpty()) { if (branchArrayList.size() == 1) { if (MainActivity.isSalonProfileOpen) { ((MainActivity) activity).removeFragment(AppConstant.TAG_SALON_PROFILE_FRAGMENT); openSalonProfile(model, from); } else { openSalonProfile(model, from); } } else { if (model.isOpen()) { model.setOpen(false); holder.recyclerView.setVisibility(View.GONE); if (holder.Redirect.equals("Home")) { holder.imgHomeService.setVisibility(View.VISIBLE); } } else { model.setOpen(true); holder.recyclerView.setVisibility(View.VISIBLE); holder.imgHomeService.setVisibility(View.GONE); } arrayList.set(position, model); } } } }); holder.imgHomeService.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (model.getSalonBranches() != null) { if (model.getSalonBranches().size() == 1) { if (MainActivity.isSalonProfileOpen) { ((MainActivity) activity).removeFragment(AppConstant.TAG_SALON_PROFILE_FRAGMENT); openSalonProfile(model, "Home"); } else { openSalonProfile(model, "Home"); } } } } }); holder.ratingBar.setClickable(false); if (from.equals("Home")) { holder.imgHomeService.setVisibility(View.VISIBLE); holder.Redirect = "Home"; } else { if (model.getSalonBranches() != null) { boolean isHomeService = false; if (!model.getSalonBranches().isEmpty()) { for (SalonBranch salonBranch : model.getSalonBranches()) { if (!salonBranch.getServices().isEmpty()) { for (ServiceModel serviceModel : salonBranch.getServices()) { if (serviceModel.getIsHomeService()) { isHomeService = true; break; } } } } if (isHomeService) { holder.imgHomeService.setVisibility(View.VISIBLE); holder.Redirect = "Home"; } else { holder.imgHomeService.setVisibility(View.GONE); holder.Redirect = "Salon"; } } else { holder.imgHomeService.setVisibility(View.GONE); holder.Redirect = "Salon"; } } } } private void openSalonProfile(SalonModel model, String redirect) { SalonProfileFragment salonProfileFragment = new SalonProfileFragment(); Bundle args = new Bundle(); args.putString("branchSalonId", String.valueOf(model.getSalonBranches().get(0).getId())); args.putString("Redirect", redirect /*holder.Redirect*/); salonProfileFragment.setArguments(args); ((MainActivity) activity).addFragment(salonProfileFragment, AppConstant.TAG_SALON_PROFILE_FRAGMENT, true); } @Override public int getItemViewType(int position) { return super.getItemViewType(position); } @Override public int getItemCount() { return arrayList.size(); } private void setMoreSalonList(ArrayList<SalonBranch> arrayList, AllSalonNew.VHHolderHome holder) { MoreSalonAdapter adapter = new MoreSalonAdapter(activity, arrayList, from); LinearLayoutManager llm = new LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false); holder.recyclerView.setLayoutManager(llm); holder.recyclerView.setLayoutManager(new LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)); // MoreSalonBaseAdapter adapter = new MoreSalonBaseAdapter(activity, arrayList, from); holder.recyclerView.setAdapter(adapter); holder.recyclerView.setOnTouchListener(new View.OnTouchListener() { // Setting on Touch Listener for handling the touch inside ScrollView @Override public boolean onTouch(View v, MotionEvent event) { // Disallow the touch request for parent scroll on touch of child view v.getParent().requestDisallowInterceptTouchEvent(true); return false; } }); } class VHHolderHome extends RecyclerView.ViewHolder { private CustomTextView txtSalonName, txtSalonArea; private ImageView imgSalon, imgHomeService, imgSalonBanner; private RecyclerView recyclerView; private LinearLayout llMainSalonView; private RatingBar ratingBar; private String Redirect = "Salon"; public VHHolderHome(View itemView) { super(itemView); txtSalonName = itemView.findViewById(R.id.txtSalonNameAllSalon); txtSalonArea = itemView.findViewById(R.id.txtSalonAreaAllSalon); imgSalon = itemView.findViewById(R.id.imgSalonLogoAllSalon); imgSalonBanner = itemView.findViewById(R.id.imgSalonBanner); imgHomeService = itemView.findViewById(R.id.imgHomeServiceAllSalon); recyclerView = itemView.findViewById(R.id.recyclerMoreSalonAllSalon); llMainSalonView = itemView.findViewById(R.id.llMainSalonView); ratingBar = itemView.findViewById(R.id.rattingSalon); ratingBar.setVisibility(View.GONE); recyclerView.setVisibility(View.GONE); imgHomeService.setVisibility(View.GONE); ratingBar.setStarEmptyDrawable(activity.getResources().getDrawable(R.drawable.ic_rating_unselect)); ratingBar.setStarFillDrawable(activity.getResources().getDrawable(R.drawable.ic_rating_selected)); ratingBar.setStarCount(5); ratingBar.setClickable(false); ratingBar.halfStar(false); } } }
MyCallBack
public interface MyCallBackValue { void callbackValue(int id, double value); void callbackValue(int id, double value, String type); }
public interface MyCallBack { void callbackCall(); }
//Make adapter object and call from activity or fragment
adapterCoupon.setRowClickCallBack(new MyCallBackValue() { @Override public void callbackValue(int id, double value) { } @Override public void callbackValue(int id, double value, String type) { couponValue = value; couponID = id; couponType = type; updateTotalDiscount(); } });//This method create in adapterprivate MyCallBackValue rowClickCallBack; public void setRowClickCallBack(MyCallBackValue rowClickCallBack) { this.rowClickCallBack = rowClickCallBack; }rowClickCallBack.callbackValue(0, 0.0, "val");
Subscribe to:
Posts (Atom)