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


Java TrafficStats.setThreadStatsTag方法代码示例

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


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

示例1: performRequest

import android.net.TrafficStats; //导入方法依赖的package包/类
@Override
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) throws IOException, AuthFailureError {
    long startTime = System.currentTimeMillis();
    if(Const.DEVELOPER_MODE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        TrafficStats.setThreadStatsTag(0xF00D);
        try {
            HttpResponse res = super.performRequest(request, additionalHeaders);
            App.getInstance().getTracker().sendTiming("net",System.currentTimeMillis()-startTime, "volley", null);
            return res;
        } finally {
            TrafficStats.clearThreadStatsTag();
        }
    } else {
        HttpResponse response = super.performRequest(request, additionalHeaders);
        App.getInstance().getTracker().sendTiming("net",System.currentTimeMillis()-startTime, "gapi", null);
        return response;
    }
}
 
开发者ID:gdgjodhpur,项目名称:gdgapp,代码行数:19,代码来源:OkStack.java

示例2: addTrafficStatsTag

import android.net.TrafficStats; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void addTrafficStatsTag(Request<?> request) {
    // Tag the request (if API >= 14)
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        TrafficStats.setThreadStatsTag(request.getTrafficStatsTag());
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:NetworkDispatcher.java

示例3: getRestaurants

import android.net.TrafficStats; //导入方法依赖的package包/类
private void getRestaurants() {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(APP_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        UserLocation location =
                LocationPreference.getUserLocation(context);
        RetroInterface.getZomatoRestApi().getRecommendedRestaurants(
                SessionPreference.getUserId(context)+"",
                location.getLatitude() + "",
                location.getLongitude() + "",
                new Callback<RestaurantResponse>() {
                    @Override
                    public void success(RestaurantResponse restaurantResponse, Response response) {

                        if (restaurantResponse != null && restaurantResponse.isSuccess()) {
                            mightList = restaurantResponse.getItems();
                            mightAdapter.refresh(mightList);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:35,代码来源:BrowseNearbyActivity.java

示例4: getFollowers

import android.net.TrafficStats; //导入方法依赖的package包/类
private void getFollowers() {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(APP_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        RetroInterface.getZomatoRestApi().getUserFollowers(
                SessionPreference.getUserId(context) + "",
                user_id + "",
                new Callback<UserListResponse>() {
                    @Override
                    public void success(UserListResponse userListResponse, Response response) {
                        if(userListResponse!=null){
                            list = userListResponse.getUsers();
                            recyclerViewAdapter.refresh(list);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:32,代码来源:FollowerFragment.java

示例5: getFollowing

import android.net.TrafficStats; //导入方法依赖的package包/类
private void getFollowing() {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(APP_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        RetroInterface.getZomatoRestApi().getUserFollowing(
                SessionPreference.getUserId(context) + "",
                user_id + "",
                new Callback<UserListResponse>() {
                    @Override
                    public void success(UserListResponse userListResponse, Response response) {
                        if (userListResponse != null) {
                            list = userListResponse.getUsers();
                            recyclerViewAdapter.refresh(list);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:31,代码来源:FollowingFragment.java

示例6: followUser

import android.net.TrafficStats; //导入方法依赖的package包/类
private void followUser(int pos, boolean isFollowing) {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(USER_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        User user = mList.get(pos);
        RetroInterface.getZomatoRestApi().followUser(
                SessionPreference.getUserId(context) + "",
                user.getId() + "",
                (isFollowing ? 1 : 0) + "",
                new Callback<NormalResponse>() {
                    @Override
                    public void success(NormalResponse userListResponse, Response response) {

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:30,代码来源:FriendAdapter.java

示例7: getRecentlyViewed

import android.net.TrafficStats; //导入方法依赖的package包/类
private void getRecentlyViewed() {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(APP_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        UserLocation location = LocationPreference.getUserLocation(context);

        RetroInterface.getZomatoRestApi().getRecentRestaurants(
                SessionPreference.getUserId(context) + "",
                location.getLatitude() + "",
                location.getLongitude() + "",
                new Callback<RestaurantResponse>() {
                    @Override
                    public void success(RestaurantResponse restaurantResponse, Response response) {
                        if (restaurantResponse != null && restaurantResponse.isSuccess()) {
                            allList = restaurantResponse.getItems();
                            allAdapter.refresh(allList);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                });

    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:34,代码来源:RecentPlaceActivity.java

示例8: goSocialLogin

import android.net.TrafficStats; //导入方法依赖的package包/类
private void goSocialLogin(User user) {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(USER_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }


        RetroInterface.getZomatoRestApi().loginSocial(
                CommonFunctions.getHashMap(user),
                new Callback<UserResponse>() {
                    @Override
                    public void success(UserResponse userResponse, Response response) {

                        if (userResponse != null && userResponse.isSuccess()) {

                            if (userResponse.getUser() != null) {
                                loginSuccess(userResponse.getUser());
                            }
                        }

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:36,代码来源:SignInBaseActivity.java

示例9: goNormalLogin

import android.net.TrafficStats; //导入方法依赖的package包/类
private void goNormalLogin(User user) {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(USER_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        RetroInterface.getZomatoRestApi().loginNormal(
                CommonFunctions.getHashMap(user),
                new Callback<UserResponse>() {
                    @Override
                    public void success(UserResponse userResponse, Response response) {

                        if (userResponse != null && userResponse.isSuccess()) {

                            if (userResponse.getUser() != null) {
                                loginSuccess(userResponse.getUser());
                            }
                        }

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:34,代码来源:SignInBaseActivity.java

示例10: goNormalRegister

import android.net.TrafficStats; //导入方法依赖的package包/类
private void goNormalRegister(User user) {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(USER_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        RetroInterface.getZomatoRestApi().registerNormal(
                CommonFunctions.getHashMap(user),
                new Callback<UserResponse>() {
                    @Override
                    public void success(UserResponse userResponse, Response response) {

                        if (userResponse != null && userResponse.isSuccess()) {

                            if (userResponse.getUser() != null) {
                                loginSuccess(userResponse.getUser());
                            }
                        }

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:35,代码来源:SignInBaseActivity.java

示例11: followUser

import android.net.TrafficStats; //导入方法依赖的package包/类
private void followUser(int pos, boolean isFollowing) {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(USER_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        User user = allList.get(pos);
        RetroInterface.getZomatoRestApi().followUser(
                SessionPreference.getUserId(context) + "",
                user.getId() + "",
                (isFollowing ? 1 : 0) + "",
                new Callback<NormalResponse>() {
                    @Override
                    public void success(NormalResponse userListResponse, Response response) {

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:30,代码来源:FindFriendActivity.java

示例12: setList

import android.net.TrafficStats; //导入方法依赖的package包/类
private void setList() {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(APP_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        RetroInterface.getZomatoRestApi().getUserSuggestion(
                SessionPreference.getUserId(context) + "",
                new Callback<UserListResponse>() {
                    @Override
                    public void success(UserListResponse userListResponse, Response response) {

                        if (userListResponse != null) {

                            allList = userListResponse.getUsers();
                            allAdapter.refresh(allList);
                        }

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );


    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:35,代码来源:FindFriendActivity.java

示例13: getPopularLocations

import android.net.TrafficStats; //导入方法依赖的package包/类
private void getPopularLocations() {

        if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
            try {
                TrafficStats.setThreadStatsTag(APP_INITIATED_REQUEST);
                // Once tag has been applied, network request has to be made request
            } finally {
                TrafficStats.clearThreadStatsTag();
            }
        }

        RetroInterface.getZomatoRestApi().getPopularLocation(
                "",
                new Callback<UserLocationResponse>() {
                    @Override
                    public void success(UserLocationResponse userLocationResponse, Response response) {
                        locationItems = userLocationResponse.getUserLocations();
                        popularAdapter.refresh(locationItems);
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:29,代码来源:SelectLocationActivity.java

示例14: getRestaurantList

import android.net.TrafficStats; //导入方法依赖的package包/类
private void getRestaurantList() {
    if (BuildConfig.NETWORK_TEST && Build.VERSION.SDK_INT >= 14) {
        try {
            TrafficStats.setThreadStatsTag(APP_INITIATED_REQUEST);
            // Once tag has been applied, network request has to be made request
        } finally {
            TrafficStats.clearThreadStatsTag();
        }
    }

    UserLocation location = LocationPreference.getUserLocation(context);

    RetroInterface.getZomatoRestApi().getAllRestaurants(
            SessionPreference.getUserId(context) + "",
            location.getLatitude() + "",
            location.getLongitude() + "",
            new Callback<RestaurantResponse>() {
                @Override
                public void success(RestaurantResponse restaurantResponse, Response response) {

                    if (restaurantResponse != null && restaurantResponse.isSuccess()) {
                        allList = restaurantResponse.getItems();
                        //allAdapter.refresh(allList);

                        refreshList();
                    }

                }

                @Override
                public void failure(RetrofitError error) {

                }
            }

    );

}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:39,代码来源:AddPlaceToCollectionActivity.java

示例15: addTrafficStatsTag

import android.net.TrafficStats; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void addTrafficStatsTag(com.hanuor.pearl.volleysingleton.Request<?> request) {
    // Tag the request (if API >= 14)
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        TrafficStats.setThreadStatsTag(request.getTrafficStatsTag());
    }
}
 
开发者ID:hanuor,项目名称:pearl,代码行数:8,代码来源:NetworkDispatcher.java


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