@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); try { if (requestCode == NameConstant.REQUEST_CODE_BACK_FROM_SIGN_IN) { if (resultCode == RESULT_OK) { Helper.setDetailsInDrawerlayout(mDrawerRelativelayout, this); } } if (requestCode == NameConstant.REQUEST_CODE_ORDER_PLACED) { storyAdapter.notifyDataSetChanged(); } } catch (Exception ex) { } }
private void startLoadMore() { isLoadingMoreData = true; if (storyAdapter != null) storyAdapter.insertMoreLoading(); }
private void endLoadMore() { isLoadingMoreData = false; if (storyAdapter != null) storyAdapter.removeMoreLoading(); }
private void loadResources() { myTitle = (TextView) findViewById(R.id.mytitle); if (AppConfiguration.getInstance(this) .iconTheme .equalsIgnoreCase(NameConstant.ICON_THEME_LIGHT)) { myTitle.setTextColor(Color.WHITE); } else { myTitle.setTextColor(Color.BLACK); } cardview = (CardView) findViewById(R.id.cardview); progressBar = (ProgressBar) findViewById(R.id.progress_bar); storyAdapter = new StoryAdapter(stories, this); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { loadCategory(currentCategory, 1, true, false); } }); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawer1MenuAdapter = new DrawerMenuAdapter(jsoncategories, context); // mDrawerRelativelayout = (RelativeLayout) findViewById(R.id.relative_left_drawer); // NetworkHelper.setDetailsInDrawerlayout(mDrawerRelativelayout, this); mDrawerRelativelayout = (RelativeLayout) findViewById(R.id.relative_left_drawer); mDrawerList = (RecyclerView) findViewById(R.id.left_drawer_list); mDrawerList.setLayoutManager(new LinearLayoutManager(context)); mDrawerList.setAdapter(drawer1MenuAdapter); Helper.setDetailsInDrawerlayout(mDrawerRelativelayout, context); ((RelativeLayout) findViewById(R.id.upperBar)) .setBackgroundColor(Color.parseColor(AppConfiguration.getInstance(this).bgcolor)); // for second drawer with id itemsRecyclerView itemsRecyclerView = (RecyclerView) findViewById(R.id.itemsRecyclerView); linearLayoutManager = new LinearLayoutManager(this); itemsRecyclerView.setLayoutManager(linearLayoutManager); itemsRecyclerView.setAdapter(storyAdapter); itemsRecyclerView.setVisibility(View.VISIBLE); itemsRecyclerView.addOnScrollListener( new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); visibleItemCount = recyclerView.getChildCount(); totalItemCount = linearLayoutManager.getItemCount(); // firstVisibleItem = firstVisibleItem = linearLayoutManager.findFirstVisibleItemPosition(); /*if (loading) { if (totalItemCount > previousTotal) { loading = false; previousTotal = totalItemCount; } }*/ if (!isLoadingMoreData) { if ((totalItemCount - visibleItemCount) <= (firstVisibleItem + 1) && totalItemCount > 0) { // End has been reached // Do something // startLoadMore(); // current_page++; // loadCategory(currentCategory, current_page, false, true); // loading = true; } } } }); drawer1MenuAdapter.setmyOnItemClickListener( new DrawerMenuAdapter.OnItemClickListener() { @Override public void onItemClick(View view, int position) { DrawerMenuAdapter.ViewHolder viewHolder = (DrawerMenuAdapter.ViewHolder) view.getTag(); category = (Category) viewHolder.itemName.getTag(); mDrawerLayout.closeDrawer(mDrawerRelativelayout); menuItemClicked(category); } }); storyAdapter.setOnItemClickListener( new StoryAdapter.OnItemClickListener() { @Override public void OnItemCick(View view, int position) { openDetailPage(position); } }); }