Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/activity indicator for android #217

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions CachedImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ const {
View,
ImageBackground,
ActivityIndicator,
NetInfo,
Platform,
StyleSheet,
} = ReactNative;

import NetInfo from "@react-native-community/netinfo";

const styles = StyleSheet.create({
image: {
backgroundColor: 'transparent'
Expand All @@ -36,7 +37,7 @@ const styles = StyleSheet.create({
});

function getImageProps(props) {
return _.omit(props, ['source', 'defaultSource', 'fallbackSource', 'LoadingIndicator', 'activityIndicatorProps', 'style', 'useQueryParamsInCacheKey', 'renderImage', 'resolveHeaders']);
return _.omit(props, ['source', 'defaultSource', 'fallbackSource', 'loadingIndicator', 'activityIndicatorProps', 'style', 'useQueryParamsInCacheKey', 'renderImage', 'resolveHeaders']);
}

const CACHED_IMAGE_REF = 'cachedImage';
Expand Down Expand Up @@ -79,9 +80,9 @@ class CachedImage extends React.Component {

componentWillMount() {
this._isMounted = true;
NetInfo.isConnected.addEventListener('connectionChange', this.handleConnectivityChange);
NetInfo.addEventListener(this.handleConnectivityChange);
// initial
NetInfo.isConnected.fetch()
NetInfo.fetch()
.then(isConnected => {
this.safeSetState({
networkAvailable: isConnected
Expand All @@ -93,7 +94,6 @@ class CachedImage extends React.Component {

componentWillUnmount() {
this._isMounted = false;
NetInfo.isConnected.removeEventListener('connectionChange', this.handleConnectivityChange);
}

componentWillReceiveProps(nextProps) {
Expand Down Expand Up @@ -199,14 +199,14 @@ class CachedImage extends React.Component {
if (LoadingIndicator) {
return (
<View style={[imageStyle, activityIndicatorStyle]}>
<LoadingIndicator {...activityIndicatorProps} />
<LoadingIndicator {...activityIndicatorProps} color="#063f71" />
</View>
);
}
return (
<ActivityIndicator
{...activityIndicatorProps}
style={[imageStyle, activityIndicatorStyle]}/>
style={[imageStyle, activityIndicatorStyle]} color="#063f71"/>
);
}
// otherwise render an image with the defaultSource with the ActivityIndicator on top of it
Expand All @@ -218,11 +218,11 @@ class CachedImage extends React.Component {
children: (
LoadingIndicator
? <View style={[imageStyle, activityIndicatorStyle]}>
<LoadingIndicator {...activityIndicatorProps} />
<LoadingIndicator {...activityIndicatorProps} color="#063f71"/>
</View>
: <ActivityIndicator
{...activityIndicatorProps}
style={activityIndicatorStyle}/>
style={activityIndicatorStyle} color="#063f71"/>
)
});
}
Expand Down