Java Code Examples for android.net.TrafficStats#clearThreadStatsTag()

The following examples show how to use android.net.TrafficStats#clearThreadStatsTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FollowingFragment.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                }
        );
    }
 
Example 2
Source File: AddPlaceToCollectionActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                }
            }

    );

}
 
Example 3
Source File: SelectLocationActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                }
        );

    }
 
Example 4
Source File: FindFriendActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                }
        );


    }
 
Example 5
Source File: FindFriendActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                }
        );
    }
 
Example 6
Source File: SignInBaseActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                }
        );

    }
 
Example 7
Source File: SignInBaseActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                }
        );
    }
 
Example 8
Source File: SignInBaseActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                }
        );

    }
 
Example 9
Source File: RecentPlaceActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                });

    }
 
Example 10
Source File: FriendAdapter.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                }
        );
    }
 
Example 11
Source File: FollowerFragment.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
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) {

                    }
                }
        );

    }
 
Example 12
Source File: PlaceDetailActivity.java    From Expert-Android-Programming with MIT License 4 votes vote down vote up
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) {

                    }
                }
        );
    }
 
Example 13
Source File: SelectLocationActivity.java    From Expert-Android-Programming with MIT License 4 votes vote down vote up
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();
                    }
                }
            });

        }

    }
 
Example 14
Source File: SearchPlaceActivity.java    From Expert-Android-Programming with MIT License 4 votes vote down vote up
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");
                        }
                    }
            );

        }

    }
 
Example 15
Source File: AddReviewActivity.java    From Expert-Android-Programming with MIT License 4 votes vote down vote up
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");
                        }
                    }
            );

        }

    }
 
Example 16
Source File: TrafficStatsCompatIcs.java    From guideshow with MIT License 4 votes vote down vote up
public static void clearThreadStatsTag() {
    TrafficStats.clearThreadStatsTag();
}
 
Example 17
Source File: TrafficStatsCompatIcs.java    From V.FlyoutTest with MIT License 4 votes vote down vote up
public static void clearThreadStatsTag() {
    TrafficStats.clearThreadStatsTag();
}
 
Example 18
Source File: SelectDeliveryAreaActivity.java    From Expert-Android-Programming with MIT License 4 votes vote down vote up
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");
                        }
                    }
            );

        }

    }
 
Example 19
Source File: o.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public static void a()
{
    TrafficStats.clearThreadStatsTag();
}
 
Example 20
Source File: TrafficStatsCompatIcs.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
public static void clearThreadStatsTag() {
    TrafficStats.clearThreadStatsTag();
}