Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
abduelrahman committed Feb 4, 2020
1 parent 3e24d5e commit 094130b
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/am/leon/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.item_config);

mediaList.add(new Media("https://brands.solutionplus.net/storage/photos/configs/blue-note-863135.jpeg", Media.TYPE_PHOTO));
mediaList.add(new Media("https://brands.solutionplus.net/storage/photos/configs/blue-ocean-large-876999.jpeg", Media.TYPE_PHOTO));
// mediaList.add("https://brands.solutionplus.net/storage/photos/configs/blue-note-863135.jpeg");
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_directions_bike_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M15.5,5.5c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM5,12c-2.8,0 -5,2.2 -5,5s2.2,5 5,5 5,-2.2 5,-5 -2.2,-5 -5,-5zM5,20.5c-1.9,0 -3.5,-1.6 -3.5,-3.5s1.6,-3.5 3.5,-3.5 3.5,1.6 3.5,3.5 -1.6,3.5 -3.5,3.5zM10.8,10.5l2.4,-2.4 0.8,0.8c1.3,1.3 3,2.1 5.1,2.1L19.1,9c-1.5,0 -2.7,-0.6 -3.6,-1.5l-1.9,-1.9c-0.5,-0.4 -1,-0.6 -1.6,-0.6s-1.1,0.2 -1.4,0.6L7.8,8.4c-0.4,0.4 -0.6,0.9 -0.6,1.4 0,0.6 0.2,1.1 0.6,1.4L11,14v5h2v-6.2l-2.2,-2.3zM19,12c-2.8,0 -5,2.2 -5,5s2.2,5 5,5 5,-2.2 5,-5 -2.2,-5 -5,-5zM19,20.5c-1.9,0 -3.5,-1.6 -3.5,-3.5s1.6,-3.5 3.5,-3.5 3.5,1.6 3.5,3.5 -1.6,3.5 -3.5,3.5z"/>
</vector>
12 changes: 6 additions & 6 deletions app/src/main/res/layout/item_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
android:layout_marginEnd="8dp"
android:maxLines="2"
android:padding="2dp"
android:text="iPhone XS all colors 64 GB 4G LTE - Gold iPhone XS all colors 64 GB 4G LTE - Gold iPhone XS all colors 64 GB 4G LTE - Gold "
android:textAlignment="textStart"
android:textSize="12sp"
android:text="iPhone XS all colors 64 GB 4G LTE - Gold iPhone XS all colors 64 GB 4G LTE - Gold iPhone XS all colors 64 GB 4G LTE - Gold " />
android:textSize="12sp" />


<LinearLayout
Expand All @@ -61,9 +61,9 @@
android:layout_marginStart="8dp"
android:maxLines="1"
android:padding="2dp"
android:text="2100 SAR"
android:textAlignment="viewStart"
android:textSize="12sp"
android:text="2100 SAR" />
android:textSize="12sp" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_config_totalAmount"
Expand All @@ -72,9 +72,9 @@
android:layout_marginStart="8dp"
android:maxLines="1"
android:padding="2dp"
android:text="3900 SAR"
android:textAlignment="viewStart"
android:textSize="12sp"
android:text="3900 SAR" />
android:textSize="12sp" />

</LinearLayout>

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="ImageView">
<item name="reload_icon">@drawable/ic_delete_sweep_black_24dp</item>
<item name="default_icon">@drawable/ic_delete_sweep_black_24dp</item>
<item name="place_holder_icon">@drawable/ic_directions_bike_black_24dp</item>
</style>

