@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); listView = (RecyclerView)view.findViewById(android.R.id.list); listView.setLayoutManager(new LinearLayoutManager(getActivity())); listView.setItemAnimator(new DefaultItemAnimator()); listView.setAdapter(adapter); view.findViewById(R.id.fabNewPlaylist).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { newPlaylist(); } }); Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.setScreenName("List of playlists"); t.send(new HitBuilders.AppViewBuilder().build()); }
public void init(BaseActivity activity){ baseActivity = activity; activityStack.push(activity); sh = new SharedHelper(activity.getApplicationContext()); loadingDialog = new LoadingDialog(activity); loadingDialog.setOnCancelListener((dialogInterface -> canceled = true)); String screenName = activity.getClass().getSimpleName(); activityMap.put(screenName + System.currentTimeMillis(), activity); if (SStaticR.ANALYTICS_ON){ // Obtain the shared Tracker instance. LIVE application = (LIVE)baseActivity.getApplication(); Tracker mTracker = application.getDefaultTracker(); mTracker.setScreenName(screenName); mTracker.send(new HitBuilders.ScreenViewBuilder().build()); } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_podcast, container, false); mActivity = (Home) getActivity(); mContext = getContext(); podcastList = (ListView) v.findViewById(R.id.podcastlist); noElements = (TextView) v.findViewById(R.id.no_elements); avi = (AVLoadingIndicatorView) v.findViewById(R.id.avi); avi.show(); // Get Programs new GetPrograms(mContext, this).execute(); App application = (App) getActivity().getApplication(); Tracker mTracker = application.getDefaultTracker(); mTracker.setScreenName(getString(R.string.podcast_view)); mTracker.send(new HitBuilders.ScreenViewBuilder().build()); return v; }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_transmissions, container, false); mActivity = (Home) getActivity(); mContext = getContext(); transmissionList = (ListView) v.findViewById(R.id.transmissionsList); noElements = (TextView) v.findViewById(R.id.no_elements); avi = (AVLoadingIndicatorView) v.findViewById(R.id.avi); avi.show(); // Get Transmissions new GetTransmissions(mContext, this, getArguments().getString(KEY_DAY)).execute(); App application = (App) getActivity().getApplication(); Tracker mTracker = application.getDefaultTracker(); mTracker.setScreenName(getString(R.string.transmisions_view)); mTracker.send(new HitBuilders.ScreenViewBuilder().build()); return v; }
@Override protected void onCreate(Bundle savedInstanceState) { getWindow().requestFeature(Window.FEATURE_ACTION_BAR); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); mContext = this; mActivity = this; avi = (AVLoadingIndicatorView) findViewById(R.id.avi); avi.show(); snackView = (View) findViewById(R.id.snackView); launchGetStations(mContext, mActivity); App application = (App) getApplication(); Tracker mTracker = application.getDefaultTracker(); mTracker.setScreenName(getString(R.string.splash_activity)); mTracker.send(new HitBuilders.ScreenViewBuilder().build()); }
/** * Gets the google analytics tracker. * * @return the google analytics tracker. */ private Tracker getTracker() { if (mTracker == null) { int checkExistence = mContext.getResources().getIdentifier("global_tracker", "xml", mContext.getPackageName()); if (checkExistence == 0) { Log.e(AnalyticsManager.class.getCanonicalName(), "Please check if you have global-services.json"); } else { mTracker = GoogleAnalytics.getInstance(mContext).newTracker(checkExistence); mTracker.enableAutoActivityTracking(false); mTracker.enableAdvertisingIdCollection(false); mTracker.enableExceptionReporting(false); } } return mTracker; }
public synchronized Tracker get(Target target) { if (!mTrackers.containsKey(target)) { Tracker tracker; switch (target) { case APP: tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker); tracker.enableAdvertisingIdCollection(true); break; default: throw new IllegalArgumentException("Unhandled analytics target " + target); } mTrackers.put(target, tracker); } return mTrackers.get(target); }
@Before public void setup() { // Mock behavior for when Tracker.send(Map<String, String>) is called tracker = mock(Tracker.class); doAnswer(new Answer<Void>() { public Void answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); //noinspection unchecked testEventPropertiesMap = (Map<String, String>) args[0]; sendCalled = true; return null; } }).when(tracker).send(anyMapOf(String.class, String.class)); provider = new GoogleAnalyticsProvider(tracker); sendCalled = false; testEventPropertiesMap = null; }
@Test public void deleteAppTrackersTest() throws Exception { prepareMockedFields(); Analytics.prepareTrackersAndFbLogger(testShop, mockContext); // Check size before deletion HashMap<String, Tracker> trackersField = Whitebox.getInternalState(Analytics.class, "mTrackers"); assertEquals(trackersField.size(), 2); // Tested method invocation Analytics.deleteAppTrackers(); // Verify final size trackersField = Whitebox.getInternalState(Analytics.class, "mTrackers"); assertEquals(trackersField.size(), 1); }
public static void sendEvent(Tracker tracker, String category, String action, String label) { if (tracker == null) return; if (category == null || category.isEmpty()) category = Utils.ANALYTICS_CATEGORY_ACTION; HitBuilders.EventBuilder analyticsEvent = new HitBuilders.EventBuilder() .setCategory(category) .setAction(action); if (label != null && !label.isEmpty()) analyticsEvent.setLabel(label); tracker.send(analyticsEvent.build()); }
synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); // Чтобы включить ведение журнала отладки, используйте adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker("global_tracker"); } return mTracker; }
public synchronized Tracker get(Target target) { if (!mTrackers.containsKey(target)) { Tracker tracker; switch (target) { case APP: tracker = GoogleAnalytics.getInstance(mContext).newTracker(R.xml.app_tracker); break; default: throw new IllegalArgumentException("Unhandled analytics target " + target); } mTrackers.put(target, tracker); } return mTrackers.get(target); }
public void trackException(Exception e) { if (e != null) { Tracker t = getGoogleAnalyticsTracker(); t.send(new HitBuilders.ExceptionBuilder() .setDescription( new StandardExceptionParser(this, null) .getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); } }
synchronized static Tracker getGATracker(Context context) { if (tracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); tracker = analytics.newTracker(R.xml.ga_app_tracker); } return tracker; }
synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker(R.xml.app_tracker); } return mTracker; }
synchronized private Tracker getDefaultTracker(Context context) { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(context); mTracker = analytics.newTracker(mGaConfigLocation); } return mTracker; }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); listView = (RecyclerView) view.findViewById(android.R.id.list); listView.setLayoutManager(new LinearLayoutManager(getActivity())); listView.setItemAnimator(new DefaultItemAnimator()); Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.setScreenName("Folders and files"); t.send(new HitBuilders.AppViewBuilder().build()); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view,savedInstanceState); list = (RecyclerView)view.findViewById(android.R.id.list); list.setItemAnimator(new DefaultItemAnimator()); setLayoutManager(); progress = (CircularProgressButton)view.findViewById(android.R.id.progress); empty = view.findViewById(android.R.id.empty); new AsyncTask<Void, Void, ArrayList<Track>>() { @Override protected void onPreExecute() { super.onPreExecute(); activity.setRefreshing(true); } @Override protected ArrayList<Track> doInBackground(Void... voids) { return (ArrayList<Track>) FileUtils.read("albumsTracks", activity); } @Override protected void onPostExecute(ArrayList<Track> tracks) { super.onPostExecute(tracks); activity.setRefreshing(false); OnTaskResult(tracks); } }.execute(); Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.setScreenName("Albums"); t.send(new HitBuilders.AppViewBuilder().build()); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); adapter = new PlayerAdapter(activity, this, playlistResultsLocal, playlistResultsVK); listView = (RecyclerView) view.findViewById(android.R.id.list); listView.setLayoutManager(new LinearLayoutManager(getActivity())); listView.setItemAnimator(new DefaultItemAnimator()); listView.setAdapter(adapter); Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.setScreenName("Playlist"); t.send(new HitBuilders.AppViewBuilder().build()); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); adapter = new PlayerAdapter(activity, this, items); listView = (RecyclerView) view.findViewById(android.R.id.list); listView.setLayoutManager(new LinearLayoutManager(getActivity())); listView.setItemAnimator(new DefaultItemAnimator()); listView.setAdapter(adapter); Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.setScreenName("Playlist"); t.send(new HitBuilders.AppViewBuilder().build()); }
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); adapter = new PlayerAdapter(activity, this, items); listView = (RecyclerView) view.findViewById(android.R.id.list); listView.setLayoutManager(new LinearLayoutManager(getActivity())); listView.setItemAnimator(new DefaultItemAnimator()); listView.setAdapter(adapter); Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.setScreenName("Now playing"); t.send(new HitBuilders.AppViewBuilder().build()); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view,savedInstanceState); list = (RecyclerView)view.findViewById(android.R.id.list); list.setItemAnimator(new DefaultItemAnimator()); setLayoutManager(); progress = (CircularProgressButton)view.findViewById(android.R.id.progress); empty = view.findViewById(android.R.id.empty); new AsyncTask<Void, Void, ArrayList<Track>>() { @Override protected void onPreExecute() { super.onPreExecute(); activity.setRefreshing(true); } @Override protected ArrayList<Track> doInBackground(Void... voids) { return (ArrayList<Track>) FileUtils.read("artistsTracks", activity); } @Override protected void onPostExecute(ArrayList<Track> tracks) { super.onPostExecute(tracks); activity.setRefreshing(false); OnTaskResult(tracks); } }.execute(); Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.setScreenName("Artists"); t.send(new HitBuilders.AppViewBuilder().build()); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); adapter = new PlayerAdapter(activity, this, items); listView = (RecyclerView) view.findViewById(android.R.id.list); listView.setLayoutManager(new LinearLayoutManager(getActivity())); listView.setItemAnimator(new DefaultItemAnimator()); listView.setAdapter(adapter); Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.setScreenName("VK audio"); t.send(new HitBuilders.AppViewBuilder().build()); }
public void update(boolean refresh) { if (refresh) { activity.setRefreshing(true); items.clear(); page = 0L; boolean isForeignVK = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean(getString(R.string.key_foreign_vk_popular), true); TaskGetPlaylistVK task = new TaskGetPlaylistVK(activity, new TaskGetPlaylistVK.OnTaskGetPlaylistListener() { @Override public void OnTaskResult(ArrayList<Track> result) { setItems(result, true); } }); if (TaskGetPlaylistVK.VK_METHOD_SEARCH.equals(method)) task.execute(method, String.valueOf(page += 1), searchQuery); else task.execute(method, String.valueOf(page += 1), String.valueOf(isForeignVK)); updateSnapshot(); listView.scrollToPosition(0); setNeedUpdate(false); } else restoreCache(); Tracker t = ((NavigationActivity)getActivity()).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.send(new HitBuilders.EventBuilder().setCategory("UX").setAction("vkAudio").setLabel(method + (refresh ? " (refresh)" : " (cache)")).build()); }
public void itemClick(int position) { if (activity.getService().isSnapshotMismatch(playlistSnapshot)) activity.getService().setTracks(items, playlistSnapshot); selectedPosition = adapter.visibleToListPosition(position); if (selectedPosition < 0) return; adapter.notifyDataSetChanged(); new Thread(new Runnable() { @Override public void run() { if (activity.getService().isShuffle()) { activity.updatePlayPause(); } activity.getService().startVolumeUpFlag = System.currentTimeMillis(); activity.getService().play(selectedPosition); activity.updatePlayPause(); Tracker t = activity.getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.send(new HitBuilders.EventBuilder().setCategory("Track").setAction("play").build()); } }).start(); }
@Override protected ArrayList<Track> doInBackground(String... params) { Activity activity = mActivity.get(); if (null == activity) { return null; } method = params[0]; long page = Long.valueOf(params[1]); if (params.length > 2) { if (TaskGetPlaylistVK.VK_METHOD_SEARCH.equals(method)) query = params[2]; if (TaskGetPlaylistVK.VK_METHOD_GET_POPULAR.equals(method)) isForeignPopular = Boolean.parseBoolean(params[2]); } List<VKApiAudio> audios = new ArrayList<VKApiAudio>(); if (VK_METHOD_GET.equals(method)) audios = getAudio("audio.get", "", VK_PAGE_SIZE, VK_PAGE_SIZE * (page - 1)); if (VK_METHOD_GET_POPULAR.equals(method)) audios = getAudio("audio.getPopular", "", VK_PAGE_SIZE, VK_PAGE_SIZE * (page - 1)); if (VK_METHOD_GET_RECOMMENDATIONS.equals(method)) audios = getAudio("audio.getRecommendations", "", VK_PAGE_SIZE, VK_PAGE_SIZE * (page - 1)); if (VK_METHOD_SEARCH.equals(method)) audios = getAudio("audio.search", query, VK_PAGE_SIZE, VK_PAGE_SIZE * (page - 1)); ArrayList<Track> tracks = new ArrayList<Track>(); for (VKApiAudio audio : audios) tracks.add(Track.fromVKApiAudio(audio)); Tracker t = ((NavigationActivity)activity).getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.send(new HitBuilders.EventBuilder().setCategory("VK").setAction(method).build()); return tracks; }
private void setShuffleMode(boolean mode){ PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("Shuffle", mode).commit(); mBoundService.setShuffle(mode); if (playingFragment != null) playingFragment.shuffleItems(); updatePlayPause(); Tracker t = getTracker(NavigationActivity.TrackerName.APP_TRACKER); t.send(new HitBuilders.EventBuilder().setCategory("UX").setAction("shuffle").setLabel(String.valueOf(mode)).build()); }
public synchronized Tracker getTracker(TrackerName trackerId) { if (!mTrackers.containsKey(trackerId)) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); Tracker t = analytics.newTracker(R.xml.global_tracker); mTrackers.put(trackerId, t); } return mTrackers.get(trackerId); }
/** * Gets the default {@link Tracker} for this {@link Application}. * @return tracker */ synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker(R.xml.global_tracker); } return mTracker; }
synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(mContext); // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG mTracker = analytics.newTracker(R.xml.app_tracker); } return mTracker; }
/*** * Tracking exception * * @param e exception to be tracked */ public void trackException(Exception e) { if (e != null) { Tracker t = getGoogleAnalyticsTracker(); t.send(new HitBuilders.ExceptionBuilder() .setDescription( new StandardExceptionParser(this, null) .getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); } }
public synchronized Tracker getTracker() { if (gaTracker != null) return gaTracker; GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); analytics.setAppOptOut(isDebuggable); if (isDebuggable) analytics.getLogger().setLogLevel(LogLevel.VERBOSE); gaTracker = analytics.newTracker(ApiObjects.analytics .get("property_id")); gaTracker.enableAdvertisingIdCollection(true); gaTracker.setSessionTimeout(-1); return gaTracker; }
/** * Gets the default {@link Tracker} for this {@link Application}. * @return tracker */ synchronized public Tracker getDefaultTracker() { if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); mTracker = analytics.newTracker(R.xml.global_tracker); mTracker.enableAdvertisingIdCollection(true); } return mTracker; }
public void trackScreenView(String screenName) { Tracker t = getGoogleAnalyticsTracker(); // Set screen name. t.setScreenName(screenName); // Send a screen view. t.send(new HitBuilders.ScreenViewBuilder().build()); GoogleAnalytics.getInstance(this).dispatchLocalHits(); }
public void trackException(Exception e) { if (e != null) { Tracker t = getGoogleAnalyticsTracker(); t.send(new HitBuilders.ExceptionBuilder() .setDescription(new StandardExceptionParser(this, null).getDescription(Thread.currentThread().getName(), e)) .setFatal(false) .build() ); } }
synchronized public Tracker getDefaultTracker() { // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG if (sTracker == null) { sTracker = sAnalytics.newTracker(R.xml.global_tracker); } return sTracker; }