android.net.TrafficStats#clearThreadStatsTag ( )源码实例Demo

下面列出了android.net.TrafficStats#clearThreadStatsTag ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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) {

                    }
                }
        );

    }
 
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) {

                    }
                }
        );
    }
 
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) {

                    }
                }
        );
    }
 
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) {

                    }
                });

    }
 
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) {

                    }
                }
        );

    }
 
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) {

                    }
                }
        );
    }
 
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) {

                    }
                }
        );

    }
 
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) {

                    }
                }
        );
    }
 
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) {

                    }
                }
        );


    }
 
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) {

                    }
                }
        );

    }
 
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) {

                }
            }

    );

}
 
private void getRestaurantDetails() {

        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().getRestaurantDetails(
                SessionPreference.getUserId(context) + "",
                restaurantItem.getId() + "",
                new Callback<RestaurantDetailResponse>() {
                    @Override
                    public void success(RestaurantDetailResponse restaurantResponse, Response response) {

                        RestaurantDetails details = restaurantResponse.getDetails();
                        List<RestaurantImage> images = details.getImages();
                        List<RestaurantTiming> timings = details.getTimings();
                        List<RestaurantImage> photos = details.getPhoto();
                        List<RestaurantMenu> menu = details.getMenu();
                        reviewItems = details.getReviews();

                        setPagerImages(images);
                        setTimings(timings);
                        setReviews();
                        updatePhotos(photos);
                        updateMenus(menu);

                        setMoreDetails(details.getReviewDetail(), details.getBookmark(), details.getBeenThere());

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
 
private void getUserLocationSearch() {

        if (search != null && !search.equals("")) {

            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().getSearchLocation(
                    search,
                    new Callback<UserLocationResponse>() {
                        @Override
                        public void success(UserLocationResponse userLocationResponse, Response response) {

                            if (userLocationResponse != null) {
                                //userLocations = userLocationResponse.getUserLocations();
                                userLocationViewModel.addUserLocations(userLocationResponse.getUserLocations());
                            }

                        }

                        @Override
                        public void failure(RetrofitError error) {
                            userHint.setText("No Users Found");
                        }
                    }
            );

            if (liveData != null) {
                liveData.removeObservers(this);
                MyLg.e(TAG, "Removed Observers");
            }

            liveData = userLocationViewModel.getUserLocationsByName("%" + search + "%");
            liveData.observe(this, new Observer<List<UserLocation>>() {
                @Override
                public void onChanged(@Nullable List<UserLocation> serviceItems) {
                    userLocations = serviceItems;
                    if (!(search.equals(""))) {
                        refreshList();
                    }
                }
            });

        }

    }
 
private void getUserLocationSearch() {

        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();
            }
        }

        UserLocation location =
                LocationPreference.getUserLocation(context);

        if (search != null && !search.equals("")) {

            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().getSearchRestaurants(
                    SessionPreference.getUserId(context) + "",
                    search,
                    location.getLatitude() + "",
                    location.getLongitude() + "",
                    new Callback<RestaurantResponse>() {
                        @Override
                        public void success(RestaurantResponse userLocationResponse, Response response) {

                            if (userLocationResponse != null) {
                                searchRestaurants = userLocationResponse.getItems();
                                searchRestaurantAdapter.refresh(searchRestaurants);

                                if (searchRestaurants.size() != 0) {
                                    userHint.setText("");
                                } else {
                                    userHint.setText("No Users Found");
                                }
                            }

                        }

                        @Override
                        public void failure(RetrofitError error) {
                            userHint.setText("No Users Found");
                        }
                    }
            );

        }

    }
 
private void getUserSearch() {

        if (search != null && !search.equals("")) {

            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().getUserSearch(
                    SessionPreference.getUserId(context)+"",
                    search,
                    new Callback<UserListResponse>() {
                        @Override
                        public void success(UserListResponse userListResponse, Response response) {

                            if (userListResponse != null) {
                                users = userListResponse.getUsers();
                                userSelectListAdapter.refresh(users);

                                if (users.size() != 0) {
                                    userHint.setText("");
                                } else {
                                    userHint.setText("No Users Found");
                                }
                            }

                        }

                        @Override
                        public void failure(RetrofitError error) {
                            userHint.setText("No Users Found");
                        }
                    }
            );

        }

    }
 
源代码16 项目: guideshow   文件: TrafficStatsCompatIcs.java
public static void clearThreadStatsTag() {
    TrafficStats.clearThreadStatsTag();
}
 
源代码17 项目: V.FlyoutTest   文件: TrafficStatsCompatIcs.java
public static void clearThreadStatsTag() {
    TrafficStats.clearThreadStatsTag();
}
 
private void getUserLocationSearch() {

        if (search != null && !search.equals("")) {

            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().getSearchLocation(
                    search,
                    new Callback<UserLocationResponse>() {
                        @Override
                        public void success(UserLocationResponse userLocationResponse, Response response) {

                            if (userLocationResponse != null) {
                                userLocations = userLocationResponse.getUserLocations();
                                userLocationAdapter.refresh(userLocations);

                                if (userLocations.size() != 0) {
                                    userHint.setText("");
                                } else {
                                    userHint.setText("No Users Found");
                                }
                            }

                        }

                        @Override
                        public void failure(RetrofitError error) {
                            userHint.setText("No Users Found");
                        }
                    }
            );

        }

    }
 
源代码19 项目: MiBandDecompiled   文件: o.java
public static void a()
{
    TrafficStats.clearThreadStatsTag();
}
 
源代码20 项目: CodenameOne   文件: TrafficStatsCompatIcs.java
public static void clearThreadStatsTag() {
    TrafficStats.clearThreadStatsTag();
}