-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: scrollbars and crash * fix: address comments
- Loading branch information
Showing
17 changed files
with
253 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
android/src/main/java/com/qliktrialreactnativestraighttable/ImageLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.qliktrialreactnativestraighttable; | ||
|
||
import android.graphics.Bitmap; | ||
import android.webkit.URLUtil; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.CountDownLatch; | ||
|
||
import okhttp3.Call; | ||
import okhttp3.Callback; | ||
import okhttp3.Response; | ||
|
||
public class ImageLoader { | ||
public Set<String> imagePaths = new HashSet<>(); | ||
public Map<String, Bitmap> imageData = new HashMap<>(); | ||
public Bitmap getImageData(String url) { | ||
return imageData.get(url); | ||
} | ||
|
||
public void addImagePath(String imageUrl) { | ||
if(!URLUtil.isValidUrl(imageUrl)) { | ||
return; | ||
} | ||
imagePaths.add(imageUrl); | ||
} | ||
|
||
public void fetchImages() { | ||
final CountDownLatch latch = new CountDownLatch(imagePaths.size()); | ||
Iterator<String> iterator = imagePaths.iterator(); | ||
while (iterator.hasNext()) { | ||
String imageUrl = iterator.next(); | ||
boolean isDuplicateImageUrl = imageData.containsKey(imageUrl); | ||
if(isDuplicateImageUrl || !URLUtil.isValidUrl(imageUrl)) { | ||
latch.countDown(); | ||
continue; | ||
} | ||
imageData.put(imageUrl, null); | ||
try { | ||
HttpUtils.get(imageUrl, new Callback() { | ||
public void onResponse(Call call, Response response) { | ||
InputStream inputStream = response.body().byteStream(); | ||
Bitmap bitmap = PixelUtils.byteStreamToBitmap(inputStream); | ||
imageData.replace(imageUrl, bitmap); | ||
latch.countDown(); | ||
} | ||
|
||
public void onFailure(Call call, IOException e) { | ||
latch.countDown(); | ||
} | ||
}); | ||
} catch(Exception e) { | ||
latch.countDown(); | ||
imageData.remove(imageUrl); | ||
e.printStackTrace(); | ||
} | ||
} | ||
try { | ||
latch.await(); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
android/src/main/java/com/qliktrialreactnativestraighttable/MockHorizontalScrollView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.qliktrialreactnativestraighttable; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.view.View; | ||
import android.widget.HorizontalScrollView; | ||
import android.widget.ScrollView; | ||
|
||
@SuppressLint("ViewConstructor") | ||
public class MockHorizontalScrollView extends HorizontalScrollView { | ||
View content; | ||
|
||
public MockHorizontalScrollView(Context context, TableView tableView) { | ||
super(context); | ||
setHorizontalScrollBarEnabled(true); | ||
setZ(PixelUtils.dpToPx(4)); | ||
|
||
content = new View(context); | ||
content.setBackgroundColor(Color.TRANSPARENT); | ||
content.setMinimumWidth(tableView.totalWidth); | ||
content.setMinimumHeight((int) PixelUtils.dpToPx(6)); | ||
addView(content); | ||
} | ||
|
||
public void setContentWidth(int width){ | ||
content.setMinimumWidth(width); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
android/src/main/java/com/qliktrialreactnativestraighttable/MockVerticalScrollView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.qliktrialreactnativestraighttable; | ||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
import android.widget.ScrollView; | ||
|
||
public class MockVerticalScrollView extends ScrollView { | ||
View content; | ||
|
||
public MockVerticalScrollView(Context context, TableView tableView) { | ||
super(context); | ||
setVerticalScrollBarEnabled(true); | ||
setZ(PixelUtils.dpToPx(4)); | ||
|
||
content = new View(context); | ||
content.setBackgroundColor(Color.TRANSPARENT); | ||
int total = tableView.dataProvider.dataSize.qcy; | ||
content.setMinimumHeight(total * tableView.rowHeight); | ||
addView(content); | ||
} | ||
|
||
public void setContentHeight(int height){ | ||
content.setMinimumHeight(height); | ||
} | ||
} |
Oops, something went wrong.