@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (AppConfiguration.getInstance(this) .iconTheme .equalsIgnoreCase(NameConstant.ICON_THEME_LIGHT)) { setTheme(R.style.AppTheme); } else { setTheme(R.style.AppThemeLight); } setContentView(R.layout.activity_drawer); context = this; toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (getPackageName().equalsIgnoreCase("com.applop")) { if (User.getInstance(this).loginType.equalsIgnoreCase("")) { Intent intent = new Intent(context, SignInActivity.class); startActivityForResult(intent, NameConstant.REQUEST_CODE_BACK_FROM_SIGN_IN); } } Helper.setToolbarColor(this); storyAdapter = new StoryAdapter(stories, this); loadResources(); setSideDrawer(); try { String categoryName = "Application"; String label = "Opened"; String action = "Opened"; AnalyticsHelper.trackEvent(categoryName, action, label, this); } catch (Exception e) { e.printStackTrace(); } try { String pageviews = "Home Page"; AnalyticsHelper.trackPageView(pageviews, this); } catch (Exception e) { e.printStackTrace(); } setads(); // show alert if exist String alertMessage = getIntent().getStringExtra("alert_message"); if (alertMessage != null) if (!alertMessage.equalsIgnoreCase("")) Helper.showAlertFeedNotification(this, alertMessage); return; }
// for loading page on click of button in navigation drawer list public void loadCategory( Category category, final int page, boolean isRefreshing, final boolean isLoadingMore) { if (category == null) { itemsRecyclerView.setVisibility(View.INVISIBLE); return; } try { String pageviews = "Category Page with Category(" + category.categoryId + ") : " + category.name; AnalyticsHelper.trackPageView(pageviews, this); } catch (Exception e) { e.printStackTrace(); } try { String categoryName = "Category"; String label = "Opened"; String action = "Category(" + category.categoryId + ") : " + category.name; AnalyticsHelper.trackEvent(categoryName, action, label, this); } catch (Exception e) { e.printStackTrace(); } myTitle.setText(category.name); currentCategory = category; current_page = page; final Context context = this; String URL = getCategoryStoryURL(category, page); // 1 MyRequestQueue.Instance(this).cancelPendingRequests("stories"); new VolleyData(this) { @Override protected void VPreExecute() { if (!isLoadingMore) { progressBar.setVisibility(View.VISIBLE); itemsRecyclerView.setVisibility(View.GONE); storyAdapter.clear(); storyAdapter.notifyDataSetChanged(); } } @Override protected void VResponse(JSONObject response, String tag) { swipeRefreshLayout.setRefreshing(false); endLoadMore(); JSONObject json = response; try { if (json != null) { try { progressBar.setVisibility(View.GONE); JSONArray jsonStories = json.getJSONArray("stories"); ArrayList<Story> stories = new ArrayList<Story>(); for (int i = 0; i < jsonStories.length(); i++) { Story story = new Story(context, jsonStories.getJSONObject(i)); // if (!IsStoryAlreadyAdded(story)){ stories.add(story); // } } itemsRecyclerView.setAdapter(storyAdapter); itemsRecyclerView.setVisibility(View.VISIBLE); storyAdapter.insertStories(stories); } catch (Exception e) { Toast.makeText(getApplicationContext(), "" + e, Toast.LENGTH_LONG).show(); } } } catch (Exception e) { Toast.makeText(getApplicationContext(), "" + e, Toast.LENGTH_LONG).show(); } } @Override protected void VError(VolleyError error, String tag) { swipeRefreshLayout.setRefreshing(false); endLoadMore(); progressBar.setVisibility(View.GONE); itemsRecyclerView.setVisibility(View.VISIBLE); } }.getJsonObject(URL, true, "stories", this); }