当前位置: 首页>>代码示例>>Java>>正文


Java HitBuilders.TimingBuilder方法代码示例

本文整理汇总了Java中com.google.android.gms.analytics.HitBuilders.TimingBuilder方法的典型用法代码示例。如果您正苦于以下问题:Java HitBuilders.TimingBuilder方法的具体用法?Java HitBuilders.TimingBuilder怎么用?Java HitBuilders.TimingBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.analytics.HitBuilders的用法示例。


在下文中一共展示了HitBuilders.TimingBuilder方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addDimensions

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
private <T> T addDimensions(T builder, HashMap<String, Object> params) {
    for (Map.Entry<String, Object> entry : params.entrySet()) {
        try {
            int dimensionInteger = Integer.parseInt(entry.getKey());
            if (entry.getValue() instanceof String) {
                if (builder instanceof HitBuilders.EventBuilder) {
                    ((HitBuilders.EventBuilder) builder).setCustomDimension(dimensionInteger, (String) entry.getValue());
                } else if (builder instanceof HitBuilders.TimingBuilder) {
                    ((HitBuilders.TimingBuilder) builder).setCustomDimension(dimensionInteger, (String) entry.getValue());
                } else if (builder instanceof HitBuilders.ScreenViewBuilder) {
                    ((HitBuilders.ScreenViewBuilder) builder).setCustomDimension(dimensionInteger, (String) entry.getValue());
                }
            }
        } catch (NumberFormatException ignore) {
        }
    }
    return builder;
}
 
开发者ID:MobileTribe,项目名称:pandroid,代码行数:19,代码来源:GoogleAnalyticsManager.java

示例2: addMetrics

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
private <T> T addMetrics(T builder, HashMap<String, Object> params) {
    for (Map.Entry<String, Object> entry : params.entrySet()) {
        try {
            int metricInteger = Integer.parseInt(entry.getKey());
            if (entry.getValue() instanceof Float) {
                if (builder instanceof HitBuilders.EventBuilder) {
                    ((HitBuilders.EventBuilder) builder).setCustomMetric(metricInteger, (Float) entry.getValue());
                } else if (builder instanceof HitBuilders.TimingBuilder) {
                    ((HitBuilders.TimingBuilder) builder).setCustomMetric(metricInteger, (Float) entry.getValue());
                } else if (builder instanceof HitBuilders.ScreenViewBuilder) {
                    ((HitBuilders.ScreenViewBuilder) builder).setCustomMetric(metricInteger, (Float) entry.getValue());
                }
            }
        } catch (NumberFormatException ignore) {
        }

    }
    return builder;
}
 
开发者ID:MobileTribe,项目名称:pandroid,代码行数:20,代码来源:GoogleAnalyticsManager.java

示例3: doTrackTiming

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
private void doTrackTiming(String aCategory, Double aValue,
    String aName, String aLabel) {

    HitBuilders.TimingBuilder hit = new HitBuilders.TimingBuilder()
        .setCategory(aCategory)
        .setValue(aValue.longValue());

    if (aName != null) {
        hit.setVariable(aName);
    }

    if (aLabel != null) {
        hit.setLabel(aLabel);
    }

    mTracker.send(hit.build());
}
 
开发者ID:mozilla-magnet,项目名称:magnet-client,代码行数:18,代码来源:Analytics.java

示例4: endTimedEvent

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
/**
 * @see AnalyticsKitProvider
 */
@Override
public void endTimedEvent(@NonNull AnalyticsEvent timedEvent) throws IllegalStateException
{
	ensureTimeTrackingMaps();

	long           endTime       = System.currentTimeMillis();
	Long           startTime     = this.eventTimes.remove(timedEvent.name());
	AnalyticsEvent finishedEvent = this.timedEvents.remove(timedEvent.name());

	if (startTime != null && finishedEvent != null)
	{
		HitBuilders.TimingBuilder timingBuilder = new HitBuilders.TimingBuilder();
		timingBuilder.setLabel(finishedEvent.name())
		             .setCategory("Timed Events")
		             .setValue(endTime - startTime);
		// add any custom attributes already set on the event
		timingBuilder.setAll(stringifyAttributesMap(finishedEvent.getAttributes()));
		this.tracker.send(timingBuilder.build());
	}
	else
	{
		throw new IllegalStateException("Attempted ending an event that was never started (or was previously ended): " + timedEvent.name());
	}
}
 
开发者ID:busybusy,项目名称:AnalyticsKit-Android,代码行数:28,代码来源:GoogleAnalyticsProvider.java

