-
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.
- Loading branch information
Wayyan
committed
Jul 6, 2020
1 parent
83fc44a
commit 24da94e
Showing
13 changed files
with
108 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
NetworkImage/src/main/java/com/devduo/networkimage/NIVConstants.kt
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package com.devduo.networkimage | ||
|
||
object NIVConstants { | ||
const val PREFIX= "https://drive.google.com/uc?export=download&id=" | ||
const val DRIVE_INDITIFIER="drive.google.com" | ||
val DRIVE_PATTERN_1= Regex("(.*)://drive.google.com/open?id=(.*)") | ||
val DRIVE_PATTERN_2=Regex("(.*)://drive.google.com/file/d/(.*)/view?usp=sharing") | ||
const val PREFIX = "https://drive.google.com/uc?export=download&id=" | ||
const val DRIVE_INDITIFIER = "drive.google.com" | ||
val DRIVE_PATTERN_1 = "drive.google.com/open?id=" | ||
val DRIVE_PATTERN_2 = "drive.google.com/file/d/" | ||
} |
16 changes: 13 additions & 3 deletions
16
NetworkImage/src/main/java/com/devduo/networkimage/NetworkImageView.kt
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
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/devduo/networkimageview/Extensions.kt
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,16 @@ | ||
package com.devduo.networkimageview | ||
|
||
import android.util.Log | ||
import android.widget.ImageView | ||
import androidx.appcompat.widget.AppCompatImageView | ||
import com.squareup.picasso.Picasso | ||
|
||
fun ImageView.fromNetwork(link: String, placeHolder: Int) { | ||
Log.e("library",link) | ||
Picasso.get() | ||
.load(link) | ||
.placeholder(placeHolder) | ||
.fit() | ||
.centerInside() | ||
.into(this) | ||
} |
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
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/devduo/networkimageview/NIVConstants.kt
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,8 @@ | ||
package com.devduo.networkimageview | ||
|
||
object NIVConstants { | ||
const val PREFIX = "https://drive.google.com/uc?export=download&id=" | ||
const val DRIVE_INDITIFIER = "drive.google.com" | ||
val DRIVE_PATTERN_1 = "drive.google.com/open?id=" | ||
val DRIVE_PATTERN_2 = "drive.google.com/file/d/" | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/devduo/networkimageview/NetworkImageView.kt
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,34 @@ | ||
package com.devduo.networkimageview | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.util.Log | ||
import android.widget.ImageView | ||
|
||
|
||
class NetworkImageView : ImageView { | ||
constructor(context: Context) : super(context) | ||
constructor(context: Context, attrs: AttributeSet? = null) : super(context, attrs) | ||
constructor( | ||
context: Context, attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : super(context, attrs, defStyleAttr) | ||
|
||
fun network(link: String, placeHolder: Int) { | ||
fromNetwork(executeLink(link), placeHolder) | ||
} | ||
|
||
private fun executeLink(link: String): String { | ||
Log.e("library,", link) | ||
return if (link.contains(NIVConstants.DRIVE_PATTERN_1)) { | ||
Log.e("library,", NIVConstants.PREFIX.plus(link.split("=")[1])) | ||
NIVConstants.PREFIX.plus(link.split("=")[1]) | ||
} else if (link.contains(NIVConstants.DRIVE_PATTERN_2)) { | ||
val firstCut = link.split("d/")[1] | ||
val id = firstCut.split("/")[0] | ||
Log.e("library,", NIVConstants.PREFIX.plus(id)) | ||
NIVConstants.PREFIX.plus(id) | ||
} else | ||
link | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<item android:gravity="center"> | ||
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:drawable="@drawable/loading" | ||
android:pivotX="50%" | ||
android:pivotY="50%" /> | ||
</item> | ||
</layer-list> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ allprojects { | |
repositories { | ||
google() | ||
jcenter() | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
|
||
|