</resources>
2 changes: 1 addition & 1 deletion leon/src/main/java/am/leon/FullScreenImageAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Object instantiateItem(@NonNull ViewGroup container, int position) {
viewInit();

String media = list.get(position);
imageView.executePicasso(media);
imageView.executePicasso(media, true);

if (media != null && media.contains(Utils.YouTube_Thumb)) {
ic_video.setVisibility(View.VISIBLE);
Expand Down
30 changes: 27 additions & 3 deletions leon/src/main/java/am/leon/LeonImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,32 @@ private void setTypedArrayValues(Context context, AttributeSet attrs, int defSty

defaultImageRes = (typedArray.getResourceId(R.styleable.LeonImageView_default_icon, R.drawable.ic_default));

videoPlayImageRes = (typedArray.getResourceId(R.styleable.LeonImageView_video_play_icon, R.drawable.ic_play_colored));
videoPlayImageRes = (typedArray.getResourceId(R.styleable.LeonImageView_play_video_icon, R.drawable.ic_play_colored));

placeHolderImageRes = (typedArray.getResourceId(R.styleable.LeonImageView_place_holder_icon, R.drawable.layer_place_holder));
typedArray.recycle();

}


private void setTypedArrayValues(Context context, int leonImageViewStyle) {
// The attributes you want retrieved
int[] attrs = {R.attr.reload_icon, R.attr.default_icon, R.attr.play_video_icon, R.attr.play_video_icon};

// Parse LeonImageView, using Context.obtainStyledAttributes()
TypedArray typedArray = context.obtainStyledAttributes(leonImageViewStyle, attrs);

reloadImageRes = (typedArray.getResourceId(R.styleable.LeonImageView_reload_icon, R.drawable.layer_reload));

defaultImageRes = (typedArray.getResourceId(R.styleable.LeonImageView_default_icon, R.drawable.ic_default));

videoPlayImageRes = (typedArray.getResourceId(R.styleable.LeonImageView_play_video_icon, R.drawable.ic_play_colored));

placeHolderImageRes = (typedArray.getResourceId(R.styleable.LeonImageView_place_holder_icon, R.drawable.layer_place_holder));
typedArray.recycle();
}


@Override
public void setOnClickListener(@Nullable View.OnClickListener l) {
if (l == null)
Expand Down Expand Up @@ -117,6 +135,12 @@ public void loadImage(Object object) {
}


protected void loadImage(Object object, boolean fromFullScreen) {
executePicasso(handleObject(object), fromFullScreen);
setMedia(handleObject(object));
}


public void loadImage(Object object, Transformation transformation) {
executePicasso(handleObject(object), transformation);
setMedia(handleObject(object));
Expand Down Expand Up @@ -282,11 +306,11 @@ private void executePicasso(String urlPath, Transformation transformation) {
}


protected void executePicasso(String urlPath) {
protected void executePicasso(String urlPath, boolean fromFullScreen) {
Picasso.get().load(urlPath)
.placeholder(getPlaceHolderImageRes())
.error(getReloadImageRes())
.into(this, new PicassoCallback(this, urlPath, true));
.into(this, new PicassoCallback(this, urlPath, fromFullScreen));
}


Expand Down
2 changes: 1 addition & 1 deletion leon/src/main/java/am/leon/PicassoCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void onClick(View view) {
if (transformation != null)
imageView.loadImage(urlPath, transformation);
else
imageView.loadImage(urlPath);
imageView.loadImage(urlPath, fromFullScreen);
}

}
3 changes: 1 addition & 2 deletions leon/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
</declare-styleable>

<declare-styleable name="LeonImageView">
<!-- <attr name="zoom_enabled" format="boolean" />-->
<attr name="reload_icon" format="reference" />
<attr name="default_icon" format="reference" />
<attr name="video_play_icon" format="reference" />
<attr name="play_video_icon" format="reference" />
<attr name="place_holder_icon" format="reference" />
</declare-styleable>

Expand Down
4 changes: 1 addition & 3 deletions leon/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
<item name="android:windowExitAnimation">@anim/slide_down</item>
</style>


// --------------------------------- ViewPager -------------------------

//------------------------------- ViewPager ----------------------------------------------------

<style name="ViewPager">
<item name="android:layout_width">match_parent</item>
Expand Down

0 comments on commit 094130b

Please sign in to comment.