forked from alexvasilkov/GestureViews
-
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
1 parent
fad1e81
commit bef0dce
Showing
10 changed files
with
129 additions
and
70 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
88 changes: 88 additions & 0 deletions
88
sample/src/main/java/com/alexvasilkov/gestures/sample/adapters/PaintingsListAdapter.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,88 @@ | ||
package com.alexvasilkov.gestures.sample.adapters; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.BaseAdapter; | ||
import android.widget.ImageView; | ||
|
||
import com.alexvasilkov.android.commons.utils.Views; | ||
import com.alexvasilkov.gestures.sample.R; | ||
import com.alexvasilkov.gestures.sample.logic.Painting; | ||
import com.alexvasilkov.gestures.sample.utils.glide.GlideHelper; | ||
|
||
public class PaintingsListAdapter extends BaseAdapter implements View.OnClickListener { | ||
|
||
private final Painting[] mPaintings; | ||
private final OnPaintingListener mListener; | ||
|
||
public PaintingsListAdapter(Painting[] paintings, OnPaintingListener listener) { | ||
mPaintings = paintings; | ||
mListener = listener; | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return mPaintings.length; | ||
} | ||
|
||
@Override | ||
public Object getItem(int position) { | ||
return mPaintings[position]; | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
return position; | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
ViewHolder holder; | ||
if (convertView == null) { | ||
holder = onCreateHolder(parent); | ||
holder.itemView.setTag(R.id.tag_holder, holder); | ||
} else { | ||
holder = (ViewHolder) convertView.getTag(R.id.tag_holder); | ||
} | ||
onBindHolder(holder, position); | ||
return holder.itemView; | ||
} | ||
|
||
private ViewHolder onCreateHolder(ViewGroup parent) { | ||
ViewHolder holder = new ViewHolder(parent); | ||
holder.image.setOnClickListener(this); | ||
return holder; | ||
} | ||
|
||
private void onBindHolder(ViewHolder holder, int position) { | ||
holder.image.setTag(R.id.tag_item, position); | ||
GlideHelper.loadResource(mPaintings[position].getImageId(), holder.image); | ||
} | ||
|
||
@Override | ||
public void onClick(@NonNull View view) { | ||
int pos = (Integer) view.getTag(R.id.tag_item); | ||
mListener.onPaintingClick(mPaintings[pos], pos, (ImageView) view); | ||
} | ||
|
||
public static ImageView getImage(View itemView) { | ||
ViewHolder holder = (ViewHolder) itemView.getTag(R.id.tag_holder); | ||
return holder == null ? null : holder.image; | ||
} | ||
|
||
static class ViewHolder { | ||
public final View itemView; | ||
public final ImageView image; | ||
|
||
public ViewHolder(ViewGroup parent) { | ||
itemView = Views.inflate(parent, R.layout.item_image); | ||
image = (ImageView) itemView; | ||
} | ||
} | ||
|
||
public interface OnPaintingListener { | ||
void onPaintingClick(Painting painting, int position, ImageView image); | ||
} | ||
|
||
} |
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
7 changes: 7 additions & 0 deletions
7
...le/src/main/java/com/alexvasilkov/gestures/sample/utils/GestureSettingsSetupListener.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,7 @@ | ||
package com.alexvasilkov.gestures.sample.utils; | ||
|
||
import com.alexvasilkov.gestures.views.interfaces.GestureView; | ||
|
||
public interface GestureSettingsSetupListener { | ||
void onSetupGestureView(GestureView view); | ||
} |
11 changes: 0 additions & 11 deletions
11
sample/src/main/res/drawable/flickr_progress_background.xml
This file was deleted.
Oops, something went wrong.
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