This file contains hidden or 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
| @Override | |
| public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
| // mListener: the item click listener. | |
| return new ViewHolder(R.layout.item_simple, parent, mListener); | |
| } | |
| @Override | |
| public void onBindViewHolder(ViewHolder holder, int position) { | |
| holder.setOnClickListener(R.id.btn_left_button, mListener); | |
| holder.setOnClickListener(R.id.btn_right_button, mListener); |
This file contains hidden or 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
| private OnRecyclerViewItemClickListener mListener = new SimpleOnRecyclerViewItemClickListener() { | |
| @Override | |
| public void onItemClick(ViewHolder holder, int position) { | |
| Toast.makeText(MainActivity.this, "click item: " + position, Toast.LENGTH_SHORT) | |
| .show(); | |
| } | |
| @Override | |
| public void onClick(View v) { | |
| ViewHolder holder = getViewHolder(v); |
This file contains hidden or 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
| public interface OnRecyclerViewItemClickListener extends View.OnClickListener { | |
| /** | |
| * @param holder The ViewHolder of the RecyclerView item. | |
| * @param position The position in which the item is clicked. | |
| */ | |
| void onItemClick(ViewHolder holder, int position); | |
| /** | |
| * Note that the ViewHolder can be got by <code>v.getTag(R.id.tag_viewholder)</code> | |
| * or using SimpleOnRecyclerViewItemClickListener#getViewHolder |
This file contains hidden or 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
| private interface OnOldTypeViewHolderClickListener { | |
| void onLeftButtonClick(View button, Object data); | |
| void onRightButtonClick(View button, Object data); | |
| void onWholdItemClick(View itemView); | |
| } |
This file contains hidden or 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
| private static class MyAdapter extends RecyclerView.Adapter<ViewHolder> { | |
| private OnRecyclerViewItemClickListener mListener; | |
| public MyAdapter(OnRecyclerViewItemClickListener listener) { | |
| mListener = listener; | |
| } | |
| @Override | |
| public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
This file contains hidden or 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
| function signUrl(url, key, keyindex) { | |
| var debug_signurl = 0; | |
| if (debug_signurl) console.log("Eric; signUrl; url=", url); | |
| // 把 http:// 取代掉成空白 | |
| // $url =~ s/^http:\/\///; | |
| // url = "http://bot1.ect.tp2.yahoo.com/echo/wssid"; | |
| // key = "TPiKKXkckSqj13OwXURLCKHAD7WXXHOh"; | |
| url = url.replace("http://", ""); |
This file contains hidden or 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
| /** | |
| * Custom Scroll listener for RecyclerView. | |
| * Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e | |
| */ | |
| public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener { | |
| public static String TAG = "EndlessScrollListener"; | |
| private int previousTotal = 0; // The total number of items in the dataset after the last load | |
| private boolean loading = true; // True if we are still waiting for the last set of data to load. | |
| private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more. |
This file contains hidden or 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
| import android.content.Context; | |
| import android.graphics.Bitmap; | |
| import android.graphics.BitmapShader; | |
| import android.graphics.Canvas; | |
| import android.graphics.ColorFilter; | |
| import android.graphics.Paint; | |
| import android.graphics.PixelFormat; | |
| import android.graphics.Rect; | |
| import android.graphics.Shader; | |
| import android.graphics.drawable.Drawable; |