示例5: processParam

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
@Override
public void processParam(HashMap<String, Object> params) {

    for (Tracker tracker : mTrackers) {

        boolean session = params.containsKey(Param.NEW_SESSION);
        if (Event.Type.SCREEN.equals(params.get(Event.TYPE))) {
            tracker.setScreenName(params.get(Event.LABEL).toString());
            // Send a screen view.
            HitBuilders.ScreenViewBuilder screenViewBuilder = new HitBuilders.ScreenViewBuilder();
            screenViewBuilder = addMetrics(screenViewBuilder, params);
            screenViewBuilder = addDimensions(screenViewBuilder, params);
            if (session) {
                screenViewBuilder.setNewSession();
                session = false;
            }
            tracker.send(screenViewBuilder.build());
        }

        if (Event.Type.TIMER.equals(params.get(Event.TYPE))) {
            HitBuilders.TimingBuilder timingBuilder = new HitBuilders.TimingBuilder()
                    .setCategory(String.valueOf(params.get(Event.CATEGORY)))
                    .setValue(parseToLong(params.get(Event.DURATION)))
                    .setVariable(String.valueOf(params.get(Event.VARIABLE)))
                    .setLabel(String.valueOf(params.get(Event.LABEL)));
            timingBuilder = addMetrics(timingBuilder, params);
            timingBuilder = addDimensions(timingBuilder, params);
            if (session) {
                timingBuilder.setNewSession();
                session = false;
            }
            tracker.send(timingBuilder.build());
        }

        if (Event.Type.ACTION.equals(params.get(Event.TYPE))) {

            HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
                    .setCategory(String.valueOf(params.get(Event.CATEGORY)))
                    .setValue(parseToLong(params.get(Event.VALUE)))
                    .setAction(String.valueOf(params.get(Event.ACTION)))
                    .setLabel(String.valueOf(params.get(Event.LABEL)));
            eventBuilder = addMetrics(eventBuilder, params);
            eventBuilder = addDimensions(eventBuilder, params);
            if (session) {
                eventBuilder.setNewSession();
            }
            tracker.send(eventBuilder.build());
        }

    }


}
 
开发者ID:MobileTribe,项目名称:pandroid,代码行数:54,代码来源:GoogleAnalyticsManager.java

示例6: TimingTracker

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
public TimingTracker(final Tracker tracker) {
    this.tracker = tracker;
    this.builder = new HitBuilders.TimingBuilder();
}
 
开发者ID:kibotu,项目名称:BloodHound,代码行数:5,代码来源:TimingTracker.java

示例7: sendTiming

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
public static void sendTiming(HitBuilders.TimingBuilder timingBuilder) {
	if (timingBuilder != null) {
		sendHit(timingBuilder.build());
	}
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:6,代码来源:GAUtils.java

示例8: onActivityResult

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
    long timeWaitedForUserReturnedToApp = System.currentTimeMillis() - timeStarted;

    HitBuilders.TimingBuilder waitingForUser = new HitBuilders.TimingBuilder()
            .setVariable("FilePicker")
            .setValue(timeWaitedForUserReturnedToApp);

    if (requestCode != FIND_FILE_REQUEST_CODE) return;

    if (resultCode != Activity.RESULT_OK) {
        waitingForUser.setLabel("Cancelled");
        mTracker.send(waitingForUser.build());
        Log.i(TAG, "User did not select a file. Possible usability problem?");
    } else {
        waitingForUser.setLabel("OK");
        mTracker.send(waitingForUser.build());
        Uri uri = null;
        if (resultData != null) {
            uri = resultData.getData();
            ContentValues fileInformation = obtainFileMetaData(uri);
            int recordsAdded = 0;
            int recordsRejected = 0;
            String message;
            HitBuilders.TimingBuilder fileLoadData = new HitBuilders.TimingBuilder();
            fileLoadData.setVariable("FileImport");
            fileLoadData.setCategory("Performance");
            try {
                timeStarted = System.currentTimeMillis();
                InputStream inputStream = getContentResolver().openInputStream(uri);
                final int BYTES_TO_READ = 3;
                byte[] buffer = new byte[BYTES_TO_READ];
                inputStream.read(buffer,0,BYTES_TO_READ);
                String encoding = GuessEncoding.guessFor(buffer);
                inputStream.close();
                inputStream = getContentResolver().openInputStream(uri);
                ReviewReader r = ReviewReader.fromStream(inputStream, encoding);
                SQLiteDatabase db = ReviewsDatabaseHelper.getDatabase(this);
                Review review = null;
                while ((review = r.next()) != null) {
                    boolean OK = ReviewsDatabaseHelper.insertGooglePlayReview(db, review);
                    if (OK) {
                        recordsAdded++;
                    } else {
                        recordsRejected++;
                    }
                }
                inputStream.close();
                final String msg = "Import completed,\nadded:" + recordsAdded + ", rejected: " + recordsRejected;
                fileInformation.put(NUM_ACCEPTED, recordsAdded);
                fileInformation.put(NUM_REJECTED, recordsRejected);
                recordFileImport(db, fileInformation);
                messageBox.setText(msg);
                Log.i(TAG, msg);
                findFileToLoadButton.setText(R.string.loadAnotherFileText);
            } catch (IOException e) {
                Log.e(TAG, "Problem accessing file of reviews", e);
                e.printStackTrace();
                message = e.getLocalizedMessage();
                messageBox.setText(message);
            } catch (UnexpectedFormatException ufe) {
                Log.w(TAG, "Unexpected CSV file detected, possibly incorrect content", ufe);
                message = ufe.getLocalizedMessage();
                messageBox.setText(message);
            }
            long loadTook = (System.currentTimeMillis() - timeStarted);
            fileLoadData.setValue(loadTook);
            fileLoadData.setLabel("CompletedOK");
            mTracker.set("FileLoad", Long.toString(loadTook));
            mTracker.send(fileLoadData.build());
        }
    }
}
 
开发者ID:julianharty,项目名称:app-store-reviews-app,代码行数:74,代码来源:LoadReviewsActivity.java

示例9: sendTiming

import com.google.android.gms.analytics.HitBuilders; //导入方法依赖的package包/类
public static void sendTiming(HitBuilders.TimingBuilder timingBuilder) {
    if (timingBuilder != null) {
        sendHit(timingBuilder.build());
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:6,代码来源:GAUtils.java


注:本文中的com.google.android.gms.analytics.HitBuilders.TimingBